diff options
Diffstat (limited to 'sokol_app.h')
| -rw-r--r-- | sokol_app.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sokol_app.h b/sokol_app.h index baaf03ba..2d5726c0 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -4764,6 +4764,20 @@ _SOKOL_PRIVATE void _sapp_vk_swapchain_create_surface( _sapp_vk_set_object_label(VK_OBJECT_TYPE_IMAGE_VIEW, (uint64_t)surf->view, view_debug_label); } +_SOKOL_PRIVATE uint32_t _sapp_vk_swapchain_min_image_count(const VkSurfaceCapabilitiesKHR* surf_caps) { + // FIXME: figure out why at least 3 swapchain images are required to appease the validation layer + // (on the Linux Intel driver, present-mode-fifo has a surf_caps.minImageCount == 3, while + // on Windows surf_caps.minImageCount == 2, and using this directly causes validation layer + // errors about the present-complete semaphore (to reproduce simply change the '= 3' below to '= 2') + SOKOL_ASSERT(surf_caps); + const uint32_t required_image_count = 3; + uint32_t min_image_count = surf_caps->minImageCount; + if (min_image_count < required_image_count) { + min_image_count = required_image_count; + } + return min_image_count; +} + _SOKOL_PRIVATE void _sapp_vk_create_swapchain(bool recreate) { SOKOL_ASSERT(_sapp.vk.physical_device); SOKOL_ASSERT(_sapp.vk.surface); @@ -4797,7 +4811,7 @@ _SOKOL_PRIVATE void _sapp_vk_create_swapchain(bool recreate) { create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; create_info.flags = 0; // FIXME? create_info.surface = _sapp.vk.surface; - create_info.minImageCount = surf_caps.minImageCount; + create_info.minImageCount = _sapp_vk_swapchain_min_image_count(&surf_caps); create_info.imageFormat = _sapp.vk.surface_format.format; create_info.imageColorSpace = _sapp.vk.surface_format.colorSpace; create_info.imageExtent.width = width; |