Mesa (main): zink: check for dedicated allocation requirements during image alloc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 19 23:53:38 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Jul 19 11:33:04 2021 -0400

zink: check for dedicated allocation requirements during image alloc

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

---

 src/gallium/drivers/zink/zink_device_info.py |  1 +
 src/gallium/drivers/zink/zink_resource.c     | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/zink/zink_device_info.py b/src/gallium/drivers/zink/zink_device_info.py
index a32eb3346eb..6e295784c55 100644
--- a/src/gallium/drivers/zink/zink_device_info.py
+++ b/src/gallium/drivers/zink/zink_device_info.py
@@ -71,6 +71,7 @@ EXTENSIONS = [
        properties=True,
        conditions=["$feats.provokingVertexLast"]),
     Extension("VK_EXT_shader_viewport_index_layer"),
+    Extension("VK_KHR_get_memory_requirements2"),
     Extension("VK_EXT_post_depth_coverage"),
     Extension("VK_KHR_driver_properties",
         alias="driver",
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index add656aa9ff..ee19ae5da04 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -509,6 +509,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
 
    VkMemoryRequirements reqs = {0};
    VkMemoryPropertyFlags flags;
+   bool need_dedicated = false;
    /* TODO: remove linear for wsi */
    bool scanout = (templ->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_LINEAR)) == (PIPE_BIND_SCANOUT | PIPE_BIND_LINEAR);
    bool shared = (templ->bind & (PIPE_BIND_SHARED | PIPE_BIND_LINEAR)) == (PIPE_BIND_SHARED | PIPE_BIND_LINEAR);
@@ -615,7 +616,23 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
          goto fail1;
       }
 
-      vkGetImageMemoryRequirements(screen->dev, obj->image, &reqs);
+      if (screen->vk.GetImageMemoryRequirements2) {
+         VkMemoryRequirements2 req2;
+         req2.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
+         VkImageMemoryRequirementsInfo2 info2;
+         info2.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2;
+         info2.pNext = NULL;
+         info2.image = obj->image;
+         VkMemoryDedicatedRequirements ded;
+         ded.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
+         ded.pNext = NULL;
+         req2.pNext = &ded;
+         screen->vk.GetImageMemoryRequirements2(screen->dev, &info2, &req2);
+         memcpy(&reqs, &req2.memoryRequirements, sizeof(VkMemoryRequirements));
+         need_dedicated = ded.prefersDedicatedAllocation || ded.requiresDedicatedAllocation;
+      } else {
+         vkGetImageMemoryRequirements(screen->dev, obj->image, &reqs);
+      }
       if (templ->usage == PIPE_USAGE_STAGING && ici.tiling == VK_IMAGE_TILING_LINEAR)
         flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
       else



More information about the mesa-commit mailing list