From eab18cb7a29cb5a8382a8e627551d399c1db62f2 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 20 Sep 2022 14:19:12 -0400 Subject: [PATCH] zink: use screen params for program reference functions these never used the context anyway Reviewed-by: Adam Jackson Part-of: --- src/gallium/drivers/zink/zink_batch.c | 2 +- src/gallium/drivers/zink/zink_compiler.c | 2 +- src/gallium/drivers/zink/zink_program.c | 19 ++++++++----------- src/gallium/drivers/zink/zink_program.h | 18 +++++++++--------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index db99306384b..018e2db7196 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -87,7 +87,7 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs) set_foreach_remove(&bs->programs, entry) { struct zink_program *pg = (struct zink_program*)entry->key; zink_batch_usage_unset(&pg->batch_uses, bs); - zink_program_reference(ctx, &pg, NULL); + zink_program_reference(screen, &pg, NULL); } bs->resource_size = 0; diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 702373c0b13..fd88fcfd98a 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -3260,7 +3260,7 @@ zink_shader_free(struct zink_context *ctx, struct zink_shader *shader) /* only remove generated tcs during parent tes destruction */ if (stage == MESA_SHADER_TESS_EVAL && shader->generated) prog->shaders[MESA_SHADER_TESS_CTRL] = NULL; - zink_gfx_program_reference(ctx, &prog, NULL); + zink_gfx_program_reference(zink_screen(ctx->base.screen), &prog, NULL); } if (shader->nir->info.stage == MESA_SHADER_TESS_EVAL && shader->generated) { /* automatically destroy generated tcs shaders when tes is destroyed */ diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 250dac4b3e6..01094f7960c 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -673,7 +673,7 @@ zink_create_gfx_program(struct zink_context *ctx, simple_mtx_lock(&prog->shaders[i]->lock); _mesa_set_add(prog->shaders[i]->programs, prog); simple_mtx_unlock(&prog->shaders[i]->lock); - zink_gfx_program_reference(ctx, NULL, prog); + zink_gfx_program_reference(screen, NULL, prog); _mesa_sha1_update(&sctx, prog->shaders[i]->base.sha1, sizeof(prog->shaders[i]->base.sha1)); } } @@ -687,7 +687,7 @@ zink_create_gfx_program(struct zink_context *ctx, fail: if (prog) - zink_destroy_gfx_program(ctx, prog); + zink_destroy_gfx_program(screen, prog); return NULL; } @@ -894,9 +894,8 @@ zink_program_num_bindings(const struct zink_program *pg, bool is_compute) } static void -deinit_program(struct zink_context *ctx, struct zink_program *pg) +deinit_program(struct zink_screen *screen, struct zink_program *pg) { - struct zink_screen *screen = zink_screen(ctx->base.screen); util_queue_fence_wait(&pg->cache_fence); if (pg->layout) VKSCR(DestroyPipelineLayout)(screen->dev, pg->layout, NULL); @@ -907,11 +906,10 @@ deinit_program(struct zink_context *ctx, struct zink_program *pg) } void -zink_destroy_gfx_program(struct zink_context *ctx, +zink_destroy_gfx_program(struct zink_screen *screen, struct zink_gfx_program *prog) { - struct zink_screen *screen = zink_screen(ctx->base.screen); - deinit_program(ctx, &prog->base); + deinit_program(screen, &prog->base); for (int i = 0; i < ZINK_GFX_SHADER_COUNT; ++i) { if (prog->shaders[i]) { @@ -959,11 +957,10 @@ zink_destroy_gfx_program(struct zink_context *ctx, } void -zink_destroy_compute_program(struct zink_context *ctx, +zink_destroy_compute_program(struct zink_screen *screen, struct zink_compute_program *comp) { - struct zink_screen *screen = zink_screen(ctx->base.screen); - deinit_program(ctx, &comp->base); + deinit_program(screen, &comp->base); if (comp->shader) _mesa_set_remove_key(comp->shader->programs, comp); @@ -1264,7 +1261,7 @@ static void zink_delete_cs_shader_state(struct pipe_context *pctx, void *cso) { struct zink_compute_program *comp = cso; - zink_compute_program_reference(zink_context(pctx), &comp, NULL); + zink_compute_program_reference(zink_screen(pctx->screen), &comp, NULL); } void diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index dfe90ee37e8..fc691ee902c 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -132,7 +132,7 @@ zink_create_gfx_program(struct zink_context *ctx, unsigned vertices_per_patch); void -zink_destroy_gfx_program(struct zink_context *ctx, +zink_destroy_gfx_program(struct zink_screen *screen, struct zink_gfx_program *prog); void @@ -145,7 +145,7 @@ void debug_describe_zink_gfx_program(char* buf, const struct zink_gfx_program *ptr); static inline bool -zink_gfx_program_reference(struct zink_context *ctx, +zink_gfx_program_reference(struct zink_screen *screen, struct zink_gfx_program **dst, struct zink_gfx_program *src) { @@ -154,7 +154,7 @@ zink_gfx_program_reference(struct zink_context *ctx, if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL, &src->base.reference, (debug_reference_descriptor)debug_describe_zink_gfx_program)) { - zink_destroy_gfx_program(ctx, old_dst); + zink_destroy_gfx_program(screen, old_dst); ret = true; } if (dst) *dst = src; @@ -162,14 +162,14 @@ zink_gfx_program_reference(struct zink_context *ctx, } void -zink_destroy_compute_program(struct zink_context *ctx, +zink_destroy_compute_program(struct zink_screen *screen, struct zink_compute_program *comp); void debug_describe_zink_compute_program(char* buf, const struct zink_compute_program *ptr); static inline bool -zink_compute_program_reference(struct zink_context *ctx, +zink_compute_program_reference(struct zink_screen *screen, struct zink_compute_program **dst, struct zink_compute_program *src) { @@ -178,7 +178,7 @@ zink_compute_program_reference(struct zink_context *ctx, if (pipe_reference_described(old_dst ? &old_dst->base.reference : NULL, &src->base.reference, (debug_reference_descriptor)debug_describe_zink_compute_program)) { - zink_destroy_compute_program(ctx, old_dst); + zink_destroy_compute_program(screen, old_dst); ret = true; } if (dst) *dst = src; @@ -186,7 +186,7 @@ zink_compute_program_reference(struct zink_context *ctx, } static inline bool -zink_program_reference(struct zink_context *ctx, +zink_program_reference(struct zink_screen *screen, struct zink_program **dst, struct zink_program *src) { @@ -195,10 +195,10 @@ zink_program_reference(struct zink_context *ctx, return false; if (pg->is_compute) { struct zink_compute_program *comp = (struct zink_compute_program*)pg; - return zink_compute_program_reference(ctx, &comp, NULL); + return zink_compute_program_reference(screen, &comp, NULL); } else { struct zink_gfx_program *prog = (struct zink_gfx_program*)pg; - return zink_gfx_program_reference(ctx, &prog, NULL); + return zink_gfx_program_reference(screen, &prog, NULL); } }