[Piglit] [PATCH 18/23] Port preprocessor glsl test from Glean to Piglit.
Fabian Bieler
fabianbieler at fastmail.fm
Thu Nov 23 20:46:10 UTC 2017
---
.../preprocessor/bogus-extension-test.frag | 12 ++++++++++
.../spec/glsl-1.10/preprocessor/elif-1.shader_test | 22 ++++++++++++++++++
.../spec/glsl-1.10/preprocessor/elif-2.shader_test | 22 ++++++++++++++++++
.../extension-defined-test.shader_test | 22 ++++++++++++++++++
.../preprocessor/extension-if-1.shader_test | 22 ++++++++++++++++++
.../preprocessor/if-0-define-macro.shader_test | 19 +++++++++++++++
tests/spec/glsl-1.10/preprocessor/if-0.shader_test | 18 +++++++++++++++
.../preprocessor/if-1-define-macro.shader_test | 18 +++++++++++++++
.../if-1-define-nested-macro.shader_test | 19 +++++++++++++++
tests/spec/glsl-1.10/preprocessor/if-1.shader_test | 18 +++++++++++++++
.../glsl-1.10/preprocessor/if-defined.shader_test | 19 +++++++++++++++
.../spec/glsl-1.10/preprocessor/if-eq.shader_test | 19 +++++++++++++++
.../spec/glsl-1.10/preprocessor/ifdef.shader_test | 19 +++++++++++++++
.../spec/glsl-1.10/preprocessor/ifndef.shader_test | 19 +++++++++++++++
.../preprocessor/multi-line-define.shader_test | 15 ++++++++++++
.../glsl-1.10/preprocessor/nested-if-1.shader_test | 25 ++++++++++++++++++++
.../glsl-1.10/preprocessor/nested-if-2.shader_test | 25 ++++++++++++++++++++
.../preprocessor/nested-if-elif.shader_test | 27 ++++++++++++++++++++++
.../glsl-1.10/preprocessor/not-defined.shader_test | 19 +++++++++++++++
19 files changed, 379 insertions(+)
create mode 100644 tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag
create mode 100644 tests/spec/glsl-1.10/preprocessor/elif-1.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/elif-2.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/extension-defined-test.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/extension-if-1.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-0-define-macro.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-0.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-1-define-macro.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-1-define-nested-macro.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-1.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-defined.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/if-eq.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/ifdef.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/ifndef.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/multi-line-define.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/nested-if-1.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/nested-if-2.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/nested-if-elif.shader_test
create mode 100644 tests/spec/glsl-1.10/preprocessor/not-defined.shader_test
diff --git a/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag b/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag
new file mode 100644
index 0000000..b4fce45
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/bogus-extension-test.frag
@@ -0,0 +1,12 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.10
+ * [end config]
+ */
+
+// Test using a non-existant function. Should not compile.
+#extension GL_FOO_bar: require
+void main()
+{
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
+}
diff --git a/tests/spec/glsl-1.10/preprocessor/elif-1.shader_test b/tests/spec/glsl-1.10/preprocessor/elif-1.shader_test
new file mode 100644
index 0000000..8d5c03f
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/elif-1.shader_test
@@ -0,0 +1,22 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO 1
+void main()
+{
+ vec4 r = vec4(0.0, 0.0, 0.0, 0.0);
+#if FOO == 1
+ r.y = 1.0;
+#elif FOO == 2
+ r.x = 1.0;
+#else
+ r.z = 1.0;
+#endif
+ gl_FragColor = r;
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/elif-2.shader_test b/tests/spec/glsl-1.10/preprocessor/elif-2.shader_test
new file mode 100644
index 0000000..b2e1018
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/elif-2.shader_test
@@ -0,0 +1,22 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO 2
+void main()
+{
+ vec4 r = vec4(0.0, 0.0, 0.0, 0.0);
+#if FOO == 1
+ r.y = 1.0;
+#elif FOO == 2
+ r.x = 1.0;
+#else
+ r.z = 1.0;
+#endif
+ gl_FragColor = r;
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (1.0, 0.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/extension-defined-test.shader_test b/tests/spec/glsl-1.10/preprocessor/extension-defined-test.shader_test
new file mode 100644
index 0000000..46b534a
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/extension-defined-test.shader_test
@@ -0,0 +1,22 @@
+# This test will only be run if we have the GL_ARB_draw_buffers
+# extension. Note the FLAG_ARB_DRAW_BUFFERS flag.
+
+[require]
+GLSL >= 1.10
+GL_ARB_DRAW_BUFFERS
+
+[fragment shader]
+#extension GL_ARB_draw_buffers: enable
+void main()
+{
+#if defined(GL_ARB_draw_buffers)
+ gl_FragData[0] = vec4(0.0, 1.0, 0.0, 0.0);
+#else
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/extension-if-1.shader_test b/tests/spec/glsl-1.10/preprocessor/extension-if-1.shader_test
new file mode 100644
index 0000000..c04ee7c
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/extension-if-1.shader_test
@@ -0,0 +1,22 @@
+# This test will only be run if we have the GL_ARB_draw_buffers
+# extension. Note the FLAG_ARB_DRAW_BUFFERS flag.
+
+[require]
+GLSL >= 1.10
+GL_ARB_DRAW_BUFFERS
+
+[fragment shader]
+#extension GL_ARB_draw_buffers: enable
+void main()
+{
+#if GL_ARB_draw_buffers == 1
+ gl_FragData[0] = vec4(0.0, 1.0, 0.0, 0.0);
+#else
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-0-define-macro.shader_test b/tests/spec/glsl-1.10/preprocessor/if-0-define-macro.shader_test
new file mode 100644
index 0000000..8e0f21c
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-0-define-macro.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define BAR(x) x
+#if 0
+#define FOO(x) BAR(x)
+#else
+#define FOO(x) (BAR(x) + BAR(x))
+#endif
+void main()
+{
+ gl_FragColor = vec4(FOO(0.25));
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.5, 0.5, 0.5, 0.5)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-0.shader_test b/tests/spec/glsl-1.10/preprocessor/if-0.shader_test
new file mode 100644
index 0000000..59330c0
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-0.shader_test
@@ -0,0 +1,18 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = vec4(0.0);
+#if 0
+ gl_FragColor += vec4(0.5);
+#else
+ gl_FragColor += vec4(0.3);
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.3, 0.3, 0.3, 0.3)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-1-define-macro.shader_test b/tests/spec/glsl-1.10/preprocessor/if-1-define-macro.shader_test
new file mode 100644
index 0000000..4539ca6
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-1-define-macro.shader_test
@@ -0,0 +1,18 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#if 1
+#define FOO(x) x
+#else
+#define FOO(x) (0.5 * (x))
+#endif
+void main()
+{
+ gl_FragColor = vec4(FOO(0.25));
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.25, 0.25, 0.25, 0.25)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-1-define-nested-macro.shader_test b/tests/spec/glsl-1.10/preprocessor/if-1-define-nested-macro.shader_test
new file mode 100644
index 0000000..a71b9fb
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-1-define-nested-macro.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define BAR(x) x
+#if 1
+#define FOO(x) BAR(x)
+#else
+#define FOO(x) (BAR(x) + BAR(x))
+#endif
+void main()
+{
+ gl_FragColor = vec4(FOO(0.25));
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.25, 0.25, 0.25, 0.25)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-1.shader_test b/tests/spec/glsl-1.10/preprocessor/if-1.shader_test
new file mode 100644
index 0000000..e3461bd
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-1.shader_test
@@ -0,0 +1,18 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = vec4(0.0);
+#if 1
+ gl_FragColor += vec4(0.5);
+#else
+ gl_FragColor += vec4(0.3);
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.5, 0.5, 0.5, 0.5)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-defined.shader_test b/tests/spec/glsl-1.10/preprocessor/if-defined.shader_test
new file mode 100644
index 0000000..721c9d3
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-defined.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO
+void main()
+{
+ gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);
+#if defined(FOO)
+ gl_FragColor.y = 1.0;
+#else
+ gl_FragColor.x = 1.0;
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/if-eq.shader_test b/tests/spec/glsl-1.10/preprocessor/if-eq.shader_test
new file mode 100644
index 0000000..03f16c5
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/if-eq.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = vec4(0.0);
+#define SYMBOL 3
+#if SYMBOL == 3
+ gl_FragColor += vec4(0.5);
+#else
+ gl_FragColor += vec4(0.3);
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.5, 0.5, 0.5, 0.5)
diff --git a/tests/spec/glsl-1.10/preprocessor/ifdef.shader_test b/tests/spec/glsl-1.10/preprocessor/ifdef.shader_test
new file mode 100644
index 0000000..7754596
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/ifdef.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO
+void main()
+{
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
+#ifdef FOO
+ gl_FragColor.y = 1.0;
+#else
+ gl_FragColor.x = 1.0;
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/ifndef.shader_test b/tests/spec/glsl-1.10/preprocessor/ifndef.shader_test
new file mode 100644
index 0000000..12912f4
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/ifndef.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO
+void main()
+{
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
+#ifndef FOO
+ gl_FragColor.y = 1.0;
+#else
+ gl_FragColor.x = 1.0;
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (1.0, 0.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/multi-line-define.shader_test b/tests/spec/glsl-1.10/preprocessor/multi-line-define.shader_test
new file mode 100644
index 0000000..a4f8388
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/multi-line-define.shader_test
@@ -0,0 +1,15 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO(x) \
+ ((x) + (x))
+void main()
+{
+ gl_FragColor = vec4(FOO(0.25));
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.5, 0.5, 0.5, 0.5)
diff --git a/tests/spec/glsl-1.10/preprocessor/nested-if-1.shader_test b/tests/spec/glsl-1.10/preprocessor/nested-if-1.shader_test
new file mode 100644
index 0000000..15dd9c2
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/nested-if-1.shader_test
@@ -0,0 +1,25 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO 1
+#define BAR 0
+void main()
+{
+ vec4 r = vec4(0.0, 0.0, 0.0, 0.0);
+#if FOO == 1
+#if BAR == 1
+ r.x = 1.0;
+#else
+ r.y = 1.0;
+#endif
+#else
+ r.z = 1.0;
+#endif
+ gl_FragColor = r;
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/nested-if-2.shader_test b/tests/spec/glsl-1.10/preprocessor/nested-if-2.shader_test
new file mode 100644
index 0000000..ba3850f
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/nested-if-2.shader_test
@@ -0,0 +1,25 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO 0
+#define BAR 0
+void main()
+{
+ vec4 r = vec4(0.0, 0.0, 0.0, 0.0);
+#if FOO == 1
+ r.z = 1.0;
+#else
+#if BAR == 1
+ r.x = 1.0;
+#else
+ r.y = 1.0;
+#endif
+#endif
+ gl_FragColor = r;
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (0.0, 1.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/nested-if-elif.shader_test b/tests/spec/glsl-1.10/preprocessor/nested-if-elif.shader_test
new file mode 100644
index 0000000..e006871
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/nested-if-elif.shader_test
@@ -0,0 +1,27 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO 0
+#define BAR 2
+void main()
+{
+ vec4 r = vec4(0.0, 0.0, 0.0, 0.0);
+#if FOO == 1
+ r.z = 1.0;
+#else
+#if BAR == 1
+ r.x = 1.0;
+#elif BAR == 2
+ r.x = 1.0;
+#else
+ r.y = 1.0;
+#endif
+#endif
+ gl_FragColor = r;
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (1.0, 0.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.10/preprocessor/not-defined.shader_test b/tests/spec/glsl-1.10/preprocessor/not-defined.shader_test
new file mode 100644
index 0000000..5d571da
--- /dev/null
+++ b/tests/spec/glsl-1.10/preprocessor/not-defined.shader_test
@@ -0,0 +1,19 @@
+[require]
+GLSL >= 1.10
+
+[fragment shader]
+#define FOO
+void main()
+{
+ gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
+#if !defined(FOO)
+ gl_FragColor.y = 1.0;
+#else
+ gl_FragColor.x = 1.0;
+#endif
+}
+
+
+[test]
+draw rect -1 -1 2 2
+relative probe rgba (0.5, 0.5) (1.0, 0.0, 0.0, 0.0)
--
2.7.4
More information about the Piglit
mailing list