mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix alignment and locking issues with CommandQueueMT
The allocations of commands in CommandQueueMT weren't aligned. This commit aligns all accesses on 64bit boundaries regardless of target platform. This ensures that all types are aligned. Lock-wise the semaphores were maked as usable when the command had ran but not when the synchronous stub had finished with it. This lead to a race condition where sometimes the semaphore got reused before it was waited on. We now mark the semaphore as free only once we're done waiting on it.
This commit is contained in:
parent
f5477ee36f
commit
24e7a54cd0
2 changed files with 14 additions and 9 deletions
|
@ -97,7 +97,7 @@ tryagain:
|
|||
return false;
|
||||
}
|
||||
|
||||
dealloc_ptr += (size >> 1) + sizeof(uint32_t);
|
||||
dealloc_ptr += (size >> 1) + 8;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,7 @@ CommandQueueMT::CommandQueueMT(bool p_sync) {
|
|||
write_ptr = 0;
|
||||
dealloc_ptr = 0;
|
||||
mutex = Mutex::create();
|
||||
command_mem = (uint8_t *)memalloc(COMMAND_MEM_SIZE);
|
||||
|
||||
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
|
||||
|
||||
|
@ -128,4 +129,5 @@ CommandQueueMT::~CommandQueueMT() {
|
|||
|
||||
memdelete(sync_sems[i].sem);
|
||||
}
|
||||
memfree(command_mem);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue