From 2617e6c028a3823c600b16dbffa5702a68b1cfa7 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Fri, 11 Mar 2022 13:55:02 +0800 Subject: [PATCH] nir/linker: disable varying from uniform lowering by default MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes performance regression for Specviewperf/Energy on AMD GPU. Other GPUs passing varying by memory may choose to re-enable it as need. Fixes: 26046250437 ("nir/linker: support uniform when optimizing varying") Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Marek Olšák Signed-off-by: Qiang Yu Part-of: --- src/compiler/nir/nir.h | 9 +++++++++ src/compiler/nir/nir_linking_helpers.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 2f1a097..5312f28 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3578,6 +3578,15 @@ typedef struct nir_shader_compiler_options { */ uint8_t support_indirect_inputs; uint8_t support_indirect_outputs; + + /** + * Remove varying loaded from uniform, let fragment shader load the + * uniform directly. GPU passing varying by memory can benifit from it + * for sure; but GPU passing varying by on chip resource may not. + * Because it saves on chip resource but may increase memory pressure when + * fragment task is far more than vertex one, so better left it disabled. + */ + bool lower_varying_from_uniform; } nir_shader_compiler_options; typedef struct nir_shader { diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index 9a60e45..c7acb73 100644 --- a/src/compiler/nir/nir_linking_helpers.c +++ b/src/compiler/nir/nir_linking_helpers.c @@ -1377,7 +1377,8 @@ nir_link_opt_varyings(nir_shader *producer, nir_shader *consumer) nir_ssa_def *ssa = intr->src[1].ssa; if (ssa->parent_instr->type == nir_instr_type_load_const) { progress |= replace_varying_input_by_constant_load(consumer, intr); - } else if (is_direct_uniform_load(ssa, &uni_scalar)) { + } else if (consumer->options->lower_varying_from_uniform && + is_direct_uniform_load(ssa, &uni_scalar)) { progress |= replace_varying_input_by_uniform_load(consumer, intr, &uni_scalar); } else { -- 2.7.4