GL_OES_sample_variables#
Supported Hardware#
Series6, Series6XE, Series6XT
Valid APIs#
OpenGL ES 3.x
Description#
This extension is one of three extensions which enhances OpenGL ES’s programmability with respect to how multisampling is performed:
GL_OES_sample_variables
GL_OES_sample_shading
GL_OES_shader_multisample_interpolation
GL_OES_sample_variables is required by the other two extensions, and adds a number of variables accessible to a fragment shader that allow control over each individual sample that contributes to the current fragment:
in lowp int gl_SampleID* // The ID of the current sample being shaded.
in mediump vec2 gl_SamplePosition* // The sub-pixel position of the sample, in the range [0,1], relative to the bottom left of the pixel.
in highp int gl_SampleMaskIn[(gl_MaxSamples+31)/32] // The sample mask generated for the current fragment by the fixed function pipeline.
out highp int gl_SampleMask[(gl_MaxSamples+31)/32]** // Output sample mask, allowing the shader to generate a different mask, programmably.
* Any use of these variables will force the fragment shader to run at sample rate, increasing the amount of fragment work.
** gl_SampleMask will be filled in with the value of gl_SampleMaskIn if it is never written to. If any execution path might write to it, all paths must write to it, or the value will be undefined.
Example#
#extension GL_OES_sample_variables : require
void main()
{
...
// Safely invert the sample mask
for (uint i = 0; i < ((gl_MaxSamples+31)/32); ++i)
{
gl_SampleMask[i] == !gl_SampleMaskIn[i];
}
...
}