Mesa (staging/22.0): vulkan/wsi: keep allocate queue families in image, just don't fill them

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 2 17:43:45 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: f2d06ab4d27b0d2ed8ea6711713ca15bc9a9a585
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2d06ab4d27b0d2ed8ea6711713ca15bc9a9a585

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Mar 14 05:54:20 2022 +1000

vulkan/wsi: keep allocate queue families in image, just don't fill them

This changes the code so that it only looks at the passed in families
when concurrent, otherwise it always allocates one.

Fixes: 48b3ef625e19 ("vulkan/wsi: handle queue families properly for non-concurrent sharing mode.")
Acked-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Acked-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Tested-by: Mike Lothian <mike at fireburn.co.uk>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15331>
(cherry picked from commit 85a94be0fec1dad9b22ee346383a4abb46a6e990)

---

 .pick_status.json           |  2 +-
 src/vulkan/wsi/wsi_common.c | 34 +++++++++++++++++++---------------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 75733054d96..34eb55b21a4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1004,7 +1004,7 @@
         "description": "vulkan/wsi: keep allocate queue families in image, just don't fill them",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "because_sha": "48b3ef625e1909c1be31fbe10adb53734af38eb4"
     },
     {
diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c
index 91f0d80b1e5..57b8e58a2d7 100644
--- a/src/vulkan/wsi/wsi_common.c
+++ b/src/vulkan/wsi/wsi_common.c
@@ -360,22 +360,26 @@ wsi_configure_image(const struct wsi_swapchain *chain,
                     struct wsi_image_info *info)
 {
    memset(info, 0, sizeof(*info));
-   uint32_t *queue_family_indices;
-
-   if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
-      queue_family_indices =
-         vk_alloc(&chain->alloc,
-                  sizeof(*queue_family_indices) *
-                  pCreateInfo->queueFamilyIndexCount,
-                  8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
-      if (!queue_family_indices)
-         goto err_oom;
-
+   uint32_t queue_family_count = 1;
+
+   if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT)
+      queue_family_count = pCreateInfo->queueFamilyIndexCount;
+
+   /*
+    * TODO: there should be no reason to allocate this, but
+    * 15331 shows that games crashed without doing this.
+    */
+   uint32_t *queue_family_indices =
+      vk_alloc(&chain->alloc,
+               sizeof(*queue_family_indices) *
+               queue_family_count,
+               8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+   if (!queue_family_indices)
+      goto err_oom;
+
+   if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT)
       for (uint32_t i = 0; i < pCreateInfo->queueFamilyIndexCount; i++)
          queue_family_indices[i] = pCreateInfo->pQueueFamilyIndices[i];
-   } else {
-      queue_family_indices = NULL;
-   }
 
    info->create = (VkImageCreateInfo) {
       .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
@@ -393,7 +397,7 @@ wsi_configure_image(const struct wsi_swapchain *chain,
       .tiling = VK_IMAGE_TILING_OPTIMAL,
       .usage = pCreateInfo->imageUsage,
       .sharingMode = pCreateInfo->imageSharingMode,
-      .queueFamilyIndexCount = pCreateInfo->queueFamilyIndexCount,
+      .queueFamilyIndexCount = queue_family_count,
       .pQueueFamilyIndices = queue_family_indices,
       .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
    };



More information about the mesa-commit mailing list