skia2/tests/sksl/shared/StructsInFunctions.glsl
John Stiles ece1d794b9 Mangle function names in GLSL.
This will be implemented in Metal and SPIR-V in followup CLs.

Change-Id: I397b4db40b15dd54cf1d8a17f414c3fe184b48d2
Bug: skia:10851
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387638
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-22 17:18:26 +00:00

29 lines
527 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorRed;
uniform vec4 colorGreen;
struct S {
float x;
int y;
};
S returns_a_struct_S() {
S s;
s.x = 1.0;
s.y = 2;
return s;
}
float accepts_a_struct_fS(S s) {
return s.x + float(s.y);
}
void modifies_a_struct_vS(inout S s) {
s.x++;
s.y++;
}
vec4 main() {
S s = returns_a_struct_S();
float x = accepts_a_struct_fS(s);
modifies_a_struct_vS(s);
bool valid = (x == 3.0 && s.x == 2.0) && s.y == 3;
return valid ? colorGreen : colorRed;
}