关于OpenGL中的布局std140统一块中的数组 [英] Regarding arrays in layout std140 uniform block for OpenGL
问题描述
根据规范:
如果成员是标量或向量的数组,则基本比对 + *和数组步幅设置为匹配单个的基本对齐方式 + *数组元素,根据规则(1),(2)和(3),并四舍五入 + *为vec4的基本对齐方式.该数组可能在 + *结束;数组后的成员的基本偏移量被四舍五入 + *至基本比对的下一个倍数.
If the member is an array of scalars or vectors, the base alignment + * and array stride are set to match 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.
这是否意味着如果我有一个(float)vec3大小为3的数组,那会是
Does this mean that if I had an array of size 3 of a (float)vec3, would it be
vec3,vec3,vec3,(12个空字节达到vec4的倍数),(由于最后一个句子,所以有16个空字节)
vec3,vec3,vec3, (12 empty bytes to reach a vec4 multiple), (16 empty bytes because of the last sentence)
或
vec3,(4个空字节),vec3,(4个空字节)vec3,(4个空字节),(由于最后一个句子,所以有16个空字节)
vec3, (4 empty bytes),vec3,(4 empty bytes)vec3,(4 empty bytes), (16 empty bytes because of the last sentence)