<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 23, 2018 at 5:11 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The SPIR-V parser splits in/out struct variables and creates<br>
a separate variable for each first-level member of the struct.<br>
When the struct variable has an initializer this means that we also<br>
need to split the initializer.<br>
---<br>
 src/compiler/spirv/vtn_<wbr>variables.c | 8 ++++++++<br>
 1 file changed, 8 insertions(+)<br>
<br>
diff --git a/src/compiler/spirv/vtn_<wbr>variables.c b/src/compiler/spirv/vtn_<wbr>variables.c<br>
index eb306d0c4a..ead68b4784 100644<br>
--- a/src/compiler/spirv/vtn_<wbr>variables.c<br>
+++ b/src/compiler/spirv/vtn_<wbr>variables.c<br>
@@ -1837,7 +1837,15 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,<br>
                interface_type->members[i]-><wbr>type;<br>
             var->members[i]->data.mode = nir_mode;<br>
             var->members[i]->data.patch = var->patch;<br>
+<br>
+            if (initializer) {<br>
+               assert(i < initializer->num_elements);<br>
+               var->members[i]->constant_<wbr>initializer =<br>
+                  nir_constant_clone(<wbr>initializer->elements[i], var->members[i]);<br>
+            }<br>
          }<br>
+<br></blockquote><div><br></div><div>Mind adding a comment?<br><br></div><div>/* We dealt with any initializers during the splitting above. */<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+         initializer = NULL;<br>
       } else {<br>
          var->var = rzalloc(b->shader, nir_variable);<br>
          var->var->name = ralloc_strdup(var->var, val->name);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>