Mesa (master): zink: remove atomic usage from batch tracking comparisons

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 8 03:24:54 UTC 2021


Module: Mesa
Branch: master
Commit: 40e8328ce5fe7445749e461dbd070a7e9d72322c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=40e8328ce5fe7445749e461dbd070a7e9d72322c

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Tue Jan 12 12:28:22 2021 -0500

zink: remove atomic usage from batch tracking comparisons

race conditions here have no impact because it cannot change the evaluation
of this condition

also no need to check zs stuff if there's no update happening

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

---

 src/gallium/drivers/zink/zink_batch.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index 2f7dd462cb7..842cc9ed9a0 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -431,8 +431,8 @@ 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 (!zink_batch_usage_matches(&res->obj->reads, batch->state->fence.batch_id) &&
-       !zink_batch_usage_matches(&res->obj->writes, batch->state->fence.batch_id)) {
+   if (res->obj->reads.usage != batch->state->fence.batch_id &&
+       res->obj->writes.usage != batch->state->fence.batch_id) {
       bool found = false;
       _mesa_set_search_and_add(batch->state->fence.resources, res->obj, &found);
       if (!found) {
@@ -450,13 +450,17 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource
       }
        }
    if (write) {
-      if (stencil)
-         zink_batch_usage_set(&stencil->obj->writes, batch->state->fence.batch_id);
-      zink_batch_usage_set(&res->obj->writes, batch->state->fence.batch_id);
+      if (res->obj->writes.usage != batch->state->fence.batch_id) {
+         if (stencil)
+            zink_batch_usage_set(&stencil->obj->writes, batch->state->fence.batch_id);
+         zink_batch_usage_set(&res->obj->writes, batch->state->fence.batch_id);
+      }
    } else {
-      if (stencil)
-         zink_batch_usage_set(&stencil->obj->reads, batch->state->fence.batch_id);
-      zink_batch_usage_set(&res->obj->reads, batch->state->fence.batch_id);
+      if (res->obj->reads.usage != batch->state->fence.batch_id) {
+         if (stencil)
+            zink_batch_usage_set(&stencil->obj->reads, batch->state->fence.batch_id);
+         zink_batch_usage_set(&res->obj->reads, batch->state->fence.batch_id);
+      }
    }
    /* multiple array entries are fine */
    if (res->obj->persistent_maps)
@@ -469,7 +473,7 @@ static bool
 ptr_add_usage(struct zink_batch *batch, struct set *s, void *ptr, struct zink_batch_usage *u)
 {
    bool found = false;
-   if (zink_batch_usage_matches(u, batch->state->fence.batch_id))
+   if (u->usage == batch->state->fence.batch_id)
       return false;
    _mesa_set_search_and_add(s, ptr, &found);
    assert(!found);



More information about the mesa-commit mailing list