summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rwxr-xr-xmain.c12
1 files 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);