Chapter 1 VK_CHECK seems to fail when acquiring the first swapchain image for a second time.
When attemping to acquiring the image of index 0 a second time, VK_CHECK fails and aborts. Output of swapchainImageIndex without VK_CHECK before crash
0
1
2
3
0
With VK_CHECK
0
1
2
3
Program error message:
Aborted (core dumped)
When pausing the thread just before it crashes, it seems the screen is also black, instead of the blue it is meant to be. There are no validation errors.
The VK_CHECK macro was not printing any error codes so I printed them myself, and it seems that it is caused by VK_SUBOPTIMAL_KHR. Adding fflush() to VK_CHECK(x) fixes the problem with the macro. I am not resizing the window, I checked SDL for the event and no resizing was occurring.
Calling
destroy_swapchain();
init_swapchain();
init_sync_structures();
Seems to fix the issue.
I started recreating the swapchain instead of just using VK_CHECK which crashes the program. I think VK_CHECK(x) should just disable any vulkan errors instead of aborting.