glslang testing: Remove dependence on testfiles from LunarGLASS.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31512 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2015-06-17 16:15:09 +00:00
parent ab556eaaea
commit 2f21fccee9
82 changed files with 2145 additions and 80 deletions

166
Test/Operations.frag Normal file
View File

@ -0,0 +1,166 @@
#version 130
uniform ivec4 uiv4;
uniform vec4 uv4;
uniform bool ub;
uniform bvec4 ub41, ub42;
uniform float uf;
uniform int ui;
#ifdef TEST_POST_110
uniform uvec4 uuv4;
uniform unsigned int uui;
#endif
void main()
{
vec4 v;
float f;
bool b;
bvec4 bv4;
int i;
#ifdef TEST_POST_110
uint u;
#endif
// floating point
v = radians(uv4);
v += degrees(v);
v += (i = ui*ui, sin(v));
v += cos(v);
v += tan(v);
v += asin(v);
v += acos(v);
v += atan(v);
v += sinh(v);
v += cosh(v);
v += tanh(v);
v += asinh(v);
v += acosh(v);
v += atanh(v);
v += pow(v, v);
v += exp(v);
v += log(v);
v += exp2(v);
v += log2(v);
v += sqrt(v);
v += inversesqrt(v);
v += abs(v);
v += sign(v);
v += floor(v);
#ifdef TEST_POST_110
v += trunc(v);
v += round(v);
v += roundEven(v);
#endif
v += ceil(v);
v += fract(v);
v += mod(v, v);
v += mod(v, v.x);
#ifdef TEST_POST_110
v += modf(v, v);
#endif
v += min(v, uv4);
v += max(v, uv4);
v += clamp(v, uv4, uv4);
v += mix(v,v,v);
#ifdef TEST_POST_110
v += mix(v,v,ub);
v += intBitsToFloat(v);
v += uintBitsToFloat(v);
v += fma(v);
v += frexp(v);
v += ldexp(v);
v += unpackUnorm2x16(v);
v += unpackUnorm4x8(v);
v += unpackSnorm4x8(v);
#endif
v += step(v,v);
v += smoothstep(v,v,v);
v += step(uf,v);
v += smoothstep(uf,uf,v);
v += normalize(v);
v += faceforward(v, v, v);
v += reflect(v, v);
v += refract(v, v, uf);
v += dFdx(v);
v += dFdy(v);
v += fwidth(v);
//noise*(v);
#ifdef TEST_POST_110
// signed integer
i += abs(ui);
i += sign(i);
i += min(i, ui);
i += max(i, ui);
i += clamp(i, ui, ui);
floatsBitsToInt(v);
packUnorm2x16(v);
packUnorm4x8(v);
packSnorm4x8(v);
// unsigned integer
u = abs(uui);
u += sign(u);
u += min(u, uui);
u += max(u, uui);
u += clamp(u, uui, uui);
u += floatsBitToInt(v);
u += packUnorm2x16(v);
u += packUnorm4x8(v);
u += packSnorm4x8(v);
u += floatBitsToUInt(v);
#endif
// bool
#ifdef TEST_POST_110
b = isnan(uf);
b = isinf(v);
#endif
b = any(lessThan(v, uv4));
b = (b && any(lessThanEqual(v, uv4)));
b = (b && any(greaterThan(v, uv4)));
b = (b && any(greaterThanEqual(v, uv4)));
b = (b && any(equal(ub41, ub42)));
b = (b && any(notEqual(ub41, ub42)));
b = (b && any(ub41));
b = (b && all(ub41));
b = (b && any(not(ub41)));
i = ((i + ui) * i - ui) / i;
i = i % ui;
if (i == ui || i != ui && i == ui ^^ i != 2)
++i;
f = ((uf + uf) * uf - uf) / uf;
f += length(v);
f += distance(v, v);
f += dot(v, v);
f += dot(f, uf);
f += cross(v.xyz, v.xyz).x;
if (f == uf || f != uf && f != 2.0)
++f;
i &= ui;
i |= 0x42;
i ^= ui;
i %= 17;
i >>= 2;
i <<= ui;
i = ~i;
b = !b;
gl_FragColor = b ? vec4(i) + vec4(f) + v : v;
}

51
Test/aggOps.frag Normal file
View File

@ -0,0 +1,51 @@
#version 130
uniform sampler2D sampler;
varying mediump vec2 coord;
varying vec4 u, w;
struct s1 {
int i;
float f;
};
struct s2 {
int i;
float f;
s1 s1_1;
};
uniform s1 foo1;
uniform s2 foo2a;
uniform s2 foo2b;
void main()
{
vec4 v;
s1 a[3], b[3];
a = s1[3](s1(int(u.x), u.y), s1(int(u.z), u.w), s1(14, 14.0));
b = s1[3](s1(17, 17.0), s1(int(w.x), w.y), s1(int(w.z), w.w));
if (foo2a == foo2b)
v = texture2D(sampler, coord);
else
v = texture2D(sampler, 2.0*coord);
if (u == v)
v *= 3.0;
if (u != v)
v *= 4.0;
if (coord == v.yw)
v *= 5.0;
if (a == b)
v *= 6.0;
if (a != b)
v *= 7.0;
gl_FragColor = v;
}

36
Test/always-discard.frag Normal file
View File

@ -0,0 +1,36 @@
#version 110
varying vec2 tex_coord;
void main (void)
{
vec4 white = vec4(1.0);
vec4 black = vec4(0.2);
vec4 color = white;
// First, cut out our circle
float x = tex_coord.x*2.0 - 1.0;
float y = tex_coord.y*2.0 - 1.0;
float radius = sqrt(x*x + y*y);
if (radius > 1.0) {
if (radius > 1.1) {
++color;
}
gl_FragColor = color;
if (radius > 1.2) {
++color;
}
}
discard;
// If we're near an edge, darken us a tiny bit
if (radius >= 0.75)
color -= abs(pow(radius, 16.0)/2.0);
gl_FragColor = color;
}

19
Test/always-discard2.frag Normal file
View File

