`
chriszeng87
  • 浏览: 738249 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

GLSL errors

阅读更多

Possible GLSL errors are as follows:

Internal compiler error

Indicates an error that is not exposed via another specific error code, or indicates an internal problem with the operation of the compiler.

Compiler memory error - shader exceeds x bytes

Long running programs can cause problems on some hardware, thus the GLSL compiler takes some measures to prevent these programs from running. One of the measures taken is to examine the length of the shader after the preprocessor has run. If this length is too long, then the shader is rejected.

Syntax error - x

The syntax at the given location did not match the required syntax of GLSL. There are a large number of reasons for why this can occur in both the preprocessing stage and the GLSL language stage. Here is a simple example:

 
attribute int int;

Since an identifier is expected after a type, this is an invalid declaration.

Undeclared identifier x

Identifiers must be declared before they can be used. The most common cause of this error is misspelling an identifier name, or using an identifier from an extension without enabling the extension. For example:

 
int x;
y = 1;


Invalid arguments passed to function x

A function was called with the incorrect number of arguments or with one or more of the arguments of the wrong type. Check that the number of arguments and their types in the function call match those of the declaration or definition of the function. For example:

 
void exampleFunction1(int x);

void exampleFunction2() {
  exampleFunction1(1, 2);
}

Postfix expression cannot be indexed

This error indicates that the indexing operator [] has been applied to an expression which does not support being indexed. The following code demonstrates how this error can occur:

 
int bar; 
return bar[0];

Index out of range

The compiler has determined that an index is out of range for the variable as it was declared.

In some cases (such as indexing a vector or an array) the bounds are known, and if the index is an expression that the compiler can calculate, it can determine if the index is out of range. The following code demonstrates how this error can occur:

 
int bar[3]; 
int baz = bar[4];

Incompatible index expression. For non-uniforms, the index must be an expression formed of the loop_index and integer constants. For uniforms, the index must be an integer constant.

There are restrictions to what kind of index is allowed on both uniform and non-uniform variables. For a uniform variable, the index must be an integer constant expression. The following code demonstrates how this error can occur:

 
// The indexing of nonuniform vectors and arrays with expressions is illegal:
vec4 b; 
float a; 
int c = 0; 
a = b[c];

// For fragment shader code, the indexing of uniform vectors and arrays with index expressions is illegal:
uniform vec4 b; 
float a; 
int c = 0; 
a = b[c];

If the variable is not a unifom, then the index can include a loop index variable.

Index must be a constant

An index is not a constant in the shader code. The following shader code demonstrates how this error can occur:

 
uniform float myArray[100];
int i = 0;
float a;

a = myArray[i];

Argument x is not a sampler

An argument is not a sampler in the shader code. A sampler is a set of GLSL uniform variable types that represent a particular texture used for texture sampling. Samplers are not allowed to be declared using a non-uniform type.

 
float my2dSampler; // Should be "uniform sample2D my2dSampler".
vec2 coord;
v4 returnData;

returnData = texture2D(my2dSampler,  coord); // Note that texture2D() is a built-in function.


Invalid macro name - cannot start with 'GL_' or contain '__'

Invalid macro name used in the shader code. The following code demonstrates how this error can occur:

 
#define get__squared(x) ( x * x )

Incompatible types in expression

Incompatible types in expression used within the shader code. The following code demonstrates how this error can occur:

 
float a; 
float b; 

if (a || b) { // Causes the error because the IF statement inputs are not Boolean.
  a = 1.0; 
}

Expression in if statement does not evaluate to a boolean

Invalid if expression used in shader code. The following code demonstrates how this error can occur:

 
struct S { 
    int x; 
}; 

bool b[2]; 

if (S) { // Causes the error because struct types are not allowed in selection IF expressions.
  return true; 
} 
else { 
  return false; 
}

if (b) { // Also causes the error because array types are not allowed in selection IF expressions.
  return true; 
} 
else { 
  return false;
}

Divide or mod by zero in constant expression

Divide or mod by zero occurred in shader code. The following code demonstrates how this error can occur:

 
int a = 5 / 0; 
float a = 5.0 / 0.0;

vec4 a; 
a[1 / 0] = 0.4;

Invalid parameter count for macro

Invalid preprocessor parameter count on macro occurred in shader code. Ensure that the number of arguments passed to the macro matches the expected number of parameters for the macro. The following code demonstrates how this error can occur:

 
#define myMacro(x) (x < 0)

myMacro(1,2)

Maximum uniform vector count exceeded

Maximum uniform vector count exceeded in shader code. The following code demonstrates how this error can occur:

 
uniform vec4 v1[1000000];

Maximum attribute vector count exceeded

Maximum attribute vector count exceeded in shader code. The following code demonstrates how this error can occur:

 
attribute vec4 v1[1000000];

Maximum varying vector count exceeded

Maximum varying vector count exceeded in shader code. The following code demonstrates how this error can occur:

 
varying vec4 v1[1000000];

Maximum shader complexity exceeded

Shader code complexity error. Shader programs that encounter this can try to use a simpler version of the shader.

Identifier already declared

Identifier already declared in the shader code. The following code demonstrates how this error can occur:

 
float a;
float a[5];

int b;
void b() {}

struct { 
  vec4 v; 
  vec3 v[2];
} example2;

Invalid character used outside of comment

Invalid character error within shader code. The following code demonstrates how this error can occur:

 
void exampleFunction() { 
  int /@9$; 
}

Invalid initializer in for loop, needs to be a single variable of type float or int and initialized to a constant

Invalid initializer in for loop within the shader code. The following code demonstrates how this error can occur:

 
void exampleFunction1() { 
  int i; 

  for (i = 0; i < 1; i++) { // Declaring i outside of the loop and assigning a value to it is an error.
  }
}

void exampleFunction2() { 
  for (int i; i < 1; i++) { // i must be initialized.
  }
}

void exampleFunction3() { 
  for (bool i = false; i; i = !i) { // i must be an int or float.
  }
}

void exampleFunction4() { 
  struct S { 
    int i; 
  }; 

  for (S s = S(2); s.i < 4; s.i++) { // i cannot be a struct.
  }
}

void exampleFunction5() { 
  float x = 0.0; 

  for (float i = x; i < 1.0; i++) { // i cannot be initialized via another variable.
  }
}

Invalid condition in for loop, needs to be in form loop_index { > | >= | < | <= | == | != } constant

Invalid condition in for loop within shader code. The following code demonstrates how this error can occur:

 
for (int i = 0; ; i++) { } // The conditional statement is missing.

for (int i = 0; 1 > i; i++) { } // The conditional must have the variable on the left.

for (int i = 0; i * 2; i++) { } // The conditional cannot use operators outside of comparison and equality operators.

Invalid iteration in for loop, needs to be in form { --loop_index | ++loop_index | loop_index++ | loop_index-- | loop_index+=constant | loop_index-=constant }

Invalid iteration in for loop within the shader code. The following code demonstrates how this error can occur:

 
void exampleFunction1() { 
  for (int i = 0; i < 1; ) { // Missing increment/decrement statement.
  }
}

void exampleFunction2() { 
  for (int i = 0; i < 10; i *= 2) { // The += and -= operators may be used but not *= or /=
  }
}

void exampleFunction3() {
  int x = 10; 

  for (int i = 0; i < 10; i += x) { // The x variable must be a constant.
  }
}

Invalid modification to loop index inside loop body

Invalid write to loop variable within shader code. The following code demonstrates how this error can occur:

 
void exampleFunction1() { 
  for (int i = 0; i < 1; i++) {
    i = 1;
  }
}

void exampleFunction2() { 
  for (int i = 0; i < 1; i++) {
    i++;
  }
}

void exampleFunction3() {
  int x = 10; 

  for (int i = 0; i < 1; i++) {
    int x; 

    i = x = 1;
  }
}

Invalid identifier name - cannot start with 'gl_', 'webgl_', '_webgl_' or contain '__'

Invalid identifier name used in shader code. The following code demonstrates how this error can occur:

 
int webgl_baz;

struct gl_faz { int bar; } svar;

void __exampleFunction2() { }

void webgl_exampleFunction3() { }

void exampleFunction1(int a__rg) { }

void exampleFunction1(int rg__) { }

Token exceeds maximum length

A token exceeds its max length in shader code. Try shortening long identifier names.

Invalid qualifier on array - cannot make arrays of attribute or const variables

Invalid qualifier on array in shader code, as demonstrated in the following:

 
attribute float foo[2];
const float bar[1];

// const array of structs not allowed:
struct S1 { int i; }; 
const S1 s1[3]; 

const struct S2 { int i; } s2[3];

Incompatible type used for return expression

Incompatible type used for return expression in shader code. The following code demonstrates how this error can occur:

 
void exampleFunction1() { 
  float a; 

  return (a + 1.0); 
}

vec2 exampleFunction2() { 
  float a; 

  return (a + 1.0); 
}

struct { bool b; } exampleFunction3() { // Note that anonymous structs are a valid return type for GLSL functions.
  return true; // Causes error in that this Boolean type does not match the expected return type.
}

Invalid qualifier on sampler variable declaration - must be uniform

Invalid qualifier on sampler variable declaration used in shader code, as demonstrated in the following:

 
varying sampler2D sampler;
varying samplerCube sampler;
attribute sampler2D sampler;
attribute samplerCube sampler;
sampler2D sampler;
sampler2D sampler[2];
samplerCube sampler;

Invalid type passed to matrix constructor - arguments must be a matrix, or a scalar / vector of float / int / bool

Invalid type passed to matrix constructor in shader code. The following code demonstrates how this error can occur:

 
struct S { int i; } s; 
mat2 v1 = mat2(s); 

int i[2]; 
mat2 v2 = mat2(i);

Invalid type passed to componentwise vector or matrix constructor - arguments must be a scalar / vector of float / int / bool

Invalid type passed to component-wise vector or matrix constructor in shader code. The following code demonstrates how this error can occur:

 
uniform sampler2D s1; 
float f = float(s1);

uniform samplerCube s2;
int i = int(s2);
bool b = int(s2);

 
// Structure and array types cannot be vector or tensor constructor arguments:
struct S { int i; } s; 
vec2 v1 = vec2(1, s); 

int i[1]; 
ivec2 v2 = ivec2(1, i);

 
// Samplers are not allowed as vector constructor arguments:
uniform sampler2D s1; 
vec4 v1 = vec4(0, 0, 0, s1); 

uniform samplerCube s2;
vec4 v2 = vec4(0, 0, 0, s2);

 
// Samplers are not allowed as matrix constructor arguments:
uniform sampler2D s1; 
mat2 v = mat2(0, 0, 0, s1);

uniform samplerCube s2; 
mat2 v = mat2(0, 0, 0, s2);

 
// Cannot pass multiple matrix arguments:
mat2 a; 
mat4 mat = mat4(a, a, a, a); 

// Structure and array types cannot be used in matrix constructors:
struct S { int i; } s; 
mat2 v1 = mat2(1, s, 0, 1);

int i[2]; 
mat2 v2 = mat2(1, i, 0, 1);

// Cannot use matrix arguments to a matrix constructor if there are more than one arguments:
mat3 m1 = mat3(vec3(0), vec2(0), mat2(1));
mat4 m2 = mat4(vec4(0), vec4(0), mat2(1), mat2(1));


Invalid argument count in componentwise vector or matrix constructor - total components passed must equal vector or matrix size

Invalid count of components passed to matrix constructor in shader code. The following code demonstrates how this error can occur:

 
float f = float(1, 2);
int i = int(1, 2);
bool b = bool(1, 2);

// Invalid component count using scalars:
mat2 mat = mat2(1.0, 2.0, 3.0);
mat3 mat = mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0);
mat4 mat = mat4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0);

// Invalid component count using vectors:
vec3 a; 
vec3 b; 
vec3 c; 
mat2 m = mat2(a, b, c);

// Invalid component count using vectors and scalars:
vec2 a; 
mat2 mat = mat2(a, 3.0);

vec4 a; 
mat3 mat = mat3(a, a, a, 3.0);

//Invalid argument counts:
vec2 a; 
mat2 m = mat2(a);

vec2 a, b, c; 
mat2 m = mat2(a, b, c);

vec3 a, b; 
mat3 m = mat3(a, b);

vec3 a, b, c, d; 
mat3 m = mat3(a, b, c, d);

vec4 a, b, c; 
mat4 m = mat4(a, b, c);

vec4 a, b, c, d, e; 
mat4 m = mat4(a, b, c, d, e);

Invalid expression on left of assignment expression

Invalid expression on left of assignment in shader code. There are many sources of this error including:

 
// Invalid constants and const variables:
const float x = 0.0; 
x = 1.0;

void exampleFunction(const float x) { 
  x = 1.0;
}

// Invalid swizzle with repeats:
vec4 x; 
x.xx = vec2(1.0, 1.0);
vec4 x; x.ww -= vec2(1.0, 1.0);
vec4 x; --x.xx;

// Invalid function call:
float test() { 
  return 0.0; 
} 
void baz() { 
  test() = 1.0;
}

// Invalid assignment expressions:
float x, y; 
x *= 2.0 = y;

float x; 
(x *= 2.0)++;

// Writing to read-only built-in variables:
gl_FrontFacing = false;
gl_PointCoord = vec2(0.0, 0.0);
gl_DepthRange.near = 1.0;

// Writing to varying variables (which are read-only) within the fragment shader:
varying vec3 baz1; 
void main() { baz1 = vec3(0.0) };

varying vec3 baz2; 
void main() { baz2.x = 1.0; }

// Uniforms and attributes cannot be left-hand values:
uniform bool abc;
abc = true;

attribute vec3 cba;
cba.z = 1.0;

// Constant objects cannot be left-hand values:
void outfunc(inout float ret) { 
  ret = 1.0; 
} 
void callingfunc() { 
  const float x = 0.0; 
  outfunc(x); 
}

const struct S { vec4 v; } svar = S(vec4(0.0)); 
svar.v.x = 1.0;

Invalid swizzle in field selection - swizzle component count must be equal or less than max vector size (4)

Too many components provided for swizzle in the shader code. The following code demonstrates how this error can occur:

 
// Cannot use more than four components:
vec2 a; 
vec4 b; 
a = b.xxxxx;

Invalid swizzle in field selection - swizzle components must be all from same set (xyzw, rgba or stpq)

For shader code, the provided swizzle components cannot be in different sets. The following code demonstrates how this error can occur:

 
// Cannot mix index types (like r and y):
vec2 a; 
vec4 b; 

b = a.ry;
b = a.xs;
b = a.sg;

Invalid swizzle component in field selection - must be from a valid GLSL set (xyzw, rgba or stpq)

An invalid swizzle component is used in the shader code. The following code demonstrates how this error can occur:

 
// Cannot use illegal characters in field selection of vectors:
vec4 b; 

b = b.cdef;

Swizzle component out of range - must select a component that exists in the vector

A swizzle component is out of range in the shader code. The following code demonstrates how this error can occur:

 
// Invalid index attempt (vec2 has no z component):
vec2 a;
vec4 b; 

b = a.yzzz;
b = a.baaa;
b = a.pqqq;

This hardware is unable to support gl_FrontFacing

Shader code using gl_FrontFacing on FL 9 hardware. The following code demonstrates how this error can occur on FL9 hardware:

 
void main() { 
  if (gl_FrontFacing) { 
    gl_FragColor = vec4(1.0, 0, 0, 1);
  }
}

Const variable requires initialization

Shader code variables declared as const require initialization. The following code demonstrates how this error can occur:

 
const float bar;
const float a, b = 0.0, c;

// Samplers can't be const variables:
const sampler2D sampler;
const samplerCube sampler;

// const anonymous structures are impossible since they can't be initialized in GLSL:
const struct { bool b; } svar;

// const structures must be initialized:
struct S { int i; }; 
const S s;

Variables declared with uniform, attribute, or varying qualifier cannot be initialized

Shader code variables declared as uniformattribute, or varying qualifier cannot be initialized. The following code demonstrates how this error can occur:

 
attribute vec3 attr1 = vec3(0.0);
uniform float uniFloat = 0.0;
varying vec2 varyVec = vec2(0.0);
uniform float uniFloat = 0.0;
varying vec2 varyVec = vec2(0.0);

Varying variable cannot have bool, int, or struct type

Shader code variables declared as varying require an underlying component type of float. The following code demonstrates how this error can occur:

 
varying int var;
varying ivec2 var;
varying ivec3 var[2];
varying bool var[3];
varying bvec4 var;

Invalid argument passed to constructor - argument must be a basic GLSL type

Invalid constructor argument used in shader code. The following code demonstrates how this error can occur:

 
struct Light {
  vec3 eyePosOrDir;
  bool isDirectional;
  vec3 intensity;
  float attenuation;
} lightData;

light = mat2(lightData);

Invalid type qualifier for function parameter - only const on in parameters is allowed

Invalid type qualifier on parameter used in shader code. The following code demonstrates how this error can occur:

 
void exampleFunction1(const inout highp float x) {}
void exampleFunction2(const inout highp float) {}
void exampleFunction3(const inout float x[1]) {}
void exampleFunction4(varying float x) {}
void exampleFunction5(attribute float x) {}

Array declarator requires a constant expression

For shader code, declarators declared as array types require a constant expression for the array size, as demonstrated as follows:

 
// Array expression must be constant:
int i = (false) ? 1 : 2; int j[i];

// Array parameter declarators must have constant size:
int bar = (true) ? 1 : 0; 
void exampleFunction1(float x[bar]) {}

// Array declarators must be const in structs:
uniform bool f; 
void exampleFunction2() { 
  int i = (f) ? 1 : 2; 
  struct { int j[i]; } svar; 
}

// The following array must have a size specified, and the size specified must be an integral constant that's greater than zero:
int arrraySize = 10; 
struct { int myArray[arrraySize + 1]; };

Array was declared with size less than or equal to zero

For shader code, array size constants must be greater than or equal to zero. The following code demonstrates how this error can occur:

 
int j[0];
int j[-1];

void exampleFunction1(int bar[0]) {}
void exampleFunction2(int bar[-1]) {}

const int bar = 0; 
void exampleFunction3(float x[bar]) {}

void exampleFunction4(float x[0]) {}

struct { int z[0]; };
struct { int i, j[0]; } svar;
struct { int j[-1]; } svar;

Type qualifiers 'uniform' and 'attribute' are invalid for structs

Invalid type qualifier for struct used in shader code. The following code demonstrates how this error can occur:

 
attribute struct { vec4 v; } svar;
varying struct { vec4 v; } svar;

Invalid field name for struct type

Invalid type qualifier for struct used in shader code (can't be varying or attribute). The following code demonstrates how this error can occur:

 
// Cannot use a name that doesn't exist on the type for field selection:
struct { int a; } svar; 
svar.b = 1;

struct S { int x; }; 
void exampleFunction() { 
  struct S { int y; } ss; 
  S s; 

  s.x = 1;
}

Invalid type for left hand side of field selection

Invalid type for left hand side of field selection used in shader code. The following code demonstrates how this error can occur:

 
vec4 b[2]; 
b.x = 1.0;

// Invalid type for field selection (svar.v is an array):
struct { vec4 v[10]; } svar; 
svar.v.x = 1.0;

Samplers are not allowed in structs

For shader code, sampler types are not supported as struct fields. The following code demonstrates how this error can occur:

 
struct { sampler2D samp; } svar;
struct { samplerCube samp; } svar;

Macros must be redefined the same as original definition

Macros must be redefined the same in shader code. The following code demonstrates how this error can occur:

 
#define A 7.0
A

#define A(x) x
A(1)

.

Invalid loop index expression passed as out / inout parameter

Using loop index as out or inout parameter in shader code. The following code demonstrates how this error can occur:

 
void zar(out int x) { 
  x = 1;
} 

void bar() { 
  for (int i = 0; i < 1; i++) { 
    zar(i); 
  }
}

Type cannot be used as a constructor

For shader code, types are not allowed to be constructed. The following code demonstrates how this error can occur:

 
void exampleFunction1() { return void(); }

sampler2D s1 = sampler2D(0);
samplerCube s2 = samplerCube(0);

Undeclared type x

Type name has not been declared in shader code. The following code demonstrates how this error can occur:

 
struct S { int x; }; 

void exampleFunction() { 
  S S = S(10); 
  S x;
}

// Member types must already be defined (forward references are not allowed):
struct { svarB foo; } svarA; 
struct svarB { int bar; };

Embedded struct declarations are not allowed

structs can't be nested in shader code. The following code demonstrates how this error can occur:

 
struct { 
  struct { int bar; } svarB; 
} svarA;

Function x is declared and used but not defined

Invoked function not defined in shader code. The following code demonstrates how this error can occur:

 
void zar(); 

void bar() { zar(); }

Function redefinition not allowed

Function illegally redefined in shader code. The following code demonstrates how this error can occur:

 
void bar(int) {} 
void bar(int) {}

void zar1(inout int i) {} 
void zar1(inout int i) {}

void zar2(in int i) {} 
void zar2(int i) {}

void zar3(int i) {} 
void zar3(in int i) {}

Function redeclaration not allowed

Function illegally re-declared in shader code. The following code demonstrates how this error can occur:

 
// Duplicate forward declarations are not allowed:
void bar(int);
void bar(int);

// A definition counts as a declaration:
void zar(int) {} 
void zar(int);

void func1(out int i) {} 
void func1(out int i);

void func2(in int i) {} 
void func2(int i);

void func3(int i) {}
void func3(in int i);

Invalid single argument to vector constructor - must be a scalar type, or another vector, or a 2x2 matrix

Invalid argument passed to vector constructor in shader code. The following code demonstrates how this error can occur:

 
// Structure and array types cannot be vector or tensor constructor arguments:
struct S { int i; } s; 
vec2 v1 = vec2(s); 

int i[2]; 
ivec2 v2 = ivec2(i);

Struct constructor arguments' types do not match the struct's field types

For shader code, struct constructors require exactly matching types. The following code demonstrates how this error can occur:

 
// Structure constructor types must match exactly in count and type:

// Types not matching:
struct S { int x; }; 
S s = S(true);

// Too few arguments:
struct S { int x, y; }; 
S s = S(1);

// Too many arguments:
struct S { int x; }; 
S s = S(1, 2);

Error: x

Custom preprocessor shader error code/message. For example, the #error directive can be used for detecting programmer inconsistencies and violation of constraints during preprocessing. When an #error directive is encountered, compilation terminates with a custom error code/message, if provided.

 
#if !defined(__cplusplus)
  #error C++ compiler required.
#endif

Be aware that the error code/message is subject to macro expansion.

Invalid location for continue statment - must be inside of a loop

Cannot execute a continue outside of a loop. The following code demonstrates how this error can occur:

 
void main(void) { 
  continue;
}

Cannot call main

main is the designated entry point, and therefore cannot be called. The following code demonstrates how this error can occur:

 
void exampleFunction { 
  main(void);
}

Invalid qualifier on non-global variable - non-global variables can be const but cannot be varying, attribute or invariant

Invalid qualifier on non-global variable used in shader code. The following code demonstrates how this error can occur:

 
void main(void) { 
  main(void);
}

void baz() { 
  main(void); 
}

Cannot redefine main or define main with incorrect signature

For shader code, you cannot redefine main or define main with an incorrect signature. The following code demonstrates how this error can occur:

 
void main(int x) {
}

void main(float x) {
}

void main(int x, float y) {
}

float main() { 
  return 1.0;
}

Cannot use reserved operators such as '~', '%=', '>>=', '<<=', '&=', '|=', or '^='

Reserved operator used in shader code. The following code demonstrates how this error can occur:

 
int a; 
a >>= 1;

int b; 
b <<= 1;
int c; 
c %= 1;
int d; 
d &= 1;
int e; 
e |= 1;
int f; 
f ^= 1;

bool g; 
bool h = ~g;

Ternary conditional operator must have boolean expression for test condition

For shader code, ternary conditional operators must have Boolean expression for the test condition. The following code demonstrates how this error can occur:

 
float a; 
int b; 
bool c; 
a = (c, a, b) ? (b = 1, 1.0) : (b = 2, 2.0);

float a; 
float b; 
int c; 
a = b ? 1.0 : c;

struct S { int x; }; 
bool baz1() { 
  S s; 
  return (s) ? true : false;
}

bool baz2() { 
  bool b[2]; 
  return (b) ? true : false;
}

Ternary conditional operator must have two expressions of equal types after test condition

For shader code, a ternary conditional operator must have two expressions of equal types after the test condition. The following code demonstrates how this error can occur:

 
float a; 
float b; 
int c; 

a = (b < 0.0) ? 1.0 : c;

Invalid location for break statement - break statements must be inside a loop

Invalid location for break statement in shader code. The following code demonstrates how this error can occur:

 
void main(void) { 
  break;
}

Invalid location for discard statement - discard statements must be inside a fragment shader

Invalid location for discard statement in shader code. The following code demonstrates how this error can occur:

 
void main(void) { 
  discard;
}

Initializer for const variable must initialize to a constant value

Non-constant initializer used in shader code. The following code demonstrates how this error can occur:

 
int x = 0; 
const int y = x;

bool x = false; 
const bool y = !x;

int x[2]; 
const int y = x[0];

ivec2 x; 
const int y = x.x;

struct structDef {int bar;}; 
structDef baz = structDef(1); 
const int y = baz.bar;

bool f = true; 
const int y = (f) ? 1 : 0;

// Function params with const are not const expressions:
void baz(const int x) { const int y = x; }

// Samplers also can't be const variables:
uniform sampler2D a; 
const sampler2D sampler = a;

uniform samplerCube b; 
const samplerCube sampler = b;

// A const struct may not contain an array:
int iArr[2]; 
struct S { int i[2]; }; 
const S s = S(iArr);

S nonConstS; 
const S s = nonConstS;

// const struct initialization requires const parameters:
struct S { int i, j; }; 
int a, b; 
const S s = S(a, b);

Functions cannot be overloaded on return type

Function overloaded on return type in shader code. The following code demonstrates how this error can occur:

 
void sin(float f) { }
void sin(vec4 f);

void pow(float f1, float f2) { }
void pow(vec4 f1, vec4 f2);

void clamp(float f1, float f2, float f3) { }
void clamp(vec4 f1, vec4 f2, vec4 f3);

void step(float f1, float f2) { }
void step(float f, vec4 v);

mat4 cross(vec3 a, vec3 b) { }
mat4 cross(vec3 a, vec3 b);

void equal(vec2 f1, vec2 f2) { }
void equal(bvec4 f1, bvec4 f2);

void any(bvec2 f) { }
void any(bvec4 f);

// Overloads on the return type are not allowed:
int baz1(int); 
void baz1(int) {}

struct S { int i; }; 
int baz2(S s) { 
  return 1;
} 
void baz2(S);

struct S { int i; }; 
struct S2 { int i; }; 
S baz3(); 
S2 baz3();

Known functions cannot be re-declared or re-defined

A known function was re-declared or re-defined in shader code. The following code demonstrates how this error can occur:

 
float sin(float f) { }
vec4 sin(vec4 f);

float pow(float f1, float f2) { }
vec4 pow(vec4 f1, vec4 f2);

float clamp(float f1, float f2, float f3) { }
vec4 clamp(vec4 f1, vec4 f2, vec4 f3);

float step(float f1, float f2) { }
vec4 step(out float f, vec4 v);

vec3 cross(vec3 a, vec3 b) { }
vec3 cross(vec3 a, vec3 b);

bvec2 equal(vec2 f1, vec2 f2) { }
bvec4 equal(inout bvec4 f1, bvec4 f2);

bool any(bvec2 f) { }
bool any(bvec4 f);

Function header definition parameter qualifiers must match declaration parameter qualifiers

A function was defined with mismatching qualifiers from its declaration in shader code. The following code demonstrates how this error can occur:

 
void baz1(int i); 
void baz1(out int i) {}

void baz2(out int i); 
void baz2(inout int i) {}

struct S { int i; }; 
void baz3(inout S i); 
void baz3(out S i) {}
void baz3(S i); 
void baz3(out S i) {}

Array size must be an integer constant expression

Array size must be an integer constant expression in shader code. The following code demonstrates how this error can occur:

 
float i = 0.0;
int arr[2];

arr[i];

Array size expression too complex

Array size unable to be calculated in shader code. The following code demonstrates how this error can occur:

 
const bool x = false; 
const bool y = !x; 
int a[int(y)];

int a[ivec2(1, 1).x];

const ivec2 x = ivec2(1, 1); 
const int y = x.x; 
int a[y];

struct structDef {int bar;}; 
const structDef baz = structDef(1); 
const int y = baz.bar; 
int a[y];

int arr[2 > 1 ? 8 : 9];

#version directive must specify 100 for version

Wrong #version directive used in shader code. The following code demonstrates how this error can occur:

 
#version 90
#version 110

#version directive can only be preceded by whitespace or comments

#version directive in wrong place in shader code. The following code demonstrates how this error can occur:

 
#define BAZ
#version 100 

Unary operator not defined for type

Unary operator not defined for this type in shader code. The following code demonstrates how this error can occur:

 
struct S { int i; } s; 
+s;

int a[2]; 
+a;

Struct declarations are disallowed in function parameter declarators

struct type declaration in function parameter not allowed in shader code. The following code demonstrates how this error can occur:

 
bool exampleFunction(struct S { bool b; } svar) { 
  return svar.b;
}

Struct type declaration exceeds maximum nesting level of 4

struct types exceeded maximum nesting level in shader code. The following code demonstrates how this error can occur:

 
struct One { bool f; };
struct Two { One one[2]; };
struct Three { Two two[2]; };
struct Four { Three three[2]; };
struct Five { One one; Two two; Three three; Four four[2]; };

Operator not defined for struct types

Illegal operator for struct type used in shader code. The following code demonstrates how this error can occur:

 
struct S {int a;}; 
S a, b; 
a <= b;

struct S {bool a;}; 
S a, b; 
a && b;

struct S {int a;}; 
S a, b; 
a += b;

Operator not defined for user-defined types that contain array types

Operator not defined for a type that contains an array type in shader code. The following code demonstrates how this error can occur:

 
struct S {int a[2];}; 
S a, b; 
a = b;

Unknown extension: x

Unknown extension used in shader code. For FL9 hardware, the following code demonstrates how this error can occur:

 
#extension GL_OES_standard_derivatives : enable\nvoid exampleFunction() { vec3 x; vec3 y = dFdx(x); }

Invalid behavior specified for extension - behavior must be require, warn, enable or disable for regular extensions, or warn or disable for 'all'

Invalid behavior specified for extension in shader code. The following code demonstrates how this error can occur:

 
#extension all : enable

#extension all : require

#extension all : unknown

Required extension x is not supported

A required extension is not supported for the shader code. For FL9 hardware, the following code demonstrates how this error can occur:

 
#extension GL_OES_standard_derivatives : require\nvoid exampleFunction() { vec3 x; vec3 y = dFdx(x); }

Preprocessor directives can only be preceded by whitespace on a line

Directive not first thing on line in shader code. The following code demonstrates how this error can occur:

 
aaaa#define A
  
  a/**/aa  #define B

  aaa#define C

aa/**/a #define D

Function declarations cannot be local

The following code demonstrates how this error can occur:

 
// Local function declarations are not allowed:
void baz(int) { 
  void bar();
}

Variable declared as type void is not allowed

The following code demonstrates how this error can occur:

 
void v[3];

void baz(void vv);
void baz(void vv) {}

struct { void a; } svar;
struct { void a[2]; } svar;

struct { void a; } svar;
struct { void a[2]; } svar;

'void' is an invalid parameter type unless used as '(void)'

The following code demonstrates how this error can occur:

 
void baz1(int, void) {}

void baz2(int, vec3, mat2, void, mat4) {}

 

 

转自:http://msdn.microsoft.com/en-us/library/ie/dn611835(v=vs.85).aspx

分享到:
评论

相关推荐

    GLSL-Debugger/glsl-devil

    **GLSL-Debugger/glsl-devil 知识点详解** GLSL-Debugger/glsl-devil 是一个专为GLSL(OpenGL Shading Language)设计的小巧而实用的调试工具。GLSL是OpenGL编程中的核心部分,用于编写顶点着色器、片段着色器等...

    hlsl2glsl hlsl转换为glsl图形化工具

    **hlsl2glsl:HLSL到GLSL的转换神器** 在计算机图形学领域,着色语言是渲染引擎的核心组成部分,它们允许开发者编写程序来控制GPU的行为,从而实现复杂的光照、纹理和几何处理效果。两种最广泛使用的着色语言分别是...

    glsl代码编辑器Shaderpad++

    Shaderpad++是一款基于Qt框架开发的GLSL代码编辑器,其设计灵感来源于经典的文本编辑器Notepad++。这款工具专为GLSL(OpenGL Shading Language)程序员量身打造,提供了丰富的特性来提升编写和调试GLSL代码的效率。 ...

    GLSL language integration vs2019 glsl提示工具个高亮和显示行号

    vs2019 glsl提示工具个高亮和显示行号

    GLSLC++

    **GLSLC++** GLSL(OpenGL Shading Language)是一种高级着色语言,用于编写图形处理单元(GPU)上的程序,通常用于3D图形渲染、游戏开发和视觉效果。GLSLC++是将GLSL与C++相结合的一种编程库,它提供了一种方便的...

    GLSL编程入门小程序

    **GLSL编程入门小程序** GLSL(OpenGL Shading Language)是一种高级着色语言,用于为OpenGL图形库编写顶点和片段着色器。它是GPU编程的重要工具,允许开发者充分利用图形处理器的强大性能,实现复杂的视觉效果。这...

    GLSL教程 pdf版

    GLSL(OpenGL Shading Language)是OpenGL编程中的一个重要部分,用于编写着色器程序,实现图形渲染的定制化。在本教程中,我们将深入探讨GLSL的基础知识、使用方法以及如何将其应用于实际的3D图形渲染中。GLSL是GPU...

    GLSL之纹理演示

    GLSL,全称为OpenGL Shading Language,是一种编程语言,用于为OpenGL图形库编写着色器。在3D图形渲染中,着色器是计算像素颜色和物体表面属性的关键部分。本话题将深入探讨GLSL中的纹理操作,以及如何在实际项目中...

    glsl图像处理,灰度化,高斯模糊,角点检测等算法,linux环境

    这里我们关注的是使用GLSL(OpenGL着色语言)在Linux环境下进行图像处理,包括灰度化、高斯模糊和角点检测等算法。GLSL是GPU编程的语言,允许我们在硬件级别上高效地执行复杂的计算。 首先,GLSL是OpenGL的一个组成...

    GLSL API.CHM

    GLSL(OpenGL Shading Language)是一种着色器语言,用于为OpenGL图形库编写顶点、片段和其他类型的着色器。这个“GLSL API.CHM”文件是一个帮助文档,旨在为学习和使用GLSL API的开发者提供详尽的参考资料。CHM...

    OpenGL4.6着色语言精通_第三版_源码_opengl_third_GLSL4.6_GLSL_源码_

    这源码是OpenGL4.6着色语言精通_第三版的全部源代码,利用GLSL 4.6和C++ 17构建高质量实时三维图形。主要重点是OpenGL着色语言(GLSL)。因此,我们不花时间讨论用OpenGL编程的基础。在这个我认为读者对在OpenGL中...

    GLSL Tutorial中英双语

    **GLSL(OpenGL Shading Language)教程中英双语详解** GLSL,全称为OpenGL Shading Language,是OpenGL渲染管线中的重要组成部分,用于编写顶点着色器、片段着色器、几何着色器等阶段的程序。这些着色器在GPU上...

    lambert glsl 简单演示

    **GLSL Lambert 简介** GLSL,全称 OpenGL Shading Language,是OpenGL图形库的一个重要组成部分,用于编写顶点着色器和片段着色器等GPU程序,赋予3D图形更多的表现力和实时计算能力。在3D渲染中,Lambert光照模型...

    OpenGL程序嵌入GLSL

    OpenGL程序嵌入GLSL是图形编程中的一个关键环节,它涉及到如何在OpenGL应用程序中使用GLSL(OpenGL Shading Language)来实现复杂的图形效果。GLSL是一种着色语言,专为OpenGL设计,允许开发者编写运行在GPU(图形...

    glsl es3 官方文档

    ### GLSL ES3官方文档知识点解析 #### 一、概述 **GLSL ES3**(OpenGL ES Shading Language Version 3.00)是专为移动设备设计的着色语言标准,旨在为移动图形处理单元(GPU)提供高级功能的同时保持良好的性能与...

    一个正确的完整glsl程序

    **GLSL程序详解** GLSL(OpenGL Shading Language)是一种着色器语言,用于定义OpenGL渲染管线中的计算和渲染操作。它允许程序员在GPU(图形处理单元)上编写代码,以实现更高效的图形处理和复杂的视觉效果。对于...

    glsl cube 简单演示

    在计算机图形学领域,GLSL (OpenGL Shading Language) 是一种强大的工具,用于编写着色器,即在GPU上运行的程序,以控制图形渲染的各个方面。本话题将深入探讨"glsl cube 简单演示",这是一个利用GLSL进行立方体渲染...

    GLSL学习__中文版

    ### GLSL学习中文版知识点详解 #### 一、GLSL简介 **OpenGL Shading Language (GLSL)** 是一种用于编写可编程着色器的语言,它主要用于OpenGL环境下的图形编程。GLSL是在2003年6月由ARB组织批准的一个OpenGL扩展,...

Global site tag (gtag.js) - Google Analytics