2021-03-16 14:40:11 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
2021-02-03 22:44:47 +00:00
|
|
|
struct Uniforms {
|
|
|
|
float4 colorGreen;
|
|
|
|
float4 colorRed;
|
|
|
|
};
|
2020-11-10 16:25:35 +00:00
|
|
|
struct Inputs {
|
|
|
|
};
|
|
|
|
struct Outputs {
|
|
|
|
float4 sk_FragColor [[color(0)]];
|
|
|
|
};
|
2021-03-22 15:57:41 +00:00
|
|
|
void bar_vf(thread float& x);
|
|
|
|
void _skOutParamHelper0_bar_vf(thread float& x) {
|
2020-12-09 17:35:48 +00:00
|
|
|
float _var0 = x;
|
2021-03-22 15:57:41 +00:00
|
|
|
bar_vf(_var0);
|
2020-12-09 17:35:48 +00:00
|
|
|
x = _var0;
|
|
|
|
}
|
2021-02-03 22:44:47 +00:00
|
|
|
|
2021-03-22 15:57:41 +00:00
|
|
|
float foo_ff2(float2 v) {
|
2021-02-03 22:44:47 +00:00
|
|
|
return v.x * v.y;
|
2020-12-02 16:53:51 +00:00
|
|
|
}
|
2021-03-22 15:57:41 +00:00
|
|
|
void bar_vf(thread float& x) {
|
Reland "Improve support for arrays in Metal."
This reverts commit 38df4c8470ab3db7455005ab0c3599a95c791d2b.
Reason for revert: updated ArrayTypes test for ES2 compatibility
Original change's description:
> Revert "Improve support for arrays in Metal."
>
> This reverts commit dd904af5666b4746d4b9af5c1f03b47ac3ec73b2.
>
> Reason for revert: breaks ANGLE
>
> Original change's description:
> > Improve support for arrays in Metal.
> >
> > Arrays in Metal now use the `array<T, N>` type instead of the C-style
> > `T[N]` type. This gives them semantics much more in line with GLSL,
> > so they can be initialized and assigned like GLSL arrays.
> >
> > This allows the ArrayTypes and Assignment tests to pass, so they have
> > been added to our dm SkSL tests. (ArrayConstructors also passes, but
> > is not ES2-compliant so it is not enabled.)
> >
> > Change-Id: Id1028311963084befd0e044e11e223af6a064dda
> > Bug: skia:10761, skia:10760, skia:11022, skia:10939
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365699
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
>
> Change-Id: If6a18dea7d6a45fa7836e9129bf81c2e536f07e3
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10761
> Bug: skia:10760
> Bug: skia:11022
> Bug: skia:10939
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365976
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
Bug: skia:10761
Bug: skia:10760
Bug: skia:11022
Bug: skia:10939
Change-Id: Ia1c4917f5d3c41162d282b3093814d861707ad30
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366144
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-04 15:57:08 +00:00
|
|
|
array<float, 2> y;
|
2020-12-02 16:53:51 +00:00
|
|
|
y[0] = x;
|
|
|
|
y[1] = x * 2.0;
|
2021-03-22 15:57:41 +00:00
|
|
|
x = foo_ff2(float2(y[0], y[1]));
|
2020-12-02 16:53:51 +00:00
|
|
|
}
|
2021-02-03 22:44:47 +00:00
|
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
2021-01-19 18:07:55 +00:00
|
|
|
Outputs _out;
|
2021-01-22 03:24:28 +00:00
|
|
|
(void)_out;
|
2020-11-10 16:25:35 +00:00
|
|
|
float x = 10.0;
|
2021-03-22 15:57:41 +00:00
|
|
|
_skOutParamHelper0_bar_vf(x);
|
2021-02-03 22:44:47 +00:00
|
|
|
_out.sk_FragColor = x == 200.0 ? _uniforms.colorGreen : _uniforms.colorRed;
|
2021-01-19 18:07:55 +00:00
|
|
|
return _out;
|
2020-11-10 16:25:35 +00:00
|
|
|
}
|