Mesa (main): vulkan/wsi: add use_prime_blit param to wsi_swapchain_init

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 11 13:08:04 UTC 2022


Module: Mesa
Branch: main
Commit: 0ad7ec56c9beed5e221a1b8f9412d477d7943b7d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ad7ec56c9beed5e221a1b8f9412d477d7943b7d

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Fri Jan  7 14:49:30 2022 +0100

vulkan/wsi: add use_prime_blit param to wsi_swapchain_init

Instead of initializing it to false and overriding it later if
needed.

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13959>

---

 src/vulkan/wsi/wsi_common.c         |  5 +++--
 src/vulkan/wsi/wsi_common_display.c |  2 +-
 src/vulkan/wsi/wsi_common_private.h |  3 ++-
 src/vulkan/wsi/wsi_common_wayland.c |  2 +-
 src/vulkan/wsi/wsi_common_win32.c   |  2 +-
 src/vulkan/wsi/wsi_common_x11.c     | 11 ++++++-----
 6 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 03b094713e3..d2a828e864f 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -220,7 +220,8 @@ wsi_swapchain_init(const struct wsi_device *wsi,
                    struct wsi_swapchain *chain,
                    VkDevice device,
                    const VkSwapchainCreateInfoKHR *pCreateInfo,
-                   const VkAllocationCallbacks *pAllocator)
+                   const VkAllocationCallbacks *pAllocator,
+                   bool use_prime_blit)
 {
    VkResult result;
 
@@ -231,7 +232,7 @@ wsi_swapchain_init(const struct wsi_device *wsi,
    chain->wsi = wsi;
    chain->device = device;
    chain->alloc = *pAllocator;
-   chain->use_prime_blit = false;
+   chain->use_prime_blit = use_prime_blit;
 
    chain->cmd_pools =
       vk_zalloc(pAllocator, sizeof(VkCommandPool) * wsi->queue_family_count, 8,
diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c
index 4990b17cc67..c25a326267b 100644
--- a/src/vulkan/wsi/wsi_common_display.c
+++ b/src/vulkan/wsi/wsi_common_display.c
@@ -1906,7 +1906,7 @@ wsi_display_surface_create_swapchain(
       return VK_ERROR_OUT_OF_HOST_MEMORY;
 
    VkResult result = wsi_swapchain_init(wsi_device, &chain->base, device,
-                                        create_info, allocator);
+                                        create_info, allocator, false);
    if (result != VK_SUCCESS) {
       vk_free(allocator, chain);
       return result;
diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h
index 3eb14d22f9e..7356d100e0c 100644
--- a/src/vulkan/wsi/wsi_common_private.h
+++ b/src/vulkan/wsi/wsi_common_private.h
@@ -80,7 +80,8 @@ wsi_swapchain_init(const struct wsi_device *wsi,
                    struct wsi_swapchain *chain,
                    VkDevice device,
                    const VkSwapchainCreateInfoKHR *pCreateInfo,
-                   const VkAllocationCallbacks *pAllocator);
+                   const VkAllocationCallbacks *pAllocator,
+                   bool use_prime_blit);
 
 enum VkPresentModeKHR
 wsi_swapchain_get_present_mode(struct wsi_device *wsi,
diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c
index 09a4f67b226..aee2791bd23 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -1237,7 +1237,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
       return VK_ERROR_OUT_OF_HOST_MEMORY;
 
    result = wsi_swapchain_init(wsi_device, &chain->base, device,
-                               pCreateInfo, pAllocator);
+                               pCreateInfo, pAllocator, false);
    if (result != VK_SUCCESS) {
       vk_free(pAllocator, chain);
       return result;
diff --git a/src/vulkan/wsi/wsi_common_win32.c b/src/vulkan/wsi/wsi_common_win32.c
index 15078485d2e..002b3f31040 100644
--- a/src/vulkan/wsi/wsi_common_win32.c
+++ b/src/vulkan/wsi/wsi_common_win32.c
@@ -596,7 +596,7 @@ wsi_win32_surface_create_swapchain(
       return VK_ERROR_OUT_OF_HOST_MEMORY;
 
    VkResult result = wsi_swapchain_init(wsi_device, &chain->base, device,
-                                        create_info, allocator);
+                                        create_info, allocator, false);
    if (result != VK_SUCCESS) {
       vk_free(allocator, chain);
       return result;
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index de9794cd1f0..8883cb430dd 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -1762,8 +1762,13 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
    if (chain == NULL)
       return VK_ERROR_OUT_OF_HOST_MEMORY;
 
+   bool use_prime_blit = false;
+   if (!wsi_device->sw)
+      if (!wsi_x11_check_dri3_compatible(wsi_device, conn))
+         use_prime_blit = true;
+
    result = wsi_swapchain_init(wsi_device, &chain->base, device,
-                               pCreateInfo, pAllocator);
+                               pCreateInfo, pAllocator, use_prime_blit);
    if (result != VK_SUCCESS)
       goto fail_alloc;
 
@@ -1799,10 +1804,6 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
     */
    chain->copy_is_suboptimal = false;
 
-   if (!wsi_device->sw)
-      if (!wsi_x11_check_dri3_compatible(wsi_device, conn))
-         chain->base.use_prime_blit = true;
-
    chain->event_id = xcb_generate_id(chain->conn);
    xcb_present_select_input(chain->conn, chain->event_id, chain->window,
                             XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |



More information about the mesa-commit mailing list