skia2/tests/sksl/shared/golden/Assignment.glsl
John Stiles dc75a97b80 Add global struct definitions to SkSL.
Previously, GLSL and Metal code generators would emit a struct wherever
the type was first used in the code, regardless of where it was
originally defined or what scope the type needs to live in. This CL adds
a ProgramElement for struct definitions, so that structs will now appear
at the top-level as they were originally defined. In the case of Metal,
some special handling is also needed to handle the Globals struct
properly.

Not yet fully supported:
- No special handling for structs declared inside functions yet
- No support for structs in separate scopes with overlapping names
The severity of the remaining issues depends mostly on whether we want
to support structs inside functions in Runtime Effects.

Change-Id: Ia95d4529506cb3fa6da63f5cb548199a93e1c0c5
Bug: skia:10922, skia:10923, skia:10925, skia:10926
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338600
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-11-30 15:26:14 +00:00

47 lines
1.0 KiB
GLSL

out vec4 sk_FragColor;
struct S {
float f;
float[5] af;
vec4 h4;
vec4[5] ah4;
};
void main() {
vec4 x;
x.w = 0.0;
x.yx = vec2(0.0);
int ai[1];
ai[0] = 0;
ivec4 ai4[1];
ai4[0] = ivec4(1, 2, 3, 4);
mat2x4 ah2x4[1];
ah2x4[0] = mat2x4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
ai[0] = 0;
ai[ai[0]] = 0;
vec4 af4[1];
af4[0].x = 0.0;
af4[0].ywxz = vec4(1.0);
S s;
s.f = 0.0;
s.af[1] = 0.0;
s.h4.zxy = vec3(9.0);
s.ah4[2].yw = vec2(5.0);
s.f = 1.0;
s.af[0] = 2.0;
s.h4 = vec4(1.0);
s.ah4[0] = vec4(2.0);
sk_FragColor = vec4(0.0);
sk_FragColor = vec4(ivec4(1, 2, 3, 4));
sk_FragColor = mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)[0].xxyz;
sk_FragColor = x;
sk_FragColor = vec4(float(ai[0]));
sk_FragColor = vec4(ai4[0]);
sk_FragColor = ah2x4[0][0];
sk_FragColor = af4[0];
sk_FragColor = vec4(0.0);
sk_FragColor = vec4(s.f);
sk_FragColor = vec4(s.af[1]);
sk_FragColor = s.h4;
sk_FragColor = s.ah4[0];
}