From 9073f68e0a90572ece60c36fcb3c541ce273231f Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 31 Oct 2022 14:16:32 -0700 Subject: [PATCH] Fix swapchain extent check when size is zero --- src/Refresh_Driver_Vulkan.c | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index d53e1be..78f189c 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -4306,6 +4306,27 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain( return 0; } + if ( swapchainSupportDetails.capabilities.currentExtent.width == 0 || + swapchainSupportDetails.capabilities.currentExtent.height == 0) + { + /* Not an error, just minimize behavior! */ + renderer->vkDestroySurfaceKHR( + renderer->instance, + swapchainData->surface, + NULL + ); + if (swapchainSupportDetails.formatsLength > 0) + { + SDL_free(swapchainSupportDetails.formats); + } + if (swapchainSupportDetails.presentModesLength > 0) + { + SDL_free(swapchainSupportDetails.presentModes); + } + SDL_free(swapchainData); + return 0; + } + swapchainData->swapchainFormat = VK_FORMAT_R8G8B8A8_UNORM; swapchainData->swapchainSwizzle.r = VK_COMPONENT_SWIZZLE_IDENTITY; swapchainData->swapchainSwizzle.g = VK_COMPONENT_SWIZZLE_IDENTITY; @@ -4384,27 +4405,6 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain( drawableHeight < swapchainSupportDetails.capabilities.minImageExtent.height || drawableHeight > swapchainSupportDetails.capabilities.maxImageExtent.height ) { - if ( swapchainSupportDetails.capabilities.currentExtent.width == 0 || - swapchainSupportDetails.capabilities.currentExtent.height == 0) - { - renderer->vkDestroySurfaceKHR( - renderer->instance, - swapchainData->surface, - NULL - ); - if (swapchainSupportDetails.formatsLength > 0) - { - SDL_free(swapchainSupportDetails.formats); - } - if (swapchainSupportDetails.presentModesLength > 0) - { - SDL_free(swapchainSupportDetails.presentModes); - } - SDL_free(swapchainData); - /* Not an error, just Windows minimize behavior! */ - return 0; - } - if (swapchainSupportDetails.capabilities.currentExtent.width != UINT32_MAX) { drawableWidth = VULKAN_INTERNAL_clamp(