Procházet zdrojové kódy

GPU Vulkan: handle VK_ERROR_SURFACE_LOST_KHR in acquire path

On Android, backgrounding and foregrounding an app causes the Vulkan
surface to be destroyed. vkAcquireNextImageKHR returns
VK_ERROR_SURFACE_LOST_KHR, but the acquire while(true) loop only calls
RecreateSwapchain which doesn't recreate the surface, resulting in an
infinite retry loop and a black screen.

Handle VK_ERROR_SURFACE_LOST_KHR by setting both needsSurfaceRecreate
and needsSwapchainRecreate, then returning to let the existing
recreation path handle it on the next call.

Fixes #15322
Sascha Reuter před 2 dny
rodič
revize
c98b36ff03
1 změnil soubory, kde provedl 7 přidání a 0 odebrání
  1. 7 0
      src/gpu/vulkan/SDL_gpu_vulkan.c

+ 7 - 0
src/gpu/vulkan/SDL_gpu_vulkan.c

@@ -10214,6 +10214,13 @@ static bool VULKAN_INTERNAL_AcquireSwapchainTexture(
             break;  // we got the next image!
         }
 
+        // Surface lost — flag for surface + swapchain recreation on next call
+        if (acquireResult == VK_ERROR_SURFACE_LOST_KHR) {
+            windowData->needsSurfaceRecreate = true;
+            windowData->needsSwapchainRecreate = true;
+            return true;
+        }
+
         // If acquisition is invalid, let's try to recreate
         Uint32 recreateSwapchainResult = VULKAN_INTERNAL_RecreateSwapchain(renderer, windowData);
         if (!recreateSwapchainResult) {