diff options
author | Timothy Arceri <[email protected]> | 2015-05-27 21:31:59 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2015-09-26 22:27:47 +1000 |
commit | 9bad7afbc2ca6003da9a19c486b81d6ed0b8b0df (patch) | |
tree | 0d6b6e1d312b15d1bf3646ccdc52f3d02b9fc3c2 | |
parent | 776a3845d6325578d51eea6e7d91ffb475862fc8 (diff) |
glsl: add helper for calculating size of AoA
V2: return 0 if not array rather than -1
Reviewed-by: Tapani Pälli <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
-rw-r--r-- | src/glsl/glsl_types.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 23ada15b854..3ec764219de 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -578,6 +578,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 |