dc75a97b80
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>
23 lines
842 B
Plaintext
23 lines
842 B
Plaintext
struct S1 { int x; };
|
|
struct S2 { S1 x; };
|
|
struct S3 { S2 x; };
|
|
struct S4 { S3 x; };
|
|
struct S5 { S4 x; };
|
|
struct S6 { S5 x; };
|
|
struct S7 { S6 x; };
|
|
struct S8 { S7 x; };
|
|
in S8 s8;
|
|
|
|
// This is the most deeply-nested mix of arrays and structs that we can make with our current
|
|
// limits of eight-deep structs and eight-dimensional arrays. This structure is actually too big to
|
|
// use in SkSL without hitting the maximum parse depth.
|
|
struct SA1 { int x[1][2][3][4][5][6][7][8]; };
|
|
struct SA2 { SA1 x[1][1][1][1][1][1][1][7]; };
|
|
struct SA3 { SA2 x[1][1][1][1][1][1][1][6]; };
|
|
struct SA4 { SA3 x[1][1][1][1][1][1][1][5]; };
|
|
struct SA5 { SA4 x[1][1][1][1][1][1][1][4]; };
|
|
struct SA6 { SA5 x[1][1][1][1][1][1][1][3]; };
|
|
struct SA7 { SA6 x[1][1][1][1][1][1][1][2]; };
|
|
struct SA8 { SA7 x[1][1][1][1][1][1][1][1]; };
|
|
in SA8 sa8[1][2][3][4][5][6][7][8];
|