Mesa (staging/22.1): zink: move BAR allocation demotion up the stack

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 17 16:05:10 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 4dbda2ee30503f41e4de92e128ecd3a23a903fe6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4dbda2ee30503f41e4de92e128ecd3a23a903fe6

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Jun 16 12:06:51 2022 -0400

zink: move BAR allocation demotion up the stack

having this so far down in the BO allocation path meant that slabs were
getting demoted to device-local and then stored as BAR in the pb cache,
which broke the cache pretty badly

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17093>
(cherry picked from commit 575005043222d317070b4c24568cdd059730f176)

---

 .pick_status.json                        |  2 +-
 src/gallium/drivers/zink/zink_bo.c       |  6 ------
 src/gallium/drivers/zink/zink_resource.c | 10 ++++++++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 93af9ffa9e5..ed8339c43bf 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -76,7 +76,7 @@
         "description": "zink: move BAR allocation demotion up the stack",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c
index d2e354ae441..933d06e1b66 100644
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -247,7 +247,6 @@ bo_create_internal(struct zink_screen *screen,
    mai.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
    mai.pNext = pNext;
    mai.allocationSize = size;
-demote:
    mai.memoryTypeIndex = screen->heap_map[heap];
    if (screen->info.mem_props.memoryTypes[mai.memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
       alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
@@ -270,11 +269,6 @@ demote:
 
    VkResult ret = VKSCR(AllocateMemory)(screen->dev, &mai, NULL, &bo->mem);
    if (!zink_screen_handle_vkresult(screen, ret)) {
-      if (heap == ZINK_HEAP_DEVICE_LOCAL_VISIBLE) {
-         heap = ZINK_HEAP_DEVICE_LOCAL;
-         mesa_loge("zink: %p couldn't allocate memory! from BAR heap: retrying as device-local", bo);
-         goto demote;
-      }
       mesa_loge("zink: couldn't allocate memory! from heap %u", heap);
       goto fail;
    }
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index fa0901795f6..add991cedc7 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -876,9 +876,15 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
    if (templ->usage == PIPE_USAGE_STAGING && obj->is_buffer)
       alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
    obj->alignment = alignment;
+retry:
    obj->bo = zink_bo(zink_bo_create(screen, reqs.size, alignment, heap, mai.pNext ? ZINK_ALLOC_NO_SUBALLOC : 0, mai.pNext));
-   if (!obj->bo)
-     goto fail2;
+   if (!obj->bo) {
+      if (heap == ZINK_HEAP_DEVICE_LOCAL_VISIBLE) {
+         heap = ZINK_HEAP_DEVICE_LOCAL;
+         goto retry;
+      }
+      goto fail2;
+   }
    if (aflags == ZINK_ALLOC_SPARSE) {
       obj->size = templ->width0;
    } else {



More information about the mesa-commit mailing list