A Shader is a program designed to run on some stage of a graphics processor. Its purpose is to execute one of the programmable stages of the rendering pipeline.

Stages

The rendering pipeline defines certain sections to be programmable. Each of these sections, or stages, represents a particular type of programmable processing. Each stage has a set of inputs and outputs, which are passed from prior stages and on to subsequent stages (whether programmable or not).

Shaders are written in the OpenGL Shading Language. The OpenGL rendering pipeline defines the following shader stages:

A program object can combine multiple shader stages (built from shader objects) into a single, linked whole. A program pipeline object can combine programs that contain individual shader stages into a whole pipeline.

While shader stages do use the same language, each stage has a separate set of inputs and outputs, as well as built-in variables. As such, shader objects are built for a specific shader stage. So while program objects can contain multiple stages, shader objects only contain code for a single stage.

Note that each stage may also have limitations on stage-specific resources; vertex shaders have a hard limit on the number of Vertex Attributes, for example. This section will discuss resources that are general to all shaders.

The query-able limits, and their associated meanings, are as follows. Note that the "*" is the stage name. It can be VERTEX, TESS_CONTROL, TESS_EVALUATION, COMPUTE, GEOMETRY or FRAGMENT. These values also have an OpenGL-required minimum; OpenGL implementations (of a certain version) will support at least this many of that resource.

MAX_*_UNIFORM_COMPONENTS

This is the number of active components of uniform variables that can be defined outside of a uniform block. The term "component" is meant as the basic component of a vector/matrix. So a vec3​ takes up 3 components. The minimum value here is 1024, enough room for 256 vec4​s.

GL_MAX_*_UNIFORM_BLOCKS

The maximum number of uniform blocks that this shader stage can access. The OpenGL-required minimum is 12 in GL 4.4, 14 in GL 4.3.

GL_MAX_*_INPUT_COMPONENTS

The maximum number of components that this stage can take as input. The required minimum value differs from shader stage to shader stage. Note that Vertex Shaders do not have this value, as they use a different output mechanic based on draw buffers.

GL_MAX_*_OUTPUT_COMPONENTS

The maximum number of components that this stage can output. The required minimum value differs from shader stage to shader stage. Note that Fragment Shaders do not have this value, as they use a different output mechanic based on draw buffers.

GL_MAX_*_TEXTURE_IMAGE_UNITS

The maximum number of texture image units that the sampler in this shader can access. The OpenGL-required minimum value is 16 for each stage.

Note: For legacy reasons, the enumerator for the fragment shader equivalent is called GL_MAX_TEXTURE_IMAGE_UNITS. No FRAGMENT.

The maximum number of image variables for this shader stage. The OpenGL-required minimum is 8 for fragment and compute shaders, and '0 for the rest. This means implementations can disallow you from using image variables outside of those specific stages.

The maximum number of different buffers that the atomic counter variables can come from. The OpenGL-required minimum is 1 for fragment shaders, 8 for compute shaders (note: possible spec typo), and again 0 for the rest.

The maximum number of different shader storage blocks that a stage can use. For fragment and compute shaders, the OpenGL-required minimum is 8; for the rest, it is 0.

Aggregate limits

While these define the resources usable to a shader stage, there are some limits beyond this, which cover all shader stages in total.

GL_MAX_UNIFORM_BUFFER_BINDINGS

The limit on the number of uniform buffer binding points. This is the limit for glBindBufferRange​ when using GL_UNIFORM_BUFFER. In GL 3.3, this value is a minimum of 36 (3 shader stages, with a minimum of 12 blocks per stage). In 4.3, this value is a minimum of 72.

GL_MAX_COMBINED_UNIFORM_BLOCKS

The maximum number of uniform blocks that all of the active programs can use. If two (or more) shader stages use the same block, they count separately towards this limit. In GL 3.3, this was 36; in 4.3, it is 70.

The total number of shader storage blocks, image variables, and fragment shader outputs across all active programs cannot exceed this number. This is the "amount of stuff" that a sequence of shaders can write to (barring Transform Feedback). This value has a minimum of 8.