[Piglit] [PATCH] glsl-1.10: Add tests for common gl_FrontFacing ternary usage.

Matt Turner mattst88 at gmail.com
Thu Jan 8 12:26:04 PST 2015


These patterns

	gl_FrontFacing ?  1.0 :  1.0
	gl_FrontFacing ? -1.0 : -1.0
	gl_FrontFacing ?  0.0 : -1.0

are recognized and optimized by the i965 driver.
---
 .../fs-frontfacing-ternary-0.0-neg-1.0.shader_test   | 20 ++++++++++++++++++++
 .../fs-frontfacing-ternary-1.0-neg-1.0.shader_test   | 20 ++++++++++++++++++++
 .../fs-frontfacing-ternary-neg-1.0-1.0.shader_test   | 20 ++++++++++++++++++++
 3 files changed, 60 insertions(+)
 create mode 100644 tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-0.0-neg-1.0.shader_test
 create mode 100644 tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-1.0-neg-1.0.shader_test
 create mode 100644 tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-neg-1.0-1.0.shader_test

diff --git a/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-0.0-neg-1.0.shader_test b/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-0.0-neg-1.0.shader_test
new file mode 100644
index 0000000..2ac9224
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-0.0-neg-1.0.shader_test
@@ -0,0 +1,20 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader passthrough
+
+[fragment shader]
+void main()
+{
+	float f = gl_FrontFacing ? 0.0 : -1.0;
+	f = f * 0.5 + 0.75; // Remap (0.0, -1.0) -> (0.75, 0.25)
+	gl_FragColor = vec4(0.0, f, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 1
+draw rect 1 0 -2 1
+relative probe rgba (0, 0) (0.0, 0.75, 0.0, 1.0)
+relative probe rgba (1, 0) (0.0, 0.75, 0.0, 1.0)
+relative probe rgba (0, 1) (0.0, 0.25, 0.0, 1.0)
+relative probe rgba (1, 1) (0.0, 0.25, 0.0, 1.0)
diff --git a/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-1.0-neg-1.0.shader_test b/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-1.0-neg-1.0.shader_test
new file mode 100644
index 0000000..b4e6360
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-1.0-neg-1.0.shader_test
@@ -0,0 +1,20 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader passthrough
+
+[fragment shader]
+void main()
+{
+	float f = gl_FrontFacing ? 1.0 : -1.0;
+	f = f * 0.25 + 0.5; // Remap (1.0, -1.0) -> (0.75, 0.25)
+	gl_FragColor = vec4(0.0, f, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 1
+draw rect 1 0 -2 1
+relative probe rgba (0, 0) (0.0, 0.75, 0.0, 1.0)
+relative probe rgba (1, 0) (0.0, 0.75, 0.0, 1.0)
+relative probe rgba (0, 1) (0.0, 0.25, 0.0, 1.0)
+relative probe rgba (1, 1) (0.0, 0.25, 0.0, 1.0)
diff --git a/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-neg-1.0-1.0.shader_test b/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-neg-1.0-1.0.shader_test
new file mode 100644
index 0000000..47a1eda
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/fs-frontfacing-ternary-neg-1.0-1.0.shader_test
@@ -0,0 +1,20 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader passthrough
+
+[fragment shader]
+void main()
+{
+	float f = gl_FrontFacing ? -1.0 : 1.0;
+	f = f * -0.25 + 0.5; // Remap (-1.0, 1.0) -> (0.75, 0.25)
+	gl_FragColor = vec4(0.0, f, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 1
+draw rect 1 0 -2 1
+relative probe rgba (0, 0) (0.0, 0.75, 0.0, 1.0)
+relative probe rgba (1, 0) (0.0, 0.75, 0.0, 1.0)
+relative probe rgba (0, 1) (0.0, 0.25, 0.0, 1.0)
+relative probe rgba (1, 1) (0.0, 0.25, 0.0, 1.0)
-- 
2.0.4



More information about the Piglit mailing list