diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 6d2535ef7a6..8bb717c09ca 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -681,7 +681,7 @@ update_nonseamless_shader_key(struct zink_context *ctx, gl_shader_stage pstage) const uint32_t new_mask = ctx->di.emulate_nonseamless[pstage] & ctx->di.cubes[pstage]; if (pstage == MESA_SHADER_COMPUTE) { if (ctx->compute_pipeline_state.key.base.nonseamless_cube_mask != new_mask) - ctx->dirty_shader_stages |= BITFIELD_BIT(pstage); + ctx->compute_dirty = true; ctx->compute_pipeline_state.key.base.nonseamless_cube_mask = new_mask; } else { if (zink_get_shader_key_base(ctx, pstage)->nonseamless_cube_mask != new_mask) @@ -1310,7 +1310,10 @@ zink_set_inlinable_constants(struct pipe_context *pctx, if (!(ctx->inlinable_uniforms_valid_mask & bit) || memcmp(inlinable_uniforms, values, num_values * 4)) { memcpy(inlinable_uniforms, values, num_values * 4); - ctx->dirty_shader_stages |= bit; + if (shader == MESA_SHADER_COMPUTE) + ctx->compute_dirty = true; + else + ctx->dirty_gfx_stages |= bit; ctx->inlinable_uniforms_valid_mask |= bit; key->inline_uniforms = true; } @@ -1350,11 +1353,12 @@ invalidate_inlined_uniforms(struct zink_context *ctx, gl_shader_stage pstage) if (!(ctx->inlinable_uniforms_valid_mask & bit)) return; ctx->inlinable_uniforms_valid_mask &= ~bit; - ctx->dirty_shader_stages |= bit; - if (pstage == MESA_SHADER_COMPUTE) + if (pstage == MESA_SHADER_COMPUTE) { + ctx->compute_dirty = true; return; - + } assert(!zink_screen(ctx->base.screen)->optimal_keys); + ctx->dirty_gfx_stages |= bit; struct zink_shader_key *key = &ctx->gfx_pipeline_state.shader_keys.key[pstage]; key->inline_uniforms = false; } diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp index 5a40053d59b..dcfd2499c7e 100644 --- a/src/gallium/drivers/zink/zink_draw.cpp +++ b/src/gallium/drivers/zink/zink_draw.cpp @@ -890,10 +890,10 @@ zink_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info) zink_update_descriptor_refs(ctx, true); zink_batch_reference_program(&ctx->batch, &ctx->curr_compute->base); } - if (ctx->dirty_shader_stages & BITFIELD_BIT(MESA_SHADER_COMPUTE)) { + if (ctx->compute_dirty) { /* update inlinable constants */ zink_update_compute_program(ctx); - ctx->dirty_shader_stages &= ~BITFIELD_BIT(MESA_SHADER_COMPUTE); + ctx->compute_dirty = false; } VkPipeline pipeline = zink_get_compute_pipeline(screen, ctx->curr_compute, diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index bca4a00d7d0..52181780d4b 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -527,11 +527,11 @@ update_gfx_program_nonseamless(struct zink_context *ctx, struct zink_gfx_program struct zink_screen *screen = zink_screen(ctx->base.screen); if (screen->driconf.inline_uniforms) update_gfx_shader_modules(ctx, screen, prog, - ctx->dirty_shader_stages & prog->stages_present, &ctx->gfx_pipeline_state, + ctx->dirty_gfx_stages & prog->stages_present, &ctx->gfx_pipeline_state, true, has_nonseamless); else update_gfx_shader_modules(ctx, screen, prog, - ctx->dirty_shader_stages & prog->stages_present, &ctx->gfx_pipeline_state, + ctx->dirty_gfx_stages & prog->stages_present, &ctx->gfx_pipeline_state, false, has_nonseamless); } @@ -551,7 +551,7 @@ zink_gfx_program_update(struct zink_context *ctx) struct zink_screen *screen = zink_screen(ctx->base.screen); if (ctx->last_vertex_stage_dirty) { gl_shader_stage pstage = ctx->last_vertex_stage->nir->info.stage; - ctx->dirty_shader_stages |= BITFIELD_BIT(pstage); + ctx->dirty_gfx_stages |= BITFIELD_BIT(pstage); if (!screen->optimal_keys) { memcpy(&ctx->gfx_pipeline_state.shader_keys.key[pstage].key.vs_base, &ctx->gfx_pipeline_state.shader_keys.last_vertex.key.vs_base, @@ -572,25 +572,25 @@ zink_gfx_program_update(struct zink_context *ctx) if (screen->optimal_keys) { ctx->gfx_pipeline_state.optimal_key = ctx->gfx_pipeline_state.shader_keys_optimal.key.val; if (ctx->gfx_pipeline_state.optimal_key != prog->last_variant_hash) { - ctx->dirty_shader_stages |= BITFIELD_BIT(ctx->last_vertex_stage->nir->info.stage); - ctx->dirty_shader_stages |= BITFIELD_BIT(MESA_SHADER_FRAGMENT); + ctx->dirty_gfx_stages |= BITFIELD_BIT(ctx->last_vertex_stage->nir->info.stage); + ctx->dirty_gfx_stages |= BITFIELD_BIT(MESA_SHADER_FRAGMENT); if (prog->shaders[MESA_SHADER_TESS_CTRL] && prog->shaders[MESA_SHADER_TESS_CTRL]->is_generated) - ctx->dirty_shader_stages |= BITFIELD_BIT(MESA_SHADER_TESS_CTRL); + ctx->dirty_gfx_stages |= BITFIELD_BIT(MESA_SHADER_TESS_CTRL); update_gfx_shader_modules_optimal(ctx, screen, prog, - ctx->dirty_shader_stages & prog->stages_present, + ctx->dirty_gfx_stages & prog->stages_present, &ctx->gfx_pipeline_state); } } else { for (unsigned i = 0; i < ZINK_GFX_SHADER_COUNT; i++) { - if (prog->stages_present & ~ctx->dirty_shader_stages & BITFIELD_BIT(i)) + if (prog->stages_present & ~ctx->dirty_gfx_stages & BITFIELD_BIT(i)) ctx->gfx_pipeline_state.modules[i] = prog->modules[i]; } /* ensure variants are always updated if keys have changed since last use */ - ctx->dirty_shader_stages |= prog->stages_present; + ctx->dirty_gfx_stages |= prog->stages_present; update_gfx_program(ctx, prog); } } else { - ctx->dirty_shader_stages |= bits; + ctx->dirty_gfx_stages |= bits; prog = zink_create_gfx_program(ctx, ctx->gfx_stages, ctx->gfx_pipeline_state.dyn_state2.vertices_per_patch); _mesa_hash_table_insert_pre_hashed(ht, hash, prog->shaders, prog); if (screen->optimal_keys) @@ -606,13 +606,13 @@ zink_gfx_program_update(struct zink_context *ctx) ctx->curr_program = prog; ctx->gfx_pipeline_state.final_hash ^= ctx->curr_program->last_variant_hash; ctx->gfx_dirty = false; - } else if (ctx->dirty_shader_stages & bits) { + } else if (ctx->dirty_gfx_stages & bits) { /* remove old hash */ ctx->gfx_pipeline_state.final_hash ^= ctx->curr_program->last_variant_hash; if (screen->optimal_keys) { if (ctx->gfx_pipeline_state.optimal_key != ctx->curr_program->last_variant_hash) update_gfx_shader_modules_optimal(ctx, screen, ctx->curr_program, - ctx->dirty_shader_stages & ctx->curr_program->stages_present, + ctx->dirty_gfx_stages & ctx->curr_program->stages_present, &ctx->gfx_pipeline_state); } else { update_gfx_program(ctx, ctx->curr_program); @@ -620,7 +620,7 @@ zink_gfx_program_update(struct zink_context *ctx) /* apply new hash */ ctx->gfx_pipeline_state.final_hash ^= ctx->curr_program->last_variant_hash; } - ctx->dirty_shader_stages &= ~bits; + ctx->dirty_gfx_stages &= ~bits; } static void @@ -1260,7 +1260,7 @@ bind_last_vertex_stage(struct zink_context *ctx) if (!zink_screen(ctx->base.screen)->optimal_keys) { if (old != MESA_SHADER_STAGES) { memset(&ctx->gfx_pipeline_state.shader_keys.key[old].key.vs_base, 0, sizeof(struct zink_vs_key_base)); - ctx->dirty_shader_stages |= BITFIELD_BIT(old); + ctx->dirty_gfx_stages |= BITFIELD_BIT(old); } else { /* always unset vertex shader values when changing to a non-vs last stage */ memset(&ctx->gfx_pipeline_state.shader_keys.key[MESA_SHADER_VERTEX].key.vs_base, 0, sizeof(struct zink_vs_key_base)); @@ -1431,7 +1431,7 @@ zink_bind_cs_state(struct pipe_context *pctx, ctx->compute_pipeline_state.module = ctx->curr_compute->curr->shader; ctx->compute_pipeline_state.final_hash ^= ctx->compute_pipeline_state.module_hash; if (ctx->compute_pipeline_state.key.base.nonseamless_cube_mask) - ctx->dirty_shader_stages |= BITFIELD_BIT(MESA_SHADER_COMPUTE); + ctx->compute_dirty = true; } zink_select_launch_grid(ctx); } diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index c24ed4cc1fd..53eb45832d7 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -223,7 +223,7 @@ zink_program_has_descriptors(const struct zink_program *pg) static inline struct zink_fs_key * zink_set_fs_key(struct zink_context *ctx) { - ctx->dirty_shader_stages |= BITFIELD_BIT(MESA_SHADER_FRAGMENT); + ctx->dirty_gfx_stages |= BITFIELD_BIT(MESA_SHADER_FRAGMENT); return zink_screen(ctx->base.screen)->optimal_keys ? &ctx->gfx_pipeline_state.shader_keys_optimal.key.fs : &ctx->gfx_pipeline_state.shader_keys.key[MESA_SHADER_FRAGMENT].key.fs; @@ -245,7 +245,7 @@ zink_set_tcs_key_patches(struct zink_context *ctx, uint8_t patch_vertices) &ctx->gfx_pipeline_state.shader_keys.key[MESA_SHADER_TESS_CTRL].key.tcs; if (tcs->patch_vertices == patch_vertices) return false; - ctx->dirty_shader_stages |= BITFIELD_BIT(MESA_SHADER_TESS_CTRL); + ctx->dirty_gfx_stages |= BITFIELD_BIT(MESA_SHADER_TESS_CTRL); tcs->patch_vertices = patch_vertices; return true; } @@ -264,7 +264,7 @@ zink_update_fs_key_samples(struct zink_context *ctx); static inline struct zink_vs_key * zink_set_vs_key(struct zink_context *ctx) { - ctx->dirty_shader_stages |= BITFIELD_BIT(MESA_SHADER_VERTEX); + ctx->dirty_gfx_stages |= BITFIELD_BIT(MESA_SHADER_VERTEX); assert(!zink_screen(ctx->base.screen)->optimal_keys); return &ctx->gfx_pipeline_state.shader_keys.key[MESA_SHADER_VERTEX].key.vs; } @@ -316,7 +316,7 @@ zink_get_shader_key_base(struct zink_context *ctx, gl_shader_stage pstage) static inline struct zink_shader_key_base * zink_set_shader_key_base(struct zink_context *ctx, gl_shader_stage pstage) { - ctx->dirty_shader_stages |= BITFIELD_BIT(pstage); + ctx->dirty_gfx_stages |= BITFIELD_BIT(pstage); assert(!zink_screen(ctx->base.screen)->optimal_keys); return &ctx->gfx_pipeline_state.shader_keys.key[pstage].base; } diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 5c935a7d3b6..d023f6ab314 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1426,8 +1426,9 @@ struct zink_context { struct zink_compute_program *curr_compute; unsigned shader_stages : ZINK_GFX_SHADER_COUNT; /* mask of bound gfx shader stages */ - unsigned dirty_shader_stages : 6; /* mask of changed shader stages */ + uint8_t dirty_gfx_stages; /* mask of changed gfx shader stages */ bool last_vertex_stage_dirty; + bool compute_dirty; struct { VkRenderingAttachmentInfo attachments[PIPE_MAX_COLOR_BUFS + 2]; //+depth, +stencil