zink: clear current gfx/compute program upon unbinding its shaders
this simplifies a lot of code Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12428>
This commit is contained in:
committed by
Marge Bot
parent
c39cbd49c1
commit
78c5cdf7e6
@@ -69,14 +69,10 @@ zink_reset_batch_state(struct zink_context *ctx, struct zink_batch_state *bs)
|
||||
zink_batch_usage_unset(&pg->batch_uses, bs);
|
||||
if (pg->is_compute) {
|
||||
struct zink_compute_program *comp = (struct zink_compute_program*)pg;
|
||||
bool in_use = comp == ctx->curr_compute;
|
||||
if (zink_compute_program_reference(screen, &comp, NULL) && in_use)
|
||||
ctx->curr_compute = NULL;
|
||||
zink_compute_program_reference(screen, &comp, NULL);
|
||||
} else {
|
||||
struct zink_gfx_program *prog = (struct zink_gfx_program*)pg;
|
||||
bool in_use = prog == ctx->curr_program;
|
||||
if (zink_gfx_program_reference(screen, &prog, NULL) && in_use)
|
||||
ctx->curr_program = NULL;
|
||||
zink_gfx_program_reference(screen, &prog, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1073,28 +1073,18 @@ zink_shader_free(struct zink_context *ctx, struct zink_shader *shader)
|
||||
struct zink_compute_program *comp = (void*)entry->key;
|
||||
_mesa_hash_table_remove_key(ctx->compute_program_cache, comp->shader);
|
||||
comp->shader = NULL;
|
||||
bool in_use = comp == ctx->curr_compute;
|
||||
if (in_use)
|
||||
ctx->compute_stage = NULL;
|
||||
if (zink_compute_program_reference(screen, &comp, NULL) && in_use)
|
||||
ctx->curr_compute = NULL;
|
||||
zink_compute_program_reference(screen, &comp, NULL);
|
||||
} else {
|
||||
struct zink_gfx_program *prog = (void*)entry->key;
|
||||
enum pipe_shader_type pstage = pipe_shader_type_from_mesa(shader->nir->info.stage);
|
||||
assert(pstage < ZINK_SHADER_COUNT);
|
||||
bool in_use = prog == ctx->curr_program;
|
||||
if (shader->nir->info.stage != MESA_SHADER_TESS_CTRL || !shader->is_generated)
|
||||
_mesa_hash_table_remove_key(ctx->program_cache, prog->shaders);
|
||||
prog->shaders[pstage] = NULL;
|
||||
if (shader->nir->info.stage == MESA_SHADER_TESS_EVAL && shader->generated)
|
||||
/* automatically destroy generated tcs shaders when tes is destroyed */
|
||||
zink_shader_free(ctx, shader->generated);
|
||||
if (in_use) {
|
||||
ctx->gfx_pipeline_state.modules[pstage] = VK_NULL_HANDLE;
|
||||
ctx->gfx_stages[pstage] = NULL;
|
||||
}
|
||||
if (zink_gfx_program_reference(screen, &prog, NULL) && in_use)
|
||||
ctx->curr_program = NULL;
|
||||
zink_gfx_program_reference(screen, &prog, NULL);
|
||||
}
|
||||
}
|
||||
_mesa_set_destroy(shader->programs, NULL);
|
||||
|
||||
@@ -885,14 +885,17 @@ bind_stage(struct zink_context *ctx, enum pipe_shader_type stage,
|
||||
ctx->curr_compute = entry->data;
|
||||
} else
|
||||
ctx->dirty_shader_stages |= 1 << stage;
|
||||
}
|
||||
} else if (!shader)
|
||||
ctx->curr_compute = NULL;
|
||||
ctx->compute_stage = shader;
|
||||
zink_select_launch_grid(ctx);
|
||||
} else {
|
||||
ctx->gfx_stages[stage] = shader;
|
||||
ctx->gfx_pipeline_state.combined_dirty = true;
|
||||
if (!shader)
|
||||
if (!shader) {
|
||||
ctx->gfx_pipeline_state.modules[stage] = VK_NULL_HANDLE;
|
||||
ctx->curr_program = NULL;
|
||||
}
|
||||
ctx->dirty_shader_stages |= 1 << stage;
|
||||
}
|
||||
if (shader && shader->nir->info.num_inlinable_uniforms)
|
||||
|
||||
Reference in New Issue
Block a user