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>
115 lines
2.7 KiB
Plaintext
115 lines
2.7 KiB
Plaintext
uniform half4 colorRed, colorGreen;
|
|
uniform half unknownInput;
|
|
|
|
bool test_half() {
|
|
bool ok = true;
|
|
half4 inputRed = colorRed;
|
|
half4 inputGreen = colorGreen;
|
|
|
|
// Vector op scalar
|
|
half4 x = inputRed + 2;
|
|
ok = ok && (x == half4(3, 2, 2, 3));
|
|
x = inputGreen.garb - 2;
|
|
ok = ok && (x == half4(-1, -1, -2, -2));
|
|
x = inputRed + inputGreen.g;
|
|
ok = ok && (x == half4(2, 1, 1, 2));
|
|
x.xyz = inputGreen.aga * 9;
|
|
ok = ok && (x == half4(9, 9, 9, 2));
|
|
x.xy = x.zw / 0.5;
|
|
ok = ok && (x == half4(18, 4, 9, 2));
|
|
|
|
// (Vector op scalar).swizzle
|
|
x = (inputRed * 5).yxwz;
|
|
ok = ok && (x == half4(0, 5, 5, 0));
|
|
|
|
// Scalar op vector
|
|
x = 2 + inputRed;
|
|
ok = ok && (x == half4(3, 2, 2, 3));
|
|
x = 10 - inputGreen.garb;
|
|
ok = ok && (x == half4(9, 9, 10, 10));
|
|
x = inputRed.r + inputGreen;
|
|
ok = ok && (x == half4(1, 2, 1, 2));
|
|
x.xyz = 9 * inputGreen.aga;
|
|
ok = ok && (x == half4(9, 9, 9, 2));
|
|
x.xy = 36 / x.zw;
|
|
ok = ok && (x == half4(4, 18, 9, 2));
|
|
|
|
// (Scalar op vector).swizzle
|
|
x = (36 / x).yxwz;
|
|
ok = ok && (x == half4(2, 9, 18, 4));
|
|
|
|
// X op= scalar.
|
|
x += 2;
|
|
x *= 2;
|
|
x -= 4;
|
|
x /= 2;
|
|
ok = ok && (x == half4(2, 9, 18, 4));
|
|
|
|
// X = X op scalar.
|
|
x = x + 2;
|
|
x = x * 2;
|
|
x = x - 4;
|
|
x = x / 2;
|
|
ok = ok && (x == half4(2, 9, 18, 4));
|
|
|
|
return ok;
|
|
}
|
|
|
|
bool test_int() {
|
|
bool ok = true;
|
|
int4 inputRed = int4(colorRed);
|
|
int4 inputGreen = int4(colorGreen);
|
|
|
|
// Vector op scalar
|
|
int4 x = inputRed + 2;
|
|
ok = ok && (x == int4(3, 2, 2, 3));
|
|
x = inputGreen.garb - 2;
|
|
ok = ok && (x == int4(-1, -1, -2, -2));
|
|
x = inputRed + inputGreen.g;
|
|
ok = ok && (x == int4(2, 1, 1, 2));
|
|
x.xyz = inputGreen.aga * 9;
|
|
ok = ok && (x == int4(9, 9, 9, 2));
|
|
x.xy = x.zw / 3;
|
|
ok = ok && (x == int4(3, 0, 9, 2));
|
|
|
|
// (Vector op scalar).swizzle
|
|
x = (inputRed * 5).yxwz;
|
|
ok = ok && (x == int4(0, 5, 5, 0));
|
|
|
|
// Scalar op vector
|
|
x = 2 + inputRed;
|
|
ok = ok && (x == int4(3, 2, 2, 3));
|
|
x = 10 - inputGreen.garb;
|
|
ok = ok && (x == int4(9, 9, 10, 10));
|
|
x = inputRed.r + inputGreen;
|
|
ok = ok && (x == int4(1, 2, 1, 2));
|
|
x.xyz = 9 * inputGreen.aga;
|
|
ok = ok && (x == int4(9, 9, 9, 2));
|
|
x.xy = 36 / x.zw;
|
|
ok = ok && (x == int4(4, 18, 9, 2));
|
|
|
|
// (Scalar op vector).swizzle
|
|
x = (36 / x).yxwz;
|
|
ok = ok && (x == int4(2, 9, 18, 4));
|
|
|
|
// X op= scalar.
|
|
x += 2;
|
|
x *= 2;
|
|
x -= 4;
|
|
x /= 2;
|
|
ok = ok && (x == int4(2, 9, 18, 4));
|
|
|
|
// X = X op scalar.
|
|
x = x + 2;
|
|
x = x * 2;
|
|
x = x - 4;
|
|
x = x / 2;
|
|
ok = ok && (x == int4(2, 9, 18, 4));
|
|
|
|
return ok;
|
|
}
|
|
|
|
half4 main(float2 coords) {
|
|
return test_half() && test_int() ? colorGreen : colorRed;
|
|
}
|