diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2020-10-15 22:35:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-15 22:35:44 +0200 |
| commit | 88a3db5bff3c5d62aec7e7ade4f6c62bf2d0ec3e (patch) | |
| tree | 971d9f7c4567f806461381078837bd7c0193dc9b /core/command_queue_mt.cpp | |
| parent | 1b443da1827e312db1aa99e3895c1879caf246ca (diff) | |
| parent | 9f654b441fffa613568e30a4c53a57390be69e12 (diff) | |
| download | redot-engine-88a3db5bff3c5d62aec7e7ade4f6c62bf2d0ec3e.tar.gz | |
Merge pull request #42315 from lyuma/command_queue_fix
core/command_queue_mt.h: Fix crash/hang when buffer fills up
Diffstat (limited to 'core/command_queue_mt.cpp')
| -rw-r--r-- | core/command_queue_mt.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index ace210ca2c..a55eed5d3c 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -31,6 +31,7 @@ #include "command_queue_mt.h" #include "core/os/os.h" +#include "core/project_settings.h" void CommandQueueMT::lock() { mutex.lock(); @@ -71,7 +72,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() { bool CommandQueueMT::dealloc_one() { tryagain: - if (dealloc_ptr == write_ptr) { + if (dealloc_ptr == (write_ptr_and_epoch >> 1)) { // The queue is empty return false; } @@ -94,6 +95,10 @@ tryagain: } CommandQueueMT::CommandQueueMT(bool p_sync) { + command_mem_size = GLOBAL_DEF_RST("memory/limits/command_queue/multithreading_queue_size_kb", DEFAULT_COMMAND_MEM_SIZE_KB); + ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/command_queue/multithreading_queue_size_kb", PropertyInfo(Variant::INT, "memory/limits/command_queue/multithreading_queue_size_kb", PROPERTY_HINT_RANGE, "1,4096,1,or_greater")); + command_mem_size *= 1024; + command_mem = (uint8_t *)memalloc(command_mem_size); if (p_sync) { sync = memnew(Semaphore); } |
