Skip to content

Commit

Permalink
Merge pull request #619 from jonpikum/glfw-vulkan-demo
Browse files Browse the repository at this point in the history
Minor fixes for GLFW Vulkan Demo
  • Loading branch information
RobLoach authored Apr 4, 2024
2 parents 055a0aa + 03aa308 commit d1fa8f7
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions demo/glfw_vulkan/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -2219,7 +2208,7 @@ int main(void) {
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
continue;
}
if (result != VK_SUCCESS) {
if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
fprintf(stderr, "vkAcquireNextImageKHR failed: %d\n", result);
return false;
}
Expand Down

0 comments on commit d1fa8f7

Please sign in to comment.