diff options
author | Jordan Halase <jordan@halase.me> | 2019-11-10 09:42:41 -0600 |
---|---|---|
committer | Jordan Halase <jordan@halase.me> | 2019-11-10 09:42:41 -0600 |
commit | 501a5257fe6cc137a0e4ff343779aa32747e1c29 (patch) | |
tree | 2ad282be04c7c299590a6d7bec23eec30b4c71ae | |
parent | b82ab62675256f47f3476421fddcbd4cebf09b64 (diff) |
Clarification
-rwxr-xr-x | main.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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); |