std140

Members of type bool, int, uint, float, and double are respectively
extracted from a buffer object by reading a single
                         uint, int, uint, float, or   double value at the specified offset.
 
Vectors with N elements with basic data types of bool, int, uint, float,
or double are extracted as N values in consecutive memory locations beginning
at the specified offset, with components stored in order with the first
(X) component at the lowest offset. The GL data type used for component
extraction is derived according to the rules for scalar members above.  
 
If the member is a scalar consuming N basic machine units, the base alignment is N.
 
If the member is a two- or four-component vector with components consuming
N basic machine units, the base alignment is 2N or 4N, respectively.
 
If the member is a three-component vector with components consuming N
basic machine units, the base alignment is 4N.
 
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.
 
If the member is a structure, the base alignment of the structure is N, where
N is the largest base alignment value of any of its members,
and rounded up to the base alignment of a vec4. The individual members of this substructure
are then assigned offsets by applying this set of rules recursively,
where the base offset of the first member of the sub-structure is equal to the
aligned offset of the structure. The structure may have padding at the end;
the base offset of the member following the sub-structure is rounded up to
the next multiple of the base alignment of the structure.
 
If the member is an array of S structures, the S elements of the array are laid
out in order, according to rule (9).
 
A structure and each structure member have
a base offset and a base alignment,
from which
an aligned offset is computed by
rounding the base offset up to a multiple of the base alignment.
 从第16个字节开始,到第27个字节,为translation的存储。(闭区间)
所以接下来的rotation的base offset 为27+1 -> 28。
rotation的base alignment为16,所以28近似为16的倍数,得出32。
base alignment 表示单个元素的字节对齐。
base offset 表示本成员对象可使用的内存初始位置。
aligned offset 表示本成员实际使用的内存初始位置。

 

 

 

posted @ 2018-05-07 14:50  fndefbwefsowpvqfx  阅读(451)  评论(0编辑  收藏  举报