skia2/resources/sksl/intrinsics/Modf.sksl
John Stiles 4a3ec173b3 Add tests to demonstrate SPIR-V error with intrinsics.
When SPIR-V generates function calls to an intrinsic, it assumes that
it can get a pointer to out-parameters referenced by the intrinsic.
This does not account for swizzled out-parameters; these are valid
lvalues, but do not work with getPointer().

The two intrinsics supported by SkSL which have an out-parameter are
frexp and modf, so these tests were fleshed out to trigger the error.
Neither of these are supported in ES2, though, so we cannot test them
via Runtime Effects.

Change-Id: Ib92707a28ba6d1c282d20e29a2a387bddf74ad23
Bug: skia:11052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370116
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-02-16 15:46:01 +00:00

20 lines
626 B
Plaintext

uniform half4 colorGreen, colorRed;
half4 main() {
float4 value = colorGreen.gggg * 2.5;
float4 whole, fraction;
bool4 ok;
// 2.5 equals 2 + 0.5.
fraction.x = modf(value.x, whole.x);
ok.x = whole.x == 2 && fraction.x == 0.5;
fraction.xy = modf(value.xy, whole.xy);
ok.y = whole.y == 2 && fraction.y == 0.5;
fraction.xyz = modf(value.xyz, whole.xyz);
ok.z = whole.z == 2 && fraction.z == 0.5;
fraction.xyzw = modf(value.xyzw, whole.xyzw);
ok.w = whole.w == 2 && fraction.w == 0.5;
return all(ok) ? colorGreen : colorRed;
}