Mesa (main): zink: move resource object ref to batch in init_storage_object

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 7 00:31:25 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed May 12 07:17:19 2021 -0400

zink: move resource object ref to batch in init_storage_object

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

---

 src/gallium/drivers/zink/zink_resource.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index a8245af9865..9e4d49d2e8d 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -1255,6 +1255,11 @@ zink_resource_object_init_storage(struct zink_context *ctx, struct zink_resource
       }
       struct zink_resource staging = *res;
       staging.obj = old_obj;
+      bool needs_unref = true;
+      if (get_resource_usage(res)) {
+         zink_batch_reference_resource_move(&ctx->batch, res);
+         needs_unref = false;
+      }
       res->obj = new_obj;
       zink_descriptor_set_refs_clear(&old_obj->desc_set_refs, old_obj);
       for (unsigned i = 0; i <= res->base.b.last_level; i++) {
@@ -1264,7 +1269,8 @@ zink_resource_object_init_storage(struct zink_context *ctx, struct zink_resource
          box.depth = util_num_layers(&res->base.b, i);
          ctx->base.resource_copy_region(&ctx->base, &res->base.b, i, 0, 0, 0, &staging.base.b, i, &box);
       }
-      zink_resource_object_reference(screen, &old_obj, NULL);
+      if (needs_unref)
+         zink_resource_object_reference(screen, &old_obj, NULL);
    }
 
    zink_resource_rebind(ctx, res);



More information about the mesa-commit mailing list