VAOs, UBOs, Transform Feedback Buffers, and SSBOs in OpenGL ES#

Vertex Array Objects (VAOs)#

These encapsulate bound vertex state such as glVertexAttribPointer. Binding a VAO applies all the encapsulated state to the global GL state. The ID Zero (’0’) is reserved by GL to represent the default VAO. Always use VAOs when working with SGX or Rogue.

APIs

  • OpenGL ES 1.x and 2.0: Extension (GL_OES_vertex_array_object), which is discussed in greater detail in the PowerVR Supported Extensions document.

  • OpenGL ES 3.x: Core.

Uploading uniforms and Uniform Buffer Objects (UBOs)#

Instead of uploading uniform data such as glUniformMatrix4fv and glUniform1 from client memory, a Uniform Buffer Object (UBO) allows uniform data to be stored in an OpenGL ES buffer object.

There are different approaches that can be used for supplying uniform data to shaders in OpenGL ES. The most optimal method will vary depending on the use case.

Here are some general guidelines which can be considered when uploading shader uniforms to the graphics core:

  • If there are only a small number of uniforms, then setting the uniforms directly – for instance, through functions such as glUniformMatrix4fv and glUniform1f – is usually the most efficient approach. This saves the overhead incurred when using a buffer.

  • If there are many uniforms that are changing in bulk, then a UBO is the most efficient method to use. Applications can map and un-map buffers to modify them. There are several slots available to bind UBOs, so an application may use more than one for each draw, such as split static, and dynamic data.

  • Consider the case of several uniforms changing in bulk at the same time, and a small number, perhaps one or two uniforms changing at different frequencies. The most efficient method is to split those uniforms out of the UBO, and update them on their own separately from the rest of the buffer. UBOs come with the general disadvantage of all buffers – if they are modified in any way, then the driver will need to ensure that any previous operations are complete before updating the buffer. Otherwise, the entire buffer must be ghosted (copied).

Use UBOs whenever they are suitable according to the guidelines above when deploying to platforms with Rogue graphics cores. However, UBOs are not recommended when deploying to platforms with SGX graphics cores.

APIs

  • OpenGL ES 1.x: Not exposed.

  • OpenGL ES 2.0: Exposed (IMG_uniform_buffer_object).

  • OpenGL ES 3.x: Core.

Transform feedback buffer objects#

These buffers are used for transform feedback. When these are bound, post-transform vertex data is automatically resolved to the buffer by the graphics hardware. The buffers can be written to and read by the graphics hardware, but cannot be accessed by the CPU. Always use these buffers when working on Rogue; however, they are not available for SGX architectures.

APIs

  • OpenGL ES 1.x and 2.0: Not exposed.

  • OpenGL ES 3.x: Core.

Shader Storage Buffer Objects (SSBOs)#

SSBOs are similar to UBOs. For example, storage blocks are defined in GLSL, and SSBOs are bound to SSBO binding points.

Unlike UBOs, SSBOs:

  • Can be written to by the graphics core.

  • Can be used as compure kernel input/output.

  • Can be much larger than UBOs – megabytes instead of kilobytes.

  • Have variable storage up to the range bound for the given buffer. The actual size of the array, based on the range of the buffer bound, can be queried at runtime in the shader using the length function on the unbounded array variable.

Although SSBOs have similar features to UBOs and transform feedback buffers, the flexibility comes at a cost. SSBO reads may be costlier than UBOs, as data is fetched from system memory like a buffer texture instead of being pre-loaded into shader registers as UBOs would. Unlike transform feedback buffers that are written to automatically when bound, SSBOs need to be written to explicitly in shader code. SSBOs are not available on SGX.

When using PowerVR Rogue graphics cores, favour UBOs and transform feedback buffers where possible, as they take optimal paths through the pipeline. SSBOs are best suited for draw indirect/dispatch compute indirect use cases.

APIs

  • OpenGL ES 1.x, 2.0, and 3.0: Not available.

  • OpenGL ES 3.1+: Core.