Mesa (main): nir/linker: add option to ignore the IO precisions for better varying packing

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 15 08:21:01 UTC 2021


Module: Mesa
Branch: main
Commit: 4c045ad11eddaf6c18019fbaa02ffcae20628848
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c045ad11eddaf6c18019fbaa02ffcae20628848

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Mon May 10 08:54:50 2021 +0200

nir/linker: add option to ignore the IO precisions for better varying packing

Backends that don't handle IO component precision can pack more varyings
into one slot if the linker ignores the precision. If the IO is vectorized
then this can save IO instructions.

Related: 165a69d2f74aefe80b070209e77950446a97c8b5
    nir: handle mediump varyings in varying compaction helpers

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10722>

---

 src/compiler/nir/nir.h                 |  5 +++++
 src/compiler/nir/nir_linking_helpers.c | 12 ++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 23bd1172559..5eda51c30f6 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3445,6 +3445,11 @@ typedef struct nir_shader_compiler_options {
 
    bool lower_uniforms_to_ubo;
 
+   /* If the precision is ignored, backends that don't handle
+    * different precisions when passing data between stages and use
+    * vectorized IO can pack more varyings when linking. */
+   bool linker_ignore_precision;
+
    nir_lower_int64_options lower_int64_options;
    nir_lower_doubles_options lower_doubles_options;
    nir_divergence_options divergence_analysis_options;
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index fa451c33389..be4144ade86 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -582,9 +582,9 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer,
             vc_info->interp_loc = get_interp_loc(in_var);
             vc_info->is_32bit = glsl_type_is_32bit(type);
             vc_info->is_patch = in_var->data.patch;
-            vc_info->is_mediump =
-               in_var->data.precision == GLSL_PRECISION_MEDIUM ||
-               in_var->data.precision == GLSL_PRECISION_LOW;
+            vc_info->is_mediump = !producer->options->linker_ignore_precision &&
+               (in_var->data.precision == GLSL_PRECISION_MEDIUM ||
+                in_var->data.precision == GLSL_PRECISION_LOW);
             vc_info->is_intra_stage_only = false;
             vc_info->initialised = true;
          }
@@ -647,9 +647,9 @@ gather_varying_component_info(nir_shader *producer, nir_shader *consumer,
                vc_info->interp_loc = get_interp_loc(out_var);
                vc_info->is_32bit = glsl_type_is_32bit(type);
                vc_info->is_patch = out_var->data.patch;
-               vc_info->is_mediump =
-                  out_var->data.precision == GLSL_PRECISION_MEDIUM ||
-                  out_var->data.precision == GLSL_PRECISION_LOW;
+               vc_info->is_mediump = !producer->options->linker_ignore_precision &&
+                  (out_var->data.precision == GLSL_PRECISION_MEDIUM ||
+                   out_var->data.precision == GLSL_PRECISION_LOW);
                vc_info->is_intra_stage_only = true;
                vc_info->initialised = true;
             }



More information about the mesa-commit mailing list