[Piglit] [PATCH] Add shader tests for out of bounds array index

Anuj Phogat anuj.phogat at gmail.com
Mon Sep 22 16:36:12 PDT 2014


Currently all the tests except 10 and 12 fail on Mesa.

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 tests/shaders/glsl-array-bounds-09.shader_test | 24 +++++++++++++++++++
 tests/shaders/glsl-array-bounds-10.shader_test | 25 ++++++++++++++++++++
 tests/shaders/glsl-array-bounds-11.shader_test | 29 +++++++++++++++++++++++
 tests/shaders/glsl-array-bounds-12.shader_test | 32 ++++++++++++++++++++++++++
 tests/shaders/glsl-array-bounds-13.shader_test | 29 +++++++++++++++++++++++
 tests/shaders/glsl-array-bounds-14.shader_test | 26 +++++++++++++++++++++
 tests/shaders/glsl-array-bounds-15.shader_test | 29 +++++++++++++++++++++++
 tests/shaders/glsl-array-bounds-16.shader_test | 24 +++++++++++++++++++
 8 files changed, 218 insertions(+)
 create mode 100644 tests/shaders/glsl-array-bounds-09.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-10.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-11.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-12.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-13.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-14.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-15.shader_test
 create mode 100644 tests/shaders/glsl-array-bounds-16.shader_test

diff --git a/tests/shaders/glsl-array-bounds-09.shader_test b/tests/shaders/glsl-array-bounds-09.shader_test
new file mode 100644
index 0000000..2ced26e
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-09.shader_test
@@ -0,0 +1,24 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader passthrough]
+
+[fragment shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ */
+#version 120
+
+float array[5];
+int idx = -2;
+
+void main()
+{
+   gl_FragColor = vec4(0.0, 1.0, 0.0, array[idx]);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-10.shader_test b/tests/shaders/glsl-array-bounds-10.shader_test
new file mode 100644
index 0000000..a61be93
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-10.shader_test
@@ -0,0 +1,25 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader passthrough]
+
+[fragment shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ */
+#version 120
+
+uniform int idx;
+float array[5];
+
+void main()
+{
+   gl_FragColor = vec4(0.0, 1.0, 0.0, array[idx]);
+}
+
+[test]
+uniform int idx -2
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-11.shader_test b/tests/shaders/glsl-array-bounds-11.shader_test
new file mode 100644
index 0000000..bd1fe1c
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-11.shader_test
@@ -0,0 +1,29 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ */
+#version 120
+
+float array[5];
+int idx = -2;
+
+void main()
+{
+   gl_FrontColor = vec4(0.0, 1.0, 0.0, array[idx]);
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+	gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-12.shader_test b/tests/shaders/glsl-array-bounds-12.shader_test
new file mode 100644
index 0000000..45917da
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-12.shader_test
@@ -0,0 +1,32 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ *
+ * In this test case the array index will not be constant folded.
+ */
+#version 120
+
+float array[5];
+uniform int idx;
+
+void main()
+{
+   gl_FrontColor = vec4(0.0, 1.0, 0.0, array[idx]);
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+	gl_FragColor = gl_Color;
+}
+
+[test]
+uniform int idx -2
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-13.shader_test b/tests/shaders/glsl-array-bounds-13.shader_test
new file mode 100644
index 0000000..12a821b
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-13.shader_test
@@ -0,0 +1,29 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ */
+#version 120
+
+float array[5];
+const int idx = -2;
+
+void main()
+{
+   gl_FrontColor = vec4(0.0, 1.0, 0.0, array[idx]);
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+	gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-14.shader_test b/tests/shaders/glsl-array-bounds-14.shader_test
new file mode 100644
index 0000000..c5f7658
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-14.shader_test
@@ -0,0 +1,26 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader passthrough]
+
+[fragment shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ *
+ * In this test case the array index may be constant folded.
+ */
+#version 120
+
+float array[];
+const int idx = -2;
+
+void main()
+{
+   gl_FragColor = vec4(0.0, 1.0, 0.0, array[idx]);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-15.shader_test b/tests/shaders/glsl-array-bounds-15.shader_test
new file mode 100644
index 0000000..6589bb6
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-15.shader_test
@@ -0,0 +1,29 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ */
+#version 120
+
+float array[5];
+const int idx = 8;
+
+void main()
+{
+   gl_FrontColor = vec4(0.0, 1.0, 0.0, array[idx]);
+   gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+	gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/shaders/glsl-array-bounds-16.shader_test b/tests/shaders/glsl-array-bounds-16.shader_test
new file mode 100644
index 0000000..5fb28f9
--- /dev/null
+++ b/tests/shaders/glsl-array-bounds-16.shader_test
@@ -0,0 +1,24 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader passthrough]
+
+[fragment shader]
+/* Verify that out-of-bounds access to an array does not result in any sort of
+ * program interruption.
+ */
+#version 120
+
+float array[5];
+const int idx = 8;
+
+void main()
+{
+   gl_FragColor = vec4(0.0, 1.0, 0.0, array[idx]);
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+draw rect -1 -1 2 3
+probe all rgb 0.0 1.0 0.0
-- 
1.9.3



More information about the Piglit mailing list