Add runtime effect test for global variables

Includes variables with and without initializers. Note that both the
.skvm and .stage output is incorrect right now. (No declarations for
global variables in .stage, and the initializer is dropped in .skvm).

Bug: skia:11295
Change-Id: Icb6d797616be6a1bc7cbdc9db4fefa7e30c65656
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371143
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni
index 3fe11ad..470df5c 100644
--- a/gn/sksl_tests.gni
+++ b/gn/sksl_tests.gni
@@ -543,6 +543,7 @@
 sksl_rte_tests = [
   "/sksl/runtime/ArrayIndexing.rte",
   "/sksl/runtime/ConversionConstructors.rte",
+  "/sksl/runtime/GlobalVariables.rte",
   "/sksl/runtime/LoopInt.rte",
   "/sksl/runtime/LoopFloat.rte",
   "/sksl/runtime/SampleWithConstantMatrix.rte",
diff --git a/resources/sksl/runtime/GlobalVariables.rte b/resources/sksl/runtime/GlobalVariables.rte
new file mode 100644
index 0000000..7c1b1fc
--- /dev/null
+++ b/resources/sksl/runtime/GlobalVariables.rte
@@ -0,0 +1,13 @@
+/*#pragma settings NoInline*/
+
+float gInitialized = -1.0;
+float gUninitialized;
+
+void init_globals() {
+    gUninitialized = gInitialized + 2;
+}
+
+float4 main() {
+    init_globals();
+    return float4(0, -gInitialized, 0, gUninitialized);
+}
diff --git a/tests/sksl/runtime/GlobalVariables.skvm b/tests/sksl/runtime/GlobalVariables.skvm
new file mode 100644
index 0000000..e022147
--- /dev/null
+++ b/tests/sksl/runtime/GlobalVariables.skvm
@@ -0,0 +1,8 @@
+2 registers, 6 instructions:
+0	r0 = splat 0 (0)
+1	r1 = splat 40000000 (2)
+loop:
+2	    store32 ptr1 r0
+3	    store32 ptr2 r0
+4	    store32 ptr3 r0
+5	    store32 ptr4 r1
diff --git a/tests/sksl/runtime/GlobalVariables.stage b/tests/sksl/runtime/GlobalVariables.stage
new file mode 100644
index 0000000..2e48474
--- /dev/null
+++ b/tests/sksl/runtime/GlobalVariables.stage
@@ -0,0 +1,9 @@
+void init_globals()
+{
+	gUninitialized = gInitialized + 2.0;
+}
+float4 main()
+{
+	init_globals();
+	return half4(float4(0.0, -gInitialized, 0.0, gUninitialized));
+}