From 1bdd2a7c867f144feaeaa1aa59472a46baa1a8d8 Mon Sep 17 00:00:00 2001 From: Rose Hudson Date: Wed, 27 Oct 2021 10:45:28 +0100 Subject: [PATCH] Vulkan: account for no limit on image count when clamping image count within device bounds, some devices can report max_image_count = 0 to indicate no limit on image count. this triggers assertion in clamp because max < min. therefore if the device reports zero we treat it as `u32::MAX` see https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSurfaceCapabilitiesKHR.html --- piet-gpu-hal/src/vulkan.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/piet-gpu-hal/src/vulkan.rs b/piet-gpu-hal/src/vulkan.rs index 582c34d..1530abb 100644 --- a/piet-gpu-hal/src/vulkan.rs +++ b/piet-gpu-hal/src/vulkan.rs @@ -423,7 +423,11 @@ impl VkInstance { // Note: can be 2 for non-Android to improve latency, but the real answer is to // implement some kind of frame pacing. const PREFERRED_IMAGE_COUNT: u32 = 3; - let image_count = PREFERRED_IMAGE_COUNT.clamp(capabilities.min_image_count, capabilities.max_image_count); + let max_image_count = match capabilities.max_image_count { + 0 => u32::MAX, + x => x, + }; + let image_count = PREFERRED_IMAGE_COUNT.clamp(capabilities.min_image_count, max_image_count); let mut extent = capabilities.current_extent; if extent.width == u32::MAX || extent.height == u32::MAX { // We're deciding the size.