Mesa (main): zink: make batch_usage_matches take a batch state param
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 16 02:58:42 UTC 2021
Module: Mesa
Branch: main
Commit: 1108db982e286d54afba4eff3b547da430dae13b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1108db982e286d54afba4eff3b547da430dae13b
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Fri May 7 08:57:12 2021 -0400
zink: make batch_usage_matches take a batch state param
no functional changes, just some unwinding in some cases
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11399>
---
src/gallium/drivers/zink/zink_batch.c | 8 ++++----
src/gallium/drivers/zink/zink_batch.h | 5 ++---
src/gallium/drivers/zink/zink_context.c | 4 ++--
src/gallium/drivers/zink/zink_resource.c | 2 +-
4 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index f69677377a6..f0017a15e18 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -547,20 +547,20 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
zink_get_depth_stencil_resources((struct pipe_resource*)res, NULL, &stencil);
/* if the resource already has usage of any sort set for this batch, we can skip hashing */
- if (res->obj->reads.usage != batch->state->fence.batch_id &&
- res->obj->writes.usage != batch->state->fence.batch_id) {
+ if (!zink_batch_usage_matches(&res->obj->reads, batch->state) &&
+ !zink_batch_usage_matches(&res->obj->writes, batch->state)) {
bool found = false;
_mesa_set_search_and_add(batch->state->fence.resources, res->obj, &found);
if (!found) {
pipe_reference(NULL, &res->obj->reference);
- if (!batch->last_batch_id || !zink_batch_usage_matches(&res->obj->reads, batch->last_batch_id))
+ if (!batch->last_batch_id || res->obj->reads.usage != batch->last_batch_id)
/* only add resource usage if it's "new" usage, though this only checks the most recent usage
* and not all pending usages
*/
batch->state->resource_size += res->obj->size;
if (stencil) {
pipe_reference(NULL, &stencil->obj->reference);
- if (!batch->last_batch_id || !zink_batch_usage_matches(&stencil->obj->reads, batch->last_batch_id))
+ if (!batch->last_batch_id || stencil->obj->reads.usage != batch->last_batch_id)
batch->state->resource_size += stencil->obj->size;
}
}
diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h
index 1079f1cf652..8db448e3e28 100644
--- a/src/gallium/drivers/zink/zink_batch.h
+++ b/src/gallium/drivers/zink/zink_batch.h
@@ -187,10 +187,9 @@ zink_batch_usage_set(struct zink_batch_usage *u, struct zink_batch_state *bs)
}
static inline bool
-zink_batch_usage_matches(struct zink_batch_usage *u, uint32_t batch_id)
+zink_batch_usage_matches(const struct zink_batch_usage *u, const struct zink_batch_state *bs)
{
- uint32_t usage = p_atomic_read(&u->usage);
- return usage == batch_id;
+ return u->usage == bs->fence.batch_id;
}
static inline bool
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 69c78b801f4..f6c1d95ca63 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -3146,8 +3146,8 @@ zink_resource_commit(struct pipe_context *pctx, struct pipe_resource *pres, unsi
struct zink_screen *screen = zink_screen(pctx->screen);
/* if any current usage exists, flush the queue */
- if (zink_batch_usage_matches(&res->obj->reads, ctx->curr_batch) ||
- zink_batch_usage_matches(&res->obj->writes, ctx->curr_batch))
+ if (res->obj->reads.usage == ctx->curr_batch ||
+ res->obj->writes.usage == ctx->curr_batch)
zink_flush_queue(ctx);
VkBindSparseInfo sparse;
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 6d6baa80a53..efb7c033d5c 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -825,7 +825,7 @@ init_mem_range(struct zink_screen *screen, struct zink_resource *res, VkDeviceSi
bool
zink_resource_has_curr_read_usage(struct zink_context *ctx, struct zink_resource *res)
{
- return zink_batch_usage_matches(&res->obj->reads, ctx->curr_batch);
+ return res->obj->reads.usage == ctx->curr_batch;
}
static uint32_t
More information about the mesa-commit
mailing list