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.
This commit is contained in:
rdb 2020-04-25 23:38:19 +02:00
parent 80ab6a28c4
commit c59a039fa8
4 changed files with 68 additions and 2 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -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();
}

View File

@ -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;