diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index b044cf214ea..d2f96d4f74c 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -701,6 +701,7 @@ void si_set_vertex_buffer_descriptor(struct si_screen *sscreen, struct si_vertex uint32_t *out); void si_emit_buffered_compute_sh_regs(struct si_context *sctx, struct radeon_cmdbuf *cs); void si_emit_buffered_gfx_sh_regs_for_mesh(struct si_context *sctx); +bool si_update_shaders_for_mesh(struct si_context *sctx, struct si_shader *old_vs, struct si_shader *new_vs); void si_init_draw_functions_GFX6(struct si_context *sctx); void si_init_draw_functions_GFX7(struct si_context *sctx); void si_init_draw_functions_GFX8(struct si_context *sctx); diff --git a/src/gallium/drivers/radeonsi/si_state_draw.cpp b/src/gallium/drivers/radeonsi/si_state_draw.cpp index 633e99a32c0..ee901bf4a15 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.cpp +++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp @@ -42,7 +42,7 @@ #define SI_VERTEX_PIPELINE_STATE_DIRTY_MASK \ (BITFIELD_MASK(MESA_SHADER_FRAGMENT + 1) | SI_SQTT_STATE_DIRTY_BIT) -template +template static bool si_update_shaders_shared_by_vertex_and_mesh_pipe(struct si_context *sctx, struct si_shader *old_vs, struct si_shader *new_vs) @@ -137,7 +137,7 @@ static bool si_update_shaders_shared_by_vertex_and_mesh_pipe(struct si_context * } bool fixed_func_face_culling_needed = !NGG || !si_shader_culling_enabled(new_vs); - bool fixed_func_face_culling_has_effect = (!HAS_TESS && !HAS_GS) || + bool fixed_func_face_culling_has_effect = (!HAS_TESS && !HAS_GS && !HAS_MS) || new_vs->selector->rast_prim == MESA_PRIM_TRIANGLES; if (sctx->fixed_func_face_culling_needed != fixed_func_face_culling_needed || @@ -218,7 +218,9 @@ static bool si_update_shaders_shared_by_vertex_and_mesh_pipe(struct si_context * (!NGG && si_pm4_state_enabled_and_changed(sctx, vs)) || si_pm4_state_enabled_and_changed(sctx, ps)) { unsigned scratch_size = 0; - if (HAS_TESS) { + if (HAS_MS) { + scratch_size = MAX2(scratch_size, sctx->ms_shader_state.current->config.scratch_bytes_per_wave); + } else if (HAS_TESS) { if (GFX_VERSION <= GFX8) /* LS */ scratch_size = MAX2(scratch_size, sctx->shader.vs.current->config.scratch_bytes_per_wave); @@ -270,6 +272,26 @@ static bool si_update_shaders_shared_by_vertex_and_mesh_pipe(struct si_context * return true; } +#if GFX_VER == 6 /* declare this function only once because it handles all chips. */ + +bool si_update_shaders_for_mesh(struct si_context *sctx, struct si_shader *old_vs, struct si_shader *new_vs) +{ + switch (sctx->screen->info.gfx_level) { + case GFX10_3: + return si_update_shaders_shared_by_vertex_and_mesh_pipe(sctx, old_vs, new_vs); + case GFX11: + return si_update_shaders_shared_by_vertex_and_mesh_pipe(sctx, old_vs, new_vs); + case GFX11_5: + return si_update_shaders_shared_by_vertex_and_mesh_pipe(sctx, old_vs, new_vs); + case GFX12: + return si_update_shaders_shared_by_vertex_and_mesh_pipe(sctx, old_vs, new_vs); + default: + UNREACHABLE("invalid GFX version for mesh shaders"); + } +} + +#endif + template static bool si_update_shaders(struct si_context *sctx) { @@ -419,7 +441,7 @@ static bool si_update_shaders(struct si_context *sctx) if (HAS_TESS && (is_vs_state_changed || is_tess_state_changed)) si_update_tess_io_layout_state(sctx); - if (!si_update_shaders_shared_by_vertex_and_mesh_pipe(sctx, old_vs, hw_vs)) + if (!si_update_shaders_shared_by_vertex_and_mesh_pipe(sctx, old_vs, hw_vs)) return false; if (GFX_VERSION >= GFX9 && unlikely(sctx->sqtt)) {