skia2/resources/sksl/inliner/TrivialArgumentsInlineDirectly.sksl
John Stiles bfc9be0f77 Migrate SkSL test inputs to the resources/ directory.
This will allow us to load these inputs for unit testing in `dm`.

Change-Id: Id256ba7c30d3ec94b98048e47af44cf9efe580d5
Bug: skia:11009
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357282
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-22 18:57:29 +00:00

66 lines
1.7 KiB
Plaintext

in half val;
uniform int ui;
uniform half4 uh4;
uniform bool b;
struct S {
half4 ah4[1];
half ah[1];
half4 h4;
half h;
};
void funcb(bool b, out half4 outColor) {
outColor = b ? outColor.xxxx : outColor.yyyy;
}
void func1(half h, out half4 outColor) {
outColor = h.xxxx;
}
void func2(half2 h2, out half4 outColor) {
outColor = h2.xyxy;
}
void func3(half3 h3, out half4 outColor) {
outColor = h3.xyzx;
}
void func4(half4 h4, out half4 outColor) {
outColor = h4;
}
void main() {
S s;
s.ah4[0] = half4(val);
s.ah[0] = val;
s.h4 = half4(val);
s.h = val;
S as[1];
as[0].ah4[0] = half4(val);
// These expressions are considered "trivial" and will be cloned directly into the inlined
// function without a temporary variable.
funcb(sk_Caps.floatIs32Bits, sk_FragColor);
func1(+s.h, sk_FragColor);
funcb(b, sk_FragColor);
func2(s.ah4[0].yw, sk_FragColor);
func2(as[0].ah4[0].xy, sk_FragColor);
func3(s.h4.zzz, sk_FragColor);
func3(uh4.xyz, sk_FragColor);
func3(s.h.xxx, sk_FragColor);
func4(half4(s.h), sk_FragColor);
func4(s.ah4[0].xxxy, sk_FragColor);
func4(uh4, sk_FragColor);
// These expressions are considered "non-trivial" and will be placed in a temporary variable
// when inlining occurs.
funcb(!sk_Caps.floatIs32Bits, sk_FragColor);
func1(-s.h, sk_FragColor);
funcb(!b, sk_FragColor);
func2(s.ah4[ui].yw, sk_FragColor);
func3(s.h4.yyy + s.h4.zzz, sk_FragColor);
func4(s.h4.y001, sk_FragColor);
}