[Piglit] [PATCH] glsl-1.10: test divide by zero doesn't crash constant evaluation

Timothy Arceri tarceri at itsqueeze.com
Thu Mar 1 21:18:07 UTC 2018


Cc: Jason Ekstrand <jason at jlekstrand.net>
Cc: Mark Janes <mark.a.janes at intel.com>
---
 .../fs-loop-unrolled-divide-by-zero.shader_test    | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/linker/fs-loop-unrolled-divide-by-zero.shader_test

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
-- 
2.14.3



More information about the Piglit mailing list