Skip to content

Commit 6d5815d

Browse files
committed
vulkan: Deal with VK_ERROR_OUT_OF_DATE_KHR returns from vkAcquireNextImageKHR.
Fixes #11075.
1 parent 6b7dad7 commit 6d5815d

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/gpu/vulkan/SDL_gpu_vulkan.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9858,24 +9858,7 @@ static bool VULKAN_INTERNAL_AcquireSwapchainTexture(
98589858
}
98599859

98609860
// Finally, try to acquire!
9861-
acquireResult = renderer->vkAcquireNextImageKHR(
9862-
renderer->logicalDevice,
9863-
windowData->swapchain,
9864-
SDL_MAX_UINT64,
9865-
windowData->imageAvailableSemaphore[windowData->frameCounter],
9866-
VK_NULL_HANDLE,
9867-
&swapchainImageIndex);
9868-
9869-
// Acquisition is invalid, let's try to recreate
9870-
if (acquireResult != VK_SUCCESS && acquireResult != VK_SUBOPTIMAL_KHR) {
9871-
Uint32 recreateSwapchainResult = VULKAN_INTERNAL_RecreateSwapchain(renderer, windowData);
9872-
if (!recreateSwapchainResult) {
9873-
return false;
9874-
} else if (recreateSwapchainResult == VULKAN_INTERNAL_TRY_AGAIN) {
9875-
// Edge case, texture is filled in with NULL but not an error
9876-
return true;
9877-
}
9878-
9861+
while (true) {
98799862
acquireResult = renderer->vkAcquireNextImageKHR(
98809863
renderer->logicalDevice,
98819864
windowData->swapchain,
@@ -9884,8 +9867,19 @@ static bool VULKAN_INTERNAL_AcquireSwapchainTexture(
98849867
VK_NULL_HANDLE,
98859868
&swapchainImageIndex);
98869869

9887-
if (acquireResult != VK_SUCCESS && acquireResult != VK_SUBOPTIMAL_KHR) {
9870+
//if (acquireResult == VK_ERROR_OUT_OF_DATE_KHR) { SDL_Log("VULKAN SWAPCHAIN OUT OF DATE"); }
9871+
9872+
if (acquireResult == VK_SUCCESS || acquireResult == VK_SUBOPTIMAL_KHR) {
9873+
break; // we got the next image!
9874+
}
9875+
9876+
// If acquisition is invalid, let's try to recreate
9877+
Uint32 recreateSwapchainResult = VULKAN_INTERNAL_RecreateSwapchain(renderer, windowData);
9878+
if (!recreateSwapchainResult) {
98889879
return false;
9880+
} else if (recreateSwapchainResult == VULKAN_INTERNAL_TRY_AGAIN) {
9881+
// Edge case, texture is filled in with NULL but not an error
9882+
return true;
98899883
}
98909884
}
98919885

0 commit comments

Comments
 (0)