[Piglit] [PATCH 4/4] glsl-1.30: Verify that gl_Frag{Color, Data} and a function out can be written

Ian Romanick idr at freedesktop.org
Wed Nov 16 13:50:38 PST 2011


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

These tests try to trick the GLSL compiler by writing a built-in
fragment shader output and a function "out" variable.  The compiler is
supposed to generate an error if a built-in output and a user-defined
shader "out" variable are written.  Writing to a built-in and a
funciton "out" should be allowed.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 .../write-gl_FragColor-and-function-output.frag    |   29 ++++++++++++++++++++
 .../write-gl_FragData-and-function-output.frag     |   29 ++++++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag
 create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag

diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag
new file mode 100644
index 0000000..ad5559a
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-function-output.frag
@@ -0,0 +1,29 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.30
+ * [end config]
+ *
+ * From page 68 of the GLSL 1.30 spec:
+ *
+ *     "Similarly, if user declared output variables are in use (statically
+ *     assigned to), then the built-in variables gl_FragColor and gl_FragData
+ *     may not be assigned to. These incorrect usages all generate compile
+ *     time errors."
+ *
+ * This test tries to trick the compiler by writing to gl_FragColor and an
+ * 'out' parameter of a function.  This is valid.
+ */
+#version 130
+
+void function(out vec4 f)
+{
+	f = vec4(1.0);
+}
+
+void main()
+{
+	vec4 v;
+
+	function(v);
+	gl_FragColor = v;
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag
new file mode 100644
index 0000000..03cb878
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-function-output.frag
@@ -0,0 +1,29 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.30
+ * [end config]
+ *
+ * From page 68 of the GLSL 1.30 spec:
+ *
+ *     "Similarly, if user declared output variables are in use (statically
+ *     assigned to), then the built-in variables gl_FragColor and gl_FragData
+ *     may not be assigned to. These incorrect usages all generate compile
+ *     time errors."
+ *
+ * This test tries to trick the compiler by writing to gl_FragColor and an
+ * 'out' parameter of a function.  This is valid.
+ */
+#version 130
+
+void function(out vec4 f)
+{
+	f = vec4(1.0);
+}
+
+void main()
+{
+	vec4 v;
+
+	function(v);
+	gl_FragData[0] = v;
+}
-- 
1.7.6.4



More information about the Piglit mailing list