disp/vulkan: Don't crash when image acquire fails multiple times

It is not uncommon for swapchain image acquire to fail multiple times in
a row e.g. when the user is continuously resizing the windown with the
mouse cursor. There is really no need to raise an exception and crash
the whole process.
This commit is contained in:
Martin Piatka
2025-03-20 13:18:22 +01:00
parent 9eeede3954
commit 0956c6a8d3

View File

@@ -564,9 +564,12 @@ bool VulkanDisplay::display_queued_image() {
int swapchain_recreation_attempt = 0;
while (swapchain_image_id == swapchain_image_out_of_date || swapchain_image_id == swapchain_image_timeout)
{
const int swapchain_recreation_warn_tries = 50;
swapchain_recreation_attempt++;
if (swapchain_recreation_attempt > 3) {
throw VulkanError{"Cannot acquire swapchain image"};
if (swapchain_image_id == swapchain_image_timeout){
vulkan_log_msg(LogLevel::warning, "Swapchain image acquire timed out\n");
} else if (swapchain_recreation_attempt > swapchain_recreation_warn_tries) {
vulkan_log_msg(LogLevel::warning, "Swapchain image acquire failed "s + std::to_string(swapchain_recreation_warn_tries) + "times in a row\n");
}
auto window_parameters = window->get_window_parameters();