From 3f622bbe815217953438dc41ccde7c8de11d3e1b Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 3 Mar 2006 17:45:43 +0000 Subject: [PATCH] track Cull:Setup time properly --- panda/src/display/graphicsEngine.cxx | 43 +++++++++++++++-------- panda/src/display/graphicsEngine.h | 2 ++ panda/src/pstatclient/pStatProperties.cxx | 3 +- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 36469a9659..03ec0b24ed 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -52,6 +52,8 @@ PStatCollector GraphicsEngine::_render_frame_pcollector("App:render_frame"); PStatCollector GraphicsEngine::_do_frame_pcollector("*:do_frame"); PStatCollector GraphicsEngine::_yield_pcollector("App:Yield"); PStatCollector GraphicsEngine::_cull_pcollector("Cull"); +PStatCollector GraphicsEngine::_cull_setup_pcollector("Cull:Setup"); +PStatCollector GraphicsEngine::_cull_sort_pcollector("Cull:Sort"); PStatCollector GraphicsEngine::_draw_pcollector("Draw"); PStatCollector GraphicsEngine::_sync_pcollector("Draw:Sync"); PStatCollector GraphicsEngine::_flip_pcollector("Draw:Flip"); @@ -580,10 +582,13 @@ render_frame() { #endif // THREADED_PIPELINE && DO_PSTATS // Now cycle the pipeline and officially begin the next frame. +#ifdef THREADED_PIPELINE { PStatTimer timer(_cycle_pcollector); _pipeline->cycle(); } +#endif // THREADED_PIPELINE + ClockObject *global_clock = ClockObject::get_global_clock(); global_clock->tick(); if (global_clock->check_errors()) { @@ -815,6 +820,8 @@ set_window_sort(GraphicsOutput *window, int sort) { //////////////////////////////////////////////////////////////////// void GraphicsEngine:: cull_and_draw_together(const GraphicsEngine::Windows &wlist) { + PStatTimer timer(_cull_pcollector); + Windows::const_iterator wi; for (wi = wlist.begin(); wi != wlist.end(); ++wi) { GraphicsOutput *win = (*wi); @@ -891,6 +898,8 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr) { //////////////////////////////////////////////////////////////////// void GraphicsEngine:: cull_to_bins(const GraphicsEngine::Windows &wlist) { + PStatTimer timer(_cull_pcollector); + // Keep track of the cameras we have already used in this thread to // render DisplayRegions. typedef pmap AlreadyCulled; @@ -941,22 +950,29 @@ cull_to_bins(GraphicsOutput *win, DisplayRegion *dr) { GraphicsStateGuardian *gsg = win->get_gsg(); nassertv(gsg != (GraphicsStateGuardian *)NULL); - PT(CullResult) cull_result = dr->get_cull_result(); - if (cull_result != (CullResult *)NULL) { - cull_result = cull_result->make_next(); - } else { - cull_result = new CullResult(gsg); + PT(CullResult) cull_result; + PT(SceneSetup) scene_setup; + { + PStatTimer timer(_cull_setup_pcollector); + cull_result = dr->get_cull_result(); + if (cull_result != (CullResult *)NULL) { + cull_result = cull_result->make_next(); + } else { + cull_result = new CullResult(gsg); + } + scene_setup = setup_scene(gsg, dr); } - PT(SceneSetup) scene_setup = setup_scene(gsg, dr); if (scene_setup != (SceneSetup *)NULL) { BinCullHandler cull_handler(cull_result); do_cull(&cull_handler, scene_setup, gsg); - - cull_result->finish_cull(); - - // Save the results for next frame. - dr->set_cull_result(cull_result, scene_setup); + + { + PStatTimer timer(_cull_sort_pcollector); + cull_result->finish_cull(); + // Save the results for next frame. + dr->set_cull_result(cull_result, scene_setup); + } } } @@ -1168,6 +1184,8 @@ do_flip_frame() { //////////////////////////////////////////////////////////////////// PT(SceneSetup) GraphicsEngine:: setup_scene(GraphicsStateGuardian *gsg, DisplayRegion *dr) { + PStatTimer timer(_cull_setup_pcollector); + GraphicsOutput *window = dr->get_window(); // The window pointer shouldn't be NULL, since we presumably got to // this particular DisplayRegion by walking through a list on a @@ -1250,9 +1268,6 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegion *dr) { void GraphicsEngine:: do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsStateGuardian *gsg) { - // Statistics - PStatTimer timer(_cull_pcollector); - CullTraverser trav(gsg); trav.set_cull_handler(cull_handler); trav.set_depth_offset_decals(depth_offset_decals && gsg->depth_offset_decals()); diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index b22b95a008..22c5bd468e 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -257,6 +257,8 @@ private: static PStatCollector _do_frame_pcollector; static PStatCollector _yield_pcollector; static PStatCollector _cull_pcollector; + static PStatCollector _cull_setup_pcollector; + static PStatCollector _cull_sort_pcollector; static PStatCollector _draw_pcollector; static PStatCollector _sync_pcollector; static PStatCollector _flip_pcollector; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 5dda76f0eb..a482a51424 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -123,7 +123,8 @@ static TimeCollectorProperties time_properties[] = { { 0, "App:Show code:Nametags:3d:Contents", { 0.0, 0.5, 0.0 } }, { 0, "App:Show code:Nametags:3d:Adjust", { 0.5, 0.0, 0.5 } }, { 1, "Cull", { 0.0, 1.0, 0.0 }, 1.0 / 30.0 }, - { 1, "Cull:Sort", { 0.3, 0.6, 0.3 } }, + { 1, "Cull:Setup", { 0.7, 0.4, 0.5 } }, + { 1, "Cull:Sort", { 0.3, 0.3, 0.6 } }, { 1, "*:Show fps", { 0.5, 0.8, 1.0 } }, { 0, "*:Munge", { 0.3, 0.3, 0.9 } }, { 0, "*:Munge:Points", { 0.2, 0.8, 0.4 } },