skia2/tests/sksl/blend/golden/BlendHue.metal

106 lines
5.2 KiB
Metal
Raw Normal View History

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
float4 src;
float4 dst;
};
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;
float4 _0_blend_hue;
{
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;
float3 _4_blend_set_color_saturation;
float3 _5_hueLumColor = _2_sda;
{
float _6_17_blend_color_saturation;
{
_6_17_blend_color_saturation = max(max(_3_dsa.x, _3_dsa.y), _3_dsa.z) - min(min(_3_dsa.x, _3_dsa.y), _3_dsa.z);
}
float _7_sat = _6_17_blend_color_saturation;
if (_5_hueLumColor.x <= _5_hueLumColor.y) {
if (_5_hueLumColor.y <= _5_hueLumColor.z) {
float3 _8_18_blend_set_color_saturation_helper;
{
_8_18_blend_set_color_saturation_helper = _5_hueLumColor.x < _5_hueLumColor.z ? float3(0.0, (_7_sat * (_5_hueLumColor.y - _5_hueLumColor.x)) / (_5_hueLumColor.z - _5_hueLumColor.x), _7_sat) : float3(0.0);
}
_5_hueLumColor.xyz = _8_18_blend_set_color_saturation_helper;
} else if (_5_hueLumColor.x <= _5_hueLumColor.z) {
float3 _9_19_blend_set_color_saturation_helper;
{
_9_19_blend_set_color_saturation_helper = _5_hueLumColor.x < _5_hueLumColor.y ? float3(0.0, (_7_sat * (_5_hueLumColor.z - _5_hueLumColor.x)) / (_5_hueLumColor.y - _5_hueLumColor.x), _7_sat) : float3(0.0);
}
_5_hueLumColor.xzy = _9_19_blend_set_color_saturation_helper;
} else {
float3 _10_20_blend_set_color_saturation_helper;
{
_10_20_blend_set_color_saturation_helper = _5_hueLumColor.z < _5_hueLumColor.y ? float3(0.0, (_7_sat * (_5_hueLumColor.x - _5_hueLumColor.z)) / (_5_hueLumColor.y - _5_hueLumColor.z), _7_sat) : float3(0.0);
}
_5_hueLumColor.zxy = _10_20_blend_set_color_saturation_helper;
}
} else if (_5_hueLumColor.x <= _5_hueLumColor.z) {
float3 _11_21_blend_set_color_saturation_helper;
{
_11_21_blend_set_color_saturation_helper = _5_hueLumColor.y < _5_hueLumColor.z ? float3(0.0, (_7_sat * (_5_hueLumColor.x - _5_hueLumColor.y)) / (_5_hueLumColor.z - _5_hueLumColor.y), _7_sat) : float3(0.0);
}
_5_hueLumColor.yxz = _11_21_blend_set_color_saturation_helper;
} else if (_5_hueLumColor.y <= _5_hueLumColor.z) {
float3 _12_22_blend_set_color_saturation_helper;
{
_12_22_blend_set_color_saturation_helper = _5_hueLumColor.y < _5_hueLumColor.x ? float3(0.0, (_7_sat * (_5_hueLumColor.z - _5_hueLumColor.y)) / (_5_hueLumColor.x - _5_hueLumColor.y), _7_sat) : float3(0.0);
}
_5_hueLumColor.yzx = _12_22_blend_set_color_saturation_helper;
} else {
float3 _13_23_blend_set_color_saturation_helper;
{
_13_23_blend_set_color_saturation_helper = _5_hueLumColor.z < _5_hueLumColor.x ? float3(0.0, (_7_sat * (_5_hueLumColor.y - _5_hueLumColor.z)) / (_5_hueLumColor.x - _5_hueLumColor.z), _7_sat) : float3(0.0);
}
_5_hueLumColor.zyx = _13_23_blend_set_color_saturation_helper;
}
_4_blend_set_color_saturation = _5_hueLumColor;
}
float3 _14_blend_set_color_luminance;
{
float _15_15_blend_color_luminance;
{
_15_15_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _3_dsa);
}
float _16_lum = _15_15_blend_color_luminance;
float _17_16_blend_color_luminance;
{
_17_16_blend_color_luminance = dot(float3(0.30000001192092896, 0.5899999737739563, 0.10999999940395355), _4_blend_set_color_saturation);
}
float3 _18_result = (_16_lum - _17_16_blend_color_luminance) + _4_blend_set_color_saturation;
float _19_minComp = min(min(_18_result.x, _18_result.y), _18_result.z);
float _20_maxComp = max(max(_18_result.x, _18_result.y), _18_result.z);
if (_19_minComp < 0.0 && _16_lum != _19_minComp) {
_18_result = _16_lum + ((_18_result - _16_lum) * _16_lum) / (_16_lum - _19_minComp);
}
_14_blend_set_color_luminance = _20_maxComp > _1_alpha && _20_maxComp != _16_lum ? _16_lum + ((_18_result - _16_lum) * (_1_alpha - _16_lum)) / (_20_maxComp - _16_lum) : _18_result;
}
_0_blend_hue = float4((((_14_blend_set_color_luminance + _in.dst.xyz) - _3_dsa) + _in.src.xyz) - _2_sda, (_in.src.w + _in.dst.w) - _1_alpha);
}
Revert "Reland "Remove inliner from IR generation stage."" This reverts commit e497a080651c05678cf4760fa6e4daa53a10355b. Reason for revert: Pinpoint disagrees Original change's description: > Reland "Remove inliner from IR generation stage." > > This reverts commit 941fc7174fc20e8a8b707f1b636c85bbf2e1294f. > > Reason for revert: performance now seems to be roughly equal or better > (~1%) over several trials. > Nanobench: http://screen/A8e8sojaXBgbMgF > > Original change's description: > > Revert "Remove inliner from IR generation stage." > > > > This reverts commit 21d7778cb5c13e729b513eaa22dbf53f58a877c8. > > > > Reason for revert: Pinpoint absolutely hates this change > > > > Original change's description: > > > Remove inliner from IR generation stage. > > > > > > There is no need to inline code during IR generation, as the optimizer > > > can now handle this. > > > > > > Change-Id: If272bfb98e945a75ec91fb4aa026e5631ac51b5b > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/315971 > > > Commit-Queue: John Stiles <johnstiles@google.com> > > > Commit-Queue: Brian Osman <brianosman@google.com> > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Auto-Submit: John Stiles <johnstiles@google.com> > > > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com > > > > Change-Id: I62c235415bcdc92a088e2a7f9c3d7dbf7e1bf669 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317976 > > Reviewed-by: John Stiles <johnstiles@google.com> > > Commit-Queue: John Stiles <johnstiles@google.com> > > TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com > > Change-Id: I6189806c678283188f4b67ee61e5886f88c2d6fc > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324891 > Reviewed-by: John Stiles <johnstiles@google.com> > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Auto-Submit: John Stiles <johnstiles@google.com> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com Change-Id: I79149467565f22f53b8c28868dd53b80f3421137 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325626 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
2020-10-13 15:19:41 +00:00
_out->sk_FragColor = _0_blend_hue;
return *_out;
}