From e0771d5832cc91fc51765d46fe3ed8f6db111da3 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 13 Dec 2021 15:24:15 -0500 Subject: [PATCH] pan/bi: Remove the "wrong" stores in IDVS variants Position shaders should only write gl_Position (and gl_PointSize on Valhall), varying shaders should only write varyings. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 3c8ccc678ed..9c457fae445 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -675,6 +675,25 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) } } +/** + * In a vertex shader, is the specified variable a position output? These kinds + * of outputs are written from position shaders when IDVS is enabled. All other + * outputs are written from the varying shader. + */ +static bool +bi_should_remove_store(nir_intrinsic_instr *intr, enum bi_idvs_mode idvs) +{ + nir_io_semantics sem = nir_intrinsic_io_semantics(intr); + + switch (sem.location) { + case VARYING_SLOT_POS: + case VARYING_SLOT_PSIZ: + return idvs == BI_IDVS_VARYING; + default: + return idvs == BI_IDVS_POSITION; + } +} + static void bi_emit_store_vary(bi_builder *b, nir_intrinsic_instr *instr) { @@ -690,6 +709,12 @@ bi_emit_store_vary(bi_builder *b, nir_intrinsic_instr *instr) unsigned imm_index = 0; bool immediate = bi_is_intr_immediate(instr, &imm_index, 16); + /* Skip stores to the wrong kind of variable in a specialized IDVS + * shader. Backend dead code elimination will clean up the mess. + */ + if (bi_should_remove_store(instr, b->shader->idvs)) + return; + bi_index address; if (immediate) { address = bi_lea_attr_imm(b,