vulkan: add vk_x11_strict_image_count option
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 5 Sep 2019 20:54:53 +0000 (23:54 +0300)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sun, 15 Sep 2019 12:37:02 +0000 (15:37 +0300)
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 <lionel.g.landwerlin@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111522
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
Cc: 19.2 <mesa-stable@lists.freedesktop.org>
src/amd/vulkan/radv_device.c
src/intel/vulkan/anv_device.c
src/util/00-mesa-defaults.conf
src/util/xmlpool/t_options.h
src/vulkan/wsi/wsi_common.h
src/vulkan/wsi/wsi_common_x11.c

index 7a6af56379787e75ee9c2bfbd98692290124b9ae..bdc38a555dedd44fc753211db19532c57c9576d9 100644 (file)
@@ -559,6 +559,7 @@ DRI_CONF_BEGIN
        DRI_CONF_SECTION_PERFORMANCE
                DRI_CONF_ADAPTIVE_SYNC("true")
                DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0)
+               DRI_CONF_VK_X11_STRICT_IMAGE_COUNT("false")
        DRI_CONF_SECTION_END
 DRI_CONF_END;
 
index b458c15abed5baf1c401f67899dbc6a85749e11d..50d910780cbac3dda369b9fad1fc07fbd9699068 100644 (file)
@@ -52,6 +52,7 @@ static const char anv_dri_options_xml[] =
 DRI_CONF_BEGIN
    DRI_CONF_SECTION_PERFORMANCE
       DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0)
+      DRI_CONF_VK_X11_STRICT_IMAGE_COUNT("false")
    DRI_CONF_SECTION_END
 DRI_CONF_END;
 
index 3deb8aee1a54316f72c049022d3d070103c4ff93..8f3e84788d9054959a47a5147174cf249ad691ca 100644 (file)
@@ -469,6 +469,15 @@ TODO: document the other workarounds.
         <application name="Rayman Legends" executable="Rayman Legends.exe">
             <option name="dynamic_texture_workaround" value="true" />
         </application>
+
+        <!-- Vulkan workarounds: -->
+
+        <!-- Works around the game not starting (does not deal with
+             the implementation returning more images than the minimum
+             specified by the application. -->
+        <engine engine_name_match="UnrealEngine4.*" engine_versions="0:21">
+            <option name="vk_x11_strict_image_count" value="true" />
+        </engine>
     </device>
     <!-- vmwgfx doesn't like full buffer swaps and can't sync to vertical retraces.-->
     <device driver="vmwgfx">
index 9f3dee4945f07db8fa057baa68b052b737ca96c7..e08ba1bf815c2725839f99631a882d19218128bd 100644 (file)
@@ -225,6 +225,11 @@ DRI_CONF_OPT_BEGIN_V(vk_x11_override_min_image_count, int, def, "0:999") \
         DRI_CONF_DESC(en,gettext("Override the VkSurfaceCapabilitiesKHR::minImageCount (0 = no override)")) \
 DRI_CONF_OPT_END
 
+#define DRI_CONF_VK_X11_STRICT_IMAGE_COUNT(def) \
+DRI_CONF_OPT_BEGIN_B(vk_x11_strict_image_count, def) \
+        DRI_CONF_DESC(en,gettext("Force the X11 WSI to create exactly the number of image specified by the application in VkSwapchainCreateInfoKHR::minImageCount")) \
+DRI_CONF_OPT_END
+
 #define DRI_CONF_MESA_GLTHREAD(def) \
 DRI_CONF_OPT_BEGIN_B(mesa_glthread, def) \
         DRI_CONF_DESC(en,gettext("Enable offloading GL driver work to a separate thread")) \
index b00fc3c18574fa404850cc0c7d1b4ed27285e835..064b16a5e7ab14f686e7dd0d12996519ed9a7d28 100644 (file)
@@ -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);
index af61bb91dca8c3cefdf612c5db3945e315ee64d3..491bd8a3702e4e892745f7a0accd29968237afb7 100644 (file)
@@ -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;