Mesa (main): zink: add util function for transferring resource refs to batch

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


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue May 11 10:27:55 2021 -0400

zink: add util function for transferring resource refs to batch

there's no point in doing unref->ref if it's known that this will happen

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

---

 src/gallium/drivers/zink/zink_batch.c | 9 +++++++++
 src/gallium/drivers/zink/zink_batch.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index 800f5a79de2..8743228d1e2 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -614,6 +614,15 @@ zink_batch_reference_resource(struct zink_batch *batch, struct zink_resource *re
    batch->has_work = true;
 }
 
+void
+zink_batch_reference_resource_move(struct zink_batch *batch, struct zink_resource *res)
+{
+   if (!batch_ptr_add_usage(batch, batch->state->resources, res->obj))
+      return;
+   batch->state->resource_size += res->obj->size;
+   batch->has_work = true;
+}
+
 void
 zink_batch_reference_bufferview(struct zink_batch *batch, struct zink_buffer_view *buffer_view)
 {
diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h
index 3448f2b6e68..7187cd00a3b 100644
--- a/src/gallium/drivers/zink/zink_batch.h
+++ b/src/gallium/drivers/zink/zink_batch.h
@@ -156,6 +156,9 @@ zink_batch_reference_resource_rw(struct zink_batch *batch,
 void
 zink_batch_reference_resource(struct zink_batch *batch, struct zink_resource *res);
 
+void
+zink_batch_reference_resource_move(struct zink_batch *batch, struct zink_resource *res);
+
 void
 zink_batch_reference_sampler_view(struct zink_batch *batch,
                                   struct zink_sampler_view *sv);



More information about the mesa-commit mailing list