Uploading Textures Efficiently#

When a non-compressed texture is uploaded to the graphics hardware, the input data is in linear scan-line format; a compressed texture is uploaded block-by-block. Internally, PowerVR hardware uses its own layout to improve memory access locality and improve cache efficiency. Reformatting of the data is done on-chip by dedicated hardware and is therefore very fast. However, it is still recommended that a few steps be taken to minimise the cost of this reformat.

These steps are as follows:

  • Textures should be uploaded during non-performance critical periods, such as initialisation. This helps avoid the frame rate dips associated with additional texture loading.

  • Avoid uploading texture data mid-frame to a texture object that has already been used for that frame.

  • Consider performing a warm-up step after texture uploads have been performed. Once again, this helps avoid the frame rate dips associated with texture loading.

Texture warm-up#

The warm-up step mentioned before ensures that textures are fully uploaded immediately. By default, glTexImage2D does not perform all the processing required to upload immediately. Instead, the texture is fully uploaded the first time it is used. It is possible to force an upload by drawing a series of triangles off screen or otherwise obscured with the texture object in question bound and so marked for use. Performing this for all textures in a scene will avoid the cost and potential stutters when they are uploaded on first use.

Texture formats and precision#

Textures should be read as lowp (see Samplers). The exceptions to this are half float textures which should be read as mediump , and float and depth textures which should be read as highp.