<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 14, 2016 at 9:13 PM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Monday, March 14, 2016 5:23:44 PM PDT Jason Ekstrand wrote:<br>
> On Sun, Mar 13, 2016 at 6:08 PM, Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> wrote:<br>
><br>
> > We want to use interface_type, not vtn_var->type.  They're normally<br>
> > equivalent, but for geometry/tessellation per-vertex interface arrays,<br>
> > we need to unwrap a level.<br>
> ><br>
> > Otherwise, we tried to iterate a structure members but instead used<br>
> > an array length.  If the array length was longer than the number of<br>
> > fields in the structure, we'd crash.<br>
> > ---<br>
> >  src/compiler/nir/spirv/vtn_variables.c | 2 +-<br>
> >  1 file changed, 1 insertion(+), 1 deletion(-)<br>
> ><br>
> > diff --git a/src/compiler/nir/spirv/vtn_variables.c<br>
> > b/src/compiler/nir/spirv/vtn_variables.c<br>
> > index 31bf416..1628042 100644<br>
> > --- a/src/compiler/nir/spirv/vtn_variables.c<br>
> > +++ b/src/compiler/nir/spirv/vtn_variables.c<br>
> > @@ -923,7 +923,7 @@ var_decoration_cb(struct vtn_builder *b, struct<br>
> > vtn_value *val, int member,<br>
> >           vtn_var->var->data.explicit_location = true;<br>
> >        } else {<br>
> >           assert(vtn_var->members);<br>
> > -         unsigned length = glsl_get_length(vtn_var->type->type);<br>
> > +         unsigned length = glsl_get_length(val->type->type);<br>
> ><br>
><br>
> Good catch.  What I think we really want here though is a "without_array"<br>
> helper.  I'm not a huge fan of grabbing the type from the value because<br>
> that comes in from the client and I don't really trust it.<br>
<br>
</div></div>Hmm...okay.  I suppose that would work, because vtn_var->members<br>
existing means that it's a struct...or array of structs.<br>
<br>
(I was afraid that we'd have to replicate the logic for deciding<br>
whether it's a normal varying array, or arrayed-interface...but<br>
I guess we don't...)<br></blockquote><div><br></div><div>I looked at the code that handles derefrences of these pre-split variables. All we do is handle it the first time we hit a struct deref so glsl_get_length(glsl_type_without_array(vtn_var->type->type)) is more-or-less exactly what we want. <br></div></div><br></div></div>