Mesa (master): st/nir: Optionally unify inputs_read/outputs_written when linking.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jan 3 00:57:43 UTC 2020


Module: Mesa
Branch: master
Commit: 19ed12afd170c97180a9cc7eb6c5589d4c427a40
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=19ed12afd170c97180a9cc7eb6c5589d4c427a40

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Jun 17 17:10:06 2019 -0500

st/nir: Optionally unify inputs_read/outputs_written when linking.

i965 and iris use inputs_read/outputs_written for a shader stage to
determine the layout of input and output storage.  Adjacent stages must
agree on the layout, so adjacent input/output bitfields must match.

This patch adds a new nir_shader_compiler_options::unify_interfaces
flag which asks the linker to unify the input/output interfaces between
adjacent stages.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3249>

---

 src/compiler/nir/nir.h                    |  6 ++++++
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 53305ae7148..976fc59bff1 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2839,6 +2839,12 @@ typedef struct nir_shader_compiler_options {
    bool vectorize_io;
    bool lower_to_scalar;
 
+   /**
+    * Should the linker unify inputs_read/outputs_written between adjacent
+    * shader stages which are linked into a single program?
+    */
+   bool unify_interfaces;
+
    /**
     * Should nir_lower_io() create load_interpolated_input intrinsics?
     *
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index e4b509ba7a7..322143d1e7b 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -813,6 +813,28 @@ st_link_nir(struct gl_context *ctx,
       shader->ir = NULL;
    }
 
+   struct shader_info *prev_info = NULL;
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+      struct gl_linked_shader *shader = shader_program->_LinkedShaders[i];
+      if (!shader)
+         continue;
+
+      struct shader_info *info = &shader->Program->nir->info;
+
+      if (prev_info &&
+          ctx->Const.ShaderCompilerOptions[i].NirOptions->unify_interfaces) {
+         prev_info->outputs_written |= info->inputs_read &
+            ~(VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER);
+         info->inputs_read |= prev_info->outputs_written &
+            ~(VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER);
+
+         prev_info->patch_outputs_written |= info->patch_inputs_read;
+         info->patch_inputs_read |= prev_info->patch_outputs_written;
+      }
+      prev_info = info;
+   }
+
    return true;
 }
 




More information about the mesa-commit mailing list