GL_IMG_shader_binary#

Supported Hardware#

Series5, Series5XT, Series6, Series6XE, Series6XT

Valid APIs#

OpenGL ES 2.0, 3.x

Description#

The OpenGL ES 2.0 and 3.0 specifications include functions “glGetShaderBinary/glShaderBinary” - allowing an application developer to retrieve, store and load binary shaders after compilation. By using this extension to cache compiled shaders, it is possible to avoid the run time cost of compiling shaders on subsequent runs. The specifications do not, however, define any binary formats for shaders, which is instead left up to each implementer. This extension enables Imagination’s shader binary format to be exposed through these mechanisms.

Typically, it is more efficient to use GL_OES_get_program_binary/GL_IMG_program_binary where available, as these also avoid the cost of linking and binding attributes - saving additional time on start up.

Example#

// Create a fragment shader
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
// Instead of uploading shader source and compiling, upload pre-compiled binary data
glShaderBinary(1, &fragmentShader, GL_SGX_BINARY_IMG, binaryShaderData, lengthOfBinaryShaderData);