broadcom/vc5: Fix translation of transform feedback's output_register field.
authorEric Anholt <eric@anholt.net>
Mon, 2 Oct 2017 20:02:32 +0000 (13:02 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 10 Oct 2017 18:42:05 +0000 (11:42 -0700)
It's a NIR driver_location, not a slot offset.

src/gallium/drivers/vc5/vc5_program.c

index d3b3d1bee702fe4fc063130611835ab26810d4bb..869220b423dd13c68a5f7c911671ed0caf08aa5f 100644 (file)
 #include "vc5_context.h"
 #include "broadcom/cle/v3d_packet_v33_pack.h"
 
+static gl_varying_slot
+vc5_get_slot_for_driver_location(nir_shader *s, uint32_t driver_location)
+{
+        nir_foreach_variable(var, &s->outputs) {
+                if (var->data.driver_location == driver_location) {
+                        return var->data.location;
+                }
+        }
+
+        return -1;
+}
+
 static void
 vc5_set_transform_feedback_outputs(struct vc5_uncompiled_shader *so,
                                    const struct pipe_stream_output_info *stream_output)
@@ -73,9 +85,11 @@ vc5_set_transform_feedback_outputs(struct vc5_uncompiled_shader *so,
                          * components of this varying.
                          */
                         for (int j = 0; j < output->num_components; j++) {
+                                gl_varying_slot slot =
+                                        vc5_get_slot_for_driver_location(so->base.ir.nir, output->register_index);
+
                                 slots[slot_count] =
-                                        v3d_slot_from_slot_and_component(VARYING_SLOT_VAR0 +
-                                                                         output->register_index,
+                                        v3d_slot_from_slot_and_component(slot,
                                                                          output->start_component + j);
                                 slot_count++;
                         }