rework nested mutex lock on FetchFramebuffer
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

pull/41/head
cosmonaut 2023-05-16 20:02:39 -07:00
parent 0ef91c7f42
commit 313b4b81cc
1 changed files with 12 additions and 7 deletions

View File

@ -1811,7 +1811,6 @@ typedef struct VulkanRenderer
uint8_t needDefrag;
uint32_t defragTimer;
uint8_t resourceFreed;
#define VULKAN_INSTANCE_FUNCTION(ext, ret, func, params) \
vkfntype_##func func;
@ -2361,7 +2360,6 @@ static void VULKAN_INTERNAL_RemoveMemoryUsedRegion(
SDL_free(usedRegion);
renderer->resourceFreed = 1;
SDL_UnlockMutex(renderer->allocatorLock);
}
@ -8489,8 +8487,6 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
uint32_t attachmentCount = 0;
uint32_t i;
SDL_LockMutex(renderer->framebufferFetchLock);
for (i = 0; i < MAX_COLOR_TARGET_BINDINGS; i += 1)
{
hash.colorAttachmentViews[i] = VK_NULL_HANDLE;
@ -8551,14 +8547,17 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
hash.width = width;
hash.height = height;
SDL_LockMutex(renderer->framebufferFetchLock);
vulkanFramebuffer = FramebufferHashArray_Fetch(
&renderer->framebufferHashArray,
&hash
);
SDL_UnlockMutex(renderer->framebufferFetchLock);
if (vulkanFramebuffer != NULL)
{
SDL_UnlockMutex(renderer->framebufferFetchLock);
return vulkanFramebuffer;
}
@ -8637,11 +8636,15 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
if (result == VK_SUCCESS)
{
SDL_LockMutex(renderer->framebufferFetchLock);
FramebufferHashArray_Insert(
&renderer->framebufferHashArray,
hash,
vulkanFramebuffer
);
SDL_UnlockMutex(renderer->framebufferFetchLock);
}
else
{
@ -8650,7 +8653,6 @@ static VulkanFramebuffer* VULKAN_INTERNAL_FetchFramebuffer(
vulkanFramebuffer = NULL;
}
SDL_UnlockMutex(renderer->framebufferFetchLock);
return vulkanFramebuffer;
}
@ -10246,7 +10248,11 @@ static void VULKAN_Wait(
{
LogVulkanResultAsError("vkWaitForFences", result);
}
}
for (i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1)
{
commandBuffer = renderer->submittedCommandBuffers[i];
VULKAN_INTERNAL_CleanCommandBuffer(renderer, commandBuffer);
}
@ -11983,7 +11989,6 @@ static Refresh_Device* VULKAN_CreateDevice(
renderer->needDefrag = 0;
renderer->defragTimer = 0;
renderer->resourceFreed = 0;
return result;
}