[Mesa-dev] [PATCH 3/4] nir: add can_replace_varying() helper

Timothy Arceri tarceri at itsqueeze.com
Tue Dec 11 04:27:38 UTC 2018


This will be reused by the following patch.
---
 src/compiler/nir/nir_linking_helpers.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index b447729c60..37644d339f 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -701,12 +701,8 @@ nir_link_xfb_varyings(nir_shader *producer, nir_shader *consumer)
 }
 
 static bool
-try_replace_constant_input(nir_shader *shader,
-                           nir_intrinsic_instr *store_intr)
+can_replace_varying(nir_variable *out_var, nir_intrinsic_instr *store_intr)
 {
-   nir_variable *out_var =
-      nir_deref_instr_get_variable(nir_src_as_deref(store_intr->src[0]));
-
    if (out_var->data.mode != nir_var_shader_out)
       return false;
 
@@ -729,6 +725,19 @@ try_replace_constant_input(nir_shader *shader,
        out_var->data.location - VARYING_SLOT_VAR0 >= MAX_VARYING)
       return false;
 
+   return true;
+}
+
+static bool
+try_replace_constant_input(nir_shader *shader,
+                           nir_intrinsic_instr *store_intr)
+{
+   nir_variable *out_var =
+      nir_deref_instr_get_variable(nir_src_as_deref(store_intr->src[0]));
+
+   if (!can_replace_varying(out_var, store_intr))
+      return false;
+
    nir_function_impl *impl = nir_shader_get_entrypoint(shader);
 
    nir_builder b;
-- 
2.19.2



More information about the mesa-dev mailing list