Mesa (main): vulkan/wsi: fix select_memory_type when all MTs are local

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 8 17:25:39 UTC 2021


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

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Wed Jul  7 15:01:13 2021 -0700

vulkan/wsi: fix select_memory_type when all MTs are local

The intention is to pick the system memory for the prime blit dst, but
that is not possible when all memory types are advertised to be local.

This fixes venus over vtest (i.e., unix socket) because the driver
provides no PCI bus info and wsi_device_matches_drm_fd returns false.  A
driver might also use can_present_on_device to force prime blit.

Fixes: 469875596a6 ("vulkan/wsi: Fix prime blits to use system memory for the destination")

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11774>

---

 src/vulkan/wsi/wsi_common_drm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/vulkan/wsi/wsi_common_drm.c b/src/vulkan/wsi/wsi_common_drm.c
index f95530cc958..70d934aef13 100644
--- a/src/vulkan/wsi/wsi_common_drm.c
+++ b/src/vulkan/wsi/wsi_common_drm.c
@@ -68,12 +68,22 @@ select_memory_type(const struct wsi_device *wsi,
                    bool want_device_local,
                    uint32_t type_bits)
 {
+   assert(type_bits);
+
+   bool all_local = true;
    for (uint32_t i = 0; i < wsi->memory_props.memoryTypeCount; i++) {
        const VkMemoryType type = wsi->memory_props.memoryTypes[i];
        bool local = type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
 
        if ((type_bits & (1 << i)) && local == want_device_local)
          return i;
+       all_local &= local;
+   }
+
+   /* ignore want_device_local when all memory types are device-local */
+   if (all_local) {
+      assert(!want_device_local);
+      return ffs(type_bits) - 1;
    }
 
    unreachable("No memory type found");



More information about the mesa-commit mailing list