Module: Mesa Branch: main Commit: 2617e6c028a3823c600b16dbffa5702a68b1cfa7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2617e6c028a3823c600b16dbffa5702a68b1cfa7
Author: Qiang Yu <[email protected]> Date: Fri Mar 11 13:55:02 2022 +0800 nir/linker: disable varying from uniform lowering by default 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 <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Qiang Yu <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15341> --- 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 2f1a09702d9..5312f28c021 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 9a60e45d47c..c7acb73793d 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 {
