[Piglit] [PATCH] glsl-1.10: Verify result of sign(a)*sign(b)

Ian Romanick idr at freedesktop.org
Sun Sep 9 22:34:29 UTC 2018


From: Ian Romanick <ian.d.romanick at intel.com>

These tests caught a bug in an optimized version of nir_op_fsign that I
was working on for i965.  I thought of a couple clever ways to optimize
sign(a)*sign(b), but most of those ways would fail one or more of the
tests with ±Inf.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 .../execution/fs-sign-times-sign.shader_test       | 53 +++++++++++++++++++
 .../execution/vs-sign-times-sign.shader_test       | 61 ++++++++++++++++++++++
 2 files changed, 114 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/execution/fs-sign-times-sign.shader_test
 create mode 100644 tests/spec/glsl-1.10/execution/vs-sign-times-sign.shader_test

diff --git a/tests/spec/glsl-1.10/execution/fs-sign-times-sign.shader_test b/tests/spec/glsl-1.10/execution/fs-sign-times-sign.shader_test
new file mode 100644
index 000000000..c46320b20
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-sign-times-sign.shader_test
@@ -0,0 +1,53 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader passthrough]
+
+[fragment shader]
+uniform vec4 v[25];
+
+void main()
+{
+	vec4 color = vec4(0.0, 1.0, 0.0, 1.0);
+
+	for (int i = 0; i < 25; i++) {
+		if (sign(v[i].x) * sign(v[i].y) != v[i].z)
+			color = vec4(1.0, 0.0, 0.0, 1.0);
+	}
+
+	gl_FragColor = color;
+}
+
+[test]
+uniform vec4 v[0]         5.0        5.0  1.0 0.0
+uniform vec4 v[1]         5.0       -5.0 -1.0 0.0
+uniform vec4 v[2]         5.0        0.0  0.0 0.0
+uniform vec4 v[3]         5.0 0x7f000000  1.0 0.0
+uniform vec4 v[4]         5.0 0xff000000 -1.0 0.0
+
+uniform vec4 v[5]        -5.0        5.0 -1.0 0.0
+uniform vec4 v[6]        -5.0       -5.0  1.0 0.0
+uniform vec4 v[7]        -5.0        0.0  0.0 0.0
+uniform vec4 v[8]        -5.0 0x7f000000 -1.0 0.0
+uniform vec4 v[9]        -5.0 0xff000000  1.0 0.0
+
+uniform vec4 v[10]        0.0        5.0  0.0 0.0
+uniform vec4 v[11]        0.0       -5.0  0.0 0.0
+uniform vec4 v[12]        0.0        0.0  0.0 0.0
+uniform vec4 v[13]        0.0 0x7f000000  0.0 0.0
+uniform vec4 v[14]        0.0 0xff000000  0.0 0.0
+
+uniform vec4 v[15] 0x7f000000        5.0  1.0 0.0
+uniform vec4 v[16] 0x7f000000       -5.0 -1.0 0.0
+uniform vec4 v[17] 0x7f000000        0.0  0.0 0.0
+uniform vec4 v[18] 0x7f000000 0x7f000000  1.0 0.0
+uniform vec4 v[19] 0x7f000000 0xff000000 -1.0 0.0
+
+uniform vec4 v[20] 0xff000000        5.0 -1.0 0.0
+uniform vec4 v[21] 0xff000000       -5.0  1.0 0.0
+uniform vec4 v[22] 0xff000000        0.0  0.0 0.0
+uniform vec4 v[23] 0xff000000 0x7f000000 -1.0 0.0
+uniform vec4 v[24] 0xff000000 0xff000000  1.0 0.0
+
+draw rect -1 -1 2 2
+probe rgb 1 1 0.0 1.0 0.0
diff --git a/tests/spec/glsl-1.10/execution/vs-sign-times-sign.shader_test b/tests/spec/glsl-1.10/execution/vs-sign-times-sign.shader_test
new file mode 100644
index 000000000..ab28b650a
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-sign-times-sign.shader_test
@@ -0,0 +1,61 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform vec4 v[25];
+
+varying vec4 color;
+
+void main()
+{
+	color = vec4(0.0, 1.0, 0.0, 1.0);
+
+	for (int i = 0; i < 25; i++) {
+		if (sign(v[i].x) * sign(v[i].y) != v[i].z)
+			color = vec4(1.0, 0.0, 0.0, 1.0);
+	}
+
+	gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+	gl_FragColor = color;
+}
+
+[test]
+uniform vec4 v[0]         5.0        5.0  1.0 0.0
+uniform vec4 v[1]         5.0       -5.0 -1.0 0.0
+uniform vec4 v[2]         5.0        0.0  0.0 0.0
+uniform vec4 v[3]         5.0 0x7f000000  1.0 0.0
+uniform vec4 v[4]         5.0 0xff000000 -1.0 0.0
+
+uniform vec4 v[5]        -5.0        5.0 -1.0 0.0
+uniform vec4 v[6]        -5.0       -5.0  1.0 0.0
+uniform vec4 v[7]        -5.0        0.0  0.0 0.0
+uniform vec4 v[8]        -5.0 0x7f000000 -1.0 0.0
+uniform vec4 v[9]        -5.0 0xff000000  1.0 0.0
+
+uniform vec4 v[10]        0.0        5.0  0.0 0.0
+uniform vec4 v[11]        0.0       -5.0  0.0 0.0
+uniform vec4 v[12]        0.0        0.0  0.0 0.0
+uniform vec4 v[13]        0.0 0x7f000000  0.0 0.0
+uniform vec4 v[14]        0.0 0xff000000  0.0 0.0
+
+uniform vec4 v[15] 0x7f000000        5.0  1.0 0.0
+uniform vec4 v[16] 0x7f000000       -5.0 -1.0 0.0
+uniform vec4 v[17] 0x7f000000        0.0  0.0 0.0
+uniform vec4 v[18] 0x7f000000 0x7f000000  1.0 0.0
+uniform vec4 v[19] 0x7f000000 0xff000000 -1.0 0.0
+
+uniform vec4 v[20] 0xff000000        5.0 -1.0 0.0
+uniform vec4 v[21] 0xff000000       -5.0  1.0 0.0
+uniform vec4 v[22] 0xff000000        0.0  0.0 0.0
+uniform vec4 v[23] 0xff000000 0x7f000000 -1.0 0.0
+uniform vec4 v[24] 0xff000000 0xff000000  1.0 0.0
+
+draw rect -1 -1 2 2
+probe rgb 1 1 0.0 1.0 0.0
-- 
2.14.4



More information about the Piglit mailing list