diff options
author | Timothy Arceri <tarceri@itsqueeze.com> | 2018-03-02 08:18:07 +1100 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2018-03-01 21:29:07 -0800 |
commit | 2879b1ef60d4dfdbae88e6795426ab1342de5ba3 (patch) | |
tree | b6ba54a7cfb2fd4936f44cd7cbad43b9960ae750 | |
parent | 4ce0887e2f7f848d2be2e435a2d0f3c80e44ea3b (diff) |
glsl-1.10: test divide by zero doesn't crash constant evaluation
Cc: Jason Ekstrand <jason@jlekstrand.net>
Cc: Mark Janes <mark.a.janes@intel.com>
-rw-r--r-- | tests/spec/glsl-1.10/linker/fs-loop-unrolled-divide-by-zero.shader_test | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.10/linker/fs-loop-unrolled-divide-by-zero.shader_test b/tests/spec/glsl-1.10/linker/fs-loop-unrolled-divide-by-zero.shader_test new file mode 100644 index 000000000..761657c3c --- /dev/null +++ b/tests/spec/glsl-1.10/linker/fs-loop-unrolled-divide-by-zero.shader_test @@ -0,0 +1,31 @@ +# From the GLSL 4.60 spec Section 5.9 (Expressions): +# +# "Dividing by zero does not cause an exception but does +# result in an unspecified value." +# +# Here we make sure that constant evaluation doesn't crash on +# a divide by zero. +# +[require] +GLSL >= 1.10 + +[vertex shader passthrough] + +[fragment shader] +void main() +{ + int j = 0; + + // We use a loop specifically to avoid Mesa's GLSL IR + // from doing the constant evaluating. In this case + // we want to test NIR which exclusively does loop + // unrolling on some drivers and will therefore end + // up doing the constant evaluation. + for (int i = 0; i < 4; i++) + j += 42/i; + + gl_FragColor.x = 255.0f / float(j); +} + +[test] +link success |