Browse Source

pgraph: fix RenderState/TransformState count in PStats exploding

This was a regression in 1.10.6 that caused PStats to misreport the amount of RenderState/TransformStates in the application.
rdb 5 years ago
parent
commit
c59a039fa8

+ 29 - 1
panda/src/pgraph/renderState.I

@@ -481,6 +481,34 @@ flush_level() {
   _cache_counter.flush_level();
 }
 
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void RenderState::
+cache_ref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_ref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_ref_only();
+#endif  // DO_PSTATS
+}
+
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void RenderState::
+cache_unref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_unref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_unref_only();
+#endif  // DO_PSTATS
+}
+
 #ifndef CPPPARSER
 /**
  * Handy templated version of get_attrib that casts to the right type.
@@ -533,7 +561,7 @@ check_hash() const {
  */
 INLINE bool RenderState::
 do_cache_unref() const {
-  cache_unref_only();
+  NodeCachedReferenceCount::cache_unref_only();
   return unref();
 }
 

+ 5 - 0
panda/src/pgraph/renderState.h

@@ -169,6 +169,11 @@ public:
   INLINE void get_attrib_def(CPT(AttribType) &attrib) const;
 #endif  // CPPPARSER
 
+  INLINE void cache_ref_only() const;
+
+protected:
+  INLINE void cache_unref_only() const;
+
 private:
   INLINE void check_hash() const;
   bool validate_filled_slots() const;

+ 29 - 1
panda/src/pgraph/transformState.I

@@ -753,6 +753,34 @@ flush_level() {
   _cache_counter.flush_level();
 }
 
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void TransformState::
+cache_ref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_ref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_ref_only();
+#endif  // DO_PSTATS
+}
+
+/**
+ * Overrides this method to update PStats appropriately.
+ */
+INLINE void TransformState::
+cache_unref_only() const {
+#ifdef DO_PSTATS
+  int old_referenced_bits = get_referenced_bits();
+  NodeCachedReferenceCount::cache_unref_only();
+  consider_update_pstats(old_referenced_bits);
+#else  // DO_PSTATS
+  NodeCachedReferenceCount::cache_unref_only();
+#endif  // DO_PSTATS
+}
+
 /**
  * Reimplements NodeReferenceCount::node_unref().  We do this because we have
  * a non-virtual unref() method.
@@ -769,7 +797,7 @@ do_node_unref() const {
  */
 INLINE bool TransformState::
 do_cache_unref() const {
-  cache_unref_only();
+  NodeCachedReferenceCount::cache_unref_only();
   return unref();
 }
 

+ 5 - 0
panda/src/pgraph/transformState.h

@@ -213,6 +213,11 @@ public:
 
   INLINE static void flush_level();
 
+  INLINE void cache_ref_only() const;
+
+protected:
+  INLINE void cache_unref_only() const;
+
 private:
   INLINE bool do_cache_unref() const;
   INLINE bool do_node_unref() const;