diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-11-21 14:31:14 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-21 14:31:14 -0300 |
commit | 640856f4d4f4e4d10e9f793caf6ac6f4d22678e6 (patch) | |
tree | 961c1f670833437b9e31a45122fc2b5793a9bbab /core/command_queue_mt.cpp | |
parent | 30dadb12281924ccb59efc8df4b3b9ee68c6e3a4 (diff) | |
parent | f9a38d2309043de9e0c763ae72aa81b25c1dfca7 (diff) |
Merge pull request #11895 from m4nu3lf/rendering/separate_thread
Restore rendering on a separate thread
Diffstat (limited to 'core/command_queue_mt.cpp')
-rw-r--r-- | core/command_queue_mt.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index 8e2aa24c22..2028a18a06 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -76,6 +76,30 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() { return &sync_sems[idx]; } +bool CommandQueueMT::dealloc_one() { +tryagain: + if (dealloc_ptr == write_ptr) { + // 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) + sizeof(uint32_t); + return true; +} + CommandQueueMT::CommandQueueMT(bool p_sync) { read_ptr = 0; |