zink: remove batch lock

this is no longer needed and allows deleting some awful code

Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
This commit is contained in:
Mike Blumenkrantz 2022-03-25 12:20:41 -04:00 committed by Marge Bot
parent bc2e29accd
commit b5d7f61e0c
3 changed files with 4 additions and 13 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);