GL_IMG_program_binary#

Supported Hardware#

Series5, Series5XT, Series6, Series6XE, Series6XT

Valid APIs#

OpenGL ES 2.0, 3.x

Description#

This extension enables PowerVR program binary formats to be queried and handled by the GL_OES_get_program_binary extension, which allows binary shader programs to be retrieved, stored and reloaded, avoiding compilation steps on subsequent runs of an application.

Example#

// Create a shader program object
GLuint shaderProgram = glCreateProgram();
// If there isn't already a binary, create a program
if (!binaryExists)
{
    // Create shaders, compile them, attach them and link them as per normal, then...
    // Retrieve the program binary size
    GLint length=0;
    glGetProgramiv(shaderProgram, GL_PROGRAM_BINARY_LENGTH, &length);
    // Pointer to the binary shader program in memory, needs to be allocated with the
    // right size.
    GLvoid* programBinaryData = (GLvoid*)malloc(length);
    // The format that the binary is retrieved in.
    GLenum binaryFormat=0;
    // Error checking variable - this should be greater than 0 after
    // glGetProgramBinaryOES, otherwise there was an error.
    GLsizei lengthWritten=0;
    glGetProgramBinaryOES(shaderProgram, length, &lengthWritten, &binaryFormat,
                   programBinaryData);
}
else
{
    // Get the binary data, how much data there is, and what format it's in from whatever
    // cache it's stored in (e.g. a file)
    // ...
    // Instead of creating, compiling, attaching and linking shaders, upload a binary
    // program data from a program that previously underwent all of these stages.
    glProgramBinaryOES(shaderProgram, binaryFormat, programBinaryData,
                programBinaryDataLength);
}