[Mesa-dev] [PATCH v2] glsl: Add without_array type predicate

Timothy Arceri t_arceri at yahoo.com.au
Wed Jul 30 14:01:18 PDT 2014


On Wed, 2014-07-30 at 10:25 -0700, Ian Romanick wrote:
> On 07/29/2014 11:18 PM, Timothy Arceri wrote:
> > On Tue, 2014-07-29 at 16:14 -0700, Ian Romanick wrote:
> >> From: Ian Romanick <ian.d.romanick at intel.com>
> >>
> >> Returns the type without any arrays.
> >>
> >> This will be used in later patches in this series.
> >>
> >> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> >> Suggested-by: Timothy Arceri <t_arceri at yahoo.com.au>
> >> Cc: Timothy Arceri <t_arceri at yahoo.com.au>
> >> ---
> >>  src/glsl/glsl_types.h | 12 ++++++++++++
> >>  1 file changed, 12 insertions(+)
> >>
> >> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
> >> index 0b63d48..9cd132a 100644
> >> --- a/src/glsl/glsl_types.h
> >> +++ b/src/glsl/glsl_types.h
> >> @@ -465,6 +465,18 @@ struct glsl_type {
> >>     }
> >>  
> >>     /**
> >> +    * Get the type stripped of any arrays
> >> +    *
> >> +    * \return
> >> +    * Pointer to the type of elements of the first non-array type for array
> >> +    * types, or pointer to itself for non-array types.
> >> +    */
> >> +   const glsl_type *without_array() const
> >> +   {
> >> +      return this->is_array() ? this->fields.array : this;
> >> +   }
> >> +
> > 
> > Sorry I noticed this as I hit send on the last email with my reviewed by
> > but shouldn't this be:
> > 
> > return this->is_array() ? this->fields.array->without_array() : this;
> 
> Right now we don't do arrays of arrays (except perhaps for geometry
> shaders?), so I didn't want to add support for a thing that I couldn't
> test. :)  Also, I think I'd rather do the arrays-of-arrays without
> recursion.  I was thinking:
> 
>    const glsl_type *t = this;
> 
>    while (t->is_array())
>       t = t->fields.array;
> 
>    return t;
> 
> Some of these patches will likely get picked back to 10.2, so I'd like
> to do this as a follow-up patch.
> 
> Does that sound good?

Yeah that's fine. I just thought we could avoid multiple changes. A
while loop if fine too I just figured that it was unlikely to have a
huge number of dimensions so it wouldn't matter to much, also recursion
is used everywhere else (getting sizes of things for example) so was
just trying to be consistent. 

As for testing there has been basic support for arrays of arrays in Mesa
since January so enabling the extension in the driver and updating patch
3[1] from my series in May would be enough to test for regressions in
piglit.
Anyway I'm getting a little off topic now but there actually isn't much
left for me to be able to submit a first attempt at enabling arrays of
arrays support I just thought I'd try write all the piglit tests before
doing this but it seems no one is interested enough review these so I've
been working on it less and less. Paul Berry seemed interested in
helping back in January but he doesn't seem to be around any more. I'd
give up but I want to finish what I've started.

[1] http://lists.freedesktop.org/archives/mesa-dev/2014-May/059274.html

> >> +   /**
> >>      * Return the amount of atomic counter storage required for a type.
> >>      */
> >>     unsigned atomic_size() const
> 




More information about the mesa-dev mailing list