Shaders in GLSL Flashcards
(44 cards)
What is not allowed in a fragment shader?
No access to adjacent fragments. Cannot change fragment position.
What are the conversion rules for GLSL?
There is no implicit conversion.
What are the basic types for GLSL?
void bool int float vec2 vec3 vec4 bvec2 bvec3 bvec4 ivec2 ivec3 ivec4 mat2 mat3 mat4 sampler2D samplerCube
What are the non-type keywords in GLSL?
attribute const uniform varying break continue do for while if else in out inout true false lowp mediump highp precision invariant discard return struct
What preprocessor directives are defined in GLSL?
# #define #undef #if #ifdef #ifndef #else #elif #endif #error #pragma #extension #version #line
What is the operator precedence for GLSL?
() defined + - ~ ! * / % \+ - << >> < > = == != & ^ | && ||
What is a sampler type?
Sampler2D and SamplerCube are opaque handlers to textures.
What are the usage restrictions on sampler types?
They can only be declared as function parameters or uniforms. Their use in expressions is limited. The cannot be used as out or inout function parameters.
What is an anonymous structure?
This: struct S { int i; }; S myStruct; // Illegal in GLSL, need "struct S myStruct"
What is an embedded structure definition?
struct S { struct T { } } // Illegal in GLSL, but this is OK: struct T { } struct S { T foo; }
How are arrays initialized at declaration in GLSL?
This is impossible.
How are variables scoped in GLSL?
By a system of statically nested scopes, as in C or Java { { } }.
What is the only shared global allowed in GLSL?
uniform
How is const used in GLSL?
Compile-time constants and read-only function parameters.
What is a GLSL attribute?
A linkage between a vertex shader and OpenGL ES per-vertex data
What is a GLSL uniform?
Uniforms form the linkage between a fragment shader, OpenGL ES, and the application. This value does not change across the primitive being processed.
What is a GLSL varying?
A linkage between a vertex shader and a fragment shader through interpolation.
What are the storage qualifiers and the rules for when they are allowed?
default, const, attribute, varying, or uniform.
Local variables may only be default.
Function parameters can only use const.
Function return types and structures do not use qualifiers.
What kind of data is used to communicate between runs of a shader?
None are allowed. This would defeat the SIMD nature of the GPU.
What is “static use” of a variable?
It is when the code contains a compiled reference to the variable, even if the code is never executed.
What do precision qualifiers do?
Specify minimum storage requirements for variables.
What is the rule for precision of operations?
Operations preserve precision of their highest-precision operand, with the exception of a few computationally-intense built-in functions, such as atan().
What does the precision keyword do for GLSL?
Creates a default precision for a storage type.
What does variance refer to in shaders?
In general, the same expression may give different values in different shaders. Shaders are compiled independently, so different shaders may have different values for the same expression.