skia2/resources/sksl/errors/UnknownDivideByZero.sksl
Ethan Nicholas c0f9815609 Added detection for non-constant-folded divide by zero errors in
SkSL.

It would previously catch 1 / 0, but fail to detect x / 0.

Bug: skia:11051
Change-Id: I3adb5942cce03a7ad40a13a8ca5d5a7f2029d6ad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366720
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
2021-02-06 03:13:16 +00:00

22 lines
798 B
Plaintext

uniform float unknownInput;
void main() {
const int zero = 0;
float x = unknownInput / 0;
x = (float2(unknownInput) / 0).x;
x = (float2(unknownInput) / float2(zero)).x;
x = (float2(unknownInput) / float2(unknownInput, 0)).x;
x = (float3(unknownInput) / float3(float(0), unknownInput, unknownInput)).x;
x = (float4(unknownInput) / float4(float2(unknownInput, float(zero)), 1, 1)).x;
x /= 0;
int y = int(unknownInput) / 0;
y = int(unknownInput) % 0;
y = (int2(unknownInput) / 0).x;
y = (int2(unknownInput) / int2(zero)).x;
y = (int2(unknownInput) / int2(unknownInput, 0)).x;
y = (int3(unknownInput) / int3(0, unknownInput, unknownInput)).x;
y = (int4(unknownInput) % int4(int2(unknownInput, int(zero)), 1, 1)).x;
y /= 0;
y %= 0;
}