Mesa (master): zink: avoid cached memory allocations when not requested

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 5 02:33:40 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Jan 28 16:32:45 2021 -0500

zink: avoid cached memory allocations when not requested

don't rely on driver orderings to not pick this

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9981>

---

 src/gallium/drivers/zink/zink_resource.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 270567691e6..b2bd1fbb3b1 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -172,14 +172,20 @@ get_memory_type_index(struct zink_screen *screen,
                       const VkMemoryRequirements *reqs,
                       VkMemoryPropertyFlags props)
 {
+   int32_t idx = -1;
    for (uint32_t i = 0u; i < VK_MAX_MEMORY_TYPES; i++) {
       if (((reqs->memoryTypeBits >> i) & 1) == 1) {
          if ((screen->info.mem_props.memoryTypes[i].propertyFlags & props) == props) {
-            return i;
-            break;
+            if (!(props & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) &&
+                screen->info.mem_props.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) {
+               idx = i;
+            } else
+               return i;
          }
       }
    }
+   if (idx >= 0)
+      return idx;
 
    unreachable("Unsupported memory-type");
    return 0;



More information about the mesa-commit mailing list