Add golden outputs for the Metal backend.
This CL also updates the blend tests to use sk_FragColor instead of returning a half4, as the Metal backend assumes that a fragment processor's `main` will return void and always synthesizes a `return *_out;` at the end. (context link: https://osscs.corp.google.com/android/platform/superproject/+/master:external/skqp/src/sksl/SkSLMetalCodeGenerator.cpp;l=803;drc=842d31b14159626054e01dd32826563a8f4214bf ) BYPASS_INCLUSIVE_LANGUAGE_REASON=see http://b/168134166 Change-Id: I330a456bf25ee72d3a29c59cd624625378ae80a0 Bug: skia:10649, skia:10757, skia:10758, skia:10759, skia:10760, skia:10761, skia:10762 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319409 Commit-Queue: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
3380be9588
commit
aeae3a58e3
12
BUILD.gn
12
BUILD.gn
@ -732,6 +732,15 @@ if (skia_compile_sksl_tests) {
|
||||
lang = "--glsl"
|
||||
settings = "--nosettings"
|
||||
}
|
||||
compile_sksl("metal_tests") {
|
||||
sources = sksl_metal_tests_sources
|
||||
outputPatterns = [ [
|
||||
"/golden/",
|
||||
".metal",
|
||||
] ]
|
||||
lang = "--metal"
|
||||
settings = "--settings"
|
||||
}
|
||||
} else {
|
||||
group("compile_sksl_fp_tests") {
|
||||
}
|
||||
@ -739,6 +748,8 @@ if (skia_compile_sksl_tests) {
|
||||
}
|
||||
group("compile_sksl_glsl_nosettings_tests") {
|
||||
}
|
||||
group("compile_sksl_metal_tests") {
|
||||
}
|
||||
}
|
||||
|
||||
optional("gpu") {
|
||||
@ -748,6 +759,7 @@ optional("gpu") {
|
||||
":compile_sksl_fp_tests",
|
||||
":compile_sksl_glsl_nosettings_tests",
|
||||
":compile_sksl_glsl_tests",
|
||||
":compile_sksl_metal_tests",
|
||||
":dehydrate_sksl",
|
||||
":run_sksllex",
|
||||
]
|
||||
|
@ -64,5 +64,7 @@ for input in inputs:
|
||||
makeEmptyFile(target + ".h")
|
||||
elif lang == "--glsl":
|
||||
compile(skslc, input, target, ".glsl")
|
||||
elif lang == "--metal":
|
||||
compile(skslc, input, target, ".metal")
|
||||
else:
|
||||
sys.exit("### Expected one of: --fp --glsl, got " + lang)
|
||||
sys.exit("### Expected one of: --fp --glsl --metal, got " + lang)
|
||||
|
@ -133,6 +133,7 @@ sksl_error_tests = [
|
||||
sksl_glsl_tests = [
|
||||
"$_tests/sksl/glsl/ForceHighPrecision.sksl",
|
||||
"$_tests/sksl/glsl/IncompleteShortIntPrecision.sksl",
|
||||
"$_tests/sksl/glsl/LayoutQualifiers.sksl",
|
||||
"$_tests/sksl/glsl/ShortIntPrecision.sksl",
|
||||
"$_tests/sksl/glsl/TextureSharpenVersion110.sksl",
|
||||
"$_tests/sksl/glsl/TextureVersion110.sksl",
|
||||
@ -184,7 +185,6 @@ sksl_shared_tests = [
|
||||
"$_tests/sksl/shared/InterfaceBlockNamed.sksl",
|
||||
"$_tests/sksl/shared/Matrices.sksl",
|
||||
"$_tests/sksl/shared/MatrixFolding.sksl",
|
||||
"$_tests/sksl/shared/ModifiersDeclaration.sksl",
|
||||
"$_tests/sksl/shared/MultipleAssignments.sksl",
|
||||
"$_tests/sksl/shared/NegatedVectorLiteral.sksl",
|
||||
"$_tests/sksl/shared/NoFragCoordsPos.vert",
|
||||
@ -326,3 +326,7 @@ sksl_glsl_tests_sources =
|
||||
# Tests in sksl_glsl_settings_tests_sources will be compiled twice, once with --settings and once
|
||||
# using --nosettings. In the latter mode, StandaloneSettings is appended to the output filename.
|
||||
sksl_glsl_settings_tests_sources = sksl_blend_tests + sksl_settings_tests
|
||||
|
||||
# Tests in sksl_metal_tests_sources will be compiled with --settings on, and are expected to
|
||||
# generate a .metal output file.
|
||||
sksl_metal_tests_sources = sksl_blend_tests + sksl_shared_tests
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_clear(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_clear(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_color(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_color(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_color_burn(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_color_burn(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_color_dodge(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_color_dodge(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_darken(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_darken(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_difference(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_difference(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_dst(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_dst(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_src_atop(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_src_atop(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_dst_in(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_dst_in(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_dst_out(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_dst_out(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_dst_over(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_dst_over(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_exclusion(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_exclusion(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_hard_light(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_hard_light(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_hue(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_hue(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_lighten(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_lighten(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_luminosity(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_luminosity(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_modulate(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_modulate(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_multiply(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_multiply(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_overlay(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_overlay(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_plus(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_plus(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_saturation(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_saturation(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_screen(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_screen(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_soft_light(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_soft_light(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_src(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_src(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_src_atop(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_src_atop(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_src_in(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_src_in(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_src_out(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_src_out(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_src_over(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_src_over(src, dst);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*#pragma settings Default*/
|
||||
|
||||
uniform half4 src, dst;
|
||||
in half4 src, dst;
|
||||
|
||||
half4 main() {
|
||||
return blend_xor(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_xor(src, dst);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_clear(vec4 src, vec4 dst) {
|
||||
return vec4(0.0);
|
||||
}
|
||||
vec4 main() {
|
||||
return vec4(0.0);
|
||||
void main() {
|
||||
sk_FragColor = vec4(0.0);
|
||||
|
||||
}
|
||||
|
20
tests/sksl/blend/golden/BlendClear.metal
Normal file
20
tests/sksl/blend/golden/BlendClear.metal
Normal file
@ -0,0 +1,20 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_clear(float4 src, float4 dst) {
|
||||
return float4(0.0);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor = float4(0.0);
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_clear(vec4 src, vec4 dst) {
|
||||
return vec4(0.0);
|
||||
}
|
||||
vec4 main() {
|
||||
return vec4(0.0);
|
||||
void main() {
|
||||
sk_FragColor = vec4(0.0);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -29,7 +30,7 @@ vec4 blend_color(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(sda, alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_color;
|
||||
{
|
||||
float _1_alpha = dst.w * src.w;
|
||||
@ -38,6 +39,6 @@ vec4 main() {
|
||||
_0_blend_color = vec4((((_blend_set_color_luminance(_2_sda, _1_alpha, _3_dsa) + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
|
||||
}
|
||||
|
||||
return _0_blend_color;
|
||||
sk_FragColor = _0_blend_color;
|
||||
|
||||
}
|
||||
|
54
tests/sksl/blend/golden/BlendColor.metal
Normal file
54
tests/sksl/blend/golden/BlendColor.metal
Normal file
@ -0,0 +1,54 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _blend_color_luminance(float3 color) {
|
||||
return dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
float3 _blend_set_color_luminance(float3 hueSatColor, float alpha, float3 lumColor) {
|
||||
float _4_blend_color_luminance;
|
||||
{
|
||||
_4_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), lumColor);
|
||||
}
|
||||
float lum = _4_blend_color_luminance;
|
||||
|
||||
float _5_blend_color_luminance;
|
||||
{
|
||||
_5_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), hueSatColor);
|
||||
}
|
||||
float3 result = (lum - _5_blend_color_luminance) + hueSatColor;
|
||||
|
||||
float minComp = min(min(result.x, result.y), result.z);
|
||||
float maxComp = max(max(result.x, result.y), result.z);
|
||||
if (minComp < 0.0 && lum != minComp) {
|
||||
result = lum + ((result - lum) * lum) / (lum - minComp);
|
||||
}
|
||||
return maxComp > alpha && maxComp != lum ? lum + ((result - lum) * (alpha - lum)) / (maxComp - lum) : result;
|
||||
}
|
||||
float4 blend_color(float4 src, float4 dst) {
|
||||
float alpha = dst.w * src.w;
|
||||
float3 sda = src.xyz * dst.w;
|
||||
float3 dsa = dst.xyz * src.w;
|
||||
return float4((((_blend_set_color_luminance(sda, alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_color;
|
||||
{
|
||||
float _1_alpha = _in.dst.w * _in.src.w;
|
||||
float3 _2_sda = _in.src.xyz * _in.dst.w;
|
||||
float3 _3_dsa = _in.dst.xyz * _in.src.w;
|
||||
_0_blend_color = float4((((_blend_set_color_luminance(_2_sda, _1_alpha, _3_dsa) + _in.dst.xyz) - _3_dsa) + _in.src.xyz) - _2_sda, (_in.src.w + _in.dst.w) - _1_alpha);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_color;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
@ -23,12 +24,12 @@ float _color_burn_component(vec2 s, vec2 d) {
|
||||
vec4 blend_color_burn(vec4 src, vec4 dst) {
|
||||
return vec4(_color_burn_component(src.xw, dst.xw), _color_burn_component(src.yw, dst.yw), _color_burn_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_color_burn;
|
||||
{
|
||||
_0_blend_color_burn = vec4(_color_burn_component(src.xw, dst.xw), _color_burn_component(src.yw, dst.yw), _color_burn_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_color_burn;
|
||||
sk_FragColor = _0_blend_color_burn;
|
||||
|
||||
}
|
||||
|
45
tests/sksl/blend/golden/BlendColorBurn.metal
Normal file
45
tests/sksl/blend/golden/BlendColorBurn.metal
Normal file
@ -0,0 +1,45 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
float _color_burn_component(float2 s, float2 d) {
|
||||
if (d.y == d.x) {
|
||||
return (s.y * d.y + s.x * (1.0 - d.y)) + d.x * (1.0 - s.y);
|
||||
} else if (s.x == 0.0) {
|
||||
return d.x * (1.0 - s.y);
|
||||
} else {
|
||||
float _1_guarded_divide;
|
||||
float _2_n = (d.y - d.x) * s.y;
|
||||
float _3_d = s.x;
|
||||
{
|
||||
_1_guarded_divide = _2_n / _3_d;
|
||||
}
|
||||
float delta = max(0.0, d.y - _1_guarded_divide);
|
||||
|
||||
return (delta * s.y + s.x * (1.0 - d.y)) + d.x * (1.0 - s.y);
|
||||
}
|
||||
}
|
||||
float4 blend_color_burn(float4 src, float4 dst) {
|
||||
return float4(_color_burn_component(src.xw, dst.xw), _color_burn_component(src.yw, dst.yw), _color_burn_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_color_burn;
|
||||
{
|
||||
_0_blend_color_burn = float4(_color_burn_component(_in.src.xw, _in.dst.xw), _color_burn_component(_in.src.yw, _in.dst.yw), _color_burn_component(_in.src.zw, _in.dst.zw), _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_color_burn;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
@ -23,12 +24,12 @@ float _color_burn_component(vec2 s, vec2 d) {
|
||||
vec4 blend_color_burn(vec4 src, vec4 dst) {
|
||||
return vec4(_color_burn_component(src.xw, dst.xw), _color_burn_component(src.yw, dst.yw), _color_burn_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_color_burn;
|
||||
{
|
||||
_0_blend_color_burn = vec4(_color_burn_component(src.xw, dst.xw), _color_burn_component(src.yw, dst.yw), _color_burn_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_color_burn;
|
||||
sk_FragColor = _0_blend_color_burn;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
@ -25,12 +26,12 @@ float _color_dodge_component(vec2 s, vec2 d) {
|
||||
vec4 blend_color_dodge(vec4 src, vec4 dst) {
|
||||
return vec4(_color_dodge_component(src.xw, dst.xw), _color_dodge_component(src.yw, dst.yw), _color_dodge_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_color_dodge;
|
||||
{
|
||||
_0_blend_color_dodge = vec4(_color_dodge_component(src.xw, dst.xw), _color_dodge_component(src.yw, dst.yw), _color_dodge_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_color_dodge;
|
||||
sk_FragColor = _0_blend_color_dodge;
|
||||
|
||||
}
|
||||
|
47
tests/sksl/blend/golden/BlendColorDodge.metal
Normal file
47
tests/sksl/blend/golden/BlendColorDodge.metal
Normal file
@ -0,0 +1,47 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
float _color_dodge_component(float2 s, float2 d) {
|
||||
if (d.x == 0.0) {
|
||||
return s.x * (1.0 - d.y);
|
||||
} else {
|
||||
float delta = s.y - s.x;
|
||||
if (delta == 0.0) {
|
||||
return (s.y * d.y + s.x * (1.0 - d.y)) + d.x * (1.0 - s.y);
|
||||
} else {
|
||||
float _1_guarded_divide;
|
||||
float _2_n = d.x * s.y;
|
||||
{
|
||||
_1_guarded_divide = _2_n / delta;
|
||||
}
|
||||
delta = min(d.y, _1_guarded_divide);
|
||||
|
||||
return (delta * s.y + s.x * (1.0 - d.y)) + d.x * (1.0 - s.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
float4 blend_color_dodge(float4 src, float4 dst) {
|
||||
return float4(_color_dodge_component(src.xw, dst.xw), _color_dodge_component(src.yw, dst.yw), _color_dodge_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_color_dodge;
|
||||
{
|
||||
_0_blend_color_dodge = float4(_color_dodge_component(_in.src.xw, _in.dst.xw), _color_dodge_component(_in.src.yw, _in.dst.yw), _color_dodge_component(_in.src.zw, _in.dst.zw), _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_color_dodge;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
@ -25,12 +26,12 @@ float _color_dodge_component(vec2 s, vec2 d) {
|
||||
vec4 blend_color_dodge(vec4 src, vec4 dst) {
|
||||
return vec4(_color_dodge_component(src.xw, dst.xw), _color_dodge_component(src.yw, dst.yw), _color_dodge_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_color_dodge;
|
||||
{
|
||||
_0_blend_color_dodge = vec4(_color_dodge_component(src.xw, dst.xw), _color_dodge_component(src.yw, dst.yw), _color_dodge_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_color_dodge;
|
||||
sk_FragColor = _0_blend_color_dodge;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -29,7 +30,7 @@ vec4 blend_color(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(sda, alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_color;
|
||||
{
|
||||
float _1_alpha = dst.w * src.w;
|
||||
@ -38,6 +39,6 @@ vec4 main() {
|
||||
_0_blend_color = vec4((((_blend_set_color_luminance(_2_sda, _1_alpha, _3_dsa) + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
|
||||
}
|
||||
|
||||
return _0_blend_color;
|
||||
sk_FragColor = _0_blend_color;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_over(vec4 src, vec4 dst) {
|
||||
return src + (1.0 - src.w) * dst;
|
||||
}
|
||||
@ -13,7 +14,7 @@ vec4 blend_darken(vec4 src, vec4 dst) {
|
||||
result.xyz = min(result.xyz, (1.0 - dst.w) * src.xyz + dst.xyz);
|
||||
return result;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_darken;
|
||||
{
|
||||
vec4 _3_blend_src_over;
|
||||
@ -26,6 +27,6 @@ vec4 main() {
|
||||
_0_blend_darken = _1_result;
|
||||
}
|
||||
|
||||
return _0_blend_darken;
|
||||
sk_FragColor = _0_blend_darken;
|
||||
|
||||
}
|
||||
|
42
tests/sksl/blend/golden/BlendDarken.metal
Normal file
42
tests/sksl/blend/golden/BlendDarken.metal
Normal file
@ -0,0 +1,42 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_src_over(float4 src, float4 dst) {
|
||||
return src + (1.0 - src.w) * dst;
|
||||
}
|
||||
float4 blend_darken(float4 src, float4 dst) {
|
||||
float4 _2_blend_src_over;
|
||||
{
|
||||
_2_blend_src_over = src + (1.0 - src.w) * dst;
|
||||
}
|
||||
float4 result = _2_blend_src_over;
|
||||
|
||||
result.xyz = min(result.xyz, (1.0 - dst.w) * src.xyz + dst.xyz);
|
||||
return result;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_darken;
|
||||
{
|
||||
float4 _3_blend_src_over;
|
||||
{
|
||||
_3_blend_src_over = _in.src + (1.0 - _in.src.w) * _in.dst;
|
||||
}
|
||||
float4 _1_result = _3_blend_src_over;
|
||||
|
||||
_1_result.xyz = min(_1_result.xyz, (1.0 - _in.dst.w) * _in.src.xyz + _in.dst.xyz);
|
||||
_0_blend_darken = _1_result;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_darken;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_over(vec4 src, vec4 dst) {
|
||||
return src + (1.0 - src.w) * dst;
|
||||
}
|
||||
@ -13,7 +14,7 @@ vec4 blend_darken(vec4 src, vec4 dst) {
|
||||
result.xyz = min(result.xyz, (1.0 - dst.w) * src.xyz + dst.xyz);
|
||||
return result;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_darken;
|
||||
{
|
||||
vec4 _3_blend_src_over;
|
||||
@ -26,6 +27,6 @@ vec4 main() {
|
||||
_0_blend_darken = _1_result;
|
||||
}
|
||||
|
||||
return _0_blend_darken;
|
||||
sk_FragColor = _0_blend_darken;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_difference(vec4 src, vec4 dst) {
|
||||
return vec4((src.xyz + dst.xyz) - 2.0 * min(src.xyz * dst.w, dst.xyz * src.w), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_difference;
|
||||
{
|
||||
_0_blend_difference = vec4((src.xyz + dst.xyz) - 2.0 * min(src.xyz * dst.w, dst.xyz * src.w), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_difference;
|
||||
sk_FragColor = _0_blend_difference;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendDifference.metal
Normal file
25
tests/sksl/blend/golden/BlendDifference.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_difference(float4 src, float4 dst) {
|
||||
return float4((src.xyz + dst.xyz) - 2.0 * min(src.xyz * dst.w, dst.xyz * src.w), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_difference;
|
||||
{
|
||||
_0_blend_difference = float4((_in.src.xyz + _in.dst.xyz) - 2.0 * min(_in.src.xyz * _in.dst.w, _in.dst.xyz * _in.src.w), _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_difference;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_difference(vec4 src, vec4 dst) {
|
||||
return vec4((src.xyz + dst.xyz) - 2.0 * min(src.xyz * dst.w, dst.xyz * src.w), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_difference;
|
||||
{
|
||||
_0_blend_difference = vec4((src.xyz + dst.xyz) - 2.0 * min(src.xyz * dst.w, dst.xyz * src.w), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_difference;
|
||||
sk_FragColor = _0_blend_difference;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_dst(vec4 src, vec4 dst) {
|
||||
return dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst;
|
||||
{
|
||||
_0_blend_dst = dst;
|
||||
}
|
||||
|
||||
return _0_blend_dst;
|
||||
sk_FragColor = _0_blend_dst;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendDst.metal
Normal file
25
tests/sksl/blend/golden/BlendDst.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_dst(float4 src, float4 dst) {
|
||||
return dst;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_dst;
|
||||
{
|
||||
_0_blend_dst = _in.dst;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_dst;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_atop(vec4 src, vec4 dst) {
|
||||
return dst.w * src + (1.0 - src.w) * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_src_atop;
|
||||
{
|
||||
_0_blend_src_atop = dst.w * src + (1.0 - src.w) * dst;
|
||||
}
|
||||
|
||||
return _0_blend_src_atop;
|
||||
sk_FragColor = _0_blend_src_atop;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendDstAtop.metal
Normal file
25
tests/sksl/blend/golden/BlendDstAtop.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_src_atop(float4 src, float4 dst) {
|
||||
return dst.w * src + (1.0 - src.w) * dst;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_src_atop;
|
||||
{
|
||||
_0_blend_src_atop = _in.dst.w * _in.src + (1.0 - _in.src.w) * _in.dst;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_src_atop;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_atop(vec4 src, vec4 dst) {
|
||||
return dst.w * src + (1.0 - src.w) * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_src_atop;
|
||||
{
|
||||
_0_blend_src_atop = dst.w * src + (1.0 - src.w) * dst;
|
||||
}
|
||||
|
||||
return _0_blend_src_atop;
|
||||
sk_FragColor = _0_blend_src_atop;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_in(vec4 src, vec4 dst) {
|
||||
return src * dst.w;
|
||||
}
|
||||
@ -11,7 +12,7 @@ vec4 blend_dst_in(vec4 src, vec4 dst) {
|
||||
return _1_blend_src_in;
|
||||
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst_in;
|
||||
{
|
||||
vec4 _2_blend_src_in;
|
||||
@ -22,6 +23,6 @@ vec4 main() {
|
||||
|
||||
}
|
||||
|
||||
return _0_blend_dst_in;
|
||||
sk_FragColor = _0_blend_dst_in;
|
||||
|
||||
}
|
||||
|
38
tests/sksl/blend/golden/BlendDstIn.metal
Normal file
38
tests/sksl/blend/golden/BlendDstIn.metal
Normal file
@ -0,0 +1,38 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_src_in(float4 src, float4 dst) {
|
||||
return src * dst.w;
|
||||
}
|
||||
float4 blend_dst_in(float4 src, float4 dst) {
|
||||
float4 _1_blend_src_in;
|
||||
{
|
||||
_1_blend_src_in = dst * src.w;
|
||||
}
|
||||
return _1_blend_src_in;
|
||||
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_dst_in;
|
||||
{
|
||||
float4 _2_blend_src_in;
|
||||
{
|
||||
_2_blend_src_in = _in.dst * _in.src.w;
|
||||
}
|
||||
_0_blend_dst_in = _2_blend_src_in;
|
||||
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_dst_in;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_in(vec4 src, vec4 dst) {
|
||||
return src * dst.w;
|
||||
}
|
||||
@ -11,7 +12,7 @@ vec4 blend_dst_in(vec4 src, vec4 dst) {
|
||||
return _1_blend_src_in;
|
||||
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst_in;
|
||||
{
|
||||
vec4 _2_blend_src_in;
|
||||
@ -22,6 +23,6 @@ vec4 main() {
|
||||
|
||||
}
|
||||
|
||||
return _0_blend_dst_in;
|
||||
sk_FragColor = _0_blend_dst_in;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_dst_out(vec4 src, vec4 dst) {
|
||||
return (1.0 - src.w) * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst_out;
|
||||
{
|
||||
_0_blend_dst_out = (1.0 - src.w) * dst;
|
||||
}
|
||||
|
||||
return _0_blend_dst_out;
|
||||
sk_FragColor = _0_blend_dst_out;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendDstOut.metal
Normal file
25
tests/sksl/blend/golden/BlendDstOut.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_dst_out(float4 src, float4 dst) {
|
||||
return (1.0 - src.w) * dst;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_dst_out;
|
||||
{
|
||||
_0_blend_dst_out = (1.0 - _in.src.w) * _in.dst;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_dst_out;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_dst_out(vec4 src, vec4 dst) {
|
||||
return (1.0 - src.w) * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst_out;
|
||||
{
|
||||
_0_blend_dst_out = (1.0 - src.w) * dst;
|
||||
}
|
||||
|
||||
return _0_blend_dst_out;
|
||||
sk_FragColor = _0_blend_dst_out;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_dst_over(vec4 src, vec4 dst) {
|
||||
return (1.0 - dst.w) * src + dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst_over;
|
||||
{
|
||||
_0_blend_dst_over = (1.0 - dst.w) * src + dst;
|
||||
}
|
||||
|
||||
return _0_blend_dst_over;
|
||||
sk_FragColor = _0_blend_dst_over;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendDstOver.metal
Normal file
25
tests/sksl/blend/golden/BlendDstOver.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_dst_over(float4 src, float4 dst) {
|
||||
return (1.0 - dst.w) * src + dst;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_dst_over;
|
||||
{
|
||||
_0_blend_dst_over = (1.0 - _in.dst.w) * _in.src + _in.dst;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_dst_over;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_dst_over(vec4 src, vec4 dst) {
|
||||
return (1.0 - dst.w) * src + dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst_over;
|
||||
{
|
||||
_0_blend_dst_over = (1.0 - dst.w) * src + dst;
|
||||
}
|
||||
|
||||
return _0_blend_dst_over;
|
||||
sk_FragColor = _0_blend_dst_over;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_dst(vec4 src, vec4 dst) {
|
||||
return dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_dst;
|
||||
{
|
||||
_0_blend_dst = dst;
|
||||
}
|
||||
|
||||
return _0_blend_dst;
|
||||
sk_FragColor = _0_blend_dst;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_exclusion(vec4 src, vec4 dst) {
|
||||
return vec4((dst.xyz + src.xyz) - (2.0 * dst.xyz) * src.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_exclusion;
|
||||
{
|
||||
_0_blend_exclusion = vec4((dst.xyz + src.xyz) - (2.0 * dst.xyz) * src.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_exclusion;
|
||||
sk_FragColor = _0_blend_exclusion;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendExclusion.metal
Normal file
25
tests/sksl/blend/golden/BlendExclusion.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_exclusion(float4 src, float4 dst) {
|
||||
return float4((dst.xyz + src.xyz) - (2.0 * dst.xyz) * src.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_exclusion;
|
||||
{
|
||||
_0_blend_exclusion = float4((_in.dst.xyz + _in.src.xyz) - (2.0 * _in.dst.xyz) * _in.src.xyz, _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_exclusion;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_exclusion(vec4 src, vec4 dst) {
|
||||
return vec4((dst.xyz + src.xyz) - (2.0 * dst.xyz) * src.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_exclusion;
|
||||
{
|
||||
_0_blend_exclusion = vec4((dst.xyz + src.xyz) - (2.0 * dst.xyz) * src.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_exclusion;
|
||||
sk_FragColor = _0_blend_exclusion;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_overlay_component(vec2 s, vec2 d) {
|
||||
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
||||
}
|
||||
@ -32,12 +33,12 @@ vec4 blend_overlay(vec4 src, vec4 dst) {
|
||||
vec4 blend_hard_light(vec4 src, vec4 dst) {
|
||||
return blend_overlay(dst, src);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_hard_light;
|
||||
{
|
||||
_0_blend_hard_light = blend_overlay(dst, src);
|
||||
}
|
||||
|
||||
return _0_blend_hard_light;
|
||||
sk_FragColor = _0_blend_hard_light;
|
||||
|
||||
}
|
||||
|
54
tests/sksl/blend/golden/BlendHardLight.metal
Normal file
54
tests/sksl/blend/golden/BlendHardLight.metal
Normal file
@ -0,0 +1,54 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _blend_overlay_component(float2 s, float2 d) {
|
||||
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
||||
}
|
||||
float4 blend_overlay(float4 src, float4 dst) {
|
||||
float _1_blend_overlay_component;
|
||||
float2 _2_s = src.xw;
|
||||
float2 _3_d = dst.xw;
|
||||
{
|
||||
_1_blend_overlay_component = 2.0 * _3_d.x <= _3_d.y ? (2.0 * _2_s.x) * _3_d.x : _2_s.y * _3_d.y - (2.0 * (_3_d.y - _3_d.x)) * (_2_s.y - _2_s.x);
|
||||
}
|
||||
float _4_blend_overlay_component;
|
||||
float2 _5_s = src.yw;
|
||||
float2 _6_d = dst.yw;
|
||||
{
|
||||
_4_blend_overlay_component = 2.0 * _6_d.x <= _6_d.y ? (2.0 * _5_s.x) * _6_d.x : _5_s.y * _6_d.y - (2.0 * (_6_d.y - _6_d.x)) * (_5_s.y - _5_s.x);
|
||||
}
|
||||
float _7_blend_overlay_component;
|
||||
float2 _8_s = src.zw;
|
||||
float2 _9_d = dst.zw;
|
||||
{
|
||||
_7_blend_overlay_component = 2.0 * _9_d.x <= _9_d.y ? (2.0 * _8_s.x) * _9_d.x : _8_s.y * _9_d.y - (2.0 * (_9_d.y - _9_d.x)) * (_8_s.y - _8_s.x);
|
||||
}
|
||||
float4 result = float4(_1_blend_overlay_component, _4_blend_overlay_component, _7_blend_overlay_component, src.w + (1.0 - src.w) * dst.w);
|
||||
|
||||
|
||||
|
||||
result.xyz = result.xyz + dst.xyz * (1.0 - src.w) + src.xyz * (1.0 - dst.w);
|
||||
return result;
|
||||
}
|
||||
float4 blend_hard_light(float4 src, float4 dst) {
|
||||
return blend_overlay(dst, src);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_hard_light;
|
||||
{
|
||||
_0_blend_hard_light = blend_overlay(_in.dst, _in.src);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_hard_light;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_overlay_component(vec2 s, vec2 d) {
|
||||
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
||||
}
|
||||
@ -32,12 +33,12 @@ vec4 blend_overlay(vec4 src, vec4 dst) {
|
||||
vec4 blend_hard_light(vec4 src, vec4 dst) {
|
||||
return blend_overlay(dst, src);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_hard_light;
|
||||
{
|
||||
_0_blend_hard_light = blend_overlay(dst, src);
|
||||
}
|
||||
|
||||
return _0_blend_hard_light;
|
||||
sk_FragColor = _0_blend_hard_light;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -94,6 +95,6 @@ vec4 blend_hue(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(_blend_set_color_saturation(sda, dsa), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
return blend_hue(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_hue(src, dst);
|
||||
}
|
||||
|
110
tests/sksl/blend/golden/BlendHue.metal
Normal file
110
tests/sksl/blend/golden/BlendHue.metal
Normal file
@ -0,0 +1,110 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _blend_color_luminance(float3 color) {
|
||||
return dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
float3 _blend_set_color_luminance(float3 hueSatColor, float alpha, float3 lumColor) {
|
||||
float _0_blend_color_luminance;
|
||||
{
|
||||
_0_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), lumColor);
|
||||
}
|
||||
float lum = _0_blend_color_luminance;
|
||||
|
||||
float _1_blend_color_luminance;
|
||||
{
|
||||
_1_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), hueSatColor);
|
||||
}
|
||||
float3 result = (lum - _1_blend_color_luminance) + hueSatColor;
|
||||
|
||||
float minComp = min(min(result.x, result.y), result.z);
|
||||
float maxComp = max(max(result.x, result.y), result.z);
|
||||
if (minComp < 0.0 && lum != minComp) {
|
||||
result = lum + ((result - lum) * lum) / (lum - minComp);
|
||||
}
|
||||
return maxComp > alpha && maxComp != lum ? lum + ((result - lum) * (alpha - lum)) / (maxComp - lum) : result;
|
||||
}
|
||||
float _blend_color_saturation(float3 color) {
|
||||
return max(max(color.x, color.y), color.z) - min(min(color.x, color.y), color.z);
|
||||
}
|
||||
float3 _blend_set_color_saturation_helper(float3 minMidMax, float sat) {
|
||||
return minMidMax.x < minMidMax.z ? float3(0.0, (sat * (minMidMax.y - minMidMax.x)) / (minMidMax.z - minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
float3 _blend_set_color_saturation(float3 hueLumColor, float3 satColor) {
|
||||
float _2_blend_color_saturation;
|
||||
{
|
||||
_2_blend_color_saturation = max(max(satColor.x, satColor.y), satColor.z) - min(min(satColor.x, satColor.y), satColor.z);
|
||||
}
|
||||
float sat = _2_blend_color_saturation;
|
||||
|
||||
if (hueLumColor.x <= hueLumColor.y) {
|
||||
if (hueLumColor.y <= hueLumColor.z) {
|
||||
float3 _3_blend_set_color_saturation_helper;
|
||||
{
|
||||
_3_blend_set_color_saturation_helper = hueLumColor.x < hueLumColor.z ? float3(0.0, (sat * (hueLumColor.y - hueLumColor.x)) / (hueLumColor.z - hueLumColor.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.xyz = _3_blend_set_color_saturation_helper;
|
||||
|
||||
} else if (hueLumColor.x <= hueLumColor.z) {
|
||||
float3 _4_blend_set_color_saturation_helper;
|
||||
float3 _5_minMidMax = hueLumColor.xzy;
|
||||
{
|
||||
_4_blend_set_color_saturation_helper = _5_minMidMax.x < _5_minMidMax.z ? float3(0.0, (sat * (_5_minMidMax.y - _5_minMidMax.x)) / (_5_minMidMax.z - _5_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.xzy = _4_blend_set_color_saturation_helper;
|
||||
|
||||
} else {
|
||||
float3 _6_blend_set_color_saturation_helper;
|
||||
float3 _7_minMidMax = hueLumColor.zxy;
|
||||
{
|
||||
_6_blend_set_color_saturation_helper = _7_minMidMax.x < _7_minMidMax.z ? float3(0.0, (sat * (_7_minMidMax.y - _7_minMidMax.x)) / (_7_minMidMax.z - _7_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.zxy = _6_blend_set_color_saturation_helper;
|
||||
|
||||
}
|
||||
} else if (hueLumColor.x <= hueLumColor.z) {
|
||||
float3 _8_blend_set_color_saturation_helper;
|
||||
float3 _9_minMidMax = hueLumColor.yxz;
|
||||
{
|
||||
_8_blend_set_color_saturation_helper = _9_minMidMax.x < _9_minMidMax.z ? float3(0.0, (sat * (_9_minMidMax.y - _9_minMidMax.x)) / (_9_minMidMax.z - _9_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.yxz = _8_blend_set_color_saturation_helper;
|
||||
|
||||
} else if (hueLumColor.y <= hueLumColor.z) {
|
||||
float3 _10_blend_set_color_saturation_helper;
|
||||
float3 _11_minMidMax = hueLumColor.yzx;
|
||||
{
|
||||
_10_blend_set_color_saturation_helper = _11_minMidMax.x < _11_minMidMax.z ? float3(0.0, (sat * (_11_minMidMax.y - _11_minMidMax.x)) / (_11_minMidMax.z - _11_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.yzx = _10_blend_set_color_saturation_helper;
|
||||
|
||||
} else {
|
||||
float3 _12_blend_set_color_saturation_helper;
|
||||
float3 _13_minMidMax = hueLumColor.zyx;
|
||||
{
|
||||
_12_blend_set_color_saturation_helper = _13_minMidMax.x < _13_minMidMax.z ? float3(0.0, (sat * (_13_minMidMax.y - _13_minMidMax.x)) / (_13_minMidMax.z - _13_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.zyx = _12_blend_set_color_saturation_helper;
|
||||
|
||||
}
|
||||
return hueLumColor;
|
||||
}
|
||||
float4 blend_hue(float4 src, float4 dst) {
|
||||
float alpha = dst.w * src.w;
|
||||
float3 sda = src.xyz * dst.w;
|
||||
float3 dsa = dst.xyz * src.w;
|
||||
return float4((((_blend_set_color_luminance(_blend_set_color_saturation(sda, dsa), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor = blend_hue(_in.src, _in.dst);
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -94,6 +95,6 @@ vec4 blend_hue(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(_blend_set_color_saturation(sda, dsa), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
return blend_hue(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_hue(src, dst);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_over(vec4 src, vec4 dst) {
|
||||
return src + (1.0 - src.w) * dst;
|
||||
}
|
||||
@ -13,7 +14,7 @@ vec4 blend_lighten(vec4 src, vec4 dst) {
|
||||
result.xyz = max(result.xyz, (1.0 - dst.w) * src.xyz + dst.xyz);
|
||||
return result;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_lighten;
|
||||
{
|
||||
vec4 _3_blend_src_over;
|
||||
@ -26,6 +27,6 @@ vec4 main() {
|
||||
_0_blend_lighten = _1_result;
|
||||
}
|
||||
|
||||
return _0_blend_lighten;
|
||||
sk_FragColor = _0_blend_lighten;
|
||||
|
||||
}
|
||||
|
42
tests/sksl/blend/golden/BlendLighten.metal
Normal file
42
tests/sksl/blend/golden/BlendLighten.metal
Normal file
@ -0,0 +1,42 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_src_over(float4 src, float4 dst) {
|
||||
return src + (1.0 - src.w) * dst;
|
||||
}
|
||||
float4 blend_lighten(float4 src, float4 dst) {
|
||||
float4 _2_blend_src_over;
|
||||
{
|
||||
_2_blend_src_over = src + (1.0 - src.w) * dst;
|
||||
}
|
||||
float4 result = _2_blend_src_over;
|
||||
|
||||
result.xyz = max(result.xyz, (1.0 - dst.w) * src.xyz + dst.xyz);
|
||||
return result;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_lighten;
|
||||
{
|
||||
float4 _3_blend_src_over;
|
||||
{
|
||||
_3_blend_src_over = _in.src + (1.0 - _in.src.w) * _in.dst;
|
||||
}
|
||||
float4 _1_result = _3_blend_src_over;
|
||||
|
||||
_1_result.xyz = max(_1_result.xyz, (1.0 - _in.dst.w) * _in.src.xyz + _in.dst.xyz);
|
||||
_0_blend_lighten = _1_result;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_lighten;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_src_over(vec4 src, vec4 dst) {
|
||||
return src + (1.0 - src.w) * dst;
|
||||
}
|
||||
@ -13,7 +14,7 @@ vec4 blend_lighten(vec4 src, vec4 dst) {
|
||||
result.xyz = max(result.xyz, (1.0 - dst.w) * src.xyz + dst.xyz);
|
||||
return result;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_lighten;
|
||||
{
|
||||
vec4 _3_blend_src_over;
|
||||
@ -26,6 +27,6 @@ vec4 main() {
|
||||
_0_blend_lighten = _1_result;
|
||||
}
|
||||
|
||||
return _0_blend_lighten;
|
||||
sk_FragColor = _0_blend_lighten;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -29,7 +30,7 @@ vec4 blend_luminosity(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(dsa, alpha, sda) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_luminosity;
|
||||
{
|
||||
float _1_alpha = dst.w * src.w;
|
||||
@ -38,6 +39,6 @@ vec4 main() {
|
||||
_0_blend_luminosity = vec4((((_blend_set_color_luminance(_3_dsa, _1_alpha, _2_sda) + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
|
||||
}
|
||||
|
||||
return _0_blend_luminosity;
|
||||
sk_FragColor = _0_blend_luminosity;
|
||||
|
||||
}
|
||||
|
54
tests/sksl/blend/golden/BlendLuminosity.metal
Normal file
54
tests/sksl/blend/golden/BlendLuminosity.metal
Normal file
@ -0,0 +1,54 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _blend_color_luminance(float3 color) {
|
||||
return dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
float3 _blend_set_color_luminance(float3 hueSatColor, float alpha, float3 lumColor) {
|
||||
float _4_blend_color_luminance;
|
||||
{
|
||||
_4_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), lumColor);
|
||||
}
|
||||
float lum = _4_blend_color_luminance;
|
||||
|
||||
float _5_blend_color_luminance;
|
||||
{
|
||||
_5_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), hueSatColor);
|
||||
}
|
||||
float3 result = (lum - _5_blend_color_luminance) + hueSatColor;
|
||||
|
||||
float minComp = min(min(result.x, result.y), result.z);
|
||||
float maxComp = max(max(result.x, result.y), result.z);
|
||||
if (minComp < 0.0 && lum != minComp) {
|
||||
result = lum + ((result - lum) * lum) / (lum - minComp);
|
||||
}
|
||||
return maxComp > alpha && maxComp != lum ? lum + ((result - lum) * (alpha - lum)) / (maxComp - lum) : result;
|
||||
}
|
||||
float4 blend_luminosity(float4 src, float4 dst) {
|
||||
float alpha = dst.w * src.w;
|
||||
float3 sda = src.xyz * dst.w;
|
||||
float3 dsa = dst.xyz * src.w;
|
||||
return float4((((_blend_set_color_luminance(dsa, alpha, sda) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_luminosity;
|
||||
{
|
||||
float _1_alpha = _in.dst.w * _in.src.w;
|
||||
float3 _2_sda = _in.src.xyz * _in.dst.w;
|
||||
float3 _3_dsa = _in.dst.xyz * _in.src.w;
|
||||
_0_blend_luminosity = float4((((_blend_set_color_luminance(_3_dsa, _1_alpha, _2_sda) + _in.dst.xyz) - _3_dsa) + _in.src.xyz) - _2_sda, (_in.src.w + _in.dst.w) - _1_alpha);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_luminosity;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -29,7 +30,7 @@ vec4 blend_luminosity(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(dsa, alpha, sda) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_luminosity;
|
||||
{
|
||||
float _1_alpha = dst.w * src.w;
|
||||
@ -38,6 +39,6 @@ vec4 main() {
|
||||
_0_blend_luminosity = vec4((((_blend_set_color_luminance(_3_dsa, _1_alpha, _2_sda) + dst.xyz) - _3_dsa) + src.xyz) - _2_sda, (src.w + dst.w) - _1_alpha);
|
||||
}
|
||||
|
||||
return _0_blend_luminosity;
|
||||
sk_FragColor = _0_blend_luminosity;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_modulate(vec4 src, vec4 dst) {
|
||||
return src * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_modulate;
|
||||
{
|
||||
_0_blend_modulate = src * dst;
|
||||
}
|
||||
|
||||
return _0_blend_modulate;
|
||||
sk_FragColor = _0_blend_modulate;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendModulate.metal
Normal file
25
tests/sksl/blend/golden/BlendModulate.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_modulate(float4 src, float4 dst) {
|
||||
return src * dst;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_modulate;
|
||||
{
|
||||
_0_blend_modulate = _in.src * _in.dst;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_modulate;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_modulate(vec4 src, vec4 dst) {
|
||||
return src * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_modulate;
|
||||
{
|
||||
_0_blend_modulate = src * dst;
|
||||
}
|
||||
|
||||
return _0_blend_modulate;
|
||||
sk_FragColor = _0_blend_modulate;
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_multiply(vec4 src, vec4 dst) {
|
||||
return vec4(((1.0 - src.w) * dst.xyz + (1.0 - dst.w) * src.xyz) + src.xyz * dst.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_multiply;
|
||||
{
|
||||
_0_blend_multiply = vec4(((1.0 - src.w) * dst.xyz + (1.0 - dst.w) * src.xyz) + src.xyz * dst.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_multiply;
|
||||
sk_FragColor = _0_blend_multiply;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendMultiply.metal
Normal file
25
tests/sksl/blend/golden/BlendMultiply.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_multiply(float4 src, float4 dst) {
|
||||
return float4(((1.0 - src.w) * dst.xyz + (1.0 - dst.w) * src.xyz) + src.xyz * dst.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_multiply;
|
||||
{
|
||||
_0_blend_multiply = float4(((1.0 - _in.src.w) * _in.dst.xyz + (1.0 - _in.dst.w) * _in.src.xyz) + _in.src.xyz * _in.dst.xyz, _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_multiply;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_multiply(vec4 src, vec4 dst) {
|
||||
return vec4(((1.0 - src.w) * dst.xyz + (1.0 - dst.w) * src.xyz) + src.xyz * dst.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_multiply;
|
||||
{
|
||||
_0_blend_multiply = vec4(((1.0 - src.w) * dst.xyz + (1.0 - dst.w) * src.xyz) + src.xyz * dst.xyz, src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_multiply;
|
||||
sk_FragColor = _0_blend_multiply;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_overlay_component(vec2 s, vec2 d) {
|
||||
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
||||
}
|
||||
@ -29,6 +30,6 @@ vec4 blend_overlay(vec4 src, vec4 dst) {
|
||||
result.xyz += dst.xyz * (1.0 - src.w) + src.xyz * (1.0 - dst.w);
|
||||
return result;
|
||||
}
|
||||
vec4 main() {
|
||||
return blend_overlay(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_overlay(src, dst);
|
||||
}
|
||||
|
45
tests/sksl/blend/golden/BlendOverlap.metal
Normal file
45
tests/sksl/blend/golden/BlendOverlap.metal
Normal file
@ -0,0 +1,45 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _blend_overlay_component(float2 s, float2 d) {
|
||||
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
||||
}
|
||||
float4 blend_overlay(float4 src, float4 dst) {
|
||||
float _0_blend_overlay_component;
|
||||
float2 _1_s = src.xw;
|
||||
float2 _2_d = dst.xw;
|
||||
{
|
||||
_0_blend_overlay_component = 2.0 * _2_d.x <= _2_d.y ? (2.0 * _1_s.x) * _2_d.x : _1_s.y * _2_d.y - (2.0 * (_2_d.y - _2_d.x)) * (_1_s.y - _1_s.x);
|
||||
}
|
||||
float _3_blend_overlay_component;
|
||||
float2 _4_s = src.yw;
|
||||
float2 _5_d = dst.yw;
|
||||
{
|
||||
_3_blend_overlay_component = 2.0 * _5_d.x <= _5_d.y ? (2.0 * _4_s.x) * _5_d.x : _4_s.y * _5_d.y - (2.0 * (_5_d.y - _5_d.x)) * (_4_s.y - _4_s.x);
|
||||
}
|
||||
float _6_blend_overlay_component;
|
||||
float2 _7_s = src.zw;
|
||||
float2 _8_d = dst.zw;
|
||||
{
|
||||
_6_blend_overlay_component = 2.0 * _8_d.x <= _8_d.y ? (2.0 * _7_s.x) * _8_d.x : _7_s.y * _8_d.y - (2.0 * (_8_d.y - _8_d.x)) * (_7_s.y - _7_s.x);
|
||||
}
|
||||
float4 result = float4(_0_blend_overlay_component, _3_blend_overlay_component, _6_blend_overlay_component, src.w + (1.0 - src.w) * dst.w);
|
||||
|
||||
|
||||
|
||||
result.xyz = result.xyz + dst.xyz * (1.0 - src.w) + src.xyz * (1.0 - dst.w);
|
||||
return result;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor = blend_overlay(_in.src, _in.dst);
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_overlay_component(vec2 s, vec2 d) {
|
||||
return 2.0 * d.x <= d.y ? (2.0 * s.x) * d.x : s.y * d.y - (2.0 * (d.y - d.x)) * (s.y - s.x);
|
||||
}
|
||||
@ -29,6 +30,6 @@ vec4 blend_overlay(vec4 src, vec4 dst) {
|
||||
result.xyz += dst.xyz * (1.0 - src.w) + src.xyz * (1.0 - dst.w);
|
||||
return result;
|
||||
}
|
||||
vec4 main() {
|
||||
return blend_overlay(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_overlay(src, dst);
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_plus(vec4 src, vec4 dst) {
|
||||
return min(src + dst, 1.0);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_plus;
|
||||
{
|
||||
_0_blend_plus = min(src + dst, 1.0);
|
||||
}
|
||||
|
||||
return _0_blend_plus;
|
||||
sk_FragColor = _0_blend_plus;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendPlus.metal
Normal file
25
tests/sksl/blend/golden/BlendPlus.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_plus(float4 src, float4 dst) {
|
||||
return min(src + dst, 1.0);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_plus;
|
||||
{
|
||||
_0_blend_plus = min(_in.src + _in.dst, 1.0);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_plus;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_plus(vec4 src, vec4 dst) {
|
||||
return min(src + dst, 1.0);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_plus;
|
||||
{
|
||||
_0_blend_plus = min(src + dst, 1.0);
|
||||
}
|
||||
|
||||
return _0_blend_plus;
|
||||
sk_FragColor = _0_blend_plus;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -94,6 +95,6 @@ vec4 blend_saturation(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(_blend_set_color_saturation(dsa, sda), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
return blend_saturation(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_saturation(src, dst);
|
||||
}
|
||||
|
110
tests/sksl/blend/golden/BlendSaturation.metal
Normal file
110
tests/sksl/blend/golden/BlendSaturation.metal
Normal file
@ -0,0 +1,110 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _blend_color_luminance(float3 color) {
|
||||
return dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
float3 _blend_set_color_luminance(float3 hueSatColor, float alpha, float3 lumColor) {
|
||||
float _0_blend_color_luminance;
|
||||
{
|
||||
_0_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), lumColor);
|
||||
}
|
||||
float lum = _0_blend_color_luminance;
|
||||
|
||||
float _1_blend_color_luminance;
|
||||
{
|
||||
_1_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), hueSatColor);
|
||||
}
|
||||
float3 result = (lum - _1_blend_color_luminance) + hueSatColor;
|
||||
|
||||
float minComp = min(min(result.x, result.y), result.z);
|
||||
float maxComp = max(max(result.x, result.y), result.z);
|
||||
if (minComp < 0.0 && lum != minComp) {
|
||||
result = lum + ((result - lum) * lum) / (lum - minComp);
|
||||
}
|
||||
return maxComp > alpha && maxComp != lum ? lum + ((result - lum) * (alpha - lum)) / (maxComp - lum) : result;
|
||||
}
|
||||
float _blend_color_saturation(float3 color) {
|
||||
return max(max(color.x, color.y), color.z) - min(min(color.x, color.y), color.z);
|
||||
}
|
||||
float3 _blend_set_color_saturation_helper(float3 minMidMax, float sat) {
|
||||
return minMidMax.x < minMidMax.z ? float3(0.0, (sat * (minMidMax.y - minMidMax.x)) / (minMidMax.z - minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
float3 _blend_set_color_saturation(float3 hueLumColor, float3 satColor) {
|
||||
float _2_blend_color_saturation;
|
||||
{
|
||||
_2_blend_color_saturation = max(max(satColor.x, satColor.y), satColor.z) - min(min(satColor.x, satColor.y), satColor.z);
|
||||
}
|
||||
float sat = _2_blend_color_saturation;
|
||||
|
||||
if (hueLumColor.x <= hueLumColor.y) {
|
||||
if (hueLumColor.y <= hueLumColor.z) {
|
||||
float3 _3_blend_set_color_saturation_helper;
|
||||
{
|
||||
_3_blend_set_color_saturation_helper = hueLumColor.x < hueLumColor.z ? float3(0.0, (sat * (hueLumColor.y - hueLumColor.x)) / (hueLumColor.z - hueLumColor.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.xyz = _3_blend_set_color_saturation_helper;
|
||||
|
||||
} else if (hueLumColor.x <= hueLumColor.z) {
|
||||
float3 _4_blend_set_color_saturation_helper;
|
||||
float3 _5_minMidMax = hueLumColor.xzy;
|
||||
{
|
||||
_4_blend_set_color_saturation_helper = _5_minMidMax.x < _5_minMidMax.z ? float3(0.0, (sat * (_5_minMidMax.y - _5_minMidMax.x)) / (_5_minMidMax.z - _5_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.xzy = _4_blend_set_color_saturation_helper;
|
||||
|
||||
} else {
|
||||
float3 _6_blend_set_color_saturation_helper;
|
||||
float3 _7_minMidMax = hueLumColor.zxy;
|
||||
{
|
||||
_6_blend_set_color_saturation_helper = _7_minMidMax.x < _7_minMidMax.z ? float3(0.0, (sat * (_7_minMidMax.y - _7_minMidMax.x)) / (_7_minMidMax.z - _7_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.zxy = _6_blend_set_color_saturation_helper;
|
||||
|
||||
}
|
||||
} else if (hueLumColor.x <= hueLumColor.z) {
|
||||
float3 _8_blend_set_color_saturation_helper;
|
||||
float3 _9_minMidMax = hueLumColor.yxz;
|
||||
{
|
||||
_8_blend_set_color_saturation_helper = _9_minMidMax.x < _9_minMidMax.z ? float3(0.0, (sat * (_9_minMidMax.y - _9_minMidMax.x)) / (_9_minMidMax.z - _9_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.yxz = _8_blend_set_color_saturation_helper;
|
||||
|
||||
} else if (hueLumColor.y <= hueLumColor.z) {
|
||||
float3 _10_blend_set_color_saturation_helper;
|
||||
float3 _11_minMidMax = hueLumColor.yzx;
|
||||
{
|
||||
_10_blend_set_color_saturation_helper = _11_minMidMax.x < _11_minMidMax.z ? float3(0.0, (sat * (_11_minMidMax.y - _11_minMidMax.x)) / (_11_minMidMax.z - _11_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.yzx = _10_blend_set_color_saturation_helper;
|
||||
|
||||
} else {
|
||||
float3 _12_blend_set_color_saturation_helper;
|
||||
float3 _13_minMidMax = hueLumColor.zyx;
|
||||
{
|
||||
_12_blend_set_color_saturation_helper = _13_minMidMax.x < _13_minMidMax.z ? float3(0.0, (sat * (_13_minMidMax.y - _13_minMidMax.x)) / (_13_minMidMax.z - _13_minMidMax.x), sat) : float3(0.0);
|
||||
}
|
||||
hueLumColor.zyx = _12_blend_set_color_saturation_helper;
|
||||
|
||||
}
|
||||
return hueLumColor;
|
||||
}
|
||||
float4 blend_saturation(float4 src, float4 dst) {
|
||||
float alpha = dst.w * src.w;
|
||||
float3 sda = src.xyz * dst.w;
|
||||
float3 dsa = dst.xyz * src.w;
|
||||
return float4((((_blend_set_color_luminance(_blend_set_color_saturation(dsa, sda), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
_out->sk_FragColor = blend_saturation(_in.src, _in.dst);
|
||||
return *_out;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _blend_color_luminance(vec3 color) {
|
||||
return dot(vec3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), color);
|
||||
}
|
||||
@ -94,6 +95,6 @@ vec4 blend_saturation(vec4 src, vec4 dst) {
|
||||
vec3 dsa = dst.xyz * src.w;
|
||||
return vec4((((_blend_set_color_luminance(_blend_set_color_saturation(dsa, sda), alpha, dsa) + dst.xyz) - dsa) + src.xyz) - sda, (src.w + dst.w) - alpha);
|
||||
}
|
||||
vec4 main() {
|
||||
return blend_saturation(src, dst);
|
||||
void main() {
|
||||
sk_FragColor = blend_saturation(src, dst);
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_screen(vec4 src, vec4 dst) {
|
||||
return src + (1.0 - src) * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_screen;
|
||||
{
|
||||
_0_blend_screen = src + (1.0 - src) * dst;
|
||||
}
|
||||
|
||||
return _0_blend_screen;
|
||||
sk_FragColor = _0_blend_screen;
|
||||
|
||||
}
|
||||
|
25
tests/sksl/blend/golden/BlendScreen.metal
Normal file
25
tests/sksl/blend/golden/BlendScreen.metal
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float4 blend_screen(float4 src, float4 dst) {
|
||||
return src + (1.0 - src) * dst;
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_screen;
|
||||
{
|
||||
_0_blend_screen = _in.src + (1.0 - _in.src) * _in.dst;
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_screen;
|
||||
|
||||
return *_out;
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
vec4 blend_screen(vec4 src, vec4 dst) {
|
||||
return src + (1.0 - src) * dst;
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_screen;
|
||||
{
|
||||
_0_blend_screen = src + (1.0 - src) * dst;
|
||||
}
|
||||
|
||||
return _0_blend_screen;
|
||||
sk_FragColor = _0_blend_screen;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#version 400
|
||||
uniform vec4 src, dst;
|
||||
out vec4 sk_FragColor;
|
||||
in vec4 src, dst;
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
@ -32,12 +33,12 @@ float _soft_light_component(vec2 s, vec2 d) {
|
||||
vec4 blend_soft_light(vec4 src, vec4 dst) {
|
||||
return dst.w == 0.0 ? src : vec4(_soft_light_component(src.xw, dst.xw), _soft_light_component(src.yw, dst.yw), _soft_light_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
vec4 main() {
|
||||
void main() {
|
||||
vec4 _0_blend_soft_light;
|
||||
{
|
||||
_0_blend_soft_light = dst.w == 0.0 ? src : vec4(_soft_light_component(src.xw, dst.xw), _soft_light_component(src.yw, dst.yw), _soft_light_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
|
||||
return _0_blend_soft_light;
|
||||
sk_FragColor = _0_blend_soft_light;
|
||||
|
||||
}
|
||||
|
54
tests/sksl/blend/golden/BlendSoftLight.metal
Normal file
54
tests/sksl/blend/golden/BlendSoftLight.metal
Normal file
@ -0,0 +1,54 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
using namespace metal;
|
||||
struct Inputs {
|
||||
float4 srcdst;
|
||||
};
|
||||
struct Outputs {
|
||||
float4 sk_FragColor [[color(0)]];
|
||||
};
|
||||
|
||||
float _guarded_divide(float n, float d) {
|
||||
return n / d;
|
||||
}
|
||||
float _soft_light_component(float2 s, float2 d) {
|
||||
if (2.0 * s.x <= s.y) {
|
||||
float _1_guarded_divide;
|
||||
float _2_n = (d.x * d.x) * (s.y - 2.0 * s.x);
|
||||
float _3_d = d.y;
|
||||
{
|
||||
_1_guarded_divide = _2_n / _3_d;
|
||||
}
|
||||
return (_1_guarded_divide + (1.0 - d.y) * s.x) + d.x * ((-s.y + 2.0 * s.x) + 1.0);
|
||||
|
||||
} else if (4.0 * d.x <= d.y) {
|
||||
float DSqd = d.x * d.x;
|
||||
float DCub = DSqd * d.x;
|
||||
float DaSqd = d.y * d.y;
|
||||
float DaCub = DaSqd * d.y;
|
||||
float _4_guarded_divide;
|
||||
float _5_n = ((DaSqd * (s.x - d.x * ((3.0 * s.y - 6.0 * s.x) - 1.0)) + ((12.0 * d.y) * DSqd) * (s.y - 2.0 * s.x)) - (16.0 * DCub) * (s.y - 2.0 * s.x)) - DaCub * s.x;
|
||||
{
|
||||
_4_guarded_divide = _5_n / DaSqd;
|
||||
}
|
||||
return _4_guarded_divide;
|
||||
|
||||
} else {
|
||||
return ((d.x * ((s.y - 2.0 * s.x) + 1.0) + s.x) - sqrt(d.y * d.x) * (s.y - 2.0 * s.x)) - d.y * s.x;
|
||||
}
|
||||
}
|
||||
float4 blend_soft_light(float4 src, float4 dst) {
|
||||
return dst.w == 0.0 ? src : float4(_soft_light_component(src.xw, dst.xw), _soft_light_component(src.yw, dst.yw), _soft_light_component(src.zw, dst.zw), src.w + (1.0 - src.w) * dst.w);
|
||||
}
|
||||
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
||||
Outputs _outputStruct;
|
||||
thread Outputs* _out = &_outputStruct;
|
||||
float4 _0_blend_soft_light;
|
||||
{
|
||||
_0_blend_soft_light = _in.dst.w == 0.0 ? _in.src : float4(_soft_light_component(_in.src.xw, _in.dst.xw), _soft_light_component(_in.src.yw, _in.dst.yw), _soft_light_component(_in.src.zw, _in.dst.zw), _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
||||
}
|
||||
|
||||
_out->sk_FragColor = _0_blend_soft_light;
|
||||
|
||||
return *_out;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user