From 0616b7ac90cf4f86bb409d34101e3a3cceac8cbe Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 5 Sep 2019 23:54:53 +0300 Subject: vulkan: add vk_x11_strict_image_count option This option strictly allocate the minImageCount given by the application at swapchain creation. This works around application that do not deal with the fact that the implementation allocates more images than the minimum specified. v2: Add values in default drirc (Bas) v3: specify engine name/version (Lionel) Signed-off-by: Lionel Landwerlin Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111522 Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Eric Engestrom Cc: 19.2 --- src/vulkan/wsi/wsi_common.h | 5 +++++ src/vulkan/wsi/wsi_common_x11.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/vulkan') diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index b00fc3c1857..064b16a5e7a 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -113,6 +113,11 @@ struct wsi_device { /* Override the minimum number of images on the swapchain. * 0 = no override */ uint32_t override_minImageCount; + + /* Forces strict number of image on the swapchain using application + * provided VkSwapchainCreateInfoKH::RminImageCount. + */ + bool strict_imageCount; } x11; uint64_t (*image_get_modifier)(VkImage image); diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index af61bb91dca..491bd8a3702 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -1413,7 +1413,9 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR); unsigned num_images = pCreateInfo->minImageCount; - if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) + if (wsi_device->x11.strict_imageCount) + num_images = pCreateInfo->minImageCount; + else if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) num_images = MAX2(num_images, 5); xcb_connection_t *conn = x11_surface_get_connection(icd_surface); @@ -1630,6 +1632,10 @@ wsi_x11_init_wsi(struct wsi_device *wsi_device, wsi_device->x11.override_minImageCount = driQueryOptioni(dri_options, "vk_x11_override_min_image_count"); } + if (driCheckOption(dri_options, "vk_x11_strict_image_count", DRI_BOOL)) { + wsi_device->x11.strict_imageCount = + driQueryOptionb(dri_options, "vk_x11_strict_image_count"); + } } wsi->base.get_support = x11_surface_get_support; -- cgit v1.2.3