[Piglit] [PATCH] Test interaction between globals and functions pulled in by linking.

Paul Berry stereotype441 at gmail.com
Wed Aug 3 17:12:13 PDT 2011


This test exercises a bug in Mesa.  If a function that is not known to
the compilation unit containing main() (IOW, neither defined not
declared in that compilation unit) attempts to access a global
variable, then improper IR is generated.

I'll be submitting a patch to Mesa to fix this problem, and to check
the IR validity after linking.  This test will ensure that the fix
won't regress.
---
 ...ltin-global-from-fn-unknown-to-main.shader_test |   31 ++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.10/linker/access-builtin-global-from-fn-unknown-to-main.shader_test

diff --git a/tests/spec/glsl-1.10/linker/access-builtin-global-from-fn-unknown-to-main.shader_test b/tests/spec/glsl-1.10/linker/access-builtin-global-from-fn-unknown-to-main.shader_test
new file mode 100644
index 0000000..09687a2
--- /dev/null
+++ b/tests/spec/glsl-1.10/linker/access-builtin-global-from-fn-unknown-to-main.shader_test
@@ -0,0 +1,31 @@
+# Test that GLSL built-in global variables can be accessed from a
+# function that is neither defined nor declared in the compilation
+# unit that defines main().
+
+[vertex shader]
+void f();
+void main()
+{
+  f();
+}
+
+[vertex shader]
+void g()
+{
+  gl_Position = gl_Vertex;
+  gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
+}
+void f()
+{
+  g();
+}
+
+[fragment shader]
+void main()
+{
+  gl_FragColor = gl_Color;
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.7.6



More information about the Piglit mailing list