From b41a1f9025c256e44aead913de6227a2e73e380a Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Wed, 17 Feb 2021 11:36:43 -0500 Subject: [PATCH] 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 Commit-Queue: Brian Osman --- gn/sksl_tests.gni | 1 + resources/sksl/runtime/GlobalVariables.rte | 13 +++++++++++++ tests/sksl/runtime/GlobalVariables.skvm | 8 ++++++++ tests/sksl/runtime/GlobalVariables.stage | 9 +++++++++ 4 files changed, 31 insertions(+) create mode 100644 resources/sksl/runtime/GlobalVariables.rte create mode 100644 tests/sksl/runtime/GlobalVariables.skvm create mode 100644 tests/sksl/runtime/GlobalVariables.stage diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni index 3fe11adcfd..470df5c25a 100644 --- a/gn/sksl_tests.gni +++ b/gn/sksl_tests.gni @@ -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", diff --git a/resources/sksl/runtime/GlobalVariables.rte b/resources/sksl/runtime/GlobalVariables.rte new file mode 100644 index 0000000000..7c1b1fc549 --- /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 0000000000..e02214766a --- /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 0000000000..2e484747ef --- /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)); +}