From a50ae3fcbffb70e46994010cb6e8fbf1788ac3ea Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 14 May 2007 18:42:03 +0000 Subject: [PATCH] report "active" vertex data --- panda/src/display/graphicsEngine.cxx | 18 +++++++++---- panda/src/display/graphicsEngine.h | 1 + panda/src/gobj/geomVertexArrayData.cxx | 6 ++--- panda/src/gobj/simpleLru.I | 25 +++++++++-------- panda/src/gobj/simpleLru.cxx | 33 +++++++++++++++++++++++ panda/src/gobj/simpleLru.h | 5 +++- panda/src/pstatclient/pStatProperties.cxx | 1 + panda/src/putil/linkedListNode.I | 17 ++++++++++++ panda/src/putil/linkedListNode.h | 1 + 9 files changed, 87 insertions(+), 20 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 34f6893d2e..4ce8bdd13f 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -78,6 +78,7 @@ PStatCollector GraphicsEngine::_delete_pcollector("App:Delete"); PStatCollector GraphicsEngine::_sw_sprites_pcollector("SW Sprites"); +PStatCollector GraphicsEngine::_vertex_data_active_pcollector("Vertex Data:Active"); PStatCollector GraphicsEngine::_vertex_data_resident_pcollector("Vertex Data:Resident"); PStatCollector GraphicsEngine::_vertex_data_compressed_pcollector("Vertex Data:Compressed"); PStatCollector GraphicsEngine::_vertex_data_disk_pcollector("Vertex Data:Disk"); @@ -679,8 +680,6 @@ render_frame() { deletor->flush(); } - GeomVertexArrayData::lru_epoch(); - GeomCacheManager::flush_level(); CullTraverser::flush_level(); RenderState::flush_level(); @@ -723,9 +722,6 @@ render_frame() { } _sw_sprites_pcollector.clear_level(); - _vertex_data_resident_pcollector.set_level(GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_resident)->get_total_size()); - _vertex_data_compressed_pcollector.set_level(GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_compressed)->get_total_size()); - _vertex_data_disk_pcollector.set_level(GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_disk)->get_total_size()); _cnode_volume_pcollector.clear_level(); _gnode_volume_pcollector.clear_level(); @@ -746,8 +742,20 @@ render_frame() { _volume_geom_pcollector.clear_level(); _test_geom_pcollector.clear_level(); + if (PStatClient::is_connected()) { + size_t resident = GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_resident)->get_total_size(); + size_t active = GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_resident)->count_active_size(); + _vertex_data_active_pcollector.set_level(active); + _vertex_data_resident_pcollector.set_level(resident - active); + _vertex_data_compressed_pcollector.set_level(GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_compressed)->get_total_size()); + _vertex_data_disk_pcollector.set_level(GeomVertexArrayData::get_global_lru(GeomVertexArrayData::RC_disk)->get_total_size()); + + } + #endif // DO_PSTATS + GeomVertexArrayData::lru_epoch(); + // Now signal all of our threads to begin their next frame. Threads::const_iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index cbe9b80445..750fb2bcad 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -360,6 +360,7 @@ private: static PStatCollector _delete_pcollector; static PStatCollector _sw_sprites_pcollector; + static PStatCollector _vertex_data_active_pcollector; static PStatCollector _vertex_data_resident_pcollector; static PStatCollector _vertex_data_compressed_pcollector; static PStatCollector _vertex_data_disk_pcollector; diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index aa681ebd23..4b45819f3e 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -369,11 +369,11 @@ release_all() { //////////////////////////////////////////////////////////////////// void GeomVertexArrayData:: lru_epoch() { - _ram_lru.consider_evict(); - _compressed_lru.consider_evict(); + _ram_lru.begin_epoch(); + _compressed_lru.begin_epoch(); // No automatic eviction from the Disk LRU. - //_disk_lru.consider_evict(); + //_disk_lru.begin_epoch(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/gobj/simpleLru.I b/panda/src/gobj/simpleLru.I index 4fd1bea4de..651d70d656 100644 --- a/panda/src/gobj/simpleLru.I +++ b/panda/src/gobj/simpleLru.I @@ -17,17 +17,6 @@ //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -SimpleLru:: -SimpleLru(size_t max_size) : LinkedListNode(true) { - _total_size = 0; - _max_size = max_size; -} - //////////////////////////////////////////////////////////////////// // Function: SimpleLru::get_total_size // Access: Published @@ -76,6 +65,20 @@ consider_evict() { } } +//////////////////////////////////////////////////////////////////// +// Function: SimpleLru::begin_epoch +// Access: Published +// Description: Marks the end of the previous epoch and the beginning +// of the next one. This will evict any objects that +// are pending eviction, and also update any internal +// bookkeeping. +//////////////////////////////////////////////////////////////////// +INLINE void SimpleLru:: +begin_epoch() { + consider_evict(); + _active_marker->enqueue_lru(this); +} + //////////////////////////////////////////////////////////////////// // Function: SimpleLruPage::Constructor // Access: Protected diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index 9da6784e89..bda2be0dbd 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -19,6 +19,18 @@ #include "simpleLru.h" +//////////////////////////////////////////////////////////////////// +// Function: SimpleLru::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +SimpleLru:: +SimpleLru(size_t max_size) : LinkedListNode(true) { + _total_size = 0; + _max_size = max_size; + _active_marker = new SimpleLruPage(0); +} + //////////////////////////////////////////////////////////////////// // Function: SimpleLru::Destructor // Access: Published, Virtual @@ -26,6 +38,8 @@ //////////////////////////////////////////////////////////////////// SimpleLru:: ~SimpleLru() { + delete _active_marker; + #ifndef NDEBUG // We're shutting down. Force-remove everything remaining, but // don't explicitly evict it (that would force vertex buffers to @@ -38,6 +52,25 @@ SimpleLru:: #endif } +//////////////////////////////////////////////////////////////////// +// Function: SimpleLru::count_active_size +// Access: Published +// Description: Returns the total size of the pages that were +// enqueued since the last call to begin_epoch(). +//////////////////////////////////////////////////////////////////// +size_t SimpleLru:: +count_active_size() const { + size_t total = 0; + + LinkedListNode *node = _prev; + while (node != _active_marker && node != this) { + total += ((SimpleLruPage *)node)->get_lru_size(); + node = ((SimpleLruPage *)node)->_prev; + } + + return total; +} + //////////////////////////////////////////////////////////////////// // Function: SimpleLru::do_evict // Access: Private diff --git a/panda/src/gobj/simpleLru.h b/panda/src/gobj/simpleLru.h index fcd79e4103..0bb343200d 100644 --- a/panda/src/gobj/simpleLru.h +++ b/panda/src/gobj/simpleLru.h @@ -30,20 +30,23 @@ class SimpleLruPage; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA SimpleLru : public LinkedListNode { PUBLISHED: - INLINE SimpleLru(size_t max_size); + SimpleLru(size_t max_size); ~SimpleLru(); INLINE size_t get_total_size() const; INLINE size_t get_max_size() const; INLINE void set_max_size(size_t max_size); + size_t count_active_size() const; INLINE void consider_evict(); + INLINE void begin_epoch(); private: void do_evict(); size_t _total_size; size_t _max_size; + SimpleLruPage *_active_marker; friend class SimpleLruPage; }; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 64042dd3de..7779171556 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -203,6 +203,7 @@ static LevelCollectorProperties level_properties[] = { { 1, "Vertex Data:Disk", { 0.6, 0.9, 0.1 } }, { 1, "Vertex Data:Compressed", { 0.5, 0.1, 0.4 } }, { 1, "Vertex Data:Resident", { 0.9, 0.1, 0.7 } }, + { 1, "Vertex Data:Active", { 0.5, 0.7, 0.9 } }, { 1, "TransformStates", { 1.0, 0.5, 0.5 }, "", 5000 }, { 1, "TransformStates:On nodes", { 0.2, 0.8, 1.0 } }, { 1, "TransformStates:Cached", { 1.0, 0.0, 0.2 } }, diff --git a/panda/src/putil/linkedListNode.I b/panda/src/putil/linkedListNode.I index 25a2c8948d..771d57a97a 100644 --- a/panda/src/putil/linkedListNode.I +++ b/panda/src/putil/linkedListNode.I @@ -88,6 +88,23 @@ insert_before(LinkedListNode *node) { node->_prev = this; } +//////////////////////////////////////////////////////////////////// +// Function: LinkedListNode::insert_after +// Access: Protected +// Description: Adds a LinkedListNode record after the indicated +// node in the doubly-linked list. +//////////////////////////////////////////////////////////////////// +INLINE void LinkedListNode:: +insert_after(LinkedListNode *node) { + nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); + nassertv(_prev == (LinkedListNode *)NULL && + _next == (LinkedListNode *)NULL); + _next = node->_next; + _prev = node; + _next->_prev = this; + node->_next = this; +} + //////////////////////////////////////////////////////////////////// // Function: LinkedListNode::take_list_from // Access: Protected diff --git a/panda/src/putil/linkedListNode.h b/panda/src/putil/linkedListNode.h index 5af32be17b..a8c073bf8e 100644 --- a/panda/src/putil/linkedListNode.h +++ b/panda/src/putil/linkedListNode.h @@ -40,6 +40,7 @@ protected: INLINE void remove_from_list(); INLINE void insert_before(LinkedListNode *node); + INLINE void insert_after(LinkedListNode *node); INLINE void take_list_from(LinkedListNode *other_root);