[Mesa-dev] [PATCH 04/13] nir: fix lowering arrays to elements for TFB outputs

Jason Ekstrand jason at jlekstrand.net
Sat Oct 13 13:09:51 UTC 2018


From: Samuel Pitoiset <samuel.pitoiset at gmail.com>

If we have a transform feedback output like:

float[2] x2_out (VARYING_SLOT_VAR1.x, 0, 0)

which is lowered by nir_lower_io_arrays_to_elements to,

float x2_out (VARYING_SLOT_VAR1.x, 0, 0)
float x2_out at 5 (VARYING_SLOT_VAR2.x, 0, 0)

We have to update the destination offset to avoid overwriting
the same value.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/compiler/nir/nir_lower_io_arrays_to_elements.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_lower_io_arrays_to_elements.c b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
index af33d153ea5..0482f82ca9c 100644
--- a/src/compiler/nir/nir_lower_io_arrays_to_elements.c
+++ b/src/compiler/nir/nir_lower_io_arrays_to_elements.c
@@ -125,6 +125,9 @@ lower_array(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *var,
          element = nir_variable_clone(var, b->shader);
          element->data.location =  var->data.location + io_offset;
 
+         if (var->data.explicit_offset)
+            element->data.offset = var->data.offset + elements_index * 4;
+
          const struct glsl_type *type = glsl_without_array(element->type);
 
          /* This pass also splits matrices so we need give them a new type. */
-- 
2.19.1



More information about the mesa-dev mailing list