On Mon, 2014-07-21 at 14:04 -0700, Ian Romanick wrote: > From: Ian Romanick <ian.d.roman...@intel.com> > > There are a bunch of places, especially in the UBO code, where we check > whether something is a matrix (or record) when we actually want to know > if it a matrix or an array of matrices (ditto for records). >
Hi Ian, I sent an alternative to this as part of and arrays of arrays series (patch 2) back in May [1]. The advantage is that it means adding only one extra function to glsl_types rather than three, it supports arrays of arrays and is more generic so can be used for other types. I guess it may be a little less readable then your alternative but that could probably be fixed by giving it a better name (its wrong anyway as it should be innermost not outermost). Anyway its just a suggestion. It will be easy enough to add arrays of arrays support to these functions later on. I haven't been working on this for a few weeks but I recall that uniform code you changed seems to be fairly arrays of arrays friendly allowing my suggestion to be used there [2] [1] http://lists.freedesktop.org/archives/mesa-dev/2014-May/059271.html [2] https://github.com/tarceri/Mesa_arrays_of_arrays/commit/ba422820d0e8b9944fd3d0278913ae3cfbb184b2 > This will be used in later patches in this series. > > Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> > --- > src/glsl/glsl_types.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h > index 0b63d48..2dfa8dd 100644 > --- a/src/glsl/glsl_types.h > +++ b/src/glsl/glsl_types.h > @@ -354,6 +354,14 @@ struct glsl_type { > } > > /** > + * Query whether or not a type is a matrix or an array of matrices > + */ > + bool is_matrix_or_array_of() const > + { > + return is_matrix() || (is_array() && fields.array->is_matrix()); > + } > + > + /** > * Query whether or not a type is a non-array numeric type > */ > bool is_numeric() const > @@ -441,6 +449,14 @@ struct glsl_type { > } > > /** > + * Query whether or not a type is a record or an array of records > + */ > + bool is_record_or_array_of() const > + { > + return is_record() || (is_array() && fields.array->is_record()); > + } > + > + /** > * Query whether or not a type is an interface > */ > bool is_interface() const > @@ -449,6 +465,14 @@ struct glsl_type { > } > > /** > + * Query whether or not a type is an interface or an array of interfaces > + */ > + bool is_interface_or_array_of() const > + { > + return is_interface() || (is_array() && fields.array->is_interface()); > + } > + > + /** > * Query whether or not a type is the void type singleton. > */ > bool is_void() const _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev