Graphics Reference
In-Depth Information
Performance Hints
How to Store Different Attributes of a Vertex
We described the two most common ways of storing vertex attributes:
an array of structures and a structure of arrays. The question to ask is
which allocation method would be the most efficient for OpenGL ES 3.0
hardware implementations. In most cases, the answer is an array of
structures. The reason is that the attribute data for each vertex can be
read in sequential fashion, which will most likely result in an efficient
memory access pattern. A disadvantage of using an array of structures
becomes apparent when an application wants to modify specific
attributes. If a subset of vertex attribute data needs to be modified (e.g.,
texture coordinates), this will result in strided updates to the vertex
buffer. When the vertex buffer is supplied as a buffer object, the entire
vertex attribute buffer will need to be reloaded. You can avoid this
inefficiency by storing vertex attributes that are dynamic in nature in a
separate buffer.
Which Data Format to Use for Vertex Attributes
The vertex attribute data format specified by the type argument in
glVertexAttribPointer can affect not only the graphics memory
storage requirements for vertex attribute data, but also the overall
performance, which is a function of the memory bandwidth required to
render the frame(s). The smaller the data footprint, the lower the memory
bandwidth required. OpenGL ES 3.0 supports a 16-bit floating-point vertex
format named GL_HALF_FLOAT (described in detail in Appendix A). Our
recommendation is that applications use GL_HALF_FLOAT wherever possible.
Texture coordinates, normals, binormals, tangent vectors, and so on are
good candidates to be stored using GL_HALF_FLOAT for each component.
Color could be stored as GL_UNSIGNED_BYTE with four components per
vertex color. We also recommend GL_HALF_FLOAT for vertex position, but
recognize that this choice might not be feasible for quite a few cases. For
such cases, the vertex position could be stored as GL_FLOAT .
How the Normalized Flag in gIVertexAttribPointer Works
Vertex attributes are internally stored as a single-precision floating-point
number before being used in a vertex shader. If the data type indicates
that the vertex attribute is not a float, then the vertex attribute will be
converted to a single-precision floating-point number before it is used
in a vertex shader. The normalized flag controls the conversion of the
non-float vertex attribute data to a single precision floating-point value.
If the  normalized flag is false, the vertex data are converted directly to a
 
Search WWH ::




Custom Search