According to specification:
If the member is an array of scalars or vectors, the base alignment + * and array stride are set to match the bas
Neither.
The appendix L from the redbook states this:
So the correct answer is vec3, (4 empty), vec3, (4 empty),vec3, (4 empty) -> 48 bytes
From the actual OpenGL Specification, version 4.3 (PDF):
3: If the member is a three-component vector with components consuming N basic machine units, the base alignment is 4N.
4: If the member is an array of scalars or vectors, the base alignment and array stride are set tomatch the base alignment of a single array element, according to rules (1), (2), and (3), and rounded up to the base alignment of a vec4. The array may have padding at the end; the base offset of the member following the array is rounded up to the next multiple of the base alignment.
So a vec3
has a base alignment of 4*4. The base alignment and array stride of an array of vec3
's is therefore 4*4. The stride is the number of bytes from one element to the next. So each element is 16 bytes in size, with the first 12 being the actual vec3
data.
Finally, there is padding equal to the base alignment at the end, so there is empty space from that.
Or, in diagram form, a vec3[3]
looks like this:
|#|#|#|0|#|#|#|0|#|#|#|0|
Where each cell is 4 bytes, #
is actual data, and 0
is unused data.