[Piglit] [PATCH 3/4] glsl-1.10 / glsl-1.30: Verify that fragment shader can only write one kind of output
Ian Romanick
idr at freedesktop.org
Wed Nov 16 13:50:37 PST 2011
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
.../write-gl_FragColor-and-gl_FragData-dead.frag | 22 +++++++++++++++++
.../write-gl_FragColor-and-gl_FragData.frag | 18 ++++++++++++++
.../write-gl_FragColor-dead-and-gl_FragData.frag | 22 +++++++++++++++++
.../write-gl_FragColor-and-user-output-dead.frag | 25 ++++++++++++++++++++
.../write-gl_FragColor-and-user-output.frag | 21 ++++++++++++++++
.../write-gl_FragColor-dead-and-user-output.frag | 25 ++++++++++++++++++++
.../write-gl_FragData-and-user-output-dead.frag | 25 ++++++++++++++++++++
.../write-gl_FragData-and-user-output.frag | 21 ++++++++++++++++
.../write-gl_FragData-dead-and-user-output.frag | 25 ++++++++++++++++++++
9 files changed, 204 insertions(+), 0 deletions(-)
create mode 100644 tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData-dead.frag
create mode 100644 tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData.frag
create mode 100644 tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-dead-and-gl_FragData.frag
create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output-dead.frag
create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output.frag
create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-dead-and-user-output.frag
create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output-dead.frag
create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output.frag
create mode 100644 tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-dead-and-user-output.frag
diff --git a/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData-dead.frag b/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData-dead.frag
new file mode 100644
index 0000000..9e25959
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData-dead.frag
@@ -0,0 +1,22 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.10
+ * [end config]
+ *
+ * From page 49 of the GLSL 1.10 spec:
+ *
+ * "If a shader statically assigns a value to gl_FragColor, it may not
+ * assign a value to any element of gl_FragData. If a shader statically
+ * writes a value to any element of gl_FragData, it may not assign a value
+ * to gl_FragColor. That is, a shader may assign values to either
+ * gl_FragColor or gl_FragData, but not both."
+ *
+ * Since these are compile time errors and are based on static assignments,
+ * the check must happen before any dead-code removal or other optimizations.
+ */
+void main()
+{
+ gl_FragColor = vec4(1.0);
+ if (false)
+ gl_FragData[0] = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData.frag b/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData.frag
new file mode 100644
index 0000000..effb9cb
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-and-gl_FragData.frag
@@ -0,0 +1,18 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.10
+ * [end config]
+ *
+ * From page 49 of the GLSL 1.10 spec:
+ *
+ * "If a shader statically assigns a value to gl_FragColor, it may not
+ * assign a value to any element of gl_FragData. If a shader statically
+ * writes a value to any element of gl_FragData, it may not assign a value
+ * to gl_FragColor. That is, a shader may assign values to either
+ * gl_FragColor or gl_FragData, but not both."
+ */
+void main()
+{
+ gl_FragColor = vec4(1.0);
+ gl_FragData[0] = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-dead-and-gl_FragData.frag b/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-dead-and-gl_FragData.frag
new file mode 100644
index 0000000..1dc45a0
--- /dev/null
+++ b/tests/spec/glsl-1.10/compiler/fragment-outputs/write-gl_FragColor-dead-and-gl_FragData.frag
@@ -0,0 +1,22 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.10
+ * [end config]
+ *
+ * From page 49 of the GLSL 1.10 spec:
+ *
+ * "If a shader statically assigns a value to gl_FragColor, it may not
+ * assign a value to any element of gl_FragData. If a shader statically
+ * writes a value to any element of gl_FragData, it may not assign a value
+ * to gl_FragColor. That is, a shader may assign values to either
+ * gl_FragColor or gl_FragData, but not both."
+ *
+ * Since these are compile time errors and are based on static assignments,
+ * the check must happen before any dead-code removal or other optimizations.
+ */
+void main()
+{
+ if (false)
+ gl_FragColor = vec4(1.0);
+ gl_FragData[0] = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output-dead.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output-dead.frag
new file mode 100644
index 0000000..40b1747
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output-dead.frag
@@ -0,0 +1,25 @@
+/* [config]
+ * expect_result: fail
+ * 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."
+ *
+ * Since these are compile time errors and are based on static assignments,
+ * the check must happen before any dead-code removal or other optimizations.
+ */
+#version 130
+
+out vec4 frag_color;
+
+void main()
+{
+ gl_FragColor = vec4(1.0);
+ if (false)
+ frag_color = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output.frag
new file mode 100644
index 0000000..acf5aa1
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-and-user-output.frag
@@ -0,0 +1,21 @@
+/* [config]
+ * expect_result: fail
+ * 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."
+ */
+#version 130
+
+out vec4 frag_color;
+
+void main()
+{
+ gl_FragColor = vec4(1.0);
+ frag_color = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-dead-and-user-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-dead-and-user-output.frag
new file mode 100644
index 0000000..9bed273
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragColor-dead-and-user-output.frag
@@ -0,0 +1,25 @@
+/* [config]
+ * expect_result: fail
+ * 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."
+ *
+ * Since these are compile time errors and are based on static assignments,
+ * the check must happen before any dead-code removal or other optimizations.
+ */
+#version 130
+
+out vec4 frag_color;
+
+void main()
+{
+ if (false)
+ gl_FragColor = vec4(1.0);
+ frag_color = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output-dead.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output-dead.frag
new file mode 100644
index 0000000..b993182
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output-dead.frag
@@ -0,0 +1,25 @@
+/* [config]
+ * expect_result: fail
+ * 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."
+ *
+ * Since these are compile time errors and are based on static assignments,
+ * the check must happen before any dead-code removal or other optimizations.
+ */
+#version 130
+
+out vec4 frag_color;
+
+void main()
+{
+ gl_FragData[0] = vec4(1.0);
+ if (false)
+ frag_color = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output.frag
new file mode 100644
index 0000000..e28dc02
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-and-user-output.frag
@@ -0,0 +1,21 @@
+/* [config]
+ * expect_result: fail
+ * 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."
+ */
+#version 130
+
+out vec4 frag_color;
+
+void main()
+{
+ gl_FragData[0] = vec4(1.0);
+ frag_color = vec4(1.0);
+}
diff --git a/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-dead-and-user-output.frag b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-dead-and-user-output.frag
new file mode 100644
index 0000000..e66b76d
--- /dev/null
+++ b/tests/spec/glsl-1.30/compiler/fragment-outputs/write-gl_FragData-dead-and-user-output.frag
@@ -0,0 +1,25 @@
+/* [config]
+ * expect_result: fail
+ * 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."
+ *
+ * Since these are compile time errors and are based on static assignments,
+ * the check must happen before any dead-code removal or other optimizations.
+ */
+#version 130
+
+out vec4 frag_color;
+
+void main()
+{
+ if (false)
+ gl_FragData[0] = vec4(1.0);
+ frag_color = vec4(1.0);
+}
--
1.7.6.4
More information about the Piglit
mailing list