0006ad01ce
Previously, any builtin functions would be optimized as a side-effect of optimizing programs that used them. Now that shared elements aren't being optimized in that way, we explicitly optimize any shared modules when they are first created. We don't remove dead elements, but we we do substitute settings, simplify, and inline. Bug: skia:10905 Change-Id: I701b5e9f52fb880ef3e6f4c67694d08602f47e95 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/336440 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
41 lines
1.5 KiB
Metal
41 lines
1.5 KiB
Metal
#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_overlay;
|
|
{
|
|
float _1_1_blend_overlay_component;
|
|
{
|
|
_1_1_blend_overlay_component = 2.0 * _in.dst.x <= _in.dst.w ? (2.0 * _in.src.x) * _in.dst.x : _in.src.w * _in.dst.w - (2.0 * (_in.dst.w - _in.dst.x)) * (_in.src.w - _in.src.x);
|
|
}
|
|
float _2_75_blend_overlay_component;
|
|
{
|
|
_2_75_blend_overlay_component = 2.0 * _in.dst.y <= _in.dst.w ? (2.0 * _in.src.y) * _in.dst.y : _in.src.w * _in.dst.w - (2.0 * (_in.dst.w - _in.dst.y)) * (_in.src.w - _in.src.y);
|
|
}
|
|
float _3_79_blend_overlay_component;
|
|
{
|
|
_3_79_blend_overlay_component = 2.0 * _in.dst.z <= _in.dst.w ? (2.0 * _in.src.z) * _in.dst.z : _in.src.w * _in.dst.w - (2.0 * (_in.dst.w - _in.dst.z)) * (_in.src.w - _in.src.z);
|
|
}
|
|
float4 _4_result = float4(_1_1_blend_overlay_component, _2_75_blend_overlay_component, _3_79_blend_overlay_component, _in.src.w + (1.0 - _in.src.w) * _in.dst.w);
|
|
|
|
|
|
|
|
_4_result.xyz = _4_result.xyz + _in.dst.xyz * (1.0 - _in.src.w) + _in.src.xyz * (1.0 - _in.dst.w);
|
|
_0_blend_overlay = _4_result;
|
|
}
|
|
_out->sk_FragColor = _0_blend_overlay;
|
|
|
|
return *_out;
|
|
}
|