From bc903d1c3b78d41732ecf9037a1cd90e6826dd07 Mon Sep 17 00:00:00 2001 From: Arman Uguray Date: Sun, 23 Apr 2023 16:05:08 -0700 Subject: [PATCH] Add check for division-by-zero in path_coarse_full The potential division by zero in this line led to visible visual artifacts when running against WebGPU in Chrome. --- shader/path_coarse_full.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shader/path_coarse_full.wgsl b/shader/path_coarse_full.wgsl index ef1bed5..58a4364 100644 --- a/shader/path_coarse_full.wgsl +++ b/shader/path_coarse_full.wgsl @@ -60,7 +60,7 @@ fn estimate_subdiv(p0: vec2, p1: vec2, p2: vec2, sqrt_tol: f32) - let d12 = p2 - p1; let dd = d01 - d12; let cross = (p2.x - p0.x) * dd.y - (p2.y - p0.y) * dd.x; - let cross_inv = 1.0 / cross; + let cross_inv = select(1.0 / cross, 1.0e9, abs(cross) < 1.0e-9); let x0 = dot(d01, dd) * cross_inv; let x2 = dot(d12, dd) * cross_inv; let scale = abs(cross / (length(dd) * (x2 - x0)));