GL_EXT_separate_shader_objects#
Supported Hardware#
Series6, Series6XE, Series6XT
Valid APIs#
OpenGL ES 2.0, 3.0
Description#
Conventional GLSL requires multiple shader stages (vertex and fragment) to be linked into a single monolithic program object to specify a GLSL shader for each stage. While this approach allows early optimisation opportunities, the hardware allows more flexibility, allowing developers to mix and match shaders at draw time instead.
This extension introduces program pipeline objects which act as containers for multiple program objects, each bound to different shader stages, to make up the equivalent of a monolithic program for fast switching, or users can bind individual shaders at run time. It also introduces a new way to update uniforms, without requiring a bind, reducing API overhead and reducing developer burden.
As well as API changes, this extension adds layout qualifiers to OpenGL ES Shading Language 1.0, so that shaders can have their inputs and outputs match up correctly even if their names do not.
Registry Link#
https://registry.khronos.org/OpenGL/extensions/ARB/ARB_separate_shader_objects.txt
Example#
// Create a vertex program
GLuint vertexShaderProgram = glCreateShaderProgramvEXT(GL_VERTEX_SHADER, 1, &vertexShaderSource);
// Create a fragment program
GLuint fragmentShaderProgram = glCreateShaderProgramvEXT(GL_FRAGMENT_SHADER, 1, &fragmentShaderSource);
// Create and bind a program pipeline object
GLuint programPipeline = 0;
glGenProgramPipelinesEXT(1, &programPipeline);
glBindProgramPipelineEXT(programPipeline);
// Bind the shader programs to the program pipeline object
glUseProgramStagesEXT(programPipeline, GL_VERTEX_SHADER_BIT_EXT, vertexShaderProgram);
glUseProgramStagesEXT(programPipeline, GL_FRAGMENT_SHADER_BIT_EXT, fragmentShaderProgram);
// Set a uniform value to a program that isn't necessarily bound
glProgramUniform1fEXT(fragmentShaderProgram, 0, 1.0f);
Example (GLSL)#
// Specify an attribute with a guaranteed location of zero
layout(location = 0) attribute highp vec3 normal;
// Specify a varying with a guaranteed location of 4
layout(location = 4) varying highp vec4 colour;