diff options
| author | m4nu3lf | 2017-10-13 18:13:52 +0100 |
|---|---|---|
| committer | m4nu3lf | 2017-11-18 18:37:44 +0000 |
| commit | f9a38d2309043de9e0c763ae72aa81b25c1dfca7 (patch) | |
| tree | 9cb30ca09a367bb9967c0dd6a69633f47c39d5da /core/command_queue_mt.cpp | |
| parent | 871c47a2bba3ce5adaf5e46e5f8d64acf5a48a1d (diff) | |
| download | godot-f9a38d2309043de9e0c763ae72aa81b25c1dfca7.tar.gz godot-f9a38d2309043de9e0c763ae72aa81b25c1dfca7.tar.zst godot-f9a38d2309043de9e0c763ae72aa81b25c1dfca7.zip | |
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 8e2aa24c2..2028a18a0 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; |
