summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Halase <jordan@halase.me>2019-11-10 09:42:41 -0600
committerJordan Halase <jordan@halase.me>2019-11-10 09:42:41 -0600
commit501a5257fe6cc137a0e4ff343779aa32747e1c29 (patch)
tree2ad282be04c7c299590a6d7bec23eec30b4c71ae
parentb82ab62675256f47f3476421fddcbd4cebf09b64 (diff)
Clarification
-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);