fix some fence edge cases
continuous-integration/drone/push Build is passing Details

pull/7/head
cosmonaut 2022-01-17 21:09:27 -08:00
parent e59e3e6b02
commit 80fdf09d86
1 changed files with 48 additions and 39 deletions

View File

@ -8469,29 +8469,32 @@ static void VULKAN_INTERNAL_ResetUsedFences(
) { ) {
uint32_t i; uint32_t i;
/* Prepare the command buffer fence for submission */ if (renderer->usedFenceCount > 0)
renderer->vkResetFences(
renderer->logicalDevice,
renderer->usedFenceCount,
renderer->usedFences
);
/* Used fences are now available */
if (renderer->usedFenceCount + renderer->availableFenceCount >= renderer->availableFenceCapacity)
{ {
renderer->availableFenceCapacity = renderer->usedFenceCount + renderer->availableFenceCount; /* Prepare the command buffer fence for submission */
renderer->availableFences = SDL_realloc( renderer->vkResetFences(
renderer->availableFences, renderer->logicalDevice,
renderer->availableFenceCapacity * sizeof(VkFence) renderer->usedFenceCount,
renderer->usedFences
); );
}
for (i = 0; i < renderer->usedFenceCount; i += 1) /* Used fences are now available */
{ if (renderer->usedFenceCount + renderer->availableFenceCount >= renderer->availableFenceCapacity)
renderer->availableFences[renderer->availableFenceCount] = renderer->usedFences[i]; {
renderer->availableFenceCount += 1; renderer->availableFenceCapacity = renderer->usedFenceCount + renderer->availableFenceCount;
renderer->availableFences = SDL_realloc(
renderer->availableFences,
renderer->availableFenceCapacity * sizeof(VkFence)
);
}
for (i = 0; i < renderer->usedFenceCount; i += 1)
{
renderer->availableFences[renderer->availableFenceCount] = renderer->usedFences[i];
renderer->availableFenceCount += 1;
}
renderer->usedFenceCount = 0;
} }
renderer->usedFenceCount = 0;
} }
/* Submission structure */ /* Submission structure */
@ -8501,15 +8504,18 @@ static void VULKAN_Wait(
) { ) {
VulkanRenderer *renderer = (VulkanRenderer*) driverData; VulkanRenderer *renderer = (VulkanRenderer*) driverData;
renderer->vkWaitForFences( if (renderer->usedFenceCount > 0)
renderer->logicalDevice, {
renderer->usedFenceCount, renderer->vkWaitForFences(
renderer->usedFences, renderer->logicalDevice,
VK_TRUE, renderer->usedFenceCount,
UINT64_MAX renderer->usedFences,
); VK_TRUE,
UINT64_MAX
);
VULKAN_INTERNAL_ResetUsedFences(renderer); VULKAN_INTERNAL_ResetUsedFences(renderer);
}
} }
static void VULKAN_Submit( static void VULKAN_Submit(
@ -8573,19 +8579,22 @@ static void VULKAN_Submit(
if (present) if (present)
{ {
/* Wait for the previous submission to complete */ /* Wait for the previous submission to complete */
vulkanResult = renderer->vkWaitForFences( if (renderer->usedFenceCount)
renderer->logicalDevice,
renderer->usedFenceCount,
renderer->usedFences,
VK_TRUE,
UINT64_MAX
);
if (vulkanResult != VK_SUCCESS)
{ {
SDL_UnlockMutex(renderer->submitLock); vulkanResult = renderer->vkWaitForFences(
LogVulkanResultAsError("vkWaitForFences", vulkanResult); renderer->logicalDevice,
return; renderer->usedFenceCount,
renderer->usedFences,
VK_TRUE,
UINT64_MAX
);
if (vulkanResult != VK_SUCCESS)
{
SDL_UnlockMutex(renderer->submitLock);
LogVulkanResultAsError("vkWaitForFences", vulkanResult);
return;
}
} }
VULKAN_INTERNAL_PostWorkCleanup(renderer); VULKAN_INTERNAL_PostWorkCleanup(renderer);