skia2/resources/sksl/intrinsics/Frexp.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

21 lines
608 B
Plaintext

uniform half4 colorGreen, colorRed;
half4 main() {
float4 value = colorGreen.gggg * 6;
int4 exp;
float4 result;
bool4 ok;
// 6 equals 0.75 * 2^3.
result.x = frexp(value.x, exp.x);
ok.x = (result.x == 0.75 && exp.x == 3);
result.xy = frexp(value.xy, exp.xy);
ok.y = (result.y == 0.75 && exp.y == 3);
result.xyz = frexp(value.xyz, exp.xyz);
ok.z = (result.z == 0.75 && exp.z == 3);
result.xyzw = frexp(value.xyzw, exp.xyzw);
ok.w = (result.w == 0.75 && exp.w == 3);
return all(ok) ? colorGreen : colorRed;
}