Mesa (staging/22.0): nir/linker: disable varying from uniform lowering by default
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 06:28:26 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: c11e0af8ad390a95751f9ae956d2c2ccb4d22f1c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c11e0af8ad390a95751f9ae956d2c2ccb4d22f1c
Author: Qiang Yu <yuq825 at gmail.com>
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 <pierre-eric.pelloux-prayer at amd.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Signed-off-by: Qiang Yu <yuq825 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15341>
(cherry picked from commit 2617e6c028a3823c600b16dbffa5702a68b1cfa7)
Conflicts:
src/compiler/nir/nir.h
---
.pick_status.json | 2 +-
src/compiler/nir/nir.h | 9 +++++++++
src/compiler/nir/nir_linking_helpers.c | 3 ++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 23ccaef3886..a6f877c2cc2 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -9604,7 +9604,7 @@
"description": "nir/linker: disable varying from uniform lowering by default",
"nominated": true,
"nomination_type": 1,
- "resolution": 5,
+ "resolution": 1,
"because_sha": "260462504372a0b398af8b41bd790a1a557abec9"
},
{
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 91660a2f836..272e1d175da 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3497,6 +3497,15 @@ typedef struct nir_shader_compiler_options {
* into same slot.
*/
nir_pack_varying_options pack_varying_options;
+
+ /**
+ * 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 872eb205692..69054398a14 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -1376,7 +1376,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 {
More information about the mesa-commit
mailing list