diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index abed98ed8ae..4d278cfb770 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -1134,6 +1134,12 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) si_update_ps_inputs_read_or_disabled(sctx); sctx->do_update_shaders = true; } + + if (old_rs->line_smooth != rs->line_smooth || + old_rs->poly_smooth != rs->poly_smooth || + old_rs->poly_stipple_enable != rs->poly_stipple_enable || + old_rs->flatshade != rs->flatshade) + si_update_vrs_flat_shading(sctx); } static void si_delete_rs_state(struct pipe_context *ctx, void *state) diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 595358067c0..0e0a0f955fc 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -585,6 +585,7 @@ void si_get_vs_key_inputs(struct si_context *sctx, struct si_shader_key *key, struct si_vs_prolog_bits *prolog_key); void si_update_ps_inputs_read_or_disabled(struct si_context *sctx); void si_update_ps_kill_enable(struct si_context *sctx); +void si_update_vrs_flat_shading(struct si_context *sctx); unsigned si_get_input_prim(const struct si_shader_selector *gs); bool si_update_ngg(struct si_context *sctx); void si_ps_key_update_framebuffer(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 1c4e6aa2aa3..e66dc69bd3f 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.cpp +++ b/src/gallium/drivers/radeonsi/si_state_draw.cpp @@ -52,7 +52,6 @@ static bool si_update_shaders(struct si_context *sctx) { struct pipe_context *ctx = (struct pipe_context *)sctx; struct si_compiler_ctx_state compiler_state; - struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; struct si_shader *old_vs = si_get_vs_inline(sctx, HAS_TESS, HAS_GS)->current; unsigned old_kill_clip_distances = old_vs ? old_vs->key.opt.kill_clip_distances : 0; struct si_shader *old_ps = sctx->shader.ps.current; @@ -230,21 +229,6 @@ static bool si_update_shaders(struct si_context *sctx) si_mark_atom_dirty(sctx, &sctx->atoms.s.msaa_sample_locs); } - if (GFX_VERSION >= GFX10_3) { - struct si_shader_info *info = &sctx->shader.ps.cso->info; - bool allow_flat_shading = info->allow_flat_shading; - - if (allow_flat_shading && - (rs->line_smooth || rs->poly_smooth || rs->poly_stipple_enable || - (!rs->flatshade && info->uses_interp_color))) - allow_flat_shading = false; - - if (sctx->allow_flat_shading != allow_flat_shading) { - sctx->allow_flat_shading = allow_flat_shading; - si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state); - } - } - if (unlikely(sctx->screen->debug_flags & DBG(SQTT) && sctx->thread_trace)) { /* Pretend the bound shaders form a vk pipeline */ uint32_t pipeline_code_hash = 0; diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index b0c7751f583..358ae4a91d8 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -3345,6 +3345,25 @@ void si_update_ps_kill_enable(struct si_context *sctx) } } +void si_update_vrs_flat_shading(struct si_context *sctx) +{ + if (sctx->chip_class >= GFX10_3 && sctx->shader.ps.cso) { + struct si_state_rasterizer *rs = sctx->queued.named.rasterizer; + struct si_shader_info *info = &sctx->shader.ps.cso->info; + bool allow_flat_shading = info->allow_flat_shading; + + if (allow_flat_shading && + (rs->line_smooth || rs->poly_smooth || rs->poly_stipple_enable || + (!rs->flatshade && info->uses_interp_color))) + allow_flat_shading = false; + + if (sctx->allow_flat_shading != allow_flat_shading) { + sctx->allow_flat_shading = allow_flat_shading; + si_mark_atom_dirty(sctx, &sctx->atoms.s.db_render_state); + } + } +} + static void si_bind_ps_shader(struct pipe_context *ctx, void *state) { struct si_context *sctx = (struct si_context *)ctx; @@ -3383,6 +3402,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state) si_ps_key_update_framebuffer_rasterizer_sample_shading(sctx); si_update_ps_inputs_read_or_disabled(sctx); si_update_ps_kill_enable(sctx); + si_update_vrs_flat_shading(sctx); } static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)