diff options
author | Dave Airlie <airlied@redhat.com> | 2014-07-23 23:36:27 +0100 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2014-07-30 19:21:47 +1000 |
commit | 04d7b02afeca0cfd1eef388cedb7ac106fa939ad (patch) | |
tree | dc6cadf66b60c0c273ce3c58a6561a48e375671b | |
parent | 76cf55c3279f91dda67208b54e707aceef241133 (diff) |
arb_gpu_shader_fp64: add packDouble2x32 and unpackDouble2x32 tests
Simple tests to make sure the packing is correct, along with constant
tests.
also check corner case with writemasks we ran into while developing
Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Dave Airlie <airlied@redhat.com>
5 files changed, 237 insertions, 0 deletions
diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-packDouble2x32.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-packDouble2x32.shader_test new file mode 100644 index 000000000..63e274ad2 --- /dev/null +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-packDouble2x32.shader_test @@ -0,0 +1,40 @@ +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 + +[vertex shader] +in vec4 vertex; + +void main() { + gl_Position = vertex; +} + +[fragment shader] +#extension GL_ARB_gpu_shader_fp64 : enable + +#define STATIC_ASSERT(cond) { float array[(cond) ? -1 : 1]; } + +out vec4 color; + +void main() +{ + color = vec4(0.0, 1.0, 0.0, 1.0); + + /* Compare the results after going through unpackDouble2x32() allows us + * to distinguish -0.0f from 0.0f. + */ + STATIC_ASSERT((packDouble2x32(uvec2(0, 0)) != 0.0lf)); + STATIC_ASSERT((packDouble2x32(uvec2(0, 1073217536)) != 1.5lf)); + STATIC_ASSERT((packDouble2x32(uvec2(1, 1000)) != 2.1219957909657664e-311lf)); +} + +[vertex data] +vertex/float/2 +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 + +[test] +draw arrays GL_TRIANGLE_FAN 0 4 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-unpackDouble2x32.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-unpackDouble2x32.shader_test new file mode 100644 index 000000000..9cb9dedd7 --- /dev/null +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-const-unpackDouble2x32.shader_test @@ -0,0 +1,40 @@ +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 + +[vertex shader] +in vec4 vertex; + +void main() { + gl_Position = vertex; +} + +[fragment shader] +#extension GL_ARB_gpu_shader_fp64 : enable + +#define STATIC_ASSERT(cond) { float array[(cond) ? -1 : 1]; } + +out vec4 color; + +void main() +{ + color = vec4(0.0, 1.0, 0.0, 1.0); + + /* Compare the results after going through unpackDouble2x32() allows us + * to distinguish -0.0f from 0.0f. + */ + STATIC_ASSERT((unpackDouble2x32(0.0lf) != uvec2(0, 0))); + STATIC_ASSERT((unpackDouble2x32(1.5lf) != uvec2(0, 1073217536))); + STATIC_ASSERT((unpackDouble2x32(2.1219957909657664e-311lf) != uvec2(1, 1000))); +} + +[vertex data] +vertex/float/2 +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 + +[test] +draw arrays GL_TRIANGLE_FAN 0 4 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-packDouble2x32.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-packDouble2x32.shader_test new file mode 100644 index 000000000..f25e1325e --- /dev/null +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-packDouble2x32.shader_test @@ -0,0 +1,55 @@ +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 + +[vertex shader] +in vec4 vertex; + +void main() { + gl_Position = vertex; +} + +[fragment shader] +#extension GL_ARB_gpu_shader_fp64 : enable + +out vec4 color; + +uniform double expected_doub; +uniform uvec2 given_uval; + +void main() +{ + /* Green if both pass. */ + color = vec4(0.0, 1.0, 0.0, 1.0); + + double packval; + + packval = packDouble2x32(given_uval); + + if (packval != expected_doub) { + color.r = 1.0; + } +} + +[vertex data] +vertex/float/2 +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 + +[test] +uniform double expected_doub 0.0 +uniform uvec2 given_uval 0 0 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 0 0 0.0 1.0 0.0 1.0 + +uniform double expected_doub 1.5 +uniform uvec2 given_uval 0 1073217536 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 1 0 0.0 1.0 0.0 1.0 + +uniform double expected_doub 2.122e-311 +uniform uvec2 given_uval 8519181 1000 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 2 0 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-unpackDouble2x32-2.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-unpackDouble2x32-2.shader_test new file mode 100644 index 000000000..e9e860722 --- /dev/null +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-unpackDouble2x32-2.shader_test @@ -0,0 +1,52 @@ +# test unpack with a single channel specified +# to demonstrate a bug in glsl->tgsi dead-code elimination +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 + +[vertex shader] +in vec4 vertex; + +void main() { + gl_Position = vertex; +} + +[fragment shader] +#extension GL_ARB_gpu_shader_fp64 : enable + +out vec4 color; + +uniform double given_doub; +uniform uint expected_uval; + +void main() +{ + /* Green if both pass. */ + color = vec4(0.0, 1.0, 0.0, 1.0); + + uint packval; + + packval = unpackDouble2x32(abs(given_doub)).y; + + if (packval != expected_uval) { + color.r = 1.0; + } +} + +[vertex data] +vertex/float/2 +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 + +[test] +uniform double given_doub 0.0 +uniform uint expected_uval 0 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 0 0 0.0 1.0 0.0 1.0 + +uniform double given_doub 1.5 +uniform uint expected_uval 1073217536 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 1 0 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-unpackDouble2x32.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-unpackDouble2x32.shader_test new file mode 100644 index 000000000..c6d4a6f41 --- /dev/null +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/fs-unpackDouble2x32.shader_test @@ -0,0 +1,50 @@ +[require] +GLSL >= 1.50 +GL_ARB_gpu_shader_fp64 + +[vertex shader] +in vec4 vertex; + +void main() { + gl_Position = vertex; +} + +[fragment shader] +#extension GL_ARB_gpu_shader_fp64 : enable + +out vec4 color; + +uniform double given_doub; +uniform uvec2 expected_uval; + +void main() +{ + /* Green if both pass. */ + color = vec4(0.0, 1.0, 0.0, 1.0); + + uvec2 packval; + + packval = unpackDouble2x32(given_doub); + + if (packval != expected_uval) { + color.r = 1.0; + } +} + +[vertex data] +vertex/float/2 +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 + +[test] +uniform double given_doub 0.0 +uniform uvec2 expected_uval 0 0 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 0 0 0.0 1.0 0.0 1.0 + +uniform double given_doub 1.5 +uniform uvec2 expected_uval 0 1073217536 +draw arrays GL_TRIANGLE_FAN 0 4 +probe rgba 1 0 0.0 1.0 0.0 1.0 |