radeonsi: move flat shading VRS enablement out of si_update_shaders

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12343>
This commit is contained in:
Marek Olšák 2021-08-10 11:22:07 -04:00 committed by Marge Bot
parent eed149aa7c
commit 5a131566b1
4 changed files with 27 additions and 16 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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)