Graphics Reference
In-Depth Information
Table 5-4
Uniform Block Layout Qualifiers
Qualifier
Description
shared
The shared qualifier specifies that the layout in memory
of the uniform block across multiple shaders or multiple
programs will be the same. To use this qualifier, the
row_major/column_major values must be identical
across definitions. Overrides std140 and packed . (default)
packed
The packed layout qualifier specifies that the compiler
can optimize the memory layout of the uniform block.
The location of the offsets must be queried when using
this qualifier, and the uniform blocks cannot be shared
across vertex/fragment shader or programs. Overrides
std140 and shared .
std140
The std140 layout qualifier specifies that the layout
of the uniform block is based on a set of standard rules
defined in the “Standard Uniform Block Layout” section
of the OpenGL ES 3.0 Specification. We detail these layout
rules in the Uniform Buffer Objects section of Chapter 4.
Overrides shared and packed .
row_major
Matrices are laid out in row-major order in memory.
column_major
Matrices are laid out in column-major order in memory.
(default)
Vertex and Fragment Shader Inputs/Outputs
Another special variable type in the OpenGL ES Shading Language is the
vertex input (or attribute) variable. Vertex input variables are used to
specify the per-vertex inputs to the vertex shader and are specified with
the in keyword. They typically store data such as positions, normals,
texture coordinates, and colors. The key here to understand is that vertex
inputs are data that are specified for each vertex being drawn. Example 5-1
is a sample vertex shader that has a position and color vertex input.
The two vertex inputs in this shader, a_position and a_color , will
be loaded with data by the application. Essentially, the application will
create a vertex array that contains a position and a color for each vertex.
Notice that the vertex inputs in Example 5-1 are preceded by the layout
qualifier. The layout qualifier in this case is used to specify the index of
the vertex attribute. The layout qualifier is optional; if it is not specified,
the linker will automatically assign locations for the vertex inputs.
We explain this entire process in full detail in Chapter 6, “Vertex
Attributes, Vertex Arrays, and Buffer Objects.”
 
 
 
Search WWH ::




Custom Search