summaryrefslogtreecommitdiff
path: root/tests/spec/glsl-1.20/execution/vector-out-of-bounds-access/fs-vec4-out-of-bounds-2.shader_test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spec/glsl-1.20/execution/vector-out-of-bounds-access/fs-vec4-out-of-bounds-2.shader_test')
-rw-r--r--tests/spec/glsl-1.20/execution/vector-out-of-bounds-access/fs-vec4-out-of-bounds-2.shader_test31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.20/execution/vector-out-of-bounds-access/fs-vec4-out-of-bounds-2.shader_test b/tests/spec/glsl-1.20/execution/vector-out-of-bounds-access/fs-vec4-out-of-bounds-2.shader_test
new file mode 100644
index 000000000..37a3a1ff5
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/vector-out-of-bounds-access/fs-vec4-out-of-bounds-2.shader_test
@@ -0,0 +1,31 @@
+/* From section 5.5 "Vector Components" of the GLSL 1.20 spec:
+ *
+ * "When indexing with non-constant expressions, behavior is undefined if the
+ * index is negative, or greater than or equal to the size of the vector."
+ *
+ * The behaviour becomes defined only in robustness extensions, however even
+ * if driver is technically allowed to crash or hang, it most likely
+ * doesn't want to.
+ */
+
+[require]
+GLSL >= 1.20
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 120
+
+void main()
+{
+ vec4 vec = vec4(1.0, 2.0, 3.0, 4.0);
+ int index = -1;
+ if (vec[index] >= 1.0) {
+ vec[index] = -1.0;
+ }
+
+ gl_FragColor = vec4(vec[index], 0.0, 0.0, 0.0);
+}
+
+[test]
+draw rect -1 -1 2 2