Uploading Textures into PBOs#

Pixel buffer objects (PBOs) were introduced in OpenGL ES 3.0 and enable applications to map GL driver allocated textures into the applications address space. Once mapped, the application can then read from or write to the texture from the CPU.

Optimal texture updates with PBOs#

PBOs can be used to reduce the number of memory copies required to transfer data to memory accessible to the graphics core. For example, if a very fast upload of texture data from file was required, a PBO could be created and directly load the contents of the file into this memory. However, if the file was loaded into application memory first and then copied into the PBO, there would be as many memory copies performed as a call to glTexImage2D.

Transfer Queue (TQ) tasks#

If glTexStorage has been used to define the texture, transfer tasks for PBO writes will be kicked when glTexImage is called. The PBO must be unmapped before any GL calls are issued for the texture. Failing to do so will result in an error.

If glTexStorage has not been used, the transfer task will be deferred to the first draw call that uses the modified texture.

If there is already a copy of the texture in graphics memory, the driver will have to TQ copy the mapped region of the texture from twiddled graphics memory to the driver’s PBO buffer.

If the application does not need to preserve the mapped region, it may specify the GL_MAP_INVALIDATE_RANGE_BIT access flag when calling glMapBufferRange. If the entire texture can be invalidated, then the application can use the GL_MAP_INVALIDATE_BUFFER_BIT flag.