demo: don't error-out on image count difference

The Vulkan spec states that create_info.minImageCount determines
the minimum number of images to create, not the exact count.
The count retrieved via vkGetSwapchainImagesKHR can (and in my
case does) differ - without penalty to the rest of the demo.
This commit is contained in:
Jonathan Bradley 2024-03-08 15:01:13 -05:00
parent 40a172bdaa
commit 03aa3086a0

View File

@ -758,7 +758,6 @@ bool create_swap_chain(struct vulkan_demo *demo) {
VkResult result;
VkSwapchainCreateInfoKHR create_info;
uint32_t queue_family_indices[2];
uint32_t old_swap_chain_images_len;
bool ret = false;
queue_family_indices[0] = (uint32_t)demo->indices.graphics;
@ -815,22 +814,12 @@ bool create_swap_chain(struct vulkan_demo *demo) {
goto cleanup;
}
old_swap_chain_images_len = demo->swap_chain_images_len;
result = vkGetSwapchainImagesKHR(demo->device, demo->swap_chain,
&demo->swap_chain_images_len, NULL);
if (result != VK_SUCCESS) {
fprintf(stderr, "vkGetSwapchainImagesKHR failed: %d\n", result);
goto cleanup;
}
if (old_swap_chain_images_len > 0 &&
old_swap_chain_images_len != demo->swap_chain_images_len) {
fprintf(stderr,
"number of assigned swap chain images changed between "
"runs. old: %u, new: %u\n",
(unsigned)old_swap_chain_images_len,
(unsigned)demo->swap_chain_images_len);
goto cleanup;
}
if (demo->swap_chain_images == NULL) {
demo->swap_chain_images =
malloc(demo->swap_chain_images_len * sizeof(VkImage));