Mesa (main): zink: remove batch lock

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 18 23:55:48 UTC 2022


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Mar 25 12:20:41 2022 -0400

zink: remove batch lock

this is no longer needed and allows deleting some awful code

Acked-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>

---

 src/gallium/drivers/zink/zink_batch.c   | 10 ++--------
 src/gallium/drivers/zink/zink_context.c |  4 +---
 src/gallium/drivers/zink/zink_context.h |  3 +--
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c
index da161b1afc9..3b640b67919 100644
--- a/src/gallium/drivers/zink/zink_batch.c
+++ b/src/gallium/drivers/zink/zink_batch.c
@@ -144,7 +144,6 @@ pop_batch_state(struct zink_context *ctx)
 void
 zink_batch_reset_all(struct zink_context *ctx)
 {
-   simple_mtx_lock(&ctx->batch_mtx);
    while (ctx->batch_states) {
       struct zink_batch_state *bs = ctx->batch_states;
       bs->fence.completed = true;
@@ -152,7 +151,6 @@ zink_batch_reset_all(struct zink_context *ctx)
       zink_reset_batch_state(ctx, bs);
       util_dynarray_append(&ctx->free_batch_states, struct zink_batch_state *, bs);
    }
-   simple_mtx_unlock(&ctx->batch_mtx);
 }
 
 void
@@ -265,7 +263,6 @@ get_batch_state(struct zink_context *ctx, struct zink_batch *batch)
    struct zink_screen *screen = zink_screen(ctx->base.screen);
    struct zink_batch_state *bs = NULL;
 
-   simple_mtx_lock(&ctx->batch_mtx);
    if (util_dynarray_num_elements(&ctx->free_batch_states, struct zink_batch_state*))
       bs = util_dynarray_pop(&ctx->free_batch_states, struct zink_batch_state*);
    if (!bs && ctx->batch_states) {
@@ -276,7 +273,6 @@ get_batch_state(struct zink_context *ctx, struct zink_batch *batch)
          pop_batch_state(ctx);
       }
    }
-   simple_mtx_unlock(&ctx->batch_mtx);
    if (bs) {
       zink_reset_batch_state(ctx, bs);
    } else {
@@ -443,14 +439,13 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
    struct zink_screen *screen = zink_screen(ctx->base.screen);
    struct zink_batch_state *bs;
 
-   simple_mtx_lock(&ctx->batch_mtx);
    if (ctx->oom_flush || ctx->batch_states_count > 10) {
       assert(!ctx->batch_states_count || ctx->batch_states);
       while (ctx->batch_states) {
          bs = ctx->batch_states;
          struct zink_fence *fence = &bs->fence;
          /* once an incomplete state is reached, no more will be complete */
-         if (!zink_check_batch_completion(ctx, fence->batch_id, true))
+         if (!zink_check_batch_completion(ctx, fence->batch_id))
             break;
 
          pop_batch_state(ctx);
@@ -470,7 +465,6 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
    }
    ctx->last_fence = &bs->fence;
    ctx->batch_states_count++;
-   simple_mtx_unlock(&ctx->batch_mtx);
    batch->work_count = 0;
 
    if (batch->swapchain) {
@@ -634,7 +628,7 @@ zink_batch_usage_check_completion(struct zink_context *ctx, const struct zink_ba
       return true;
    if (zink_batch_usage_is_unflushed(u))
       return false;
-   return zink_check_batch_completion(ctx, u->usage, false);
+   return zink_check_batch_completion(ctx, u->usage);
 }
 
 void
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index ff4d87bc043..d1866b5fc79 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -114,7 +114,6 @@ zink_context_destroy(struct pipe_context *pctx)
    if (ctx->dd)
       zink_descriptors_deinit_bindless(ctx);
 
-   simple_mtx_destroy(&ctx->batch_mtx);
    if (ctx->batch.state) {
       zink_clear_batch_state(ctx, ctx->batch.state);
       zink_batch_state_destroy(screen, ctx->batch.state);
@@ -3361,7 +3360,7 @@ zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id)
 }
 
 bool
-zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id, bool have_lock)
+zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id)
 {
    assert(ctx->batch.state);
    if (!batch_id)
@@ -4413,7 +4412,6 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
       util_dynarray_init(&ctx->di.bindless[i].resident, NULL);
    }
 
-   simple_mtx_init(&ctx->batch_mtx, mtx_plain);
    zink_start_batch(ctx, &ctx->batch);
    if (!ctx->batch.state)
       goto fail;
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index 8c824867450..ac00aaa46d4 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -197,7 +197,6 @@ struct zink_context {
 
    struct pipe_device_reset_callback reset;
 
-   simple_mtx_t batch_mtx;
    struct zink_fence *deferred_fence;
    struct zink_fence *last_fence; //the last command buffer submitted
    struct zink_batch_state *batch_states; //list of submitted batch states: ordered by increasing timeline id
@@ -399,7 +398,7 @@ void
 zink_wait_on_batch(struct zink_context *ctx, uint32_t batch_id);
 
 bool
-zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id, bool have_lock);
+zink_check_batch_completion(struct zink_context *ctx, uint32_t batch_id);
 
 void
 zink_flush_queue(struct zink_context *ctx);



More information about the mesa-commit mailing list