21.06.2014 Views

GLSL 3.30 - OpenGL

GLSL 3.30 - OpenGL

GLSL 3.30 - OpenGL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4 Variables and Types<br />

Types and declarators are the same as for other input, output, and uniform variable declarations outside<br />

blocks, with these exceptions:<br />

• initializers are not allowed<br />

• sampler types are not allowed<br />

• structure definitions cannot be nested inside a block<br />

Otherwise, built-in types, previously declared structures, and arrays of these are allowed as the type of a<br />

declarator in the same manner they are allowed outside a block.<br />

If no optional qualifier is used in a member-declaration, the qualification of the variable is just in, out, or<br />

uniform as determined by interface-qualifier. If optional qualifiers are used, they can include<br />

interpolation and storage qualifiers and they must declare an input, output, or uniform variable consistent<br />

with the interface qualifier of the block: Input variables, output variables, and uniform variables can only<br />

be in in blocks, out blocks, and uniform blocks, respectively. Repeating the in, out, or uniform<br />

interface qualifier for a member's storage qualifier is optional. Declarations using the deprecated<br />

attribute and varying qualifiers are not allowed. For example,<br />

in Material {<br />

smooth in vec4 Color1; // legal, input inside in block<br />

smooth vec4 Color2; // legal, 'in' inherited from 'in Material'<br />

vec2 TexCoord;<br />

// legal, TexCoord is an input<br />

uniform float Atten; // illegal, mismatched interfaces<br />

varying vec2 TexCoord2;//illegal, deprecated keywords don't get new uses<br />

};<br />

For this section, define an interface to be one of these<br />

• All the uniforms of a program. This spans all compilation units linked together within one program.<br />

• The boundary between adjacent programmable pipeline stages: This spans all the outputs in all<br />

compilation units of the first stage and all the inputs in all compilation units of the second stage.<br />

The block name (block-name) is used to match interfaces: an output block of one pipeline stage will be<br />

matched to an input block with the same name in the subsequent pipeline stage. For uniform blocks, the<br />

application uses the block name to identify the block. Block names have no other use within a shader<br />

beyond interface matching; it is an error to use a block name at global scope for anything other than as a<br />

block name (e.g., use of a block name for a global variable name or function name is currently reserved).<br />

Matched block names within an interface (as defined above) must match in terms of having the same<br />

number of declarations with the same sequence of types and the same sequence of member names, as well<br />

as having the same member-wise layout qualification (see next section). Furthermore, if a matching block<br />

is declared as an array, then the array sizes must also match (or follow array matching rules for the<br />

interface between a vertex and a geometry shader). Any mismatch will generate a link error. A block<br />

name is allowed to have different definitions in different interfaces within the same shader, allowing, for<br />

example, an input block and output block to have the same name.<br />

33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!