@ -0,0 +1,19 @@
#version 110
varying vec2 tex_coord;
void main (void)
{
vec4 white = vec4(1.0);
vec4 black = vec4(0.2);
vec4 color = white;
// First, cut out our circle
float x = tex_coord.x*2.0 - 1.0;
float y = tex_coord.y*2.0 - 1.0;
discard;
gl_FragColor = color;
}

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/Operations.frag
Operations.frag
Shader version: 130
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/aggOps.frag
aggOps.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
WARNING: 0:6: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/always-discard.frag
always-discard.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/always-discard2.frag
always-discard2.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/conditionalDiscard.frag
conditionalDiscard.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/conversion.frag
conversion.frag
Shader version: 130
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/dataOut.frag
dataOut.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/dataOutIndirect.frag
dataOutIndirect.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/deepRvalue.frag
deepRvalue.frag
Shader version: 120
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/depthOut.frag
depthOut.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
WARNING: 0:4: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/discard-dce.frag
discard-dce.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/doWhileLoop.frag
doWhileLoop.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/earlyReturnDiscard.frag
earlyReturnDiscard.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/flowControl.frag
flowControl.frag
Shader version: 120
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/forLoop.frag
forLoop.frag
Shader version: 130
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/functionCall.frag
functionCall.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/functionSemantics.frag
functionSemantics.frag
Warning, version 400 is not yet complete; most version-specific features are present, but some are missing.
Shader version: 400

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/length.frag
length.frag
Shader version: 120
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/localAggregates.frag
localAggregates.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
WARNING: 0:5: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/loops.frag
loops.frag
WARNING: 0:14: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/loopsArtificial.frag
loopsArtificial.frag
WARNING: 0:14: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/matrix.frag
matrix.frag
WARNING: 0:6: varying deprecated in version 130; may be removed in future release
WARNING: 0:17: varying deprecated in version 130; may be removed in future release
WARNING: 0:22: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/matrix2.frag
matrix2.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
WARNING: 0:13: varying deprecated in version 130; may be removed in future release
WARNING: 0:15: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/newTexture.frag
newTexture.frag
Warning, version 430 is not yet complete; most version-specific features are present, but some are missing.
Shader version: 430

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/prepost.frag
prepost.frag
Shader version: 140
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/simpleFunctionCall.frag
simpleFunctionCall.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
Shader version: 150

View File

