diff --git a/Test/Operations.frag b/Test/Operations.frag new file mode 100644 index 000000000..820048f22 --- /dev/null +++ b/Test/Operations.frag @@ -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; +} diff --git a/Test/aggOps.frag b/Test/aggOps.frag new file mode 100644 index 000000000..a0450dca9 --- /dev/null +++ b/Test/aggOps.frag @@ -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; +} diff --git a/Test/always-discard.frag b/Test/always-discard.frag new file mode 100644 index 000000000..cea4ceec6 --- /dev/null +++ b/Test/always-discard.frag @@ -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; + +} diff --git a/Test/always-discard2.frag b/Test/always-discard2.frag new file mode 100644 index 000000000..a619369d6 --- /dev/null +++ b/Test/always-discard2.frag @@ -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; + +} diff --git a/Test/baseResults/Operations.frag.out b/Test/baseResults/Operations.frag.out index 008fdaa0e..c0a4d2d48 100644 --- a/Test/baseResults/Operations.frag.out +++ b/Test/baseResults/Operations.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/Operations.frag +Operations.frag Shader version: 130 0:? Sequence diff --git a/Test/baseResults/aggOps.frag.out b/Test/baseResults/aggOps.frag.out index 9faf8be2a..85916b640 100644 --- a/Test/baseResults/aggOps.frag.out +++ b/Test/baseResults/aggOps.frag.out @@ -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 diff --git a/Test/baseResults/always-discard.frag.out b/Test/baseResults/always-discard.frag.out index dbb95cafc..efd5d5556 100644 --- a/Test/baseResults/always-discard.frag.out +++ b/Test/baseResults/always-discard.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/always-discard.frag +always-discard.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/always-discard2.frag.out b/Test/baseResults/always-discard2.frag.out index fc1b4cf92..27992c169 100644 --- a/Test/baseResults/always-discard2.frag.out +++ b/Test/baseResults/always-discard2.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/always-discard2.frag +always-discard2.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/conditionalDiscard.frag.out b/Test/baseResults/conditionalDiscard.frag.out index 80ea0e4eb..902093db8 100644 --- a/Test/baseResults/conditionalDiscard.frag.out +++ b/Test/baseResults/conditionalDiscard.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/conditionalDiscard.frag +conditionalDiscard.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/conversion.frag.out b/Test/baseResults/conversion.frag.out index a400a7569..24550835c 100644 --- a/Test/baseResults/conversion.frag.out +++ b/Test/baseResults/conversion.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/conversion.frag +conversion.frag Shader version: 130 0:? Sequence diff --git a/Test/baseResults/dataOut.frag.out b/Test/baseResults/dataOut.frag.out index 105b844cf..669a13db6 100644 --- a/Test/baseResults/dataOut.frag.out +++ b/Test/baseResults/dataOut.frag.out @@ -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 diff --git a/Test/baseResults/dataOutIndirect.frag.out b/Test/baseResults/dataOutIndirect.frag.out index ac20659b7..41c922154 100644 --- a/Test/baseResults/dataOutIndirect.frag.out +++ b/Test/baseResults/dataOutIndirect.frag.out @@ -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 diff --git a/Test/baseResults/deepRvalue.frag.out b/Test/baseResults/deepRvalue.frag.out index 92d6b6292..6640f25ac 100644 --- a/Test/baseResults/deepRvalue.frag.out +++ b/Test/baseResults/deepRvalue.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/deepRvalue.frag +deepRvalue.frag Shader version: 120 0:? Sequence diff --git a/Test/baseResults/depthOut.frag.out b/Test/baseResults/depthOut.frag.out index ee01a9fa7..635ae6fa4 100644 --- a/Test/baseResults/depthOut.frag.out +++ b/Test/baseResults/depthOut.frag.out @@ -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 diff --git a/Test/baseResults/discard-dce.frag.out b/Test/baseResults/discard-dce.frag.out index 034233dc3..c7d09a4c7 100644 --- a/Test/baseResults/discard-dce.frag.out +++ b/Test/baseResults/discard-dce.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/discard-dce.frag +discard-dce.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/doWhileLoop.frag.out b/Test/baseResults/doWhileLoop.frag.out index 010f05090..e89441a9b 100644 --- a/Test/baseResults/doWhileLoop.frag.out +++ b/Test/baseResults/doWhileLoop.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/doWhileLoop.frag +doWhileLoop.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/earlyReturnDiscard.frag.out b/Test/baseResults/earlyReturnDiscard.frag.out index 8516ae564..f3b63cd92 100644 --- a/Test/baseResults/earlyReturnDiscard.frag.out +++ b/Test/baseResults/earlyReturnDiscard.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/earlyReturnDiscard.frag +earlyReturnDiscard.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/flowControl.frag.out b/Test/baseResults/flowControl.frag.out index fb90d4b38..91fa85029 100644 --- a/Test/baseResults/flowControl.frag.out +++ b/Test/baseResults/flowControl.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/flowControl.frag +flowControl.frag Shader version: 120 0:? Sequence diff --git a/Test/baseResults/forLoop.frag.out b/Test/baseResults/forLoop.frag.out index 4100a2e84..52d96ae59 100644 --- a/Test/baseResults/forLoop.frag.out +++ b/Test/baseResults/forLoop.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/forLoop.frag +forLoop.frag Shader version: 130 0:? Sequence diff --git a/Test/baseResults/functionCall.frag.out b/Test/baseResults/functionCall.frag.out index 70a1d6d02..3996503c8 100644 --- a/Test/baseResults/functionCall.frag.out +++ b/Test/baseResults/functionCall.frag.out @@ -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 diff --git a/Test/baseResults/functionSemantics.frag.out b/Test/baseResults/functionSemantics.frag.out index 967d9188a..7117352f3 100644 --- a/Test/baseResults/functionSemantics.frag.out +++ b/Test/baseResults/functionSemantics.frag.out @@ -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 diff --git a/Test/baseResults/length.frag.out b/Test/baseResults/length.frag.out index 182036799..5f2182b3d 100644 --- a/Test/baseResults/length.frag.out +++ b/Test/baseResults/length.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/length.frag +length.frag Shader version: 120 0:? Sequence diff --git a/Test/baseResults/localAggregates.frag.out b/Test/baseResults/localAggregates.frag.out index 7f2fd8d7d..538087a9b 100644 --- a/Test/baseResults/localAggregates.frag.out +++ b/Test/baseResults/localAggregates.frag.out @@ -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 diff --git a/Test/baseResults/loops.frag.out b/Test/baseResults/loops.frag.out index 5a373846f..36e8e5ae3 100644 --- a/Test/baseResults/loops.frag.out +++ b/Test/baseResults/loops.frag.out @@ -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 diff --git a/Test/baseResults/loopsArtificial.frag.out b/Test/baseResults/loopsArtificial.frag.out index cbe7e1548..b5cb844ee 100644 --- a/Test/baseResults/loopsArtificial.frag.out +++ b/Test/baseResults/loopsArtificial.frag.out @@ -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 diff --git a/Test/baseResults/matrix.frag.out b/Test/baseResults/matrix.frag.out index 03a8513f1..9f20b8592 100644 --- a/Test/baseResults/matrix.frag.out +++ b/Test/baseResults/matrix.frag.out @@ -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 diff --git a/Test/baseResults/matrix2.frag.out b/Test/baseResults/matrix2.frag.out index 734b5b1a1..d5b6d7d5e 100644 --- a/Test/baseResults/matrix2.frag.out +++ b/Test/baseResults/matrix2.frag.out @@ -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 diff --git a/Test/baseResults/newTexture.frag.out b/Test/baseResults/newTexture.frag.out index 7ce20f7a3..68094b37f 100644 --- a/Test/baseResults/newTexture.frag.out +++ b/Test/baseResults/newTexture.frag.out @@ -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 diff --git a/Test/baseResults/prepost.frag.out b/Test/baseResults/prepost.frag.out index 5af8dbb8f..581210c00 100644 --- a/Test/baseResults/prepost.frag.out +++ b/Test/baseResults/prepost.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/prepost.frag +prepost.frag Shader version: 140 0:? Sequence diff --git a/Test/baseResults/simpleFunctionCall.frag.out b/Test/baseResults/simpleFunctionCall.frag.out index de58dd43d..cb55c55c6 100644 --- a/Test/baseResults/simpleFunctionCall.frag.out +++ b/Test/baseResults/simpleFunctionCall.frag.out @@ -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 diff --git a/Test/baseResults/spv.140.vert.out b/Test/baseResults/spv.140.vert.out index 35470ddc5..4e035e7bc 100644 --- a/Test/baseResults/spv.140.vert.out +++ b/Test/baseResults/spv.140.vert.out @@ -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 .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 diff --git a/Test/baseResults/structAssignment.frag.out b/Test/baseResults/structAssignment.frag.out index e29ffc639..5371c9395 100644 --- a/Test/baseResults/structAssignment.frag.out +++ b/Test/baseResults/structAssignment.frag.out @@ -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 diff --git a/Test/baseResults/structDeref.frag.out b/Test/baseResults/structDeref.frag.out index a06a460be..11109be2b 100644 --- a/Test/baseResults/structDeref.frag.out +++ b/Test/baseResults/structDeref.frag.out @@ -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 diff --git a/Test/baseResults/structure.frag.out b/Test/baseResults/structure.frag.out index c97f31d09..b37932d55 100644 --- a/Test/baseResults/structure.frag.out +++ b/Test/baseResults/structure.frag.out @@ -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 diff --git a/Test/baseResults/swizzle.frag.out b/Test/baseResults/swizzle.frag.out index 551a14bcd..d706c6c89 100644 --- a/Test/baseResults/swizzle.frag.out +++ b/Test/baseResults/swizzle.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/swizzle.frag +swizzle.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/syntaxError.frag.out b/Test/baseResults/syntaxError.frag.out index 8648f276e..2d9bc6a56 100644 --- a/Test/baseResults/syntaxError.frag.out +++ b/Test/baseResults/syntaxError.frag.out @@ -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. diff --git a/Test/baseResults/test.frag.out b/Test/baseResults/test.frag.out index 43c6d7d03..4fd96c2e8 100644 --- a/Test/baseResults/test.frag.out +++ b/Test/baseResults/test.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/test.frag +test.frag Shader version: 110 0:? Sequence diff --git a/Test/baseResults/texture.frag.out b/Test/baseResults/texture.frag.out index 2ecae961c..6e40f368a 100644 --- a/Test/baseResults/texture.frag.out +++ b/Test/baseResults/texture.frag.out @@ -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 diff --git a/Test/baseResults/types.frag.out b/Test/baseResults/types.frag.out index 9b5319976..fb52b1a4c 100644 --- a/Test/baseResults/types.frag.out +++ b/Test/baseResults/types.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/types.frag +types.frag Shader version: 130 0:? Sequence diff --git a/Test/baseResults/uniformArray.frag.out b/Test/baseResults/uniformArray.frag.out index 7f6796bac..6c70af8e9 100644 --- a/Test/baseResults/uniformArray.frag.out +++ b/Test/baseResults/uniformArray.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/uniformArray.frag +uniformArray.frag Shader version: 130 0:? Sequence diff --git a/Test/baseResults/variableArrayIndex.frag.out b/Test/baseResults/variableArrayIndex.frag.out index a7d1058f0..cf7cc2bb4 100644 --- a/Test/baseResults/variableArrayIndex.frag.out +++ b/Test/baseResults/variableArrayIndex.frag.out @@ -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 diff --git a/Test/baseResults/varyingArray.frag.out b/Test/baseResults/varyingArray.frag.out index 1ca2daad7..f537e26ad 100644 --- a/Test/baseResults/varyingArray.frag.out +++ b/Test/baseResults/varyingArray.frag.out @@ -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 diff --git a/Test/baseResults/varyingArrayIndirect.frag.out b/Test/baseResults/varyingArrayIndirect.frag.out index 7a79ab86d..52a48a6e0 100644 --- a/Test/baseResults/varyingArrayIndirect.frag.out +++ b/Test/baseResults/varyingArrayIndirect.frag.out @@ -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 diff --git a/Test/baseResults/voidFunction.frag.out b/Test/baseResults/voidFunction.frag.out index 065287ec2..342119d00 100644 --- a/Test/baseResults/voidFunction.frag.out +++ b/Test/baseResults/voidFunction.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/voidFunction.frag +voidFunction.frag Shader version: 120 0:? Sequence diff --git a/Test/baseResults/whileLoop.frag.out b/Test/baseResults/whileLoop.frag.out index 6d0700a0c..5147bff14 100644 --- a/Test/baseResults/whileLoop.frag.out +++ b/Test/baseResults/whileLoop.frag.out @@ -1,4 +1,4 @@ -../../LunarGLASS/test/whileLoop.frag +whileLoop.frag Shader version: 110 0:? Sequence diff --git a/Test/conditionalDiscard.frag b/Test/conditionalDiscard.frag new file mode 100644 index 000000000..58e6fa5d5 --- /dev/null +++ b/Test/conditionalDiscard.frag @@ -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; +} diff --git a/Test/conversion.frag b/Test/conversion.frag new file mode 100644 index 000000000..f17293b89 --- /dev/null +++ b/Test/conversion.frag @@ -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); +} diff --git a/Test/dataOut.frag b/Test/dataOut.frag new file mode 100644 index 000000000..258f534ea --- /dev/null +++ b/Test/dataOut.frag @@ -0,0 +1,8 @@ +#version 130 + +varying vec4 Color; + +void main() +{ + gl_FragData[1] = Color; +} diff --git a/Test/dataOutIndirect.frag b/Test/dataOutIndirect.frag new file mode 100644 index 000000000..d6b8667d7 --- /dev/null +++ b/Test/dataOutIndirect.frag @@ -0,0 +1,10 @@ +#version 130 + +varying vec4 Color; + +uniform int i; + +void main() +{ + gl_FragData[i] = Color; +} diff --git a/Test/deepRvalue.frag b/Test/deepRvalue.frag new file mode 100644 index 000000000..4d8808667 --- /dev/null +++ b/Test/deepRvalue.frag @@ -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); +} diff --git a/Test/depthOut.frag b/Test/depthOut.frag new file mode 100644 index 000000000..5a8927101 --- /dev/null +++ b/Test/depthOut.frag @@ -0,0 +1,10 @@ +#version 130 + +varying vec4 Color; +varying float Depth; + +void main() +{ + gl_FragDepth = Depth; + gl_FragColor = Color; +} diff --git a/Test/discard-dce.frag b/Test/discard-dce.frag new file mode 100644 index 000000000..f2fef4d11 --- /dev/null +++ b/Test/discard-dce.frag @@ -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; + +} diff --git a/Test/doWhileLoop.frag b/Test/doWhileLoop.frag new file mode 100644 index 000000000..3d6f93c51 --- /dev/null +++ b/Test/doWhileLoop.frag @@ -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; +} diff --git a/Test/earlyReturnDiscard.frag b/Test/earlyReturnDiscard.frag new file mode 100644 index 000000000..718ea72f3 --- /dev/null +++ b/Test/earlyReturnDiscard.frag @@ -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; +} diff --git a/Test/flowControl.frag b/Test/flowControl.frag new file mode 100644 index 000000000..eaa6fb1da --- /dev/null +++ b/Test/flowControl.frag @@ -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; +} diff --git a/Test/forLoop.frag b/Test/forLoop.frag new file mode 100644 index 000000000..117ecad15 --- /dev/null +++ b/Test/forLoop.frag @@ -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; +} diff --git a/Test/functionCall.frag b/Test/functionCall.frag new file mode 100644 index 000000000..e1fc0e07f --- /dev/null +++ b/Test/functionCall.frag @@ -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; +} diff --git a/Test/functionSemantics.frag b/Test/functionSemantics.frag new file mode 100644 index 000000000..67ff5f516 --- /dev/null +++ b/Test/functionSemantics.frag @@ -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); +} diff --git a/Test/length.frag b/Test/length.frag new file mode 100644 index 000000000..74c286f33 --- /dev/null +++ b/Test/length.frag @@ -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()); +} diff --git a/Test/localAggregates.frag b/Test/localAggregates.frag new file mode 100644 index 000000000..d8a7fb18d --- /dev/null +++ b/Test/localAggregates.frag @@ -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); +} diff --git a/Test/loops.frag b/Test/loops.frag new file mode 100644 index 000000000..ce2d2a0b2 --- /dev/null +++ b/Test/loops.frag @@ -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; +} diff --git a/Test/loopsArtificial.frag b/Test/loopsArtificial.frag new file mode 100644 index 000000000..2f196af8e --- /dev/null +++ b/Test/loopsArtificial.frag @@ -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; +} diff --git a/Test/matrix.frag b/Test/matrix.frag new file mode 100644 index 000000000..150e0434f --- /dev/null +++ b/Test/matrix.frag @@ -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; +} diff --git a/Test/matrix2.frag b/Test/matrix2.frag new file mode 100644 index 000000000..eb2c53c2e --- /dev/null +++ b/Test/matrix2.frag @@ -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); +} diff --git a/Test/newTexture.frag b/Test/newTexture.frag new file mode 100644 index 000000000..9d012093d --- /dev/null +++ b/Test/newTexture.frag @@ -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); +} diff --git a/Test/prepost.frag b/Test/prepost.frag new file mode 100644 index 000000000..dfd456660 --- /dev/null +++ b/Test/prepost.frag @@ -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) +} diff --git a/Test/simpleFunctionCall.frag b/Test/simpleFunctionCall.frag new file mode 100644 index 000000000..59f0ccd58 --- /dev/null +++ b/Test/simpleFunctionCall.frag @@ -0,0 +1,15 @@ +#version 150 + +uniform vec4 bigColor; +varying vec4 BaseColor; +uniform float d; + +vec4 foo() +{ + return BaseColor; +} + +void main() +{ + gl_FragColor = foo(); +} diff --git a/Test/structAssignment.frag b/Test/structAssignment.frag new file mode 100644 index 000000000..959f854ed --- /dev/null +++ b/Test/structAssignment.frag @@ -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); +} diff --git a/Test/structDeref.frag b/Test/structDeref.frag new file mode 100644 index 000000000..376e408f1 --- /dev/null +++ b/Test/structDeref.frag @@ -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); +} diff --git a/Test/structure.frag b/Test/structure.frag new file mode 100644 index 000000000..97e79cb01 --- /dev/null +++ b/Test/structure.frag @@ -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); +} + diff --git a/Test/swizzle.frag b/Test/swizzle.frag new file mode 100644 index 000000000..14f507ecd --- /dev/null +++ b/Test/swizzle.frag @@ -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; +} diff --git a/Test/syntaxError.frag b/Test/syntaxError.frag new file mode 100644 index 000000000..fcbeb69e1 --- /dev/null +++ b/Test/syntaxError.frag @@ -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; +} diff --git a/Test/test.frag b/Test/test.frag new file mode 100644 index 000000000..1b7d0e95e --- /dev/null +++ b/Test/test.frag @@ -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); +} diff --git a/Test/testlist b/Test/testlist index 5c06ce1e0..b77fd8cfe 100644 --- a/Test/testlist +++ b/Test/testlist @@ -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 diff --git a/Test/texture.frag b/Test/texture.frag new file mode 100644 index 000000000..8e5391eef --- /dev/null +++ b/Test/texture.frag @@ -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); +} \ No newline at end of file diff --git a/Test/types.frag b/Test/types.frag new file mode 100644 index 000000000..48701d890 --- /dev/null +++ b/Test/types.frag @@ -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); +} diff --git a/Test/uniformArray.frag b/Test/uniformArray.frag new file mode 100644 index 000000000..7db287642 --- /dev/null +++ b/Test/uniformArray.frag @@ -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; +} diff --git a/Test/variableArrayIndex.frag b/Test/variableArrayIndex.frag new file mode 100644 index 000000000..63b49c784 --- /dev/null +++ b/Test/variableArrayIndex.frag @@ -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]); +} + diff --git a/Test/varyingArray.frag b/Test/varyingArray.frag new file mode 100644 index 000000000..3bd152fe9 --- /dev/null +++ b/Test/varyingArray.frag @@ -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; +} diff --git a/Test/varyingArrayIndirect.frag b/Test/varyingArrayIndirect.frag new file mode 100644 index 000000000..d45e601b4 --- /dev/null +++ b/Test/varyingArrayIndirect.frag @@ -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]; +} diff --git a/Test/voidFunction.frag b/Test/voidFunction.frag new file mode 100644 index 000000000..4767f7ab1 --- /dev/null +++ b/Test/voidFunction.frag @@ -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; +} diff --git a/Test/whileLoop.frag b/Test/whileLoop.frag new file mode 100644 index 000000000..a9541f917 --- /dev/null +++ b/Test/whileLoop.frag @@ -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; +}