summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-10-23 21:56:29 +1100
committerTimothy Arceri <[email protected]>2018-10-24 08:21:29 +1100
commit7c694cbfa43388b7394142e5d75e1c0a0d2a8ca9 (patch)
tree551c0a8b269f618b70c89dfa655663851ef33179 /src/compiler/nir
parent0a7664fe8c79580d3f1702ae1106c6824b3fbf2b (diff)
nir: add linking helper nir_link_xfb_varyings()
The linking opts shouldn't try removing or compacting XFB varyings in the consumer. To avoid this we copy the always_active_io flag from the producer. Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.h1
-rw-r--r--src/compiler/nir/nir_linking_helpers.c33
2 files changed, 34 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 0ba19cbb25d..60ea4fbc7ff 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2799,6 +2799,7 @@ bool nir_remove_unused_io_vars(nir_shader *shader, struct exec_list *var_list,
uint64_t *used_by_other_stage_patches);
void nir_compact_varyings(nir_shader *producer, nir_shader *consumer,
bool default_to_smooth_interp);
+void nir_link_xfb_varyings(nir_shader *producer, nir_shader *consumer);
typedef enum {
/* If set, this forces all non-flat fragment shader inputs to be
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index 85677b7c176..ca46a6b71b0 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -523,3 +523,36 @@ nir_compact_varyings(nir_shader *producer, nir_shader *consumer,
compact_components(producer, consumer, comps, interp_type, interp_loc,
default_to_smooth_interp);
}
+
+/*
+ * Mark XFB varyings as always_active_io in the consumer so the linking opts
+ * don't touch them.
+ */
+void
+nir_link_xfb_varyings(nir_shader *producer, nir_shader *consumer)
+{
+ nir_variable *input_vars[MAX_VARYING] = {};
+
+ nir_foreach_variable(var, &consumer->inputs) {
+ if (var->data.location >= VARYING_SLOT_VAR0 &&
+ var->data.location - VARYING_SLOT_VAR0 < MAX_VARYING) {
+
+ unsigned location = var->data.location - VARYING_SLOT_VAR0;
+ input_vars[location] = var;
+ }
+ }
+
+ nir_foreach_variable(var, &producer->outputs) {
+ if (var->data.location >= VARYING_SLOT_VAR0 &&
+ var->data.location - VARYING_SLOT_VAR0 < MAX_VARYING) {
+
+ if (!var->data.always_active_io)
+ continue;
+
+ unsigned location = var->data.location - VARYING_SLOT_VAR0;
+ if (input_vars[location]) {
+ input_vars[location]->data.always_active_io = true;
+ }
+ }
+ }
+}