Skip to content

Commit 63be56c

Browse files
committed
Backport part of b21e8fd that fixes an issue with geometry generation when multithreaded pipeline is enabled
Fixes bullet soft body issue as well as LP 1671639
1 parent 20085d1 commit 63be56c

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

panda/src/putil/copyOnWritePointer.cxx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,17 @@ get_write_pointer() {
9999
}
100100

101101
PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy();
102+
_cow_object->CachedTypedWritableReferenceCount::cache_unref();
103+
_cow_object->_lock_mutex.release();
102104

103-
// We can't call cache_unref_delete, because we hold the lock.
104-
if (!_cow_object->CachedTypedWritableReferenceCount::cache_unref()) {
105-
_cow_object->_lock_mutex.release();
106-
delete _cow_object;
107-
} else {
108-
_cow_object->_lock_mutex.release();
109-
}
105+
MutexHolder holder(new_object->_lock_mutex);
110106
_cow_object = new_object;
111-
_cow_object->cache_ref();
107+
_cow_object->CachedTypedWritableReferenceCount::cache_ref();
112108
_cow_object->_lock_status = CopyOnWriteObject::LS_locked_write;
113109
_cow_object->_locking_thread = current_thread;
114110

111+
return new_object;
112+
115113
} else if (_cow_object->get_cache_ref_count() > 1) {
116114
// No one else has it specifically read-locked, but there are
117115
// other CopyOnWritePointers holding the same object, so we should
@@ -124,19 +122,17 @@ get_write_pointer() {
124122
}
125123

126124
PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy();
125+
_cow_object->CachedTypedWritableReferenceCount::cache_unref();
126+
_cow_object->_lock_mutex.release();
127127

128-
// We can't call cache_unref_delete, because we hold the lock.
129-
if (!_cow_object->CachedTypedWritableReferenceCount::cache_unref()) {
130-
_cow_object->_lock_mutex.release();
131-
delete _cow_object;
132-
} else {
133-
_cow_object->_lock_mutex.release();
134-
}
128+
MutexHolder holder(new_object->_lock_mutex);
135129
_cow_object = new_object;
136-
_cow_object->cache_ref();
130+
_cow_object->CachedTypedWritableReferenceCount::cache_ref();
137131
_cow_object->_lock_status = CopyOnWriteObject::LS_locked_write;
138132
_cow_object->_locking_thread = current_thread;
139133

134+
return new_object;
135+
140136
} else {
141137
// No other thread has the pointer locked, and we're the only
142138
// CopyOnWritePointer with this object. We can safely write to it

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy