Vulkan: Recreate an additional swapchain that stays suboptimal

Only out of date and a lost surface recreated one, so a TV whose mode
changed without a resize (MoltenVK reports SUBOPTIMAL when the layer's
size no longer matches) kept a stretched picture. Like the main
swapchain, it's now recreated after a few SUBOPTIMAL presents in a row.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-22 23:03:16 +02:00
1 parent 22aa12d047
commit 771e40e297
3 files changed
+10 -1

No files matched your search

+8 -1
View File
@@ -187,7 +187,14 @@ void FrameData::PresentExtraSwapchains(VulkanContext *vulkan) {
VkResult res = vkQueuePresentKHR(vulkan->GetGraphicsQueue(), &present);
if (res == VK_ERROR_OUT_OF_DATE_KHR || res == VK_ERROR_SURFACE_LOST_KHR) {
swapchain->outOfDate = true;
} else if (res != VK_SUCCESS && res != VK_SUBOPTIMAL_KHR) {
} else if (res == VK_SUBOPTIMAL_KHR) {
// Like the main swapchain, recreated once it stays that way (a TV's mode changed without a resize).
if (++swapchain->suboptimalFrames > VulkanContext::MAX_INFLIGHT_FRAMES) {
swapchain->outOfDate = true;
}
} else if (res == VK_SUCCESS) {
swapchain->suboptimalFrames = 0;
} else {
ERROR_LOG(Log::G3D, "vkQueuePresentKHR failed for an additional swapchain: %s", VulkanResultToString(res));
}
swapchain->acquired = false;