Vulkan-Tutorial icon indicating copy to clipboard operation
Vulkan-Tutorial copied to clipboard

Possibly wrong code snippet

Open Pacheco95 opened this issue 2 years ago • 0 comments

The range of the possible resolutions is defined in the VkSurfaceCapabilitiesKHR structure. Vulkan tells us to match the resolution of the window by setting the width and height in the currentExtent member. However, some window managers do allow us to differ here and this is indicated by setting the width and height in currentExtent to a special value: the maximum value of uint32_t. In that case we’ll pick the resolution that best matches the window within the minImageExtent and maxImageExtent bounds. But we must specify the resolution in the correct unit

So if Vulkan doesn’t fix the swap extent for us, we can’t just use the original {WIDTH, HEIGHT}. Instead, we must use glfwGetFramebufferSize to query the resolution of the window in pixel before matching it against the minimum and maximum image extent.

currentExtent is the current width and height of the surface, or the special value (0xFFFFFFFF, 0xFFFFFFFF) indicating that the surface size will be determined by the extent of a swapchain targeting the surface.

From those quotes I understood that if

capabilities.currentExtent.width == std::numeric_limits<uint32_t>::max()

then, Vulkan already did set up the correct extent, right?

So, if my understanding was correct, the comparison should be ==, not != thus avoiding the call to glfwGetFramebufferSize()

https://github.com/KhronosGroup/Vulkan-Tutorial/blob/c6df655c9fe3b65595c3e60676922f35f00c3e8f/en/03_Drawing_a_triangle/01_Presentation/01_Swap_chain.adoc?plain=1#L324

Pacheco95 avatar Nov 04 '23 22:11 Pacheco95