summaryrefslogtreecommitdiffstats
path: root/core/templates/command_queue_mt.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2021-06-09 12:09:31 -0300
committerreduz <reduzio@gmail.com>2021-06-09 13:10:49 -0300
commitc66b2651a62568b68e0e0540a1f260652cb5ffdb (patch)
treec499ad94ad905a7e6271a138c9da6e62ccc2db41 /core/templates/command_queue_mt.cpp
parent0818a466c0a81c7c9793fd8109d25a74f49c00ae (diff)
downloadredot-engine-c66b2651a62568b68e0e0540a1f260652cb5ffdb.tar.gz
Refactor CommandQueueMT
* RingBuffer had no reason to be in this context * A single buffer is used that can grow as much as the game needs. This should make thread loading entirely reliable.
Diffstat (limited to 'core/templates/command_queue_mt.cpp')
-rw-r--r--core/templates/command_queue_mt.cpp29
1 files changed, 0 insertions, 29 deletions
diff --git a/core/templates/command_queue_mt.cpp b/core/templates/command_queue_mt.cpp
index 238bf3975c..04a8095f0b 100644
--- a/core/templates/command_queue_mt.cpp
+++ b/core/templates/command_queue_mt.cpp
@@ -70,35 +70,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
return &sync_sems[idx];
}
-bool CommandQueueMT::dealloc_one() {
-tryagain:
- if (dealloc_ptr == (write_ptr_and_epoch >> 1)) {
- // The queue is empty
- return false;
- }
-
- uint32_t size = *(uint32_t *)&command_mem[dealloc_ptr];
-
- if (size == 0) {
- // End of command buffer wrap down
- dealloc_ptr = 0;
- goto tryagain;
- }
-
- if (size & 1) {
- // Still used, nothing can be deallocated
- return false;
- }
-
- dealloc_ptr += (size >> 1) + 8;
- return true;
-}
-
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);
}
@@ -108,5 +80,4 @@ CommandQueueMT::~CommandQueueMT() {
if (sync) {
memdelete(sync);
}
- memfree(command_mem);
}