mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
pgraph: Remove need for grabbing lock in RenderState destructor
This commit is contained in:
parent
4e925a839a
commit
94570f20aa
@ -90,6 +90,6 @@ add_total_size(int count) {
|
||||
INLINE void CacheStats::
|
||||
add_num_states(int count) {
|
||||
#ifndef NDEBUG
|
||||
_num_states += count;
|
||||
_num_states.fetch_add(count, std::memory_order_relaxed);
|
||||
#endif // NDEBUG
|
||||
}
|
||||
|
@ -51,12 +51,13 @@ reset(double now) {
|
||||
void CacheStats::
|
||||
write(std::ostream &out, const char *name) const {
|
||||
#ifndef NDEBUG
|
||||
int num_states = _num_states.load(std::memory_order_relaxed);
|
||||
out << name << " cache: " << _cache_hits << " hits, "
|
||||
<< _cache_misses << " misses\n"
|
||||
<< _cache_adds + _cache_new_adds << "(" << _cache_new_adds << ") adds(new), "
|
||||
<< _cache_dels << " dels, "
|
||||
<< _total_cache_size << " / " << _num_states << " = "
|
||||
<< (double)_total_cache_size / (double)_num_states
|
||||
<< _total_cache_size << " / " << num_states << " = "
|
||||
<< (double)_total_cache_size / (double)num_states
|
||||
<< " average cache size\n";
|
||||
#endif // NDEBUG
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "clockObject.h"
|
||||
#include "patomic.h"
|
||||
#include "pnotify.h"
|
||||
|
||||
/**
|
||||
@ -45,7 +46,7 @@ private:
|
||||
int _cache_new_adds = 0;
|
||||
int _cache_dels = 0;
|
||||
int _total_cache_size = 0;
|
||||
int _num_states = 0;
|
||||
patomic<int> _num_states {0};
|
||||
double _last_reset = 0.0;
|
||||
|
||||
bool _cache_report = false;
|
||||
|
@ -117,8 +117,6 @@ RenderState::
|
||||
nassertv(!is_destructing());
|
||||
set_destructing();
|
||||
|
||||
LightReMutexHolder holder(*_states_lock);
|
||||
|
||||
// unref() should have cleared these.
|
||||
nassertv(_saved_entry == -1);
|
||||
nassertv(_composition_cache.is_empty() && _invert_composition_cache.is_empty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user