summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2011-08-03 15:31:51 -0700
committerPaul Berry <stereotype441@gmail.com>2011-08-05 15:13:55 -0700
commit003e317617e022d660dc9a9c727f71023857895b (patch)
tree5b0649e7f036a0b4e7d95fceddcb2472df53ccad
parent801d6debf196e2c77fe0ed372731edcedbead462 (diff)
Test interaction between globals and functions pulled in by linking.
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. Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--tests/spec/glsl-1.10/linker/access-builtin-global-from-fn-unknown-to-main.shader_test31
1 files changed, 31 insertions, 0 deletions
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 00000000..09687a20
--- /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