added hierarchical profiling (needs more cleanup)
avoid dynamic allocations in btRaycastVehicle
This commit is contained in:
@@ -29,6 +29,9 @@
|
||||
#include "GLDebugDrawer.h"
|
||||
|
||||
static GLDebugDrawer gDebugDrawer;
|
||||
#include "LinearMath/btQuickProf.h"
|
||||
|
||||
CProfileIterator * gProfileIterator=0;
|
||||
|
||||
|
||||
namespace
|
||||
@@ -80,6 +83,9 @@ DemoApplication* CreatDemo(btDemoEntry* entry)
|
||||
{
|
||||
demo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
||||
}
|
||||
|
||||
CProfileManager::Reset();
|
||||
|
||||
return demo;
|
||||
|
||||
}
|
||||
@@ -107,6 +113,9 @@ void Timer(int)
|
||||
|
||||
void SimulationLoop()
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (gDrawAabb)
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawAabb);
|
||||
@@ -146,10 +155,15 @@ void SimulationLoop()
|
||||
|
||||
|
||||
if (!demo->isIdle())
|
||||
{
|
||||
demo->clientMoveAndDisplay();
|
||||
else
|
||||
demo->displayCallback();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
demo->displayCallback();
|
||||
}
|
||||
if (testSelection != testIndex)
|
||||
{
|
||||
testIndex = testSelection;
|
||||
@@ -161,11 +175,24 @@ void SimulationLoop()
|
||||
viewY = 0.0f;
|
||||
Resize(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Keyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
if (key >= 0x31 && key < 0x37)
|
||||
{
|
||||
int child = key-0x31;
|
||||
gProfileIterator->Enter_Child(child);
|
||||
}
|
||||
if (key==0x30)
|
||||
{
|
||||
gProfileIterator->Enter_Parent();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 27:
|
||||
@@ -211,7 +238,10 @@ void MouseMotion(int x, int y)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
gProfileIterator = CProfileManager::Get_Iterator();
|
||||
|
||||
|
||||
int bulletVersion = btGetVersion();
|
||||
printf("Bullet version %d\n",bulletVersion);
|
||||
|
||||
|
||||
@@ -104,9 +104,6 @@ void BasicDemo::clientMoveAndDisplay()
|
||||
void BasicDemo::displayCallback(void) {
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
m_dynamicsWorld->updateAabbs();
|
||||
|
||||
renderme();
|
||||
|
||||
|
||||
@@ -300,8 +300,6 @@ void CcdPhysicsDemo::displayCallback(void) {
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
m_dynamicsWorld->updateAabbs();
|
||||
|
||||
|
||||
renderme();
|
||||
|
||||
@@ -431,11 +429,13 @@ int maxNumOutstandingTasks = 4;
|
||||
createSolverLocalStoreMemory,
|
||||
maxNumOutstandingTasks));
|
||||
|
||||
m_solver = new btParallelSequentialImpulseSolver(threadSupportSolver,maxNumOutstandingTasks);
|
||||
m_solver = new btParallelSequentialImpulseSolver(m_threadSupportSolver,maxNumOutstandingTasks);
|
||||
#else
|
||||
m_solver = new btSequentialImpulseConstraintSolver;
|
||||
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
|
||||
|
||||
m_solver = solver;
|
||||
//default solverMode is SOLVER_RANDMIZE_ORDER. Warmstarting seems not to improve convergence, see
|
||||
//m_solver->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
||||
//solver->setSolverMode(0);//btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
||||
|
||||
#endif //USE_PARALLEL_SOLVER
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
|
||||
#endif
|
||||
|
||||
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
|
||||
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,m_collisionConfiguration);
|
||||
#else
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
#endif//USE_PARALLEL_DISPATCHER
|
||||
|
||||
@@ -29,6 +29,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/btDefaultMotionState.h"
|
||||
|
||||
|
||||
#include "BMF_Api.h"
|
||||
|
||||
extern bool gDisableDeactivation;
|
||||
@@ -77,6 +78,7 @@ m_shootBoxShape(0),
|
||||
|
||||
DemoApplication::~DemoApplication()
|
||||
{
|
||||
|
||||
if (m_shootBoxShape)
|
||||
delete m_shootBoxShape;
|
||||
|
||||
@@ -756,6 +758,88 @@ void DemoApplication::resetPerspectiveProjection()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
extern CProfileIterator * gProfileIterator;
|
||||
|
||||
void DemoApplication::displayProfileString(int xOffset,int yStart,char* message)
|
||||
{
|
||||
glRasterPos3f(xOffset,yStart,0);
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),message);
|
||||
}
|
||||
|
||||
|
||||
void DemoApplication::showProfileInfo(float& xOffset,float& yStart, float yIncr)
|
||||
{
|
||||
|
||||
static double time_since_reset = 0.f;
|
||||
if (!m_idle)
|
||||
{
|
||||
time_since_reset = CProfileManager::Get_Time_Since_Reset();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
//recompute profiling data, and store profile strings
|
||||
|
||||
char blockTime[128];
|
||||
|
||||
double totalTime = 0;
|
||||
|
||||
int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset();
|
||||
|
||||
gProfileIterator->First();
|
||||
|
||||
double parent_time = gProfileIterator->Is_Root() ? time_since_reset : gProfileIterator->Get_Current_Parent_Total_Time();
|
||||
|
||||
{
|
||||
sprintf(blockTime,"--- Profiling: %s (total running time: %.3f m) ---", gProfileIterator->Get_Current_Parent_Name(), parent_time );
|
||||
displayProfileString(xOffset,yStart,blockTime);
|
||||
yStart += yIncr;
|
||||
sprintf(blockTime,"press number (1,2...) to display child timings, or 0 to go up to parent" );
|
||||
displayProfileString(xOffset,yStart,blockTime);
|
||||
yStart += yIncr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
double accumulated_time = 0.f;
|
||||
|
||||
for (int i = 0; !gProfileIterator->Is_Done(); gProfileIterator->Next())
|
||||
{
|
||||
double current_total_time = gProfileIterator->Get_Current_Total_Time();
|
||||
accumulated_time += current_total_time;
|
||||
double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
|
||||
|
||||
sprintf(blockTime,"%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)",
|
||||
++i, gProfileIterator->Get_Current_Name(), fraction,
|
||||
(current_total_time / (double)frames_since_reset),gProfileIterator->Get_Current_Total_Calls());
|
||||
displayProfileString(xOffset,yStart,blockTime);
|
||||
yStart += yIncr;
|
||||
totalTime += current_total_time;
|
||||
}
|
||||
|
||||
sprintf(blockTime,"%s (%.3f %%) :: %.3f ms", "Unaccounted",
|
||||
// (min(0, time_since_reset - totalTime) / time_since_reset) * 100);
|
||||
parent_time > SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
|
||||
|
||||
displayProfileString(xOffset,yStart,blockTime);
|
||||
yStart += yIncr;
|
||||
|
||||
|
||||
|
||||
sprintf(blockTime,"-------------------------------------------------");
|
||||
displayProfileString(xOffset,yStart,blockTime);
|
||||
yStart += yIncr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DemoApplication::renderme()
|
||||
{
|
||||
updateCamera();
|
||||
@@ -823,6 +907,8 @@ void DemoApplication::renderme()
|
||||
{
|
||||
setOrthographicProjection();
|
||||
|
||||
showProfileInfo(xOffset,yStart,yIncr);
|
||||
|
||||
#ifdef USE_QUICKPROF
|
||||
|
||||
|
||||
|
||||
@@ -39,15 +39,20 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btMatrix3x3.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
class btCollisionShape;
|
||||
class btDynamicsWorld;
|
||||
class btRigidBody;
|
||||
class btTypedConstraint;
|
||||
|
||||
|
||||
|
||||
|
||||
class DemoApplication
|
||||
{
|
||||
|
||||
void displayProfileString(int xOffset,int yStart,char* message);
|
||||
|
||||
protected:
|
||||
|
||||
btClock m_clock;
|
||||
@@ -82,7 +87,10 @@ class DemoApplication
|
||||
bool m_singleStep;
|
||||
bool m_idle;
|
||||
int m_lastKey;
|
||||
|
||||
|
||||
void showProfileInfo(float& xOffset,float& yStart, float yIncr);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DemoApplication();
|
||||
|
||||
@@ -372,9 +372,6 @@ void RagdollDemo::displayCallback()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
m_dynamicsWorld->updateAabbs();
|
||||
|
||||
renderme();
|
||||
|
||||
glFlush();
|
||||
|
||||
@@ -449,21 +449,9 @@ void VehicleDemo::clientMoveAndDisplay()
|
||||
|
||||
void VehicleDemo::displayCallback(void)
|
||||
{
|
||||
|
||||
clientMoveAndDisplay();
|
||||
return;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
|
||||
//m_dynamicsWorld->updateAabbs();
|
||||
|
||||
//draw contactpoints
|
||||
//m_physicsEnvironmentPtr->CallbackTriggers();
|
||||
|
||||
|
||||
//renderme();
|
||||
renderme();
|
||||
|
||||
|
||||
glFlush();
|
||||
|
||||
Reference in New Issue
Block a user