skia2/tests/sksl/shared/StructArrayFollowedByScalar.metal
John Stiles 31c87103c6 Fix parsing error with structs containing arrays.
Previously, a struct containing a vardecl with multiple declarations
would interpret arrays incorrectly. An array would be applied to ALL
variables in the decl after its initial appearance. That is,
`int w, x[10], y, z;` would be interpreted as
`int w, x[10], y[10], z[10];`.

This is now fixed and our test case runs as expected.

Change-Id: I5b4a617c58cdfb83face651effd42770a1f68638
Bug: oss-fuzz:37622
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/441879
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-25 17:27:12 +00:00

24 lines
528 B
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct S {
array<float, 3> rgb;
float a;
};
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
S s;
s.rgb[0] = 0.0;
s.rgb[1] = 1.0;
s.rgb[2] = 0.0;
s.a = 1.0;
_out.sk_FragColor = float4(s.rgb[0], s.rgb[1], s.rgb[2], s.a);
return _out;
}