From bca30aafed897554f0667ade0645d1ffd9284bfb Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 8 Oct 2025 20:02:31 -0700
Subject: [PATCH] Ignore VK_SUBOPTIMAL_KHR on the Android platform
This is returned whenever the device has been rotated, and can be safely ignored.
Fixes https://github.com/libsdl-org/SDL/issues/12950
(cherry picked from commit 00ffddece8f374ab8616aea1d5af5b91a00b875c)
---
src/gpu/vulkan/SDL_gpu_vulkan.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c
index cb9fbbd19aa5d..8adfaacd7fbc5 100644
--- a/src/gpu/vulkan/SDL_gpu_vulkan.c
+++ b/src/gpu/vulkan/SDL_gpu_vulkan.c
@@ -10664,7 +10664,13 @@ static bool VULKAN_Submit(
presentData->windowData->inFlightFences[presentData->windowData->frameCounter] = (SDL_GPUFence*)vulkanCommandBuffer->inFlightFence;
(void)SDL_AtomicIncRef(&vulkanCommandBuffer->inFlightFence->referenceCount);
- if (presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
+// On the Android platform, VK_SUBOPTIMAL_KHR is returned whenever the device is rotated. We'll just ignore this for now.
+#ifndef SDL_PLATFORM_ANDROID
+ if (presentResult == VK_SUBOPTIMAL_KHR) {
+ presentData->windowData->needsSwapchainRecreate = true;
+ }
+#endif
+ if (presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
presentData->windowData->needsSwapchainRecreate = true;
}
} else {