diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2010-07-13 21:56:07 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2010-07-14 15:22:05 -0700 |
commit | fc726fbbbb8b5990d87cde24927f826ff5f63aea (patch) | |
tree | e566005d7613149dfd8fc39fb58d4b4bb021a28c /tests/shaders | |
parent | d9cf9dcdc5df3d684c0bbaca607fe1b44f12c3da (diff) |
Add GLSL 1.20 tests for constant expressions involving builtins.
Diffstat (limited to 'tests/shaders')
25 files changed, 546 insertions, 0 deletions
diff --git a/tests/shaders/glsl-const-builtin-abs.shader_test b/tests/shaders/glsl-const-builtin-abs.shader_test new file mode 100644 index 00000000..1c5af276 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-abs.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float x = abs(-0.5); + gl_FragColor = vec4(0.0, x + x, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-acos.shader_test b/tests/shaders/glsl-const-builtin-acos.shader_test new file mode 100644 index 00000000..4b535b65 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-acos.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float zero = acos(1.0); + const float zero2 = acos(1); + gl_FragColor = vec4(zero, 1.0, zero2, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-asin.shader_test b/tests/shaders/glsl-const-builtin-asin.shader_test new file mode 100644 index 00000000..db5a535e --- /dev/null +++ b/tests/shaders/glsl-const-builtin-asin.shader_test @@ -0,0 +1,20 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float zero = asin(0.0); + gl_FragColor = vec4(zero, 1.0, zero, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-atan.shader_test b/tests/shaders/glsl-const-builtin-atan.shader_test new file mode 100644 index 00000000..4a231302 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-atan.shader_test @@ -0,0 +1,24 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float x = atan(100.0, 100.0); + const float y = atan(1); + if (x == y) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-clamp.shader_test b/tests/shaders/glsl-const-builtin-clamp.shader_test new file mode 100644 index 00000000..b111690d --- /dev/null +++ b/tests/shaders/glsl-const-builtin-clamp.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const vec2 v1 = clamp(vec2(-10.0, -15.0), vec2(-5.0, 5.0), vec2(1.0, 10.0)); + const vec2 v2 = clamp(v1, -0.25, 1.25); + gl_FragColor = vec4(0.0, v2.x + v2.y, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-cos.shader_test b/tests/shaders/glsl-const-builtin-cos.shader_test new file mode 100644 index 00000000..8a53d00a --- /dev/null +++ b/tests/shaders/glsl-const-builtin-cos.shader_test @@ -0,0 +1,20 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float one = cos(0.0); + gl_FragColor = vec4(0, one, 0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-degrees.shader_test b/tests/shaders/glsl-const-builtin-degrees.shader_test new file mode 100644 index 00000000..1017d35a --- /dev/null +++ b/tests/shaders/glsl-const-builtin-degrees.shader_test @@ -0,0 +1,23 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const int x = int(degrees(3.1415926535)); + if (x == 180) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-derivatives.shader_test b/tests/shaders/glsl-const-builtin-derivatives.shader_test new file mode 100644 index 00000000..86051f79 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-derivatives.shader_test @@ -0,0 +1,26 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float dx = dFdx(0.0); + const float dy = dFdy(0.0); + const float fw = fwidth(0.0); + if (dx == 0.0 && dy == 0.0 && fw == 0.0) { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + } else { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + } +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-dot.shader_test b/tests/shaders/glsl-const-builtin-dot.shader_test new file mode 100644 index 00000000..c18e0984 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-dot.shader_test @@ -0,0 +1,23 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const vec2 c1 = vec2(0.5, 0.25); + const vec2 c2 = vec2(1.0, 2.0); + const float c = dot(c1, c2); + gl_FragColor = vec4(0.0, c, 0.0, 0.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-exp-log.shader_test b/tests/shaders/glsl-const-builtin-exp-log.shader_test new file mode 100644 index 00000000..84fd8ba7 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-exp-log.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float one = log(exp(2)) - 1.0; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-exp2.shader_test b/tests/shaders/glsl-const-builtin-exp2.shader_test new file mode 100644 index 00000000..2e901233 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-exp2.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float one = exp2(16) - 65535; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-floor-ceil.shader_test b/tests/shaders/glsl-const-builtin-floor-ceil.shader_test new file mode 100644 index 00000000..668b8e82 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-floor-ceil.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float one = ceil(1.4) - floor(1.4); + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-fract.shader_test b/tests/shaders/glsl-const-builtin-fract.shader_test new file mode 100644 index 00000000..ac6d9ba4 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-fract.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float one = fract(5.1) * 10.0; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-greaterThan.shader_test b/tests/shaders/glsl-const-builtin-greaterThan.shader_test new file mode 100644 index 00000000..cecf7baa --- /dev/null +++ b/tests/shaders/glsl-const-builtin-greaterThan.shader_test @@ -0,0 +1,25 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const vec2 small = vec2(1.0, 2.0); + const vec2 large = vec2(2.0, 3.0); + const bvec2 gt = greaterThan(large, small); + if (gt.x && gt.y) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-inversesqrt.shader_test b/tests/shaders/glsl-const-builtin-inversesqrt.shader_test new file mode 100644 index 00000000..f8b72382 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-inversesqrt.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const vec4 q = inversesqrt(vec4(16.0)); + const float one = q.x + q.y + q.z + q.w; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-log2.shader_test b/tests/shaders/glsl-const-builtin-log2.shader_test new file mode 100644 index 00000000..7e2d802b --- /dev/null +++ b/tests/shaders/glsl-const-builtin-log2.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float one = log2(65536) - 15; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-max.shader_test b/tests/shaders/glsl-const-builtin-max.shader_test new file mode 100644 index 00000000..af0a2dc0 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-max.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float x = max(0.25, -5.0); + const vec2 v = max(vec2(0.5, 0.2), 0.25); + gl_FragColor = vec4(0.0, x + v.x + v.y, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-min.shader_test b/tests/shaders/glsl-const-builtin-min.shader_test new file mode 100644 index 00000000..754934cb --- /dev/null +++ b/tests/shaders/glsl-const-builtin-min.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float x = min(0.25, 0.5); + const vec2 v = min(vec2(0.25, 0.7), 0.5); + gl_FragColor = vec4(0.0, x + v.x + v.y, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-mod.shader_test b/tests/shaders/glsl-const-builtin-mod.shader_test new file mode 100644 index 00000000..c5e31691 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-mod.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const vec2 v1 = mod(vec2(5.0, 4.0), 3.0); + const vec2 v2 = mod(vec2(5.0, 6.0), vec2(3.0, 5.0)); + gl_FragColor = vec4(0.0, v1.x - v1.y, 0.0, v2.x - v2.y); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgba 15 15 0.0 1.0 0.0 1.0 diff --git a/tests/shaders/glsl-const-builtin-pow.shader_test b/tests/shaders/glsl-const-builtin-pow.shader_test new file mode 100644 index 00000000..da5ec66c --- /dev/null +++ b/tests/shaders/glsl-const-builtin-pow.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const vec2 v = pow(vec2(2,9), vec2(2,0.5)); + const float one = v.x - v.y; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-radians.shader_test b/tests/shaders/glsl-const-builtin-radians.shader_test new file mode 100644 index 00000000..5c31291b --- /dev/null +++ b/tests/shaders/glsl-const-builtin-radians.shader_test @@ -0,0 +1,23 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const int pi = int(radians(180.0)*100); + if (pi == 314) + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + else + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-sign.shader_test b/tests/shaders/glsl-const-builtin-sign.shader_test new file mode 100644 index 00000000..95684f9a --- /dev/null +++ b/tests/shaders/glsl-const-builtin-sign.shader_test @@ -0,0 +1,22 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const vec3 signs = sign(vec3(0.0, -42.9, 55.7)); + const float one = float(signs.x == signs.y + signs.z); + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-sin.shader_test b/tests/shaders/glsl-const-builtin-sin.shader_test new file mode 100644 index 00000000..68475528 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-sin.shader_test @@ -0,0 +1,20 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float one = sin(1.5707963267949); + gl_FragColor = vec4(0, one, 0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-sqrt.shader_test b/tests/shaders/glsl-const-builtin-sqrt.shader_test new file mode 100644 index 00000000..cbcb9214 --- /dev/null +++ b/tests/shaders/glsl-const-builtin-sqrt.shader_test @@ -0,0 +1,21 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() +{ + const float one = sqrt(16) - 3; + gl_FragColor = vec4(0.0, one, 0.0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 diff --git a/tests/shaders/glsl-const-builtin-tan.shader_test b/tests/shaders/glsl-const-builtin-tan.shader_test new file mode 100644 index 00000000..af7f4bdf --- /dev/null +++ b/tests/shaders/glsl-const-builtin-tan.shader_test @@ -0,0 +1,20 @@ +[require] +GL >= 2.0 +GLSL >= 1.20 + +[vertex shader file] +glsl-mvp.vert + +[fragment shader] +#version 120 +void main() { + const float one = tan(0.785398163397448); + gl_FragColor = vec4(0, one, 0, one); +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear +ortho +draw rect 10 10 10 10 +probe rgb 15 15 0.0 1.0 0.0 |