mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
metal: Added missing lock in METAL_INTERNAL_PerformPendingDestroys.
Without this lock, a concurrent call to SDL_ReleaseGPUBuffer, SDL_ReleaseGPUTransferBuffer or SDL_ReleaseGPUTexture can cause one of the arrays to be reallocated while METAL_INTERNAL_PerformPendingDestroys is iterating over it, causing a bad day all around.
(cherry picked from commit 1492911c7d)
This commit is contained in:
parent
46f87cdc5a
commit
cc150bc566
1 changed files with 4 additions and 0 deletions
|
|
@ -3545,6 +3545,8 @@ static void METAL_INTERNAL_PerformPendingDestroys(
|
|||
Sint32 i;
|
||||
Uint32 j;
|
||||
|
||||
SDL_LockMutex(renderer->disposeLock);
|
||||
|
||||
for (i = renderer->bufferContainersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
referenceCount = 0;
|
||||
for (j = 0; j < renderer->bufferContainersToDestroy[i]->bufferCount; j += 1) {
|
||||
|
|
@ -3574,6 +3576,8 @@ static void METAL_INTERNAL_PerformPendingDestroys(
|
|||
renderer->textureContainersToDestroyCount -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_UnlockMutex(renderer->disposeLock);
|
||||
}
|
||||
|
||||
// Fences
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue