From 11e467c378212e5aefaaa5246839d72764a54ea2 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Fri, 11 Oct 2019 11:50:22 -0700 Subject: [PATCH] freedreno/ir3: don't DCE ij_pix if used for pre-fs-texture-fetch When we enable pre-dispatch texture fetch, we could have a scenario where the barycentric i/j coord sysval is not used in the shader, but only used for the varying fetch for the pre-dispatch texture fetch. In this case we need to take care not to DCE this sysval. Signed-off-by: Rob Clark Reviewed-by: Kristian H. Kristensen --- src/freedreno/ir3/ir3.h | 4 ++-- src/freedreno/ir3/ir3_compiler_nir.c | 2 +- src/freedreno/ir3/ir3_depth.c | 14 +++++++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index f7a87ee076a..8b8788a8a97 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -1062,13 +1062,13 @@ void ir3_print(struct ir3 *ir); void ir3_print_instr(struct ir3_instruction *instr); /* depth calculation: */ +struct ir3_shader_variant; int ir3_delayslots(struct ir3_instruction *assigner, struct ir3_instruction *consumer, unsigned n); void ir3_insert_by_depth(struct ir3_instruction *instr, struct list_head *list); -void ir3_depth(struct ir3 *ir); +void ir3_depth(struct ir3 *ir, struct ir3_shader_variant *so); /* copy-propagate: */ -struct ir3_shader_variant; void ir3_cp(struct ir3 *ir, struct ir3_shader_variant *so); /* group neighbors and insert mov's to resolve conflicts: */ diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 081d4cf19ec..39bef63a780 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -3142,7 +3142,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, ir3_print(ir); } - ir3_depth(ir); + ir3_depth(ir, so); if (ir3_shader_debug & IR3_DBG_OPTMSGS) { printf("AFTER DEPTH:\n"); diff --git a/src/freedreno/ir3/ir3_depth.c b/src/freedreno/ir3/ir3_depth.c index bc42bfdeb3b..49feda7b195 100644 --- a/src/freedreno/ir3/ir3_depth.c +++ b/src/freedreno/ir3/ir3_depth.c @@ -27,6 +27,7 @@ #include "util/u_math.h" #include "ir3.h" +#include "ir3_shader.h" /* * Instruction Depth: @@ -209,7 +210,7 @@ remove_unused_by_block(struct ir3_block *block) } static bool -compute_depth_and_remove_unused(struct ir3 *ir) +compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so) { unsigned i; bool progress = false; @@ -221,6 +222,13 @@ compute_depth_and_remove_unused(struct ir3 *ir) */ list_for_each_entry (struct ir3_block, block, &ir->block_list, node) { list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) { + /* special case, if pre-fs texture fetch used, we cannot + * eliminate the barycentric i/j input + */ + if (so->num_sampler_prefetch && + (instr->opc == OPC_META_INPUT) && + (instr->input.sysval == SYSTEM_VALUE_BARYCENTRIC_PIXEL)) + continue; instr->flags |= IR3_INSTR_UNUSED; } } @@ -263,10 +271,10 @@ compute_depth_and_remove_unused(struct ir3 *ir) } void -ir3_depth(struct ir3 *ir) +ir3_depth(struct ir3 *ir, struct ir3_shader_variant *so) { bool progress; do { - progress = compute_depth_and_remove_unused(ir); + progress = compute_depth_and_remove_unused(ir, so); } while (progress); } -- 2.30.2