mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-27 05:30:24 +01:00
zink: inline program cache structs
derefs-- Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12532>
This commit is contained in:
parent
bdbcf256a1
commit
ad6847cf53
6 changed files with 15 additions and 17 deletions
|
|
@ -1071,7 +1071,7 @@ zink_shader_free(struct zink_context *ctx, struct zink_shader *shader)
|
|||
set_foreach(shader->programs, entry) {
|
||||
if (shader->nir->info.stage == MESA_SHADER_COMPUTE) {
|
||||
struct zink_compute_program *comp = (void*)entry->key;
|
||||
_mesa_hash_table_remove_key(ctx->compute_program_cache, comp->shader);
|
||||
_mesa_hash_table_remove_key(&ctx->compute_program_cache, comp->shader);
|
||||
comp->shader = NULL;
|
||||
zink_compute_program_reference(screen, &comp, NULL);
|
||||
} else {
|
||||
|
|
@ -1079,7 +1079,7 @@ zink_shader_free(struct zink_context *ctx, struct zink_shader *shader)
|
|||
enum pipe_shader_type pstage = pipe_shader_type_from_mesa(shader->nir->info.stage);
|
||||
assert(pstage < ZINK_SHADER_COUNT);
|
||||
if (shader->nir->info.stage != MESA_SHADER_TESS_CTRL || !shader->is_generated)
|
||||
_mesa_hash_table_remove_key(ctx->program_cache, prog->shaders);
|
||||
_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 */
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@ zink_context_destroy(struct pipe_context *pctx)
|
|||
u_upload_destroy(pctx->stream_uploader);
|
||||
u_upload_destroy(pctx->const_uploader);
|
||||
slab_destroy_child(&ctx->transfer_pool);
|
||||
_mesa_hash_table_destroy(ctx->program_cache, NULL);
|
||||
_mesa_hash_table_destroy(ctx->compute_program_cache, NULL);
|
||||
_mesa_hash_table_clear(&ctx->program_cache, NULL);
|
||||
_mesa_hash_table_clear(&ctx->compute_program_cache, NULL);
|
||||
_mesa_hash_table_destroy(ctx->render_pass_cache, NULL);
|
||||
slab_destroy_child(&ctx->transfer_pool_unsync);
|
||||
|
||||
|
|
@ -3526,16 +3526,12 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
|||
if (!ctx->blitter)
|
||||
goto fail;
|
||||
|
||||
ctx->program_cache = _mesa_hash_table_create(NULL,
|
||||
hash_gfx_program,
|
||||
equals_gfx_program);
|
||||
ctx->compute_program_cache = _mesa_hash_table_create(NULL,
|
||||
_mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
_mesa_hash_table_init(&ctx->program_cache, ctx, hash_gfx_program, equals_gfx_program);
|
||||
_mesa_hash_table_init(&ctx->compute_program_cache, ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
|
||||
ctx->render_pass_cache = _mesa_hash_table_create(NULL,
|
||||
hash_render_pass_state,
|
||||
equals_render_pass_state);
|
||||
if (!ctx->program_cache || !ctx->compute_program_cache || !ctx->render_pass_cache)
|
||||
if (!ctx->render_pass_cache)
|
||||
goto fail;
|
||||
|
||||
const uint8_t data[] = {0};
|
||||
|
|
|
|||
|
|
@ -203,14 +203,14 @@ struct zink_context {
|
|||
bool shader_reads_basevertex;
|
||||
struct zink_gfx_pipeline_state gfx_pipeline_state;
|
||||
enum pipe_prim_type gfx_prim_mode;
|
||||
struct hash_table *program_cache;
|
||||
struct hash_table program_cache;
|
||||
struct zink_gfx_program *curr_program;
|
||||
|
||||
struct zink_descriptor_data *dd;
|
||||
|
||||
struct zink_shader *compute_stage;
|
||||
struct zink_compute_pipeline_state compute_pipeline_state;
|
||||
struct hash_table *compute_program_cache;
|
||||
struct hash_table compute_program_cache;
|
||||
struct zink_compute_program *curr_compute;
|
||||
|
||||
unsigned dirty_shader_stages : 6; /* mask of changed shader stages */
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ update_compute_program(struct zink_context *ctx)
|
|||
const unsigned bits = 1 << PIPE_SHADER_COMPUTE;
|
||||
if (ctx->dirty_shader_stages & bits) {
|
||||
struct zink_compute_program *comp = zink_create_compute_program(ctx, ctx->compute_stage);
|
||||
_mesa_hash_table_insert(ctx->compute_program_cache, comp->shader, comp);
|
||||
_mesa_hash_table_insert(&ctx->compute_program_cache, comp->shader, comp);
|
||||
ctx->compute_pipeline_state.dirty = true;
|
||||
ctx->curr_compute = comp;
|
||||
ctx->dirty_shader_stages &= bits;
|
||||
|
|
@ -203,13 +203,13 @@ update_gfx_program(struct zink_context *ctx)
|
|||
unsigned bits = u_bit_consecutive(PIPE_SHADER_VERTEX, 5);
|
||||
if (ctx->dirty_shader_stages & bits) {
|
||||
struct zink_gfx_program *prog = NULL;
|
||||
struct hash_entry *entry = _mesa_hash_table_search(ctx->program_cache,
|
||||
struct hash_entry *entry = _mesa_hash_table_search(&ctx->program_cache,
|
||||
ctx->gfx_stages);
|
||||
if (entry)
|
||||
zink_update_gfx_program(ctx, (struct zink_gfx_program*)entry->data);
|
||||
else {
|
||||
prog = zink_create_gfx_program(ctx, ctx->gfx_stages);
|
||||
entry = _mesa_hash_table_insert(ctx->program_cache, prog->shaders, prog);
|
||||
entry = _mesa_hash_table_insert(&ctx->program_cache, prog->shaders, prog);
|
||||
}
|
||||
prog = (struct zink_gfx_program*)(entry ? entry->data : NULL);
|
||||
if (prog && prog != ctx->curr_program) {
|
||||
|
|
|
|||
|
|
@ -879,7 +879,7 @@ bind_stage(struct zink_context *ctx, enum pipe_shader_type stage,
|
|||
{
|
||||
if (stage == PIPE_SHADER_COMPUTE) {
|
||||
if (shader && shader != ctx->compute_stage) {
|
||||
struct hash_entry *entry = _mesa_hash_table_search(ctx->compute_program_cache, shader);
|
||||
struct hash_entry *entry = _mesa_hash_table_search(&ctx->compute_program_cache, shader);
|
||||
if (entry) {
|
||||
ctx->compute_pipeline_state.dirty = true;
|
||||
ctx->curr_compute = entry->data;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ struct zink_program {
|
|||
|
||||
/* the shader cache stores a mapping of zink_shader_key::VkShaderModule */
|
||||
struct hash_table shader_cache[ZINK_SHADER_COUNT];
|
||||
|
||||
bool removed;
|
||||
};
|
||||
|
||||
struct zink_gfx_program {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue