zink: update shader modules in gfx program when flagged dirty

for shader keys to work right, these need to actually update the shader
module that's being used

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7193>
This commit is contained in:
Mike Blumenkrantz
2020-08-18 15:03:15 -04:00
committed by Marge Bot
parent eeff625ab3
commit e96afeeb7b
3 changed files with 16 additions and 5 deletions

View File

@@ -164,7 +164,9 @@ get_gfx_program(struct zink_context *ctx)
if (ctx->dirty_shader_stages) {
struct hash_entry *entry = _mesa_hash_table_search(ctx->program_cache,
ctx->gfx_stages);
if (!entry) {
if (entry)
zink_update_gfx_program(ctx, entry->data);
else {
struct zink_gfx_program *prog;
prog = zink_create_gfx_program(ctx, ctx->gfx_stages);
entry = _mesa_hash_table_insert(ctx->program_cache, prog->shaders, prog);

View File

@@ -287,7 +287,7 @@ zink_shader_cache_reference(struct zink_screen *screen,
}
static void
update_shader_modules(struct zink_context *ctx, struct zink_shader *stages[ZINK_SHADER_COUNT], struct zink_gfx_program *prog)
update_shader_modules(struct zink_context *ctx, struct zink_shader *stages[ZINK_SHADER_COUNT], struct zink_gfx_program *prog, bool update)
{
struct zink_shader *dirty[ZINK_SHADER_COUNT] = {NULL};
@@ -307,7 +307,7 @@ update_shader_modules(struct zink_context *ctx, struct zink_shader *stages[ZINK_
dirty[i]->has_geometry_shader = dirty[MESA_SHADER_GEOMETRY] || stages[PIPE_SHADER_GEOMETRY];
zm = get_shader_module_for_stage(ctx, dirty[i], prog);
zink_shader_module_reference(zink_screen(ctx->base.screen), &prog->modules[type], zm);
} else if (stages[type]) /* reuse existing shader module */
} else if (stages[type] && !update) /* reuse existing shader module */
zink_shader_module_reference(zink_screen(ctx->base.screen), &prog->modules[type], ctx->curr_program->modules[type]);
prog->shaders[type] = stages[type];
}
@@ -330,7 +330,6 @@ static void
init_slot_map(struct zink_context *ctx, struct zink_gfx_program *prog)
{
unsigned existing_shaders = 0;
/* if there's a case where we'll be reusing any shaders, we need to reuse the slot map too */
if (ctx->curr_program) {
for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
@@ -357,6 +356,12 @@ init_slot_map(struct zink_context *ctx, struct zink_gfx_program *prog)
}
}
void
zink_update_gfx_program(struct zink_context *ctx, struct zink_gfx_program *prog)
{
update_shader_modules(ctx, ctx->gfx_stages, prog, true);
}
struct zink_gfx_program *
zink_create_gfx_program(struct zink_context *ctx,
struct zink_shader *stages[ZINK_SHADER_COUNT])
@@ -370,7 +375,7 @@ zink_create_gfx_program(struct zink_context *ctx,
init_slot_map(ctx, prog);
update_shader_modules(ctx, stages, prog);
update_shader_modules(ctx, stages, prog, false);
for (int i = 0; i < ARRAY_SIZE(prog->pipelines); ++i) {
prog->pipelines[i] = _mesa_hash_table_create(NULL,

View File

@@ -70,6 +70,10 @@ struct zink_gfx_program {
struct set *render_passes;
};
void
zink_update_gfx_program(struct zink_context *ctx, struct zink_gfx_program *prog);
struct zink_gfx_program *
zink_create_gfx_program(struct zink_context *ctx,
struct zink_shader *stages[ZINK_SHADER_COUNT]);