Handle swapchain image setup failures

This commit is contained in:
LunaDL committed 2026-11-27 16:18:34 -04:00
1 parent 9a7a469ed6
commit b9cc1c80af
1 file changed
+11 -3
+11 -3
View File
@@ -965,17 +965,25 @@ static int swap_init_locked(void) {
cr = g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, NULL);
if (cr != VK_SUCCESS || !g_nimg) {
SWLOGE("present: vkGetSwapchainImagesKHR count failed (%s)", vk_result_name(cr));
g_nimg = 0;
return -1;
}
g_images = calloc(g_nimg, sizeof(VkImage));
if (!g_images) {
SWLOGE("present: failed to allocate swapchain image list");
g_nimg = 0;
return -1;
}
cr = g_vk.GetSwapchainImagesKHR(g_dev, g_swapchain, &g_nimg, g_images);
if (cr != VK_SUCCESS || create_present_semaphores() != 0) {
SWLOGE("present: failed to initialize per-image present semaphores (%s)",
vk_result_name(cr));
if (cr != VK_SUCCESS) {
SWLOGE("present: vkGetSwapchainImagesKHR failed (%s)", vk_result_name(cr));
free(g_images);
g_images = NULL;
g_nimg = 0;
return -1;
}
if (create_present_semaphores() != 0) {
SWLOGE("present: failed to initialize per-image present semaphores");
return -1;
}