[Piglit] [PATCH v2 4/4] glsl-4.40: add tests for interpolateAt* with swizzles / array subscripts on vectors

Nicolai Hähnle nhaehnle at gmail.com
Tue Aug 1 10:51:33 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

For swizzles, the language changed in GLSL 4.40.

For array subscripts, it's not entirely clear whether the clarification
wrt interpolant being an l-value should be backdated even earlier or not.
Keeping it a 4.40 test should be enough for practical purposes.
---
 .../fs-interpolateAtCentroid-swizzle.shader_test   | 69 ++++++++++++++++++++
 .../fs-interpolateAtOffset-swizzle.shader_test     | 73 ++++++++++++++++++++++
 .../fs-interpolateAtSample-swizzle.shader_test     | 70 +++++++++++++++++++++
 3 files changed, 212 insertions(+)
 create mode 100644 tests/spec/glsl-4.40/execution/fs-interpolateAtCentroid-swizzle.shader_test
 create mode 100644 tests/spec/glsl-4.40/execution/fs-interpolateAtOffset-swizzle.shader_test
 create mode 100644 tests/spec/glsl-4.40/execution/fs-interpolateAtSample-swizzle.shader_test

diff --git a/tests/spec/glsl-4.40/execution/fs-interpolateAtCentroid-swizzle.shader_test b/tests/spec/glsl-4.40/execution/fs-interpolateAtCentroid-swizzle.shader_test
new file mode 100644
index 0000000..2e4820d
--- /dev/null
+++ b/tests/spec/glsl-4.40/execution/fs-interpolateAtCentroid-swizzle.shader_test
@@ -0,0 +1,69 @@
+# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation
+# Functions) to:
+#
+#    "Component selection operators (e.g., .xy) may be used when specifying
+#     interpolant."
+#
+# Furthermore, GLSL 4.60 clarified that
+#
+#    "(...) interpolant must be an l-value from an in declaration; this can
+#     include a variable, a block or structure member, an array element, or
+#     some combination of these."
+#
+# which means array subscripts on vectors should also be allowed.
+#
+
+[require]
+GLSL >= 4.40
+
+[vertex shader]
+#version 440
+
+in vec4 piglit_vertex;
+
+out vec3 a;
+
+void main()
+{
+   gl_Position = piglit_vertex;
+
+   a = piglit_vertex.xyz;
+}
+
+[fragment shader]
+#version 440
+
+in vec3 a;
+
+uniform int u_idx;
+
+out vec4 color;
+
+void main()
+{
+   vec2 delta1 = a.yx - interpolateAtCentroid(a.yx);
+   float delta2 = a[2] - interpolateAtCentroid(a[2]);
+   float delta3 = a[u_idx] - interpolateAtCentroid(a[u_idx]);
+
+   if (delta1 != vec2(0.0)) {
+      color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0);
+   } else if (delta2 != 0.0) {
+      color = vec4(0.2, delta2 + 0.5, 0.0, 0.0);
+   } else if (delta3 != 0.0) {
+      color = vec4(0.3, delta3 + 0.5, 0.0, 0.0);
+   } else {
+      color = vec4(0.0, 1.0, 0.0, 1.0);
+   }
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform int u_idx 0
+draw rect -1 -1 1 2
+
+uniform int u_idx 1
+draw rect 0 -1 1 2
+
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-4.40/execution/fs-interpolateAtOffset-swizzle.shader_test b/tests/spec/glsl-4.40/execution/fs-interpolateAtOffset-swizzle.shader_test
new file mode 100644
index 0000000..a463c14
--- /dev/null
+++ b/tests/spec/glsl-4.40/execution/fs-interpolateAtOffset-swizzle.shader_test
@@ -0,0 +1,73 @@
+# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation
+# Functions) to:
+#
+#    "Component selection operators (e.g., .xy) may be used when specifying
+#     interpolant."
+#
+# Furthermore, GLSL 4.60 clarified that
+#
+#    "(...) interpolant must be an l-value from an in declaration; this can
+#     include a variable, a block or structure member, an array element, or
+#     some combination of these."
+#
+# which means array subscripts on vectors should also be allowed.
+#
+
+[require]
+GLSL >= 4.40
+
+[vertex shader]
+#version 440
+
+in vec4 piglit_vertex;
+
+out vec3 a;
+
+void main()
+{
+   gl_Position = piglit_vertex;
+
+   a = piglit_vertex.xyz;
+}
+
+[fragment shader]
+#version 440
+
+in vec3 a;
+
+uniform vec2 u_offset;
+uniform int u_idx;
+
+out vec4 color;
+
+void main()
+{
+   /* u_offset is always 0, so these should all be the same. */
+   vec2 delta1 = a.yx - interpolateAtOffset(a.yx, u_offset);
+   float delta2 = a[2] - interpolateAtOffset(a[2], u_offset);
+   float delta3 = a[u_idx] - interpolateAtOffset(a[u_idx], u_offset);
+
+   if (delta1 != vec2(0.0)) {
+      color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0);
+   } else if (delta2 != 0.0) {
+      color = vec4(0.2, delta2 + 0.5, 0.0, 0.0);
+   } else if (delta3 != 0.0) {
+      color = vec4(0.3, delta3 + 0.5, 0.0, 0.0);
+   } else {
+      color = vec4(0.0, 1.0, 0.0, 1.0);
+   }
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform vec2 u_offset 0 0
+
+uniform int u_idx 0
+draw rect -1 -1 1 2
+
+uniform int u_idx 1
+draw rect 0 -1 1 2
+
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-4.40/execution/fs-interpolateAtSample-swizzle.shader_test b/tests/spec/glsl-4.40/execution/fs-interpolateAtSample-swizzle.shader_test
new file mode 100644
index 0000000..74663b1
--- /dev/null
+++ b/tests/spec/glsl-4.40/execution/fs-interpolateAtSample-swizzle.shader_test
@@ -0,0 +1,70 @@
+# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation
+# Functions) to:
+#
+#    "Component selection operators (e.g., .xy) may be used when specifying
+#     interpolant."
+#
+# Furthermore, GLSL 4.60 clarified that
+#
+#    "(...) interpolant must be an l-value from an in declaration; this can
+#     include a variable, a block or structure member, an array element, or
+#     some combination of these."
+#
+# which means array subscripts on vectors should also be allowed.
+#
+
+[require]
+GLSL >= 4.40
+
+[vertex shader]
+#version 440
+
+in vec4 piglit_vertex;
+
+out vec3 a;
+
+void main()
+{
+   gl_Position = piglit_vertex;
+
+   a = piglit_vertex.xyz;
+}
+
+[fragment shader]
+#version 440
+
+in vec3 a;
+
+uniform int u_idx;
+
+out vec4 color;
+
+void main()
+{
+   /* There is no multi-sampling, so these should all be the same. */
+   vec2 delta1 = a.yx - interpolateAtSample(a.yx, 0);
+   float delta2 = a[2] - interpolateAtSample(a[2], 0);
+   float delta3 = a[u_idx] - interpolateAtSample(a[u_idx], 0);
+
+   if (delta1 != vec2(0.0)) {
+      color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0);
+   } else if (delta2 != 0.0) {
+      color = vec4(0.2, delta2 + 0.5, 0.0, 0.0);
+   } else if (delta3 != 0.0) {
+      color = vec4(0.3, delta3 + 0.5, 0.0, 0.0);
+   } else {
+      color = vec4(0.0, 1.0, 0.0, 1.0);
+   }
+}
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+uniform int u_idx 0
+draw rect -1 -1 1 2
+
+uniform int u_idx 1
+draw rect 0 -1 1 2
+
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.9.3



More information about the Piglit mailing list