From 90300d22d97c1d4f41a52996cf054d36c3088a82 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 28 Apr 2005 21:17:27 +0000 Subject: [PATCH] track active cache --- panda/src/display/graphicsEngine.cxx | 1 + panda/src/gobj/qpgeomCacheEntry.cxx | 20 +++++++++++++++++++- panda/src/gobj/qpgeomCacheManager.cxx | 7 +++++++ panda/src/gobj/qpgeomCacheManager.h | 1 + panda/src/pstatclient/pStatProperties.cxx | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index e713c66d9d..b10442de65 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -501,6 +501,7 @@ render_frame() { CullTraverser::_nodes_pcollector.clear_level(); CullTraverser::_geom_nodes_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_erase_pcollector.clear_level(); qpGeomCacheManager::_geom_cache_evict_pcollector.clear_level(); diff --git a/panda/src/gobj/qpgeomCacheEntry.cxx b/panda/src/gobj/qpgeomCacheEntry.cxx index f900872d06..7cdbaf51ec 100644 --- a/panda/src/gobj/qpgeomCacheEntry.cxx +++ b/panda/src/gobj/qpgeomCacheEntry.cxx @@ -57,6 +57,10 @@ record() { cache_mgr->_geom_cache_record_pcollector.add_level(1); _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 // so we don't have to play games with it later--this is inner-loop // stuff. @@ -86,7 +90,14 @@ refresh() { remove_from_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_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; } diff --git a/panda/src/gobj/qpgeomCacheManager.cxx b/panda/src/gobj/qpgeomCacheManager.cxx index f7e9cf3473..c3432fd1fc 100644 --- a/panda/src/gobj/qpgeomCacheManager.cxx +++ b/panda/src/gobj/qpgeomCacheManager.cxx @@ -23,6 +23,7 @@ qpGeomCacheManager *qpGeomCacheManager::_global_ptr = NULL; 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_erase_pcollector("Geom cache operations:erase"); PStatCollector qpGeomCacheManager::_geom_cache_evict_pcollector("Geom cache operations:evict"); @@ -106,6 +107,12 @@ evict_old_entries() { entry->evict_callback(); + if (PStatClient::is_connected()) { + if (entry->_last_frame_used == current_frame) { + qpGeomCacheManager::_geom_cache_active_pcollector.sub_level(1); + } + } + --_total_size; entry->remove_from_list(); _geom_cache_evict_pcollector.add_level(1); diff --git a/panda/src/gobj/qpgeomCacheManager.h b/panda/src/gobj/qpgeomCacheManager.h index 3d0faf034c..4f705187a5 100644 --- a/panda/src/gobj/qpgeomCacheManager.h +++ b/panda/src/gobj/qpgeomCacheManager.h @@ -87,6 +87,7 @@ private: public: static PStatCollector _geom_cache_size_pcollector; + static PStatCollector _geom_cache_active_pcollector; static PStatCollector _geom_cache_record_pcollector; static PStatCollector _geom_cache_erase_pcollector; static PStatCollector _geom_cache_evict_pcollector; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index a99750bc5f..f7af346188 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/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:Index", { 0.8, 0.6, 0.3 } }, { 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:record", { 0.2, 0.4, 0.8 } }, { 1, "Geom cache operations:erase", { 0.4, 0.8, 0.2 } },