Skip to content

Commit 8ec0372

Browse files
committed
Merge pull request godotengine#90470 from RandomShaper/fix_cmd_queue_mt_reentrancy
CommandQueueMT: Fix flush re-entrancy
2 parents 17665ec + 114b14b commit 8ec0372

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

core/templates/command_queue_mt.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ class CommandQueueMT {
364364
void _flush() {
365365
lock();
366366

367+
if (unlikely(flush_read_ptr)) {
368+
// Re-entrant call.
369+
unlock();
370+
return;
371+
}
372+
367373
WorkerThreadPool::thread_enter_command_queue_mt_flush(this);
368374
while (flush_read_ptr < command_mem.size()) {
369375
uint64_t size = *(uint64_t *)&command_mem[flush_read_ptr];
@@ -376,13 +382,6 @@ class CommandQueueMT {
376382
sync_sem->sem.post(); // Release in case it needs sync/ret.
377383
}
378384

379-
if (unlikely(flush_read_ptr == 0)) {
380-
// A reentrant call flushed.
381-
DEV_ASSERT(command_mem.is_empty());
382-
unlock();
383-
return;
384-
}
385-
386385
flush_read_ptr += size;
387386
}
388387
WorkerThreadPool::thread_exit_command_queue_mt_flush();

0 commit comments

Comments
 (0)