169c8903be
This is a reland of 22dcb5fd7e
Original change's description:
> Add coords parameter to all .sksl test files used as runtime effects
>
> Convert to use the newer MakeForShader factory, which requires this.
>
> Change-Id: Ifaf6054054027c78f3f3fe15596e435e0f79b877
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399336
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
Bug: skia:11919
Change-Id: I5f745c54b2bc3712f2281db6e067345903e81931
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401836
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
70 lines
1.6 KiB
Plaintext
70 lines
1.6 KiB
Plaintext
uniform half4 colorGreen;
|
|
uniform half unknownInput;
|
|
|
|
struct S {
|
|
half4 ah4[1];
|
|
half ah[1];
|
|
half4 h4;
|
|
half h;
|
|
};
|
|
|
|
// Each helper function needs to reference the variable multiple times, because if it's only read
|
|
// from once, it is inlined directly whether or not it is trivial.
|
|
half4 funcb(bool b) {
|
|
return half4(b, b, b, !b);
|
|
}
|
|
|
|
half4 func1(half h) {
|
|
return h.xxxx * h.xxxx;
|
|
}
|
|
|
|
half4 func2(half2 h2) {
|
|
return h2.xyxy * h2.yxyx;
|
|
}
|
|
|
|
half4 func3(half3 h3) {
|
|
return h3.xyzx * h3.xyzx;
|
|
}
|
|
|
|
half4 func4(half4 h4) {
|
|
return h4 * h4;
|
|
}
|
|
|
|
half4 main(float2 coords) {
|
|
S s;
|
|
s.ah4[0] = half4(unknownInput);
|
|
s.ah[0] = unknownInput;
|
|
s.h4 = half4(unknownInput);
|
|
s.h = unknownInput;
|
|
|
|
S as[1];
|
|
as[0].ah4[0] = half4(unknownInput);
|
|
|
|
bool b = bool(unknownInput);
|
|
int i = int(unknownInput);
|
|
|
|
// These expressions are considered "trivial" and will be cloned directly into the inlined
|
|
// function without a temporary variable.
|
|
half4 var;
|
|
var = func1(+s.h);
|
|
var = funcb(b);
|
|
var = func2(s.ah4[0].yw);
|
|
var = func2(as[0].ah4[0].xy);
|
|
var = func3(s.h4.zzz);
|
|
var = func3(colorGreen.xyz);
|
|
var = func3(s.h.xxx);
|
|
var = func4(half4(s.h));
|
|
var = func4(s.ah4[0].xxxy);
|
|
var = func4(colorGreen);
|
|
|
|
// These expressions are considered "non-trivial" and will be placed in a temporary variable
|
|
// when inlining occurs.
|
|
var = func1(-s.h);
|
|
var = funcb(!b);
|
|
// var = func2(as[i].h4.yw); // indexing by non-constant expressions disallowed in ES2
|
|
var = func3(s.h4.yyy + s.h4.zzz);
|
|
var = func4(s.h4.y001);
|
|
|
|
return colorGreen;
|
|
}
|