zink: remove shader_id

now that shaders are per-program, shader_id is no longer useful

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11691>
This commit is contained in:
Mike Blumenkrantz 2021-05-14 15:17:03 -04:00 committed by Marge Bot
parent 61f2667cf5
commit 0cf643db5d
7 changed files with 7 additions and 19 deletions

View file

@ -931,7 +931,6 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
struct zink_shader *ret = CALLOC_STRUCT(zink_shader);
bool have_psiz = false;
ret->shader_id = p_atomic_inc_return(&screen->shader_id);
ret->programs = _mesa_pointer_set_create(NULL);
nir_variable_mode indirect_derefs_modes = nir_var_function_temp;
@ -1065,7 +1064,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->shader_id);
_mesa_hash_table_remove_key(ctx->compute_program_cache, comp->shader);
comp->shader = NULL;
bool in_use = comp == ctx->curr_compute;
if (in_use)
@ -1123,7 +1122,6 @@ zink_shader_tcs_create(struct zink_context *ctx, struct zink_shader *vs)
{
unsigned vertices_per_patch = ctx->gfx_pipeline_state.vertices_per_patch;
struct zink_shader *ret = CALLOC_STRUCT(zink_shader);
ret->shader_id = 0; //special value for internal shaders
ret->programs = _mesa_pointer_set_create(NULL);
nir_shader *nir = nir_shader_create(NULL, MESA_SHADER_TESS_CTRL, &zink_screen(ctx->base.screen)->nir_options, NULL);

View file

@ -68,7 +68,6 @@ zink_tgsi_to_nir(struct pipe_screen *screen, const struct tgsi_token *tokens);
struct zink_shader {
struct util_live_shader base;
unsigned shader_id;
struct nir_shader *nir;
struct zink_so_info streamout;

View file

@ -3553,8 +3553,8 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
hash_gfx_program,
equals_gfx_program);
ctx->compute_program_cache = _mesa_hash_table_create(NULL,
_mesa_hash_uint,
_mesa_key_uint_equal);
_mesa_hash_pointer,
_mesa_key_pointer_equal);
ctx->render_pass_cache = _mesa_hash_table_create(NULL,
hash_render_pass_state,
equals_render_pass_state);

View file

@ -167,10 +167,10 @@ update_compute_program(struct zink_context *ctx)
if (ctx->dirty_shader_stages & bits) {
struct zink_compute_program *comp = NULL;
struct hash_entry *entry = _mesa_hash_table_search(ctx->compute_program_cache,
&ctx->compute_stage->shader_id);
ctx->compute_stage);
if (!entry) {
comp = zink_create_compute_program(ctx, ctx->compute_stage);
entry = _mesa_hash_table_insert(ctx->compute_program_cache, &comp->shader->shader_id, comp);
entry = _mesa_hash_table_insert(ctx->compute_program_cache, comp->shader, comp);
}
comp = (struct zink_compute_program*)(entry ? entry->data : NULL);
if (comp && comp != ctx->curr_compute) {

View file

@ -114,7 +114,6 @@ shader_key_vs_gen(struct zink_context *ctx, struct zink_shader *zs,
struct zink_vs_key *vs_key = &key->key.vs;
key->size = sizeof(struct zink_vs_key);
vs_key->shader_id = zs->shader_id;
vs_key->clip_halfz = ctx->rast_state->base.clip_halfz;
switch (zs->nir->info.stage) {
case MESA_SHADER_VERTEX:
@ -140,8 +139,6 @@ shader_key_fs_gen(struct zink_context *ctx, struct zink_shader *zs,
struct zink_fs_key *fs_key = &key->key.fs;
key->size = sizeof(struct zink_fs_key);
fs_key->shader_id = zs->shader_id;
/* if gl_SampleMask[] is written to, we have to ensure that we get a shader with the same sample count:
* in GL, rast_samples==1 means ignore gl_SampleMask[]
* in VK, gl_SampleMask[] is never ignored
@ -165,7 +162,6 @@ shader_key_tcs_gen(struct zink_context *ctx, struct zink_shader *zs,
struct zink_tcs_key *tcs_key = &key->key.tcs;
key->size = sizeof(struct zink_tcs_key);
tcs_key->shader_id = zs->shader_id;
tcs_key->vertices_per_patch = ctx->gfx_pipeline_state.vertices_per_patch;
tcs_key->vs_outputs_written = shaders[PIPE_SHADER_VERTEX]->nir->info.outputs_written;
}
@ -548,14 +544,14 @@ zink_create_compute_program(struct zink_context *ctx, struct zink_shader *shader
pipe_reference_init(&comp->base.reference, 1);
comp->base.is_compute = true;
/* TODO: cs shader keys placeholder for now */
_mesa_hash_table_init(&comp->base.shader_cache[0], comp, _mesa_hash_u32, _mesa_key_u32_equal);
_mesa_hash_table_init(&comp->base.shader_cache[0], comp, _mesa_hash_pointer, _mesa_key_pointer_equal);
comp->module = CALLOC_STRUCT(zink_shader_module);
assert(comp->module);
pipe_reference_init(&comp->module->reference, 1);
comp->module->shader = zink_shader_compile(screen, shader, shader->nir, NULL);
assert(comp->module->shader);
_mesa_hash_table_insert(&comp->base.shader_cache[0], &shader->shader_id, comp->module);
_mesa_hash_table_insert(&comp->base.shader_cache[0], shader, comp->module);
struct zink_shader_module *zm = NULL;
zink_shader_module_reference(zink_screen(ctx->base.screen), &zm, comp->module);

View file

@ -92,8 +92,6 @@ struct zink_screen {
uint64_t mem_cache_size;
unsigned mem_cache_count;
unsigned shader_id;
uint64_t total_video_mem;
uint64_t total_mem;

View file

@ -27,14 +27,12 @@
# define ZINK_SHADER_KEYS_H
struct zink_vs_key {
unsigned shader_id;
bool clip_halfz;
bool push_drawid;
bool last_vertex_stage;
};
struct zink_fs_key {
unsigned shader_id;
uint8_t coord_replace_bits;
bool coord_replace_yinvert;
bool samples;
@ -42,7 +40,6 @@ struct zink_fs_key {
};
struct zink_tcs_key {
unsigned shader_id;
unsigned vertices_per_patch;
uint64_t vs_outputs_written;
};