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>
This commit is contained in:
Brian Osman 2021-02-17 11:36:43 -05:00 committed by Skia Commit-Bot
parent 78a845aa19
commit b41a1f9025
4 changed files with 31 additions and 0 deletions

View File

@ -543,6 +543,7 @@ sksl_settings_tests = [
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",

View File

@ -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);
}

View File

@ -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

View File

@ -0,0 +1,9 @@
void init_globals()
{
gUninitialized = gInitialized + 2.0;
}
float4 main()
{
init_globals();
return half4(float4(0.0, -gInitialized, 0.0, gUninitialized));
}