From 501a5257fe6cc137a0e4ff343779aa32747e1c29 Mon Sep 17 00:00:00 2001 From: Jordan Halase Date: Sun, 10 Nov 2019 09:42:41 -0600 Subject: Clarification --- main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 4a32cd0..4572828 100755 --- a/main.c +++ b/main.c @@ -1315,6 +1315,11 @@ int rvkConfigureSurface(struct RenderVulkan *vk) static int rvkCreateRawSwapchain(struct RenderVulkan *vk, uint32_t width, uint32_t height) { + /* We must retrieve the surface capabilities every time we make a new + * swapchain because it can change every frame. For example, the + * minimum and maximum extents can change per-frame as the user drag- + * resizes the window. + */ VkSurfaceCapabilitiesKHR surfaceCapabilities; VkResult result; if ((result = vk->api->vkGetPhysicalDeviceSurfaceCapabilitiesKHR( @@ -1337,9 +1342,10 @@ static int rvkCreateRawSwapchain(struct RenderVulkan *vk, uint32_t width, uint32 * Nonetheless, clamping the returned window size to the minimum and * maximum surface capabilities seems to fix the problem completely. * - * Furthermore, it may be possible that we don't even need to query the - * window system for its size at all, and could possibly simply use the - * `currentExtent` of the `VkSurfaceCapabilitiesKHR`. + * The `currentExtent` may hold a special value `UINT32_MAX` to mean + * that the extent will be chosen by the swapchain, instead of the + * usual other way around. This is why we pass our own width and height + * instead of just querying the `currentExtent`. */ width = CLAMP(width, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); height = CLAMP(height, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); -- cgit v1.2.1