From fa5f9a7e15dd886ab1534404671914f31402fb46 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 24 Sep 2004 17:56:14 +0000 Subject: [PATCH] clean up state pstatting --- panda/src/display/graphicsStateGuardian.I | 31 +++++++++++++-------- panda/src/display/graphicsStateGuardian.cxx | 5 ++-- panda/src/display/graphicsStateGuardian.h | 2 +- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 32d5e85fed..e1670506db 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -241,14 +241,17 @@ reset_if_new() { //////////////////////////////////////////////////////////////////// INLINE void GraphicsStateGuardian:: modify_state(const RenderState *state) { + if (!state->is_empty()) { #ifndef NDEBUG - if (gsg_cat.is_spam()) { - gsg_cat.spam() << "Modifying GSG state with:\n"; - state->write(gsg_cat.spam(false), 2); - } + if (gsg_cat.is_spam()) { + gsg_cat.spam() << "Modifying GSG state with:\n"; + state->write(gsg_cat.spam(false), 2); + } #endif - _state = _state->issue_delta_modify(state, this); - finish_modify_state(); + _state_pcollector.add_level(1); + _state = _state->issue_delta_modify(state, this); + finish_modify_state(); + } } //////////////////////////////////////////////////////////////////// @@ -265,14 +268,17 @@ modify_state(const RenderState *state) { //////////////////////////////////////////////////////////////////// INLINE void GraphicsStateGuardian:: set_state(const RenderState *state) { + if (state != _state) { #ifndef NDEBUG - if (gsg_cat.is_spam()) { - gsg_cat.spam() << "Setting GSG state to:\n"; - state->write(gsg_cat.spam(false), 2); - } + if (gsg_cat.is_spam()) { + gsg_cat.spam() << "Setting GSG state to:\n"; + state->write(gsg_cat.spam(false), 2); + } #endif - _state = _state->issue_delta_set(state, this); - finish_modify_state(); + _state_pcollector.add_level(1); + _state = _state->issue_delta_set(state, this); + finish_modify_state(); + } } //////////////////////////////////////////////////////////////////// @@ -286,6 +292,7 @@ set_state(const RenderState *state) { INLINE void GraphicsStateGuardian:: set_transform(const TransformState *transform) { if (transform != _transform) { + _state_pcollector.add_level(1); _transform = transform; issue_transform(transform); } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index b0b99046c4..811e17f0d7 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -55,9 +55,9 @@ PStatCollector GraphicsStateGuardian::_vertices_tristrip_pcollector("Vertices:Tr PStatCollector GraphicsStateGuardian::_vertices_trifan_pcollector("Vertices:Triangle fans"); PStatCollector GraphicsStateGuardian::_vertices_tri_pcollector("Vertices:Triangles"); PStatCollector GraphicsStateGuardian::_vertices_other_pcollector("Vertices:Other"); +PStatCollector GraphicsStateGuardian::_state_pcollector("State changes"); PStatCollector GraphicsStateGuardian::_transform_state_pcollector("State changes:Transforms"); PStatCollector GraphicsStateGuardian::_texture_state_pcollector("State changes:Textures"); -PStatCollector GraphicsStateGuardian::_other_state_pcollector("State changes:Other"); PStatCollector GraphicsStateGuardian::_draw_primitive_pcollector("Draw:Primitive"); PStatCollector GraphicsStateGuardian::_clear_pcollector("Draw:Clear"); PStatCollector GraphicsStateGuardian::_flush_pcollector("Draw:Flush"); @@ -233,7 +233,6 @@ release_geom(GeomContext *) { void GraphicsStateGuardian:: set_state_and_transform(const RenderState *state, const TransformState *transform) { - set_transform(transform); set_state(state); } @@ -1246,9 +1245,9 @@ init_frame_pstats() { _vertices_tri_pcollector.clear_level(); _vertices_other_pcollector.clear_level(); + _state_pcollector.clear_level(); _transform_state_pcollector.clear_level(); _texture_state_pcollector.clear_level(); - _other_state_pcollector.clear_level(); } } diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index c41fabc03d..550d6a0b01 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -293,9 +293,9 @@ public: static PStatCollector _vertices_trifan_pcollector; static PStatCollector _vertices_tri_pcollector; static PStatCollector _vertices_other_pcollector; + static PStatCollector _state_pcollector; static PStatCollector _transform_state_pcollector; static PStatCollector _texture_state_pcollector; - static PStatCollector _other_state_pcollector; static PStatCollector _draw_primitive_pcollector; static PStatCollector _clear_pcollector; static PStatCollector _flush_pcollector;