March 2013
Intermediate to advanced
984 pages
26h 18m
English
When you group a number of variables in a uniform buffer or shader storage buffer, and want to read or write their values outside a shader, you need to know the offset of each one. You can query these offsets, but for large collections of uniforms this process requires many queries and is cumbersome. As an alternative, the standard layout qualifiers request that the GLSL shader compiler organize the variables according to a set of rules, where you can predictably compute the offset of any member in the block.
In order to qualify a block to use the std140 layout, you need to add a layout directive to its declaration, as demonstrated below:
layout (std140) uniform UniformBlock { // ...