[Piglit] [PATCH] squash! glsl-1.10: Test the sign() function with abs() and negation of its argument

Ian Romanick idr at freedesktop.org
Tue Jun 26 22:26:52 UTC 2018


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

While working on the fix, I thought of a couple other corner cases.
The original fix did not fix these tests... probably just squash into
a single commit.
---
 .../execution/fs-sign-sat-neg-abs.shader_test      | 22 +++++++++++++++
 .../execution/vs-sign-sat-neg-abs.shader_test      | 32 ++++++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/execution/fs-sign-sat-neg-abs.shader_test
 create mode 100644 tests/spec/glsl-1.10/execution/vs-sign-sat-neg-abs.shader_test

diff --git a/tests/spec/glsl-1.10/execution/fs-sign-sat-neg-abs.shader_test b/tests/spec/glsl-1.10/execution/fs-sign-sat-neg-abs.shader_test
new file mode 100644
index 000000000..21dcfa918
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-sign-sat-neg-abs.shader_test
@@ -0,0 +1,22 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader passthrough]
+
+[fragment shader]
+uniform vec4 arg0;
+uniform vec4 expect;
+
+void main()
+{
+	if (clamp(sign(-abs(arg0)), 0.0, 1.0) != expect)
+		gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+	else
+		gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+
+[test]
+uniform vec4 arg0 -5.0 5.0 0.0 0.0
+uniform vec4 expect 0.0 0.0 0.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-sat-neg-abs.shader_test b/tests/spec/glsl-1.10/execution/vs-sign-sat-neg-abs.shader_test
new file mode 100644
index 000000000..2cfbae477
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-sign-sat-neg-abs.shader_test
@@ -0,0 +1,32 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform vec4 arg0;
+uniform vec4 expect;
+
+varying vec4 color;
+
+void main()
+{
+
+	if (clamp(sign(-abs(arg0)), 0.0, 1.0) != expect)
+		color = vec4(1.0, 0.0, 0.0, 1.0);
+	else
+		color = vec4(0.0, 1.0, 0.0, 1.0);
+	gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+varying vec4 color;
+
+void main()
+{
+	gl_FragColor = color;
+}
+
+[test]
+uniform vec4 arg0 -5.0 5.0 0.0 0.0
+uniform vec4 expect 0.0 0.0 0.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