skia2/tests/sksl/shared/GeometricIntrinsics.metal
John Stiles 92748af1a5 Inline functions of the form 'return (expr)' only.
This drastically reduces the number of functions which we allow to be
inlined. If this change does not hurt our performance, it will allow us
to trivially remove hundreds of LOC. All current data leads us to
believe that it may affect the Mali 400 but is highly unlikely to change
results on any other device in the tree.

More info: http://go/optimization-in-sksl-inliner

Change-Id: Ia6b706742ce5407453e0e697b6c1f9201084c0e8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384858
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-03-15 19:46:46 +00:00

35 lines
830 B
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
float4 colorGreen;
};
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
float scalar(float x, float y) {
x = abs(x);
x = abs(x - y);
x = (x * y);
x = sign(x);
return x;
}
float2 vector(float2 x, float2 y) {
x = float2(length(x));
x = float2(distance(x, y));
x = float2(dot(x, y));
x = normalize(x);
return x;
}
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
float x = scalar(1.0, 2.0);
float2 y = vector(float2(1.0, 2.0), float2(3.0, 4.0));
_out.sk_FragColor = _uniforms.colorGreen;
return _out;
}