wsi: add minImageCount override
authorEric Engestrom <eric.engestrom@intel.com>
Thu, 29 Aug 2019 22:49:29 +0000 (23:49 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Fri, 6 Sep 2019 22:16:05 +0000 (23:16 +0100)
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> (v1)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/util/xmlpool/t_options.h
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common.h
src/vulkan/wsi/wsi_common_private.h
src/vulkan/wsi/wsi_common_x11.c

index 6bfc5c652e31490353faf3f2525d182699c6b0a4..9f3dee4945f07db8fa057baa68b052b737ca96c7 100644 (file)
@@ -220,6 +220,11 @@ DRI_CONF_OPT_BEGIN_B(adaptive_sync,def) \
         DRI_CONF_DESC(en,gettext("Adapt the monitor sync to the application performance (when possible)")) \
 DRI_CONF_OPT_END
 
+#define DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(def) \
+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_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 50304e773c92bba7e5591f94277e8cadd0bbe5c4..b8f6c6d70de620c383c77738b3acf24e3dff53b2 100644 (file)
@@ -101,7 +101,7 @@ wsi_device_init(struct wsi_device *wsi,
 #undef WSI_GET_CB
 
 #ifdef VK_USE_PLATFORM_XCB_KHR
-   result = wsi_x11_init_wsi(wsi, alloc);
+   result = wsi_x11_init_wsi(wsi, alloc, dri_options);
    if (result != VK_SUCCESS)
       goto fail;
 #endif
index 46e51286e09d880ed47e7280fe9d8ddf549c3875..b00fc3c18574fa404850cc0c7d1b4ed27285e835 100644 (file)
@@ -109,6 +109,12 @@ struct wsi_device {
     * available. Not all window systems might support this. */
    bool enable_adaptive_sync;
 
+   struct {
+      /* Override the minimum number of images on the swapchain.
+       * 0 = no override */
+      uint32_t override_minImageCount;
+   } x11;
+
    uint64_t (*image_get_modifier)(VkImage image);
 
 #define WSI_CB(cb) PFN_vk##cb cb
index 60d45bc540000b331aae78296ab37c643b488acb..88c360a2409066e1b98c0c852dba016d214703a0 100644 (file)
@@ -138,7 +138,8 @@ struct wsi_interface {
 };
 
 VkResult wsi_x11_init_wsi(struct wsi_device *wsi_device,
-                          const VkAllocationCallbacks *alloc);
+                          const VkAllocationCallbacks *alloc,
+                          const struct driOptionCache *dri_options);
 void wsi_x11_finish_wsi(struct wsi_device *wsi_device,
                         const VkAllocationCallbacks *alloc);
 VkResult wsi_wl_init_wsi(struct wsi_device *wsi_device,
index 91130432a3e166c52f20f751d366e07731e745ec..af61bb91dca8c3cefdf612c5db3945e315ee64d3 100644 (file)
@@ -38,6 +38,7 @@
 #include <xf86drm.h>
 #include "drm-uapi/drm_fourcc.h"
 #include "util/hash_table.h"
+#include "util/xmlconfig.h"
 
 #include "vk_util.h"
 #include "wsi_common_private.h"
@@ -523,6 +524,9 @@ x11_surface_get_capabilities(VkIcdSurfaceBase *icd_surface,
    /* There is no real maximum */
    caps->maxImageCount = 0;
 
+   if (wsi_device->x11.override_minImageCount)
+      caps->minImageCount = wsi_device->x11.override_minImageCount;
+
    caps->supportedTransforms = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
    caps->currentTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
    caps->maxImageArrayLayers = 1;
@@ -1589,7 +1593,8 @@ fail_alloc:
 
 VkResult
 wsi_x11_init_wsi(struct wsi_device *wsi_device,
-                 const VkAllocationCallbacks *alloc)
+                 const VkAllocationCallbacks *alloc,
+                 const struct driOptionCache *dri_options)
 {
    struct wsi_x11 *wsi;
    VkResult result;
@@ -1620,6 +1625,13 @@ wsi_x11_init_wsi(struct wsi_device *wsi_device,
       goto fail_mutex;
    }
 
+   if (dri_options) {
+      if (driCheckOption(dri_options, "vk_x11_override_min_image_count", DRI_INT)) {
+         wsi_device->x11.override_minImageCount =
+            driQueryOptioni(dri_options, "vk_x11_override_min_image_count");
+      }
+   }
+
    wsi->base.get_support = x11_surface_get_support;
    wsi->base.get_capabilities2 = x11_surface_get_capabilities2;
    wsi->base.get_formats = x11_surface_get_formats;