From 5cdbbcc2abb4442c24571f777964f41e7cd95d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 11 Aug 2021 00:28:57 -0400 Subject: [PATCH] radeonsi: eliminate a not-found conditional for PrimID in si_get_ps_input_cntl Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_shader_nir.c | 11 +++++++++++ src/gallium/drivers/radeonsi/si_state_shaders.c | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 832dd4fed5c..8da24a4bd68 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -483,6 +483,17 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf scan_instruction(nir, info, instr); } + if (info->stage == MESA_SHADER_VERTEX || info->stage == MESA_SHADER_TESS_EVAL) { + /* Add the PrimitiveID output, but don't increment num_outputs. + * The driver inserts PrimitiveID only when it's used by the pixel shader, + * and si_emit_spi_map uses this unconditionally when such a pixel shader is used. + */ + info->output_semantic[info->num_outputs] = VARYING_SLOT_PRIMITIVE_ID; + info->output_semantic_to_slot[VARYING_SLOT_PRIMITIVE_ID] = info->num_outputs; + info->output_type[info->num_outputs] = nir_type_uint32; + info->output_usagemask[info->num_outputs] = 0x1; + } + if (nir->info.stage == MESA_SHADER_FRAGMENT) { info->allow_flat_shading = !(info->uses_persp_center || info->uses_persp_centroid || info->uses_persp_sample || info->uses_linear_center || diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 221b9a43153..b217ec7eb54 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -3571,11 +3571,7 @@ static unsigned si_get_ps_input_cntl(struct si_context *sctx, struct si_shader * S_028644_ATTR1_VALID(!!(fp16_lo_hi_mask & 0x2)); } } else { - /* VS output not found. */ - if (semantic == VARYING_SLOT_PRIMITIVE_ID) { - /* PrimID is written after the last output when HW VS is used. */ - ps_input_cntl |= S_028644_OFFSET(vs->info.vs_output_param_offset[vsinfo->num_outputs]); - } else if (!G_028644_PT_SPRITE_TEX(ps_input_cntl)) { + if (!G_028644_PT_SPRITE_TEX(ps_input_cntl)) { /* No corresponding output found, load defaults into input. * Don't set any other bits. * (FLAT_SHADE=1 completely changes behavior) */