From 82598e5ca9b401ecfd98fdb3b175a5b0952f0ddb Mon Sep 17 00:00:00 2001 From: Evan Hemsley <2342303+thatcosmonaut@users.noreply.github.com> Date: Sat, 12 Oct 2024 22:02:22 -0700 Subject: [PATCH] GPU Vulkan: Fix frame counter timing (#11189) --- src/gpu/vulkan/SDL_gpu_vulkan.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index 4f4ae3cdf8..5d888d1eef 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -10294,9 +10294,6 @@ static bool VULKAN_Submit( renderer->unifiedQueue, &presentInfo); - presentData->windowData->frameCounter = - (presentData->windowData->frameCounter + 1) % MAX_FRAMES_IN_FLIGHT; - if (presentResult == VK_SUCCESS || presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) { // If presenting, the swapchain is using the in-flight fence presentData->windowData->inFlightFences[presentData->windowData->frameCounter] = (SDL_GPUFence*)vulkanCommandBuffer->inFlightFence; @@ -10308,6 +10305,10 @@ static bool VULKAN_Submit( } else { CHECK_VULKAN_ERROR_AND_RETURN(presentResult, vkQueuePresentKHR, false) } + + presentData->windowData->frameCounter = + (presentData->windowData->frameCounter + 1) % MAX_FRAMES_IN_FLIGHT; + } // Check if we can perform any cleanups