Mesa (staging/21.1): zink: track persistent resource objects, not resources

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 24 12:31:35 UTC 2021


Module: Mesa
Branch: staging/21.1
Commit: f4390988cf50f3014be0a854a28b46406a7eb44e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4390988cf50f3014be0a854a28b46406a7eb44e

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Apr 15 08:40:34 2021 -0400

zink: track persistent resource objects, not resources

this is broken after the backing object split because resources themselves
no longer have guaranteed lifetimes

Fixes: 616720d6aec ("zink: track resource_object usage instead of resource usage")

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

---

 .pick_status.json                     |  2 +-
 src/gallium/drivers/zink/zink_batch.c | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index a2cdb549cb0..917d68bedac 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -427,7 +427,7 @@
         "description": "zink: track persistent resource objects, not resources",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "616720d6aec7db5c919bb3e79510b1c83fb99c47"
     },
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index b19a1ba5e48..3e452b67a63 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -490,13 +490,14 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
    vkResetFences(zink_screen(ctx->base.screen)->dev, 1, &batch->state->fence.fence);
 
    struct zink_screen *screen = zink_screen(ctx->base.screen);
-   util_dynarray_foreach(&batch->state->persistent_resources, struct zink_resource*, res) {
-       assert(!(*res)->obj->offset);
+   while (util_dynarray_contains(&batch->state->persistent_resources, struct zink_resource_object*)) {
+      struct zink_resource_object *obj = util_dynarray_pop(&batch->state->persistent_resources, struct zink_resource_object*);
+       assert(!obj->offset);
        VkMappedMemoryRange range = {
           VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
           NULL,
-          (*res)->obj->mem,
-          (*res)->obj->offset,
+          obj->mem,
+          obj->offset,
           VK_WHOLE_SIZE,
        };
        vkFlushMappedMemoryRanges(screen->dev, 1, &range);
@@ -568,7 +569,7 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
    }
    /* multiple array entries are fine */
    if (res->obj->persistent_maps)
-      util_dynarray_append(&batch->state->persistent_resources, struct zink_resource*, res);
+      util_dynarray_append(&batch->state->persistent_resources, struct zink_resource_object*, res->obj);
 
    batch->has_work = true;
 }



More information about the mesa-commit mailing list