Browse Source

Fix draw calls being listed under Primitive Setup in PStats, etc.

Previously, all draw calls would be grouped under "Primitive Setup", rather than under the appropriate bin collector.  This commit fixes that and adds a few other useful collectors as well.
rdb 7 years ago
parent
commit
53cec96c07

+ 5 - 2
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -91,6 +91,7 @@ PStatCollector CLP(GraphicsStateGuardian)::_vertex_array_update_pcollector("Draw
 PStatCollector CLP(GraphicsStateGuardian)::_texture_update_pcollector("Draw:Update texture");
 PStatCollector CLP(GraphicsStateGuardian)::_texture_update_pcollector("Draw:Update texture");
 PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO");
 PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO");
 PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors");
 PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors");
+PStatCollector CLP(GraphicsStateGuardian)::_check_residency_pcollector("*:PStats:Check residency");
 
 
 // The following noop functions are assigned to the corresponding glext
 // The following noop functions are assigned to the corresponding glext
 // function pointers in the class, in case the functions are not defined by
 // function pointers in the class, in case the functions are not defined by
@@ -3949,6 +3950,7 @@ end_frame(Thread *current_thread) {
   // connects PStats, at which point it will then correct the assessment.  No
   // connects PStats, at which point it will then correct the assessment.  No
   // harm done.
   // harm done.
   if (has_fixed_function_pipeline() && PStatClient::is_connected()) {
   if (has_fixed_function_pipeline() && PStatClient::is_connected()) {
+    PStatTimer timer(_check_residency_pcollector);
     check_nonresident_texture(_prepared_objects->_texture_residency.get_inactive_resident());
     check_nonresident_texture(_prepared_objects->_texture_residency.get_inactive_resident());
     check_nonresident_texture(_prepared_objects->_texture_residency.get_active_resident());
     check_nonresident_texture(_prepared_objects->_texture_residency.get_active_resident());
 
 
@@ -7208,6 +7210,8 @@ do_issue_shade_model() {
  */
  */
 void CLP(GraphicsStateGuardian)::
 void CLP(GraphicsStateGuardian)::
 do_issue_shader() {
 do_issue_shader() {
+  PStatTimer timer(_draw_set_state_shader_pcollector);
+
   ShaderContext *context = 0;
   ShaderContext *context = 0;
   Shader *shader = (Shader *)_target_shader->get_shader();
   Shader *shader = (Shader *)_target_shader->get_shader();
 
 
@@ -10919,7 +10923,6 @@ set_state_and_transform(const RenderState *target,
   _instance_count = _target_shader->get_instance_count();
   _instance_count = _target_shader->get_instance_count();
 
 
   if (_target_shader != _state_shader) {
   if (_target_shader != _state_shader) {
-    // PStatGPUTimer timer(this, _draw_set_state_shader_pcollector);
     do_issue_shader();
     do_issue_shader();
     _state_shader = _target_shader;
     _state_shader = _target_shader;
     _state_mask.clear_bit(TextureAttrib::get_class_slot());
     _state_mask.clear_bit(TextureAttrib::get_class_slot());
@@ -11075,7 +11078,7 @@ set_state_and_transform(const RenderState *target,
   int texture_slot = TextureAttrib::get_class_slot();
   int texture_slot = TextureAttrib::get_class_slot();
   if (_target_rs->get_attrib(texture_slot) != _state_rs->get_attrib(texture_slot) ||
   if (_target_rs->get_attrib(texture_slot) != _state_rs->get_attrib(texture_slot) ||
       !_state_mask.get_bit(texture_slot)) {
       !_state_mask.get_bit(texture_slot)) {
-    // PStatGPUTimer timer(this, _draw_set_state_texture_pcollector);
+    PStatGPUTimer timer(this, _draw_set_state_texture_pcollector);
     determine_target_texture();
     determine_target_texture();
     do_issue_texture();
     do_issue_texture();
 
 

+ 1 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -1126,6 +1126,7 @@ public:
   static PStatCollector _texture_update_pcollector;
   static PStatCollector _texture_update_pcollector;
   static PStatCollector _fbo_bind_pcollector;
   static PStatCollector _fbo_bind_pcollector;
   static PStatCollector _check_error_pcollector;
   static PStatCollector _check_error_pcollector;
+  static PStatCollector _check_residency_pcollector;
 
 
 public:
 public:
   virtual TypeHandle get_type() const {
   virtual TypeHandle get_type() const {

+ 5 - 2
panda/src/gobj/geom.cxx

@@ -1844,8 +1844,11 @@ check_valid(const GeomVertexDataPipelineReader *data_reader) const {
 bool GeomPipelineReader::
 bool GeomPipelineReader::
 draw(GraphicsStateGuardianBase *gsg,
 draw(GraphicsStateGuardianBase *gsg,
      const GeomVertexDataPipelineReader *data_reader, bool force) const {
      const GeomVertexDataPipelineReader *data_reader, bool force) const {
-  PStatTimer timer(Geom::_draw_primitive_setup_pcollector);
-  bool all_ok = gsg->begin_draw_primitives(this, data_reader, force);
+  bool all_ok;
+  {
+    PStatTimer timer(Geom::_draw_primitive_setup_pcollector);
+    all_ok = gsg->begin_draw_primitives(this, data_reader, force);
+  }
   if (all_ok) {
   if (all_ok) {
     Geom::Primitives::const_iterator pi;
     Geom::Primitives::const_iterator pi;
     for (pi = _cdata->_primitives.begin();
     for (pi = _cdata->_primitives.begin();