GL_EXT_gpu_shader5#

Supported Hardware#

Series6, Series6XE, Series6XT

Valid APIs#

OpenGL ES 3.1

Description#

This extension adds a number of useful, but miscellaneous features to the OpenGL ES shading language. These features are as follows:

  • support for indexing into arrays of opaque types (samplers, and atomic counters) using dynamically uniform integer expressions;

  • support for indexing into arrays of images and shader storage blocks using only constant integral expressions;

  • extending the uniform block capability to allow shaders to index into an array of uniform blocks;

  • a “precise” qualifier allowing computations to be carried out exactly as specified in the shader source to avoid optimization-induced invariance issues (which might cause cracking in tessellation);

  • new built-in functions supporting:

    • fused floating-point multiply-add operations;

  • extending the textureGather() built-in functions provided by OpenGL ES Shading Language 3.10:

    • allowing shaders to use arbitrary offsets computed at run-time to select a 2x2 footprint to gather from; and

    • allowing shaders to use separate independent offsets for each of the four texels returned, instead of requiring a fixed 2x2 footprint.

Example#

#extension GL_EXT_gpu_shader5 : require
uniform lowp sampler2DArray arrayOfTextureArrays[8];
uniform lowp sampler2D gatherableTexture;
in highp vec2 textureCoords;
in highp float a, b, c;
void main()
{
    ...
    // Loop through and reference each member of an array of texture arrays.
    highp vec4 value = vec4(0.0);
    for (uint i = 0; i < 8; ++i)
    {
        for (uint j = 0; j < 8; ++j)
        {
            value += texture(arrayOfTextureArrays[i], vec3(textureCoords, j));
        }
    }
    ...
    // Perform an explicit fused multiply-add
    highp float result;
    result = fma(a,b,c);
    ...
    // Ensure that no optimisations are done on any calculations that affect the result of a value (result2);
    precise highp float result2;
    result2 = a * b + c;
    ...
    // Gather four texels from a texture that aren't necessarily neighbours, obtaining the red channel.
    ivec2 offsets[4] = {ivec2(0,0), ivec2(5, 0), ivec2(5, 5), ivec2(0, 5)};
    vec4 gatheredTexels = textureGatherOffsets(gatherableTexture, textureCoords, offsets, 0);
    ...
}