[Mesa-dev] [PATCH v2] nir: fix compacting varyings when XFB outputs are present
Samuel Pitoiset
samuel.pitoiset at gmail.com
Wed Oct 10 14:46:33 UTC 2018
We shouldn't try to compact any varyings known as always
active IO, especially XFB outputs. For example, if one
component of an xfb output is also used as input varying
in the next stage, it shouldn't be compacted.
This small helper just marks all XFB varyings as always_active_io
in the consumer to not compact them.
v2: add a little helper
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/compiler/nir/nir_linking_helpers.c | 33 ++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index 88014e9a1d..433729bd79 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -480,6 +480,36 @@ compact_components(nir_shader *producer, nir_shader *consumer, uint8_t *comps,
&producer->info.outputs_read);
}
+/* Mark XFB varyings as always_active_io in the consumer to not compact them. */
+static void
+link_xfb_varyings(nir_shader *producer, nir_shader *consumer)
+{
+ nir_variable *input_vars[32] = {};
+
+ nir_foreach_variable(var, &consumer->inputs) {
+ if (var->data.location >= VARYING_SLOT_VAR0 &&
+ var->data.location - VARYING_SLOT_VAR0 < 32) {
+
+ 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 < 32) {
+
+ if (!var->data.explicit_xfb_buffer)
+ continue;
+
+ unsigned location = var->data.location - VARYING_SLOT_VAR0;
+ if (input_vars[location]) {
+ input_vars[location]->data.always_active_io = true;
+ }
+ }
+ }
+}
+
/* We assume that this has been called more-or-less directly after
* remove_unused_varyings. At this point, all of the varyings that we
* aren't going to be using have been completely removed and the
@@ -501,6 +531,9 @@ nir_compact_varyings(nir_shader *producer, nir_shader *consumer,
uint8_t interp_type[32] = {0};
uint8_t interp_loc[32] = {0};
+ if (producer->info.has_transform_feedback_varyings)
+ link_xfb_varyings(producer, consumer);
+
get_slot_component_masks_and_interp_types(&producer->outputs, comps,
interp_type, interp_loc,
producer->info.stage,
--
2.19.1
More information about the mesa-dev
mailing list