Browse Source

track active cache

David Rose 20 years ago
parent
commit
90300d22d9

+ 1 - 0
panda/src/display/graphicsEngine.cxx

@@ -501,6 +501,7 @@ render_frame() {
   CullTraverser::_nodes_pcollector.clear_level();
   CullTraverser::_nodes_pcollector.clear_level();
   CullTraverser::_geom_nodes_pcollector.clear_level();
   CullTraverser::_geom_nodes_pcollector.clear_level();
   CullTraverser::_geoms_pcollector.clear_level();
   CullTraverser::_geoms_pcollector.clear_level();
+  qpGeomCacheManager::_geom_cache_active_pcollector.clear_level();
   qpGeomCacheManager::_geom_cache_record_pcollector.clear_level();
   qpGeomCacheManager::_geom_cache_record_pcollector.clear_level();
   qpGeomCacheManager::_geom_cache_erase_pcollector.clear_level();
   qpGeomCacheManager::_geom_cache_erase_pcollector.clear_level();
   qpGeomCacheManager::_geom_cache_evict_pcollector.clear_level();
   qpGeomCacheManager::_geom_cache_evict_pcollector.clear_level();

+ 19 - 1
panda/src/gobj/qpgeomCacheEntry.cxx

@@ -57,6 +57,10 @@ record() {
   cache_mgr->_geom_cache_record_pcollector.add_level(1);
   cache_mgr->_geom_cache_record_pcollector.add_level(1);
   _last_frame_used = ClockObject::get_global_clock()->get_frame_count();
   _last_frame_used = ClockObject::get_global_clock()->get_frame_count();
 
 
+  if (PStatClient::is_connected()) {
+    qpGeomCacheManager::_geom_cache_active_pcollector.add_level(1);
+  }
+
   // Increment our own reference count while we're in the queue, just
   // Increment our own reference count while we're in the queue, just
   // so we don't have to play games with it later--this is inner-loop
   // so we don't have to play games with it later--this is inner-loop
   // stuff.
   // stuff.
@@ -86,7 +90,14 @@ refresh() {
   remove_from_list();
   remove_from_list();
   insert_before(cache_mgr->_list);
   insert_before(cache_mgr->_list);
 
 
-  _last_frame_used = ClockObject::get_global_clock()->get_frame_count();
+  int current_frame = ClockObject::get_global_clock()->get_frame_count();
+  if (PStatClient::is_connected()) {
+    if (_last_frame_used != current_frame) {
+      qpGeomCacheManager::_geom_cache_active_pcollector.add_level(1);
+    }
+  }
+
+  _last_frame_used = current_frame;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -115,6 +126,13 @@ erase() {
   cache_mgr->_geom_cache_size_pcollector.set_level(cache_mgr->_total_size);
   cache_mgr->_geom_cache_size_pcollector.set_level(cache_mgr->_total_size);
   cache_mgr->_geom_cache_erase_pcollector.add_level(1);
   cache_mgr->_geom_cache_erase_pcollector.add_level(1);
 
 
+  if (PStatClient::is_connected()) {
+    int current_frame = ClockObject::get_global_clock()->get_frame_count();
+    if (_last_frame_used == current_frame) {
+      qpGeomCacheManager::_geom_cache_active_pcollector.sub_level(1);
+    }
+  }
+
   return this;
   return this;
 }
 }
 
 

+ 7 - 0
panda/src/gobj/qpgeomCacheManager.cxx

@@ -23,6 +23,7 @@
 qpGeomCacheManager *qpGeomCacheManager::_global_ptr = NULL;
 qpGeomCacheManager *qpGeomCacheManager::_global_ptr = NULL;
 
 
 PStatCollector qpGeomCacheManager::_geom_cache_size_pcollector("Geom cache size");
 PStatCollector qpGeomCacheManager::_geom_cache_size_pcollector("Geom cache size");
+PStatCollector qpGeomCacheManager::_geom_cache_active_pcollector("Geom cache size:Active");
 PStatCollector qpGeomCacheManager::_geom_cache_record_pcollector("Geom cache operations:record");
 PStatCollector qpGeomCacheManager::_geom_cache_record_pcollector("Geom cache operations:record");
 PStatCollector qpGeomCacheManager::_geom_cache_erase_pcollector("Geom cache operations:erase");
 PStatCollector qpGeomCacheManager::_geom_cache_erase_pcollector("Geom cache operations:erase");
 PStatCollector qpGeomCacheManager::_geom_cache_evict_pcollector("Geom cache operations:evict");
 PStatCollector qpGeomCacheManager::_geom_cache_evict_pcollector("Geom cache operations:evict");
@@ -106,6 +107,12 @@ evict_old_entries() {
 
 
     entry->evict_callback();
     entry->evict_callback();
 
 
+    if (PStatClient::is_connected()) {
+      if (entry->_last_frame_used == current_frame) {
+        qpGeomCacheManager::_geom_cache_active_pcollector.sub_level(1);
+      }
+    }
+
     --_total_size;
     --_total_size;
     entry->remove_from_list();
     entry->remove_from_list();
     _geom_cache_evict_pcollector.add_level(1);
     _geom_cache_evict_pcollector.add_level(1);

+ 1 - 0
panda/src/gobj/qpgeomCacheManager.h

@@ -87,6 +87,7 @@ private:
 
 
 public:
 public:
   static PStatCollector _geom_cache_size_pcollector;
   static PStatCollector _geom_cache_size_pcollector;
+  static PStatCollector _geom_cache_active_pcollector;
   static PStatCollector _geom_cache_record_pcollector;
   static PStatCollector _geom_cache_record_pcollector;
   static PStatCollector _geom_cache_erase_pcollector;
   static PStatCollector _geom_cache_erase_pcollector;
   static PStatCollector _geom_cache_evict_pcollector;
   static PStatCollector _geom_cache_evict_pcollector;

+ 1 - 0
panda/src/pstatclient/pStatProperties.cxx

@@ -170,6 +170,7 @@ static LevelCollectorProperties level_properties[] = {
   { 1, "Vertex buffer switch:Vertex",      { 0.8, 0.0, 0.6 } },
   { 1, "Vertex buffer switch:Vertex",      { 0.8, 0.0, 0.6 } },
   { 1, "Vertex buffer switch:Index",       { 0.8, 0.6, 0.3 } },
   { 1, "Vertex buffer switch:Index",       { 0.8, 0.6, 0.3 } },
   { 1, "Geom cache size",                  { 0.6, 0.8, 0.6 },  "", 500 },
   { 1, "Geom cache size",                  { 0.6, 0.8, 0.6 },  "", 500 },
+  { 1, "Geom cache size:Active",           { 0.9, 1.0, 0.3 },  "", 500 },
   { 1, "Geom cache operations",            { 1.0, 0.6, 0.6 },  "", 500 },
   { 1, "Geom cache operations",            { 1.0, 0.6, 0.6 },  "", 500 },
   { 1, "Geom cache operations:record",     { 0.2, 0.4, 0.8 } },
   { 1, "Geom cache operations:record",     { 0.2, 0.4, 0.8 } },
   { 1, "Geom cache operations:erase",      { 0.4, 0.8, 0.2 } },
   { 1, "Geom cache operations:erase",      { 0.4, 0.8, 0.2 } },