diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 496a05e273..c79b470c28 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1431,7 +1431,11 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, } if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) { - win->clear(current_thread); + if (win->is_any_clear_active()) { + GraphicsStateGuardian *gsg = win->get_gsg(); + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); + win->clear(current_thread); + } int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { @@ -1476,6 +1480,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, gsg->prepare_display_region(&dr_reader); if (dr_reader.is_any_clear_active()) { + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); gsg->clear(dr); } @@ -1651,7 +1656,10 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { // a current context for PStatGPUTimer to work. { PStatGPUTimer timer(gsg, win->get_draw_window_pcollector(), current_thread); - win->clear(current_thread); + if (win->is_any_clear_active()) { + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); + win->clear(current_thread); + } if (display_cat.is_spam()) { display_cat.spam() @@ -2015,6 +2023,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre win->change_scenes(&dr_reader); gsg->prepare_display_region(&dr_reader); if (dr_reader.is_any_clear_active()) { + PStatGPUTimer timer(gsg, win->get_clear_window_pcollector(), current_thread); gsg->clear(dr_reader.get_object()); } diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index c94c83f54c..992f634dd9 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -703,6 +703,15 @@ get_draw_window_pcollector() { return _draw_window_pcollector; } +/** + * Returns a PStatCollector for timing the clear operation for just this + * GraphicsOutput. + */ +INLINE PStatCollector &GraphicsOutput:: +get_clear_window_pcollector() { + return _clear_window_pcollector; +} + /** * Display the spam message associated with begin_frame */ diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index c8237059b8..33bfddb79f 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -77,6 +77,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, _lock("GraphicsOutput"), _cull_window_pcollector(_cull_pcollector, name), _draw_window_pcollector(_draw_pcollector, name), + _clear_window_pcollector(_draw_window_pcollector, "Clear"), _size(0, 0) { #ifdef DO_MEMORY_USAGE diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index f426b41bee..49c257e17e 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -289,6 +289,7 @@ public: INLINE PStatCollector &get_cull_window_pcollector(); INLINE PStatCollector &get_draw_window_pcollector(); + INLINE PStatCollector &get_clear_window_pcollector(); protected: virtual void pixel_factor_changed(); @@ -409,6 +410,7 @@ protected: static PStatCollector _draw_pcollector; PStatCollector _cull_window_pcollector; PStatCollector _draw_window_pcollector; + PStatCollector _clear_window_pcollector; public: static TypeHandle get_class_type() { diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 0e82a23f88..93c732e5d7 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -92,7 +92,6 @@ PStatCollector GraphicsStateGuardian::_transform_state_pcollector("State changes PStatCollector GraphicsStateGuardian::_texture_state_pcollector("State changes:Textures"); PStatCollector GraphicsStateGuardian::_draw_primitive_pcollector("Draw:Primitive:Draw"); PStatCollector GraphicsStateGuardian::_draw_set_state_pcollector("Draw:Set State"); -PStatCollector GraphicsStateGuardian::_clear_pcollector("Draw:Clear"); PStatCollector GraphicsStateGuardian::_flush_pcollector("Draw:Flush"); PStatCollector GraphicsStateGuardian::_compute_dispatch_pcollector("Draw:Compute dispatch"); diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index c64bbe692a..e1c9435fef 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -685,7 +685,6 @@ public: static PStatCollector _texture_state_pcollector; static PStatCollector _draw_primitive_pcollector; static PStatCollector _draw_set_state_pcollector; - static PStatCollector _clear_pcollector; static PStatCollector _flush_pcollector; static PStatCollector _compute_dispatch_pcollector; static PStatCollector _wait_occlusion_pcollector; diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index d5a8763fc8..3a65317c5e 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -113,8 +113,6 @@ clear(Thread *current_thread) { << get_name() << " " << (void *)this << "\n"; } - PStatGPUTimer timer(glgsg, glgsg->_clear_pcollector); - // Disable the scissor test, so we can clear the whole buffer. glDisable(GL_SCISSOR_TEST); glgsg->_scissor_enabled = false; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 6ce88525f5..efa5592539 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -3405,7 +3405,6 @@ finish() { */ void CLP(GraphicsStateGuardian):: clear(DrawableRegion *clearable) { - PStatGPUTimer timer(this, _clear_pcollector); report_my_gl_errors(); if (!clearable->is_any_clear_active()) { diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index fd3c44c917..4adc287cb4 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -202,8 +202,6 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { */ void TinyGraphicsStateGuardian:: clear(DrawableRegion *clearable) { - PStatTimer timer(_clear_pcollector); - if ((!clearable->get_clear_color_active())&& (!clearable->get_clear_depth_active())&& (!clearable->get_clear_stencil_active())) {