diff --git a/src/vulkan/wsi/wsi_common_win32.c b/src/vulkan/wsi/wsi_common_win32.c index 0dc1a359cf8..d53fb782128 100644 --- a/src/vulkan/wsi/wsi_common_win32.c +++ b/src/vulkan/wsi/wsi_common_win32.c @@ -466,7 +466,6 @@ wsi_win32_surface_create_swapchain( chain->base.acquire_next_image = wsi_win32_acquire_next_image; chain->base.queue_present = wsi_win32_queue_present; chain->base.present_mode = wsi_swapchain_get_present_mode(wsi_device, create_info); - chain->base.image_count = num_images; chain->extent = create_info->imageExtent; chain->wsi = wsi; @@ -477,27 +476,22 @@ wsi_win32_surface_create_swapchain( assert(wsi_device->sw); chain->base.use_buffer_blit = true; - for (uint32_t image = 0; image < chain->base.image_count; image++) { + for (uint32_t image = 0; image < num_images; image++) { result = wsi_win32_image_init(device, chain, create_info, allocator, &chain->images[image]); - if (result != VK_SUCCESS) { - while (image > 0) { - --image; - wsi_win32_image_finish(chain, allocator, - &chain->images[image]); - } - wsi_swapchain_finish(&chain->base); - vk_free(allocator, chain); - goto fail_init_images; - } + if (result != VK_SUCCESS) + goto fail; + + chain->base.image_count++; } *swapchain_out = &chain->base; return VK_SUCCESS; -fail_init_images: +fail: + wsi_win32_swapchain_destroy(&chain->base, allocator); return result; }