From 06febefd7e54d25d09da445c0eadff92a242682b Mon Sep 17 00:00:00 2001 From: John Stiles Date: Sat, 26 Sep 2020 00:18:55 -0400 Subject: [PATCH] Add 'tricky' OutParams golden output. This was adapted from a test in SkSLInterpreterOutParams and presents a challenging double swizzle. Change-Id: Icb7b3bbb18d4b3cfa0c26acb524c08812ba88096 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319920 Commit-Queue: John Stiles Commit-Queue: Brian Osman Auto-Submit: John Stiles Reviewed-by: Brian Osman --- gn/sksl_tests.gni | 1 + tests/sksl/shared/OutParamsTricky.sksl | 13 ++++++++++ tests/sksl/shared/golden/OutParamsTricky.glsl | 15 ++++++++++++ .../sksl/shared/golden/OutParamsTricky.metal | 24 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 tests/sksl/shared/OutParamsTricky.sksl create mode 100644 tests/sksl/shared/golden/OutParamsTricky.glsl create mode 100644 tests/sksl/shared/golden/OutParamsTricky.metal diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni index fdf661853f..eacd6eee40 100644 --- a/gn/sksl_tests.gni +++ b/gn/sksl_tests.gni @@ -193,6 +193,7 @@ sksl_shared_tests = [ "$_tests/sksl/shared/Offset.sksl", "$_tests/sksl/shared/Operators.sksl", "$_tests/sksl/shared/OutParams.sksl", + "$_tests/sksl/shared/OutParamsTricky.sksl", "$_tests/sksl/shared/RectangleTexture.sksl", "$_tests/sksl/shared/ResizeMatrix.sksl", "$_tests/sksl/shared/SampleMask.sksl", diff --git a/tests/sksl/shared/OutParamsTricky.sksl b/tests/sksl/shared/OutParamsTricky.sksl new file mode 100644 index 0000000000..59926c2c4b --- /dev/null +++ b/tests/sksl/shared/OutParamsTricky.sksl @@ -0,0 +1,13 @@ +half2 tricky(half x, half y, inout half2 color, half z) { + color.xy = color.yx; + return half2(x + y, z); +} + +void func(inout half4 color) { + half2 t = tricky(1, 2, color.rb, 5); + color.ga = t; +} + +void main() { + func(sk_FragColor); +} diff --git a/tests/sksl/shared/golden/OutParamsTricky.glsl b/tests/sksl/shared/golden/OutParamsTricky.glsl new file mode 100644 index 0000000000..63138b1ca1 --- /dev/null +++ b/tests/sksl/shared/golden/OutParamsTricky.glsl @@ -0,0 +1,15 @@ + +out vec4 sk_FragColor; +void main() { + { + vec2 _5_3_color = sk_FragColor.xz; + { + _5_3_color.xy = _5_3_color.yx; + } + sk_FragColor.xz = _5_3_color; + + + sk_FragColor.yw = vec2(3.0, 5.0); + } + +} diff --git a/tests/sksl/shared/golden/OutParamsTricky.metal b/tests/sksl/shared/golden/OutParamsTricky.metal new file mode 100644 index 0000000000..fd99bea65a --- /dev/null +++ b/tests/sksl/shared/golden/OutParamsTricky.metal @@ -0,0 +1,24 @@ +#include +#include +using namespace metal; +struct Inputs { +}; +struct Outputs { + float4 sk_FragColor [[color(0)]]; +}; +fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) { + Outputs _outputStruct; + thread Outputs* _out = &_outputStruct; + { + float2 _5_3_color = _out->sk_FragColor.xz; + { + _5_3_color.xy = _5_3_color.yx; + } + _out->sk_FragColor.xz = _5_3_color; + + + _out->sk_FragColor.yw = float2(3.0, 5.0); + } + + return *_out; +}