skia2/tests/sksl/shared/FunctionAnonymousParameters.metal
John Stiles f604efbeb4 Add support for anonymous function parameters in SkSL.
Anonymous function parameters are now automatically assigned a name,
"_skAnonymousParamN", where N is the parameter index.

Change-Id: I87adcd51ed025c76ae2b333317f21b523a4632b4
Bug: skia:12769
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/489538
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-12-28 20:47:05 +00:00

28 lines
847 B
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct S {
int i;
};
struct Uniforms {
half4 colorGreen;
half4 colorRed;
};
struct Inputs {
};
struct Outputs {
half4 sk_FragColor [[color(0)]];
};
half4 fnGreen_h4bf2(Uniforms _uniforms, bool b, float2 _skAnonymousParam1) {
return _uniforms.colorGreen;
}
half4 fnRed_h4ifS(Uniforms _uniforms, int _skAnonymousParam0, float f, S _skAnonymousParam2) {
return _uniforms.colorRed;
}
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
_out.sk_FragColor = bool(_uniforms.colorGreen.y) ? fnGreen_h4bf2(_uniforms, true, coords) : fnRed_h4ifS(_uniforms, 123, 3.1400001049041748, S{0});
return _out;
}