@ -17,6 +17,7 @@ To get other information, use one of the following options:
(Each option must be specified separately, but can go anywhere in the command line.)
-V create SPIR-V in file <stage>.spv
-H print human readable form of SPIR-V; turns on -V
-E print pre-processed glsl. Cannot be used with -V, -H or -l.
-c configuration dump; use to create default configuration file (redirect to a .conf file)
-d default to desktop (#version 110) when there is no version in the shader (default is ES version 100)
-i intermediate tree (glslang AST) is printed out

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/structAssignment.frag
structAssignment.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/structDeref.frag
structDeref.frag
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/structure.frag
structure.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/swizzle.frag
swizzle.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/syntaxError.frag
syntaxError.frag
ERROR: 0:9: 'vec5' : undeclared identifier
ERROR: 0:9: '' : syntax error
ERROR: 2 compilation errors. No code generated.

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/test.frag
test.frag
Shader version: 110
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/texture.frag
texture.frag
WARNING: 0:14: varying deprecated in version 130; may be removed in future release
WARNING: 0:15: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/types.frag
types.frag
Shader version: 130
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/uniformArray.frag
uniformArray.frag
Shader version: 130
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/variableArrayIndex.frag
variableArrayIndex.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
Shader version: 130

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/varyingArray.frag
varyingArray.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
WARNING: 0:6: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/varyingArrayIndirect.frag
varyingArrayIndirect.frag
WARNING: 0:3: varying deprecated in version 130; may be removed in future release
WARNING: 0:4: varying deprecated in version 130; may be removed in future release
WARNING: 0:6: varying deprecated in version 130; may be removed in future release

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/voidFunction.frag
voidFunction.frag
Shader version: 120
0:? Sequence

View File

@ -1,4 +1,4 @@
../../LunarGLASS/test/whileLoop.frag
whileLoop.frag
Shader version: 110
0:? Sequence

View File

@ -0,0 +1,14 @@
#version 110
uniform sampler2D tex;
varying vec2 coord;
void main (void)
{
vec4 v = texture2D(tex, coord);
if (v == vec4(0.1,0.2,0.3,0.4))
discard;
gl_FragColor = v;
}

112
Test/conversion.frag Normal file
View File

@ -0,0 +1,112 @@
#version 130
uniform bool u_b;
uniform bvec2 u_b2;
uniform bvec3 u_b3;
uniform bvec4 u_b4;
uniform int u_i;
uniform ivec2 u_i2;
uniform ivec3 u_i3;
uniform ivec4 u_i4;
uniform float u_f;
uniform vec2 u_f2;
uniform vec3 u_f3;
uniform vec4 u_f4;
uniform bool i_b;
uniform bvec2 i_b2;
uniform bvec3 i_b3;
uniform bvec4 i_b4;
flat in int i_i;
flat in ivec2 i_i2;
flat in ivec3 i_i3;
flat in ivec4 i_i4;
in float i_f;
in vec2 i_f2;
in vec3 i_f3;
in vec4 i_f4;
void main()
{
bool b = bool(u_i) ^^ bool(u_f);
bvec2 b2 = bvec2(u_i, u_f);
bvec3 b3 = bvec3(u_i, u_f, i_i);
bvec4 b4 = bvec4(u_i, u_f, i_i, i_f);
int i = int(u_f) + int(b);
ivec2 i2 = ivec2(u_f2) + ivec2(b2);
ivec3 i3 = ivec3(u_f3) + ivec3(b3);
ivec4 i4 = ivec4(u_f4) + ivec4(b4);
float f = i;
vec2 f2 = i2;
vec3 f3 = i3;
vec4 f4 = i4;
f += (float(i) + float(b));
f2 -= vec2(i2) + vec2(b2);
f3 /= vec3(i3) + vec3(b3);
f4 += vec4(i4) + vec4(b4);
f4 += vec4(bvec4(i_i4));
f4 += vec4(bvec4(u_f4));
f += f - i;
f2 += vec2(f, i) + i2;
f3 += i3 + vec3(f, i, f);
f4 += vec4(b, i, f, i) + i4;
f2 += vec2(f, i) * i;
f3 += vec3(f, i, f) + i;
f4 += i - vec4(b, i, f, i);
i2 += ivec2(f, i);
i3 += ivec3(f, i, f);
i4 += ivec4(b, i, f, i);
if (f < i || i < f ||
f2 == i2 ||
i3 != f3)
f = (b ? i : f2.x) + (b2.x ? f3.x : i2.y);
gl_FragColor =
b ||
b2.x ||
b2.y ||
b3.x ||
b3.y ||
b3.z ||
b4.x ||
b4.y ||
b4.z ||
b4.w ? vec4(
i +
i2.x +
i2.y +
i3.x +
i3.y +
i3.z +
i4.x +
i4.y +
i4.z +
i4.w +
f +
f2.x +
f2.y +
f3.x +
f3.y +
f3.z +
f4.x +
f4.y +
f4.z +
f4.w) : vec4(1.0);
// with constants...
ivec4 cv2 = ivec4(1.0);
bvec4 cv5 = bvec4(cv2);
gl_FragColor += float(cv5);
}

8
Test/dataOut.frag Normal file
View File

@ -0,0 +1,8 @@
#version 130
varying vec4 Color;
void main()
{
gl_FragData[1] = Color;
}

10
Test/dataOutIndirect.frag Normal file
View File

@ -0,0 +1,10 @@
#version 130
varying vec4 Color;
uniform int i;
void main()
{
gl_FragData[i] = Color;
}

36
Test/deepRvalue.frag Normal file
View File

@ -0,0 +1,36 @@
#version 120
uniform sampler2D sampler;
vec4 v1 = vec4(2.0, 3.0, 5.0, 7.0);
vec4 v2 = vec4(11.0, 13.0, 17.0, 19.0);
vec4 v3 = vec4(23.0, 29.0, 31.0, 37.0);
vec4 v4 = vec4(41.0, 43.0, 47.0, 53.0);
struct str {
int a;
vec2 b[3];
bool c;
};
void main()
{
mat4 m = mat4(v1, v2, v3, v4);
mat4 mm = matrixCompMult(m, m);
float f = mm[1].w; // should be 19 * 19 = 361
// do a deep access to a spontaneous r-value
float g = matrixCompMult(m, m)[2].y; // should be 29 * 29 = 841
float h = str(1, vec2[3](vec2(2.0, 3.0), vec2(4.0, 5.0), vec2(6.0, 7.0)), true).b[1][1]; // should be 5.0
float i = texture2D(sampler, vec2(0.5,0.5)).y;
i += (i > 0.1 ? v1 : v2)[3];
str t;
i += (t = str(1, vec2[3](vec2(2.0, 3.0), vec2(4.0, 5.0), vec2(6.0, 7.0)), true)).b[2].y; // should be 7.0
gl_FragColor = vec4(f, g, h, i);
}

10
Test/depthOut.frag Normal file
View File

@ -0,0 +1,10 @@
#version 130
varying vec4 Color;
varying float Depth;
void main()
{
gl_FragDepth = Depth;
gl_FragColor = Color;
}

35
Test/discard-dce.frag Normal file
View File

@ -0,0 +1,35 @@
#version 110
varying vec2 tex_coord;
void main (void)
{
vec4 white = vec4(1.0);
vec4 black = vec4(0.2);
vec4 color = white;
// First, cut out our circle
float x = tex_coord.x*2.0 - 1.0;
float y = tex_coord.y*2.0 - 1.0;
float radius = sqrt(x*x + y*y);
if (radius > 1.0) {
if (radius > 1.1) {
++color;
}
gl_FragColor = color;
if (radius > 1.2) {
++color;
}
discard;
}
// If we're near an edge, darken us a tiny bit
if (radius >= 0.75)
color -= abs(pow(radius, 16.0)/2.0);
gl_FragColor = color;
}

16
Test/doWhileLoop.frag Normal file
View File

@ -0,0 +1,16 @@
#version 110
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
void main()
{
vec4 color = BaseColor;
do {
color += bigColor;
} while (color.x < d);
gl_FragColor = color;
}

View File

@ -0,0 +1,102 @@
#version 110
uniform float d;
uniform vec4 bigColor, smallColor;
uniform vec4 otherColor;
varying float c;
uniform float threshhold;
uniform float threshhold2;
uniform float threshhold3;
uniform float minimum;
varying vec4 BaseColor;
uniform bool b;
void main()
{
vec4 color = BaseColor;
vec4 color2;
color2 = otherColor;
if (c > d)
color += bigColor;
else
color += smallColor;
if (color.z < minimum)
return;
color.z++;
if (color.z > threshhold)
discard;
color++;
// Two path, different rest
if (color.w > threshhold2) {
if (color.z > threshhold2)
return;
else if (b)
color.z++;
else {
if (color.x < minimum) {
discard;
} else {
color++;
}
}
} else {
if (b)
discard;
else
return;
}
// // Two path, shared rest
// if (color.w > threshhold2) {
// if (color.z > threshhold2)
// return;
// else if (b)
// color++;
// else {
// if (color.x < minimum) {
// discard;
// } else {
// color++;
// }
// }
// } else {
// if (b)
// discard;
// else
// return;
// }
// // One path
// if (color.w > threshhold2) {
// if (color.z > threshhold2)
// return;
// else {
// if (color.x < minimum) {
// discard;
// } else {
// color++;
// }
// }
// } else {
// if (b)
// discard;
// else
// return;
// }
gl_FragColor = color * color2;
}

23
Test/flowControl.frag Normal file
View File

@ -0,0 +1,23 @@
#version 120
uniform float d;
uniform vec4 bigColor, smallColor;
uniform vec4 otherColor;
varying float c;
varying vec4 BaseColor;
void main()
{
vec4 color = BaseColor;
vec4 color2;
color2 = otherColor;
if (c > d)
color += bigColor;
else
color += smallColor;
gl_FragColor = color * color2;
}

41
Test/forLoop.frag Normal file
View File

@ -0,0 +1,41 @@
#version 130
uniform vec4 bigColor;
in vec4 BaseColor;
in float f;
uniform int Count;
uniform uvec4 v4;
void main()
{
vec4 color = BaseColor;
for (int i = 0; i < Count; ++i) {
color += bigColor;
}
gl_FragColor = color;
float sum = 0.0;
for (int i = 0; i < 4; ++i)
sum += v4[i];
vec4 tv4;
for (int i = 0; i < 4; ++i)
tv4[i] = v4[i] * 4u;
gl_FragColor += vec4(sum) + tv4;
vec4 r;
r.xyz = BaseColor.xyz;
for (int i = 0; i < Count; ++i)
r.w = f;
gl_FragColor.xyz += r.xyz;
for (int i = 0; i < 16; i += 4)
gl_FragColor *= f;
}

44
Test/functionCall.frag Normal file
View File

@ -0,0 +1,44 @@
#version 130
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
float h = 0.0;
float foo(vec4 bar)
{
return bar.x + bar.y;
}
void bar()
{
}
float unreachableReturn()
{
if (d < 4.2)
return 1.2;
else
return 4.5;
// might be another return inserted here by builders, has to be correct type
}
float missingReturn()
{
if (d < 4.5) {
h = d;
return 3.9;
}
}
void main()
{
vec4 color = vec4(foo(BaseColor));
bar();
float f = unreachableReturn();
float g = missingReturn();
gl_FragColor = color * f * h;
}

View File

@ -0,0 +1,63 @@
#version 400
uniform float u;
int foo(int a, const int b, in int c, const in int d, out int e, inout int f)
{
int sum = a + b + c + d + f; // no e, it is out only
// sum should be 47 now
a *= 64;
// no b, it is read only
c *= 64;
// no d, it is read only
e = 64 * 16; // e starts undefined
f *= 64;
sum += a + 64 * b + c + 64 * d + e + f; // everything has a value now, totaling of 64(1+2+4+8+16+32) = 64*63 = 4032
// sum should be 4032 + 47 = 4079
return sum;
}
int foo2(float a, vec3 b, out int r)
{
r = int(3.0 * a);
return int(5.0 * b.y);
}
int foo3()
{
if (u > 3.2) {
discard;
return 1000000;
}
return 2000000;
}
void main()
{
int e;
int t = 2;
struct s {
ivec4 t;
} f;
f.t.y = 32;
// test the different qualifers
int color = foo(1, 2, t+t, 8, e, f.t.y);
color += 128 * (e + f.t.y); // right side should be 128(64(16 + 32)) = 393216
// sum should be 4079 + 393216 = 397295
// test conversions
float arg;
float ret;
ret = foo2(4, ivec3(1,2,3), arg); // ret = 10, param = 12.0
color += int(ret + arg); // adds 22, for total of 397317
color += foo3(); // theoretically, add 2000000, for total of 2397317
gl_FragColor = vec4(color);
}

18
Test/length.frag Normal file
View File

@ -0,0 +1,18 @@
#version 120
uniform vec4 u[3];
#ifdef TEST_POST_110
varying vec2 v[];
#else
varying vec2 v[2];
#endif
void main()
{
int a[5];
vec2 t = v[0] + v[1];
gl_FragColor = vec4(u.length() * v.length() * a.length());
}

72
Test/localAggregates.frag Normal file
View File

@ -0,0 +1,72 @@
#version 130
uniform sampler2D sampler;
varying vec2 coord;
varying vec4 color;
struct s1 {
int i;
float f;
};
struct s2 {
int i;
float f;
s1 s1_1;
vec4 bleh;
};
struct s3 {
s2 s2_1;
int i;
float f;
s1 s1_1;
};
uniform s1 foo;
uniform s2 foo2;
uniform s3 foo3;
uniform float[16] uFloatArray;
uniform int condition;
void main()
{
s2 locals2;
s3 locals3;
float localFArray[16];
int localIArray[8];
locals2 = foo3.s2_1;
if (foo3.s2_1.i > 0) {
locals2.s1_1.f = 1.0;
localFArray[4] = coord.x;
localIArray[2] = foo3.s2_1.i;
} else {
locals2.s1_1.f = coord.x;
localFArray[4] = 1.0;
localIArray[2] = 0;
}
if (localIArray[2] == 0)
++localFArray[4];
float localArray[16];
int x = 5;
localArray[x] = coord.x;
float[16] a;
for (int i = 0; i < 16; i++)
a[i] = 0.0;
if (condition == 1)
a = localArray;
locals2.bleh = color;
locals2.bleh.z = coord.y;
gl_FragColor = locals2.bleh * (localFArray[4] + locals2.s1_1.f + localArray[x] + a[x]) * texture2D(sampler, coord);
}

320
Test/loops.frag Normal file
View File

@ -0,0 +1,320 @@
#version 130
uniform vec4 bigColor;
uniform vec4 bigColor1_1;
uniform vec4 bigColor1_2;
uniform vec4 bigColor1_3;
uniform vec4 bigColor2;
uniform vec4 bigColor3;
uniform vec4 bigColor4;
uniform vec4 bigColor5;
uniform vec4 bigColor6;
uniform vec4 bigColor7;
uniform vec4 bigColor8;
varying vec4 BaseColor;
uniform float d;
uniform float d2;
uniform float d3;
uniform float d4;
uniform float d5;
uniform float d6;
uniform float d7;
uniform float d8;
uniform float d9;
uniform float d10;
uniform float d11;
uniform float d12;
uniform float d13;
uniform float d14;
uniform float d15;
uniform float d16;
uniform float d17;
uniform float d18;
uniform float d19;
uniform float d20;
uniform float d21;
uniform float d22;
uniform float d23;
uniform float d24;
uniform float d25;
uniform float d26;
uniform float d27;
uniform float d28;
uniform float d29;
uniform float d30;
uniform float d31;
uniform float d32;
uniform float d33;
uniform float d34;
uniform int Count;
void main()
{
vec4 color = BaseColor;
// Not a real loop
while (true) {
if (color.x < 0.33) {
color += vec4(0.33);
break;
}
if (color.x < 0.66) {
color += vec4(0.66);
break;
}
color += vec4(0.33);
break;
}
// While
while (color.x < d) {
color += bigColor;
}
// While (latchy)
while (color.z < d) {
color += bigColor1_1;
if (color.w < d)
continue;
color += bigColor1_1;
}
// While (constant)
while (color.x < 42.0) {
++color;
}
// While (complicated-conditional)
while (color.w < d2 && color.y < d3) {
color += bigColor1_2;
}
// While (multi-exit)
while (color.z < d3) {
color += bigColor1_3;
if (color.y < d4)
break;
color += bigColor1_3;
}
// For (dynamic)
for (int i = 0; i < Count; ++i) {
color += bigColor2;
}
// Do while
do {
color += bigColor3;
} while (color.x < d2);
// For (static)
for (int i = 0; i < 42; ++i) {
color.z += d3;
}
// For (static) flow-control
for (int i = 0; i < 100; ++i) {
if (color.z < 20.0)
color.x++;
else
color.y++;
if (color.w < 20.0)
if (color.z > color.y)
0; // do nothing
}
// For (static) flow-control with latch merge
for (int i = 0; i < 120; ++i) {
if (color.z < 20.0)
color.x++;
else
color.y++;
}
// For (static) latchy
for (int i = 0; i < 42; ++i) {
color.z += d3;
if (color.x < d4)
continue;
++color.w;
}
// For (static) multi-exit
for (int i = 0; i < 42; ++i) {
color.z += d3;
if (color.x < d4)
break;
++color.w;
}
// Latchy
do {
color += bigColor4;
if (color.x < d4)
continue;
if (color.y < d4)
color.y += d4;
else
color.x += d4;
} while (color.z < d4);
// Do while flow control
do {
color += bigColor5;
if (color.y < d5)
color.y += d5;
} while (color.x < d5);
// If then loop
if (color.x < d6) {
while (color.y < d6)
color += bigColor6;
} else {
while (color.z < d6)
color.z += bigColor6.z;
}
// If then multi-exit
if (color.x < d6) {
while (color.y < d6) {
color += bigColor6;
if (d7 < 1.0)
break;
}
} else {
while (color.z < d6)
color.z += bigColor6.z;
}
// Multi-exit
do {
if (d7 < 0.0)
break;
color += bigColor7;
if (d7 < 1.0) {
color.z++;
break;
}
color += BaseColor;
} while (true);
// Multi-exit2
do {
// invariant conditional break at the top of the loop. This could be a
// situation where unswitching the loop has no real increases in code
// size.
if (d8 < 0.0)
break;
color += bigColor7;
if (d8 < 1.0) {
color.z++;
if (d8 < 2.0) {
color.y++;
} else {
color.x++;
}
break;
}
color += BaseColor;
} while (color.z < d8);
// Deep exit
while (color.w < d9) {
if (d9 > d8) {
if (color.x <= d7) {
if (color.z == 5.0)
color.w++;
else
break;
}
}
}
// No end loop-back.
while (color.z < d10) {
color.y++;
if (color.y < d11) {
color.z++;
if (color.w < d12)
color.w++;
else
color.x++;
continue;
}
color++;
break;
}
// Multi-continue
while (color.x < 10.0) {
color += bigColor8;
if (color.z < d8)
if (color.w < d6)
continue;
color.y += bigColor8.x;
}
color++;
gl_FragColor = color;
// Early Return
while (color.x < d14) {
if (color.y < d15) {
return;
}
else
color++;
}
color++;
while (color.w < d16) {
color.w++;
}
// While (complicated-conditional)
while (color.w < d2 && color.y < d3) {
color += bigColor1_2;
if (color.z < d3)
return;
}
do {
if (color.y < d18)
return;
color++;
} while (color.x < d17);
// Early Discard
while (color.y < d16) {
if (color.w < d16) {
discard;
} else
color++;
}
color++;
gl_FragColor = color;
}

96
Test/loopsArtificial.frag Normal file
View File

@ -0,0 +1,96 @@
#version 130
uniform vec4 bigColor;
uniform vec4 bigColor1_1;
uniform vec4 bigColor1_2;
uniform vec4 bigColor1_3;
uniform vec4 bigColor2;
uniform vec4 bigColor3;
uniform vec4 bigColor4;
uniform vec4 bigColor5;
uniform vec4 bigColor6;
uniform vec4 bigColor7;
uniform vec4 bigColor8;
varying vec4 BaseColor;
uniform float d;
uniform float d2;
uniform float d3;
uniform float d4;
uniform float d5;
uniform float d6;
uniform float d7;
uniform float d8;
uniform float d9;
uniform float d10;
uniform float d11;
uniform float d12;
uniform float d13;
uniform float d14;
uniform float d15;
uniform float d16;
uniform float d17;
uniform float d18;
uniform float d19;
uniform float d20;
uniform float d21;
uniform float d22;
uniform float d23;
uniform float d24;
uniform float d25;
uniform float d26;
uniform float d27;
uniform float d28;
uniform float d29;
uniform float d30;
uniform float d31;
uniform float d32;
uniform float d33;
uniform float d34;
uniform int Count;
void main()
{
vec4 color = BaseColor;
// Latchy2
do {
color += bigColor4;
if (color.x < d4) {
color.z += 2.0;
if (color.z < d4) {
color.x++;
continue;
}
}
if (color.y < d4)
color.y += d4;
else
color.x += d4;
} while (color.z < d4);
// Immediate dominator
while (color.w < d13) {
if (color.z < d13)
color++;
else
color--;
// code from Latchy 2
color += bigColor4;
if (color.x < d4) {
color.z += 2.0;
if (color.z < d4) {
color.x++;
continue;
}
}
if (color.y < d4)
color.y += d4;
else
color.x += d4;
}
color++;
gl_FragColor = color;
}

55
Test/matrix.frag Normal file
View File

@ -0,0 +1,55 @@
#version 130
//#define TEST_POST_110
uniform mat3 colorTransform;
varying vec3 Color;
uniform mat4 m, n;
#ifdef TEST_POST_110
uniform mat4x3 um43;
uniform mat3x4 un34;
#else
uniform mat4 um43;
uniform mat4 un34;
#endif
varying vec4 v;
#ifdef TEST_POST_110
varying vec3 u;
#else
varying vec4 u;
#endif
void main()
{
gl_FragColor = vec4(un34[1]);
gl_FragColor += vec4(Color * colorTransform, 1.0);
if (m != n)
gl_FragColor += v;
else {
gl_FragColor += m * v;
gl_FragColor += v * (m - n);
}
#ifdef TEST_POST_110
mat3x4 m34 = outerProduct(v, u);
m34 += mat4(v.x);
m34 += mat4(u, u.x, u, u.x, u, u.x, u.x);
#else
mat4 m34 = mat4(v.x*u.x, v.x*u.y, v.x*u.z, v.x*u.w,
v.y*u.x, v.y*u.y, v.y*u.z, v.y*u.w,
v.z*u.x, v.z*u.y, v.z*u.z, v.z*u.w,
v.w*u.x, v.w*u.y, v.w*u.z, v.w*u.w);
m34 += mat4(v.x);
m34 += mat4(u, u.x, u, u.x, u, u.x, u.x);
#endif
if (m34 == un34)
gl_FragColor += m34 * u;
else
gl_FragColor += (un34 * um43) * v;
}

50
Test/matrix2.frag Normal file
View File

@ -0,0 +1,50 @@
#version 150
uniform mat3 colorTransform;
varying vec3 Color;
uniform mat4 m, n;
uniform mat4x3 um43;
uniform mat3x4 un34;
uniform mat2 um2;
uniform mat3 um3;
uniform mat4 um4;
varying vec4 v;
varying vec3 u;
out vec4 FragColor;
void main()
{
mat3x4 m34 = outerProduct(v, u);
m34 += mat3x4(4.3);
FragColor = vec4(Color, 1.0);
FragColor *= vec4(FragColor * m34, 1.0);
m34 *= v.x;
mat4 m44 = mat4(un34);
m44 += m34 * um43;
FragColor += (-m44) * v;
FragColor *= matrixCompMult(m44, m44);
m34 = transpose(um43);
FragColor *= vec4(FragColor * m34, 1.0);
FragColor *= vec4(determinant(um4));
mat2 inv = inverse(um2);
FragColor *= vec4(inv[0][0], inv[1][0], inv[0][1], inv[1][1]);
mat3 inv3 = inverse(um3);
FragColor *= vec4(inv3[2][1]);
mat4 inv4 = inverse(um4);
FragColor *= inv4;
FragColor = vec4(FragColor * matrixCompMult(un34, un34), FragColor.w);
}

75
Test/newTexture.frag Normal file
View File

@ -0,0 +1,75 @@
#version 430
uniform samplerBuffer sb;
uniform sampler2DRect sr;
uniform sampler2D s2D;
uniform sampler3D s3D;
uniform samplerCube sCube;
uniform samplerCubeShadow sCubeShadow;
uniform sampler2DShadow s2DShadow;
uniform sampler2DArray s2DArray;
uniform sampler2DArrayShadow s2DArrayShadow;
uniform isampler2D is2D;
uniform isampler3D is3D;
uniform isamplerCube isCube;
uniform isampler2DArray is2DArray;
uniform isampler2DMS is2Dms;
uniform usampler2D us2D;
uniform usampler3D us3D;
uniform usamplerCube usCube;
uniform usampler2DArray us2DArray;
in float c1D;
in vec2 c2D;
in vec3 c3D;
in vec4 c4D;
flat in int ic1D;
flat in ivec2 ic2D;
flat in ivec3 ic3D;
flat in ivec4 ic4D;
out vec4 FragData;
void main()
{
vec4 v = texture(s2D, c2D);
v += textureProj(s3D, c4D);
v += textureLod(s2DArray, c3D, 1.2);
v.y += textureOffset(s2DShadow, c3D, ivec2(3), c1D);
v += texelFetch(s3D, ic3D, ic1D);
v += texelFetchOffset(s2D, ic2D, 4, ic2D);
v.y += textureLodOffset(s2DShadow, c3D, c1D, ivec2(3));
v += textureProjLodOffset(s2D, c3D, c1D, ivec2(3));
v += textureGrad(sCube, c3D, c3D, c3D);
v.x += textureGradOffset(s2DArrayShadow, c4D, c2D, c2D, ivec2(3));
v += textureProjGrad(s3D, c4D, c3D, c3D);
v += textureProjGradOffset(s2D, c3D, c2D, c2D, ivec2(3));
ivec4 iv = texture(is2D, c2D);
v += vec4(iv);
iv = textureProjOffset(is2D, c4D, ivec2(3));
v += vec4(iv);
iv = textureProjLod(is2D, c3D, c1D);
v += vec4(iv);
iv = textureProjGrad(is2D, c3D, c2D, c2D);
v += vec4(iv);
iv = texture(is3D, c3D, 4.2);
v += vec4(iv);
iv = textureLod(isCube, c3D, c1D);
v += vec4(iv);
iv = texelFetch(is2DArray, ic3D, ic1D);
v += vec4(iv);
iv += texelFetch(is2Dms, ic2D, ic1D);
v += vec4(iv);
v += texelFetch(sb, ic1D);
v += texelFetch(sr, ic2D);
ivec2 iv2 = textureSize(sCubeShadow, 2);
// iv2 += textureSize(is2Dms);
FragData = v + vec4(iv2, 0.0, 0.0);
}

38
Test/prepost.frag Normal file
View File

@ -0,0 +1,38 @@
#version 140
void main()
{
struct s {
float y[5];
} str;
float t;
int index = 5; // all indexing is 4
str.y[4] = 2.0; // 2.0
t = ++str.y[--index]; // 3.0
str.y[4] += t; // 6.0
t = str.y[4]--; // 5.0 (t = 6.0)
str.y[index++] += t; // 11.0
--str.y[--index]; // 10.0
float x = str.y[4];
++x;
--x;
x++;
x--;
// x is 10.0
float y = x * ++x; // 10 * 11
float z = y * x--; // 110 * 11
// x is 10.0
// z is 1210.0
vec4 v = vec4(1.0, 2.0, 3.0, 4.0);
v.y = v.z--; // (1,3,2,4)
v.x = --v.w; // (3,3,2,3)
gl_FragColor = z * v;// (3630.0, 3630.0, 2420.0, 3630.0)
}

View File

@ -0,0 +1,15 @@
#version 150
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
vec4 foo()
{
return BaseColor;
}
void main()
{
gl_FragColor = foo();
}

View File

@ -0,0 +1,39 @@
#version 130
uniform sampler2D sampler;
varying mediump vec2 coord;
struct lunarStruct1 {
int i;
float f;
};
struct lunarStruct2 {
int i;
float f;
lunarStruct1 s1_1;
};
struct lunarStruct3 {
lunarStruct2 s2_1;
int i;
float f;
lunarStruct1 s1_1;
};
uniform lunarStruct1 foo;
uniform lunarStruct2 foo2;
uniform lunarStruct3 foo3;
void main()
{
lunarStruct2 locals2;
if (foo3.s2_1.i > 0)
locals2 = foo3.s2_1;
else
locals2 = foo2;
gl_FragColor = locals2.s1_1.f * texture2D(sampler, coord);
}

71
Test/structDeref.frag Normal file
View File

@ -0,0 +1,71 @@
#version 130
uniform sampler2D sampler;
varying vec2 coord;
struct s0 {
int i;
};
struct s00 {
s0 s0_0;
};
struct s1 {
int i;
float f;
s0 s0_1;
};
struct s2 {
int i;
float f;
s1 s1_1;
};
struct s3 {
s2[12] s2_1;
int i;
float f;
s1 s1_1;
};
uniform s0 foo0;
uniform s1 foo1;
uniform s2 foo2;
uniform s3 foo3;
uniform s00 foo00;
void main()
{
s0 locals0;
s2 locals2;
s00 locals00;
float[6] fArray;
s1[10] locals1Array;
if (foo3.s2_1[9].i > 0) {
locals2.f = 1.0;
locals2.s1_1 = s1(0, 1.0, s0(0));
fArray = float[6]( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
locals1Array[6] = foo1;
locals0 = s0(0);
locals00 = s00(s0(0));
} else {
locals2.f = coord.x;
locals2.s1_1 = s1(1, coord.y, foo0);
fArray = float[6]( 0.0, 1.0, 2.0, 3.0, 4.0, 5.0);
locals1Array[6] = locals2.s1_1;
locals0 = foo1.s0_1;
locals00 = foo00;
}
if (locals0.i > 5)
locals0 = locals00.s0_0;
gl_FragColor = (float(locals0.i) + locals1Array[6].f + fArray[3] + locals2.s1_1.f) * texture2D(sampler, coord);
}

31
Test/structure.frag Normal file
View File

@ -0,0 +1,31 @@
#version 130
uniform sampler2D sampler;
varying vec2 coord;
struct lunarStruct1 {
int i;
float f[4];
vec4 color[5];
};
struct lunarStruct2 {
int i[5];
float f;
lunarStruct1 s1_1[7];
};
uniform lunarStruct1 foo;
uniform lunarStruct2 foo2[5];
void main()
{
float scale = 0.0;
if (foo2[3].i[4] > 0)
scale = foo2[3].s1_1[2].color[3].x;
else
scale = foo2[3].s1_1[2].f[3];
gl_FragColor = scale * texture2D(sampler, coord);
}

52
Test/swizzle.frag Normal file
View File

@ -0,0 +1,52 @@
#version 110
uniform float blend;
uniform vec4 u;
uniform bool p;
varying vec2 t;
void main()
{
float blendscale = 1.789;
vec4 w = u;
vec4 w_undef; // test undef
vec4 w_dep = u; // test dependent swizzles
vec4 w_reorder = u; // test reordering
vec4 w2 = u;
vec4 w_flow = u; // test flowControl
w_reorder.z = blendscale;
w.wy = t;
w_reorder.x = blendscale;
w2.xyzw = u.zwxy;
w_reorder.y = blendscale;
w_dep.xy = w2.xz;
w_dep.zw = t;
w_undef.xy = u.zw;
if (p)
w_flow.x = t.x;
else
w_flow.x = t.y;
gl_FragColor = mix(w_reorder, w_undef, w * w2 * w_dep * w_flow);
vec2 c = t;
vec4 rep = vec4(0.0, 0.0, 0.0, 1.0);
if (c.x < 0.0)
c.x *= -1.0;
if (c.x <= 1.0)
rep.x = 3.4;
gl_FragColor += rep;
}

16
Test/syntaxError.frag Normal file
View File

@ -0,0 +1,16 @@
#version 120
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
void main()
{
vec5 color = BaseColor;
do {
color += bigColor;
} while (color.x < d);
gl_FragColor = color;
}

22
Test/test.frag Normal file
View File

@ -0,0 +1,22 @@
#version 110
uniform sampler2D texSampler2D;
uniform sampler3D texSampler3D;
uniform float blend;
uniform vec2 scale;
uniform vec4 u;
varying vec2 t;
varying vec3 coords;
void main()
{
float blendscale = 1.789;
vec4 v = texture2D(texSampler2D, (t + scale) / scale ).wzyx;
vec4 w = texture3D(texSampler3D, coords) + v;
gl_FragColor = mix(w, u, blend * blendscale);
}

View File

@ -83,43 +83,43 @@ numeral.frag
450.comp
dce.frag
atomic_uint.frag
../../LunarGLASS/test/aggOps.frag
../../LunarGLASS/test/always-discard.frag
../../LunarGLASS/test/always-discard2.frag
../../LunarGLASS/test/conditionalDiscard.frag
../../LunarGLASS/test/conversion.frag
../../LunarGLASS/test/dataOut.frag
../../LunarGLASS/test/dataOutIndirect.frag
../../LunarGLASS/test/deepRvalue.frag
../../LunarGLASS/test/depthOut.frag
../../LunarGLASS/test/discard-dce.frag
../../LunarGLASS/test/doWhileLoop.frag
../../LunarGLASS/test/earlyReturnDiscard.frag
../../LunarGLASS/test/flowControl.frag
../../LunarGLASS/test/forLoop.frag
../../LunarGLASS/test/functionCall.frag
../../LunarGLASS/test/functionSemantics.frag
../../LunarGLASS/test/length.frag
../../LunarGLASS/test/localAggregates.frag
../../LunarGLASS/test/loops.frag
../../LunarGLASS/test/loopsArtificial.frag
../../LunarGLASS/test/matrix.frag
../../LunarGLASS/test/matrix2.frag
../../LunarGLASS/test/newTexture.frag
../../LunarGLASS/test/Operations.frag
../../LunarGLASS/test/prepost.frag
../../LunarGLASS/test/simpleFunctionCall.frag
../../LunarGLASS/test/structAssignment.frag
../../LunarGLASS/test/structDeref.frag
../../LunarGLASS/test/structure.frag
../../LunarGLASS/test/swizzle.frag
../../LunarGLASS/test/syntaxError.frag
../../LunarGLASS/test/test.frag
../../LunarGLASS/test/texture.frag
../../LunarGLASS/test/types.frag
../../LunarGLASS/test/uniformArray.frag
../../LunarGLASS/test/variableArrayIndex.frag
../../LunarGLASS/test/varyingArray.frag
../../LunarGLASS/test/varyingArrayIndirect.frag
../../LunarGLASS/test/voidFunction.frag
../../LunarGLASS/test/whileLoop.frag
aggOps.frag
always-discard.frag
always-discard2.frag
conditionalDiscard.frag
conversion.frag
dataOut.frag
dataOutIndirect.frag
deepRvalue.frag
depthOut.frag
discard-dce.frag
doWhileLoop.frag
earlyReturnDiscard.frag
flowControl.frag
forLoop.frag
functionCall.frag
functionSemantics.frag
length.frag
localAggregates.frag
loops.frag
loopsArtificial.frag
matrix.frag
matrix2.frag
newTexture.frag
Operations.frag
prepost.frag
simpleFunctionCall.frag
structAssignment.frag
structDeref.frag
structure.frag
swizzle.frag
syntaxError.frag
test.frag
texture.frag
types.frag
uniformArray.frag
variableArrayIndex.frag
varyingArray.frag
varyingArrayIndirect.frag
voidFunction.frag
whileLoop.frag

73
Test/texture.frag Normal file
View File

@ -0,0 +1,73 @@
#version 130
uniform sampler1D texSampler1D;
uniform sampler2D texSampler2D;
uniform sampler3D texSampler3D;
uniform samplerCube texSamplerCube;
uniform sampler1DShadow shadowSampler1D;
uniform sampler2DShadow shadowSampler2D;
uniform float blend;
uniform vec2 scale;
uniform vec4 u;
varying vec2 t;
varying vec2 coords2D;
void main()
{
float blendscale = 1.789;
float bias = 2.0;
float lod = 3.0;
float proj = 2.0;
float coords1D = 1.789;
vec3 coords3D = vec3(1.789, 2.718, 3.453);
vec4 coords4D = vec4(1.789, 2.718, 3.453, 2.0);
vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
color += texture1D (texSampler1D, coords1D);
color += texture1D (texSampler1D, coords1D, bias);
color += texture1DProj(texSampler1D, coords2D);
color += texture1DProj(texSampler1D, coords4D);
color += texture1DProj(texSampler1D, coords2D, bias);
color += texture1DProj(texSampler1D, coords4D, bias);
color += texture2D (texSampler2D, coords2D);
color += texture2D (texSampler2D, coords2D, bias);
color += texture2DProj (texSampler2D, coords3D);
color += texture2DProj (texSampler2D, coords4D, bias);
color += texture3D (texSampler3D, coords3D);
color += texture3D (texSampler3D, coords3D, bias);
color += texture3DProj (texSampler3D, coords4D);
color += texture3DProj (texSampler3D, coords4D, bias);
color += textureCube (texSamplerCube, coords3D);
color += textureCube (texSamplerCube, coords3D, bias);
color += shadow1D (shadowSampler1D, coords3D);
color += shadow1D (shadowSampler1D, coords3D, bias);
color += shadow2D (shadowSampler2D, coords3D);
color += shadow2D (shadowSampler2D, coords3D, bias);
color += shadow1DProj (shadowSampler1D, coords4D);
color += shadow1DProj (shadowSampler1D, coords4D, bias);
color += shadow2DProj (shadowSampler2D, coords4D);
color += shadow2DProj (shadowSampler2D, coords4D, bias);
ivec2 iCoords2D = ivec2(0, 5);
int iLod = 1;
color += texelFetch(texSampler2D, iCoords2D, iLod);
vec2 gradX = dFdx(coords2D);
vec2 gradY = dFdy(coords2D);
const ivec2 offset = ivec2(3, -7);
color += textureGrad(texSampler2D, coords2D, gradX, gradY);
color += textureProjGrad(texSampler2D, vec3(coords2D, proj), gradX, gradY);
color += textureGradOffset(texSampler2D, coords2D, gradX, gradY, offset);
color += textureProjGradOffset(texSampler2D, coords3D, gradX, gradY, offset);
color += textureGrad(shadowSampler2D, vec3(coords2D, lod), gradX, gradY);
gl_FragColor = mix(color, u, blend * blendscale);
}

81
Test/types.frag Normal file
View File

@ -0,0 +1,81 @@
#version 130
uniform bool u_b;
uniform bvec2 u_b2;
uniform bvec3 u_b3;
uniform bvec4 u_b4;
uniform int u_i;
uniform ivec2 u_i2;
uniform ivec3 u_i3;
uniform ivec4 u_i4;
uniform float u_f;
uniform vec2 u_f2;
uniform vec3 u_f3;
uniform vec4 u_f4;
uniform bool i_b;
uniform bvec2 i_b2;
uniform bvec3 i_b3;
uniform bvec4 i_b4;
flat in int i_i;
flat in ivec2 i_i2;
flat in ivec3 i_i3;
flat in ivec4 i_i4;
in float i_f;
in vec2 i_f2;
in vec3 i_f3;
in vec4 i_f4;
void main()
{
bool b = u_b && i_b;
bvec2 b2 = bvec2(u_b2.x && i_b2.x && u_b2.y && i_b2.y);
bvec3 b3 = bvec3(u_b3.x && i_b3.x && u_b3.y && i_b3.y && u_b3.z && i_b3.z);
bvec4 b4 = bvec4(u_b4.x && i_b4.x && u_b4.y && i_b4.y && u_b4.z && i_b4.z && u_b4.w && i_b4.w);
int i = u_i + i_i;
ivec2 i2 = u_i2 + i_i2;
ivec3 i3 = u_i3 + i_i3;
ivec4 i4 = u_i4 + i_i4;
float f = u_f + i_f;
vec2 f2 = u_f2 + i_f2;
vec3 f3 = u_f3 + i_f3;
vec4 f4 = u_f4 + i_f4;
gl_FragColor =
b ||
b2.x ||
b2.y ||
b3.x ||
b3.y ||
b3.z ||
b4.x ||
b4.y ||
b4.z ||
b4.w ? vec4(
i +
i2.x +
i2.y +
i3.x +
i3.y +
i3.z +
i4.x +
i4.y +
i4.z +
i4.w +
f +
f2.x +
f2.y +
f3.x +
f3.y +
f3.z +
f4.x +
f4.y +
f4.z +
f4.w) : vec4(1.0);
}

16
Test/uniformArray.frag Normal file
View File

@ -0,0 +1,16 @@
#version 130
uniform sampler2D texSampler2D;
uniform vec3 inColor;
uniform vec4 color[6];
uniform float alpha[16];
void main()
{
vec4 texColor = color[1] + color[1];
texColor.xyz += inColor;
texColor.a += alpha[12];
gl_FragColor = texColor;
}

View File

@ -0,0 +1,48 @@
#version 130
uniform sampler2D sampler;
varying vec2 coord;
struct lunarStruct1 {
int i;
float f;
};
struct lunarStruct2 {
int i;
float f;
lunarStruct1 s1_1;
};
struct lunarStruct3 {
lunarStruct2 s2_1[3];
int i;
float f;
lunarStruct1 s1_1;
};
uniform lunarStruct1 foo;
uniform lunarStruct2 foo2[5];
uniform lunarStruct3 foo3;
uniform int Count;
void main()
{
float scale;
int iLocal = Count;
if (foo3.s2_1[1].i > 0)
scale = foo2[foo3.s2_1[foo.i].i + 2 + ++iLocal].s1_1.f;
else
scale = foo3.s2_1[0].s1_1.f;
//for (int i = 0; i < iLocal; ++i) {
// scale += foo2[i].f;
//}
gl_FragColor = scale * texture2D(sampler, coord);
vec2[3] constructed = vec2[3](coord, vec2(scale), vec2(1.0, 2.0));
gl_FragColor += vec4(constructed[foo.i], constructed[foo.i]);
}

19
Test/varyingArray.frag Normal file
View File

@ -0,0 +1,19 @@
#version 130
uniform sampler2D texSampler2D;
varying vec4 color;
varying float alpha;
varying vec4 gl_TexCoord[6];
varying vec4 foo[3];
void main()
{
vec4 texColor = texture2D(texSampler2D, vec2(gl_TexCoord[4] + gl_TexCoord[5]));
texColor += color;
texColor.a = alpha;
gl_FragColor = foo[1] + gl_TexCoord[0] + gl_TexCoord[4] + texColor;
}

View File

@ -0,0 +1,21 @@
#version 130
uniform sampler2D texSampler2D;
varying vec4 color;
varying float alpha;
varying vec4 gl_TexCoord[6];
varying vec4 userIn[2];
uniform int a, b;
void main()
{
vec4 texColor = texture2D(texSampler2D, vec2(userIn[b] + gl_TexCoord[a] + gl_TexCoord[5]));
texColor += color;
texColor.a = alpha;
gl_FragColor = gl_TexCoord[0] + gl_TexCoord[b] + texColor + userIn[a];
}

34
Test/voidFunction.frag Normal file
View File

@ -0,0 +1,34 @@
#version 120
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
float bar = 2.0;
void foo()
{
bar++;
return;
}
void foo2()
{
bar++;
}
void main()
{
vec4 outColor = bigColor;
foo();
foo2();
outColor.x += bar;
gl_FragColor = outColor;
return;
}

16
Test/whileLoop.frag Normal file
View File

@ -0,0 +1,16 @@
#version 110
uniform vec4 bigColor;
varying vec4 BaseColor;
uniform float d;
void main()
{
vec4 color = BaseColor;
while (color.x < d) {
color += bigColor;
}
gl_FragColor = color;
}