aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2018-12-11 11:53:54 +1100
committerTimothy Arceri <[email protected]>2019-01-02 12:19:17 +1100
commitc0aba8b0dc7b3e6cde019a0f2b30bb3a62d666ce (patch)
treeb5b9ee34e6a2d330e18f08c9df69ece3ff69e358
parent50de3f80a807c657b317173c437f217bc7bd74da (diff)
nir: add can_replace_varying() helper
This will be reused by the following patch. Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/compiler/nir/nir_linking_helpers.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index 582d6b90b94..b6eaebcb6a4 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -561,8 +561,7 @@ 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_intrinsic_instr *store_intr)
{
nir_deref_instr *out_deref = nir_src_as_deref(store_intr->src[0]);
if (out_deref->mode != nir_var_shader_out)
@@ -589,11 +588,24 @@ 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)
+{
+ if (!can_replace_varying(store_intr))
+ return false;
+
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
nir_builder b;
nir_builder_init(&b, impl);
+ nir_variable *out_var =
+ nir_deref_instr_get_variable(nir_src_as_deref(store_intr->src[0]));
+
bool progress = false;
nir_foreach_block(block, impl) {
nir_foreach_instr(instr, block) {