[Mesa-dev] [PATCH 07/25] glsl: add helper for calculating size of AoA
Ian Romanick
idr at freedesktop.org
Thu Aug 20 10:45:30 PDT 2015
This patch is
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
On 08/19/2015 09:37 PM, Timothy Arceri wrote:
> V2: return 0 if not array rather than -1
>
> Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
> ---
> src/glsl/glsl_types.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
> index e7c73da..469ee3e 100644
> --- a/src/glsl/glsl_types.h
> +++ b/src/glsl/glsl_types.h
> @@ -550,6 +550,25 @@ struct glsl_type {
> }
>
> /**
> + * Return the total number of elements in an array including the elements
> + * in arrays of arrays.
> + */
> + unsigned arrays_of_arrays_size() const
> + {
> + if (!is_array())
> + return 0;
> +
> + unsigned size = length;
> + const glsl_type *base_type = fields.array;
> +
> + while (base_type->is_array()) {
> + size = size * base_type->length;
> + base_type = base_type->fields.array;
> + }
> + return size;
> + }
> +
> + /**
> * Return the amount of atomic counter storage required for a type.
> */
> unsigned atomic_size() const
>
More information about the mesa-dev
mailing list