[Mesa-dev] [RFC PATCH 06/13] nir: fixing the xfb_offset for arrays of structs

Alejandro PiƱeiro apinheiro at igalia.com
Sat Dec 8 11:48:14 UTC 2018


Equivalent to previous patch (so comments applies), but implemented on
a different place. We would need to chose in which one.
---
 src/compiler/nir/nir_gather_xfb_info.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/compiler/nir/nir_gather_xfb_info.c b/src/compiler/nir/nir_gather_xfb_info.c
index bf432583ddb..6611691b686 100644
--- a/src/compiler/nir/nir_gather_xfb_info.c
+++ b/src/compiler/nir/nir_gather_xfb_info.c
@@ -101,6 +101,27 @@ compare_xfb_output_offsets(const void *_a, const void *_b)
    return a->offset - b->offset;
 }
 
+static void
+fix_struct_array_xfb_offset(nir_variable *var)
+{
+   if (!glsl_type_is_array(var->type))
+      return;
+
+   const struct glsl_type *child_type = glsl_get_array_element(var->type);
+
+   if (!glsl_type_is_struct(child_type))
+      return;
+
+   if (var->data.explicit_offset)
+      return;
+
+   int offset = glsl_get_struct_field_offset(child_type, 0);
+   if (offset != -1) {
+      var->data.explicit_offset = 1;
+      var->data.offset = offset;
+   }
+}
+
 nir_xfb_info *
 nir_gather_xfb_info(const nir_shader *shader, void *mem_ctx)
 {
@@ -115,6 +136,8 @@ nir_gather_xfb_info(const nir_shader *shader, void *mem_ctx)
     */
    unsigned num_outputs = 0;
    nir_foreach_variable(var, &shader->outputs) {
+      fix_struct_array_xfb_offset(var);
+
       if (var->data.explicit_xfb_buffer &&
           var->data.explicit_offset) {
 
-- 
2.19.1



More information about the mesa-dev mailing list