Mesa (main): vulkan/wsi: Fix prime blits to use system memory for the destination

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 2 23:55:01 UTC 2021


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Jul  1 13:38:25 2021 -0700

vulkan/wsi: Fix prime blits to use system memory for the destination

The intention here was to pass VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT to
select_memory_types() when requesting device local memory, or simply
pass 0 for the prime blit destination which should be in system memory.

Unfortunately, that meant we did (type.propertyFlags & 0) == 0 which
was vacuously true, causing us to not filter out device local types.

Fixes hybrid display of Vulkan apps on Intel TGL+DG1 systems.

Tested-by: Luis Felipe Strano Moraes <luis.strano at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11680>

---

 src/vulkan/wsi/wsi_common_drm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c
index 57d10c4aa6d..f95530cc958 100644
--- a/src/vulkan/wsi/wsi_common_drm.c
+++ b/src/vulkan/wsi/wsi_common_drm.c
@@ -65,12 +65,14 @@ wsi_device_matches_drm_fd(const struct wsi_device *wsi, int drm_fd)
 
 static uint32_t
 select_memory_type(const struct wsi_device *wsi,
-                   VkMemoryPropertyFlags props,
+                   bool want_device_local,
                    uint32_t type_bits)
 {
    for (uint32_t i = 0; i < wsi->memory_props.memoryTypeCount; i++) {
        const VkMemoryType type = wsi->memory_props.memoryTypes[i];
-       if ((type_bits & (1 << i)) && (type.propertyFlags & props) == props)
+       bool local = type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
+
+       if ((type_bits & (1 << i)) && local == want_device_local)
          return i;
    }
 
@@ -305,8 +307,7 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
       .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
       .pNext = &memory_dedicated_info,
       .allocationSize = reqs.size,
-      .memoryTypeIndex = select_memory_type(wsi, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
-                                            reqs.memoryTypeBits),
+      .memoryTypeIndex = select_memory_type(wsi, true, reqs.memoryTypeBits),
    };
    result = wsi->AllocateMemory(chain->device, &memory_info,
                                 &chain->alloc, &image->memory);
@@ -477,7 +478,7 @@ wsi_create_prime_image(const struct wsi_swapchain *chain,
       .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
       .pNext = &prime_memory_dedicated_info,
       .allocationSize = linear_size,
-      .memoryTypeIndex = select_memory_type(wsi, 0, reqs.memoryTypeBits),
+      .memoryTypeIndex = select_memory_type(wsi, false, reqs.memoryTypeBits),
    };
    result = wsi->AllocateMemory(chain->device, &prime_memory_info,
                                 &chain->alloc, &image->prime.memory);
@@ -531,8 +532,7 @@ wsi_create_prime_image(const struct wsi_swapchain *chain,
       .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
       .pNext = &memory_dedicated_info,
       .allocationSize = reqs.size,
-      .memoryTypeIndex = select_memory_type(wsi, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
-                                            reqs.memoryTypeBits),
+      .memoryTypeIndex = select_memory_type(wsi, true, reqs.memoryTypeBits),
    };
    result = wsi->AllocateMemory(chain->device, &memory_info,
                                 &chain->alloc, &image->memory);



More information about the mesa-commit mailing list