[Mesa-dev] [PATCH V6 11/27] glsl: calculate AoA uniform offset correctly for structs
Timothy Arceri
t_arceri at yahoo.com.au
Tue Oct 6 13:59:35 PDT 2015
On Tue, 2015-10-06 at 13:10 -0700, Ian Romanick wrote:
> On 09/28/2015 07:42 PM, Timothy Arceri wrote:
> > This allows the correct offset to be calculated for use in indirect
> > indexing of samplers.
> > ---
> > src/glsl/glsl_types.cpp | 16 +++++++++++++++-
> > 1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
> > index 0ead0f2..6664a47 100644
> > --- a/src/glsl/glsl_types.cpp
> > +++ b/src/glsl/glsl_types.cpp
> > @@ -1072,7 +1072,21 @@ glsl_type::record_location_offset(unsigned
> > length) const
> > const glsl_type *wa = st->without_array();
> > if (wa->is_record()) {
> > unsigned r_offset = wa->record_location_offset(wa
> > ->length);
> > - offset += st->is_array() ? st->length * r_offset :
> > r_offset;
> > + offset += st->is_array() ?
> > + st->arrays_of_arrays_size() * r_offset : r_offset;
> > + } else if (st->is_array() && st->fields.array
> > ->is_array()) {
> > + unsigned outer_array_size = st->length;
> > + const glsl_type *base_type = st->fields.array;
> > +
> > + /* For arrays of arrays only the outer arrays take up
> > a uniform
> > + * slot for each element the innermost array only
> > takes up a
> > + * single slot.
> > + */
>
> This sentence doesn't parse very well. That is causing me to have
> trouble understanding why this is different than
> arrays_of_arrays_size();
Your right that doesn't read well. It's arrays_of_arrays_size() without
the innermost array added to the total.
>
> > + while (base_type->fields.array->is_array()) {
> > + outer_array_size = outer_array_size * base_type
> > ->length;
> > + base_type = base_type->fields.array;
> > + }
> > + offset += outer_array_size;
> > } else {
> > /* We dont worry about arrays here because unless the
> > array
> > * contains a structure or another array it only takes
> > up a single
> >
>
More information about the mesa-dev
mailing list