From 934d9ac15a6c885277ab520cec97a807c67c6ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sat, 14 Oct 2023 14:33:18 +0200 Subject: [PATCH] Fix shader compilation on Chrome --- shader/fine.wgsl | 10 +++++----- shader/path_count.wgsl | 18 +++++++++--------- shader/path_count_setup.wgsl | 2 +- shader/path_tiling.wgsl | 12 ++++++------ shader/path_tiling_setup.wgsl | 2 +- src/shaders.rs | 6 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/shader/fine.wgsl b/shader/fine.wgsl index 5d500ad04..848ca6905 100644 --- a/shader/fine.wgsl +++ b/shader/fine.wgsl @@ -182,9 +182,9 @@ fn fill_path_ms(fill: CmdFill, wg_id: vec2, local_id: vec2) -> array= xy0.x; - let sign = select(-1.0, 1.0, is_positive_slope); - let xt0 = floor(xy0.x * sign); - let c = xy0.x * sign - xt0; + let sign_ = select(-1.0, 1.0, is_positive_slope); + let xt0 = floor(xy0.x * sign_); + let c = xy0.x * sign_ - xt0; let y0i = floor(xy0.y); let ytop = y0i + 1.0; let b = min((dy * c + dx * (ytop - xy0.y)) * idxdy, ONE_MINUS_ULP); @@ -194,12 +194,12 @@ fn fill_path_ms(fill: CmdFill, wg_id: vec2, local_id: vec2) -> array= s0.x; - let sign = select(-1.0, 1.0, is_positive_slope); - let xt0 = floor(s0.x * sign); - let c = s0.x * sign - xt0; + let sign_ = select(-1.0, 1.0, is_positive_slope); + let xt0 = floor(s0.x * sign_); + let c = s0.x * sign_ - xt0; let y0 = floor(s0.y); let ytop = select(y0 + 1.0, ceil(s0.y), s0.y == s1.y); let b = min((dy * c + dx * (ytop - s0.y)) * idxdy, ONE_MINUS_ULP); @@ -89,7 +89,7 @@ fn main( if robust_err != 0.0 { a -= ROBUST_EPSILON * sign(robust_err); } - let x0 = xt0 * sign + select(-1.0, 0.0, is_positive_slope); + let x0 = xt0 * sign_ + select(-1.0, 0.0, is_positive_slope); let path = paths[line.path_ix]; let bbox = vec4(path.bbox); @@ -129,8 +129,8 @@ fn main( } else { let fudge = select(1.0, 0.0, is_positive_slope); if xmin < f32(bbox.x) { - var f = round((sign * (f32(bbox.x) - x0) - b + fudge) / a); - if (x0 + sign * floor(a * f + b) < f32(bbox.x)) == is_positive_slope { + var f = round((sign_ * (f32(bbox.x) - x0) - b + fudge) / a); + if (x0 + sign_ * floor(a * f + b) < f32(bbox.x)) == is_positive_slope { f += 1.0; } let ynext = i32(y0 + f - floor(a * f + b) + 1.0); @@ -149,8 +149,8 @@ fn main( } } if max(s0.x, s1.x) > f32(bbox.z) { - var f = round((sign * (f32(bbox.z) - x0) - b + fudge) / a); - if (x0 + sign * floor(a * f + b) < f32(bbox.z)) == is_positive_slope { + var f = round((sign_ * (f32(bbox.z) - x0) - b + fudge) / a); + if (x0 + sign_ * floor(a * f + b) < f32(bbox.z)) == is_positive_slope { f += 1.0; } if is_positive_slope { @@ -178,7 +178,7 @@ fn main( let z = floor(zf); // x, y are tile coordinates relative to render target let y = i32(y0 + f32(subix) - z); - let x = i32(x0 + sign * z); + let x = i32(x0 + sign_ * z); let base = i32(path.tiles) + (y - bbox.y) * stride - bbox.x; let top_edge = select(last_z == z, y0 == s0.y, subix == 0u); if top_edge && x + 1 < bbox.z { diff --git a/shader/path_count_setup.wgsl b/shader/path_count_setup.wgsl index 95af29c38..3715aa59b 100644 --- a/shader/path_count_setup.wgsl +++ b/shader/path_count_setup.wgsl @@ -5,7 +5,7 @@ #import bump @group(0) @binding(0) -var bump: BumpAllocators; +var bump: BumpAllocators; @group(0) @binding(1) var indirect: IndirectCount; diff --git a/shader/path_tiling.wgsl b/shader/path_tiling.wgsl index fad5d725e..50544a9f1 100644 --- a/shader/path_tiling.wgsl +++ b/shader/path_tiling.wgsl @@ -8,7 +8,7 @@ #import tile @group(0) @binding(0) -var bump: BumpAllocators; +var bump: BumpAllocators; @group(0) @binding(1) var seg_counts: array; @@ -62,9 +62,9 @@ fn main( let idxdy = 1.0 / (dx + dy); var a = dx * idxdy; let is_positive_slope = s1.x >= s0.x; - let sign = select(-1.0, 1.0, is_positive_slope); - let xt0 = floor(s0.x * sign); - let c = s0.x * sign - xt0; + let sign_ = select(-1.0, 1.0, is_positive_slope); + let xt0 = floor(s0.x * sign_); + let c = s0.x * sign_ - xt0; let y0i = floor(s0.y); let ytop = select(y0i + 1.0, ceil(s0.y), s0.y == s1.y); let b = min((dy * c + dx * (ytop - s0.y)) * idxdy, ONE_MINUS_ULP); @@ -72,9 +72,9 @@ fn main( if robust_err != 0.0 { a -= ROBUST_EPSILON * sign(robust_err); } - let x0i = i32(xt0 * sign + 0.5 * (sign - 1.0)); + let x0i = i32(xt0 * sign_ + 0.5 * (sign_ - 1.0)); let z = floor(a * f32(seg_within_line) + b); - let x = x0i + i32(sign * z); + let x = x0i + i32(sign_ * z); let y = i32(y0i + f32(seg_within_line) - z); let path = paths[line.path_ix]; diff --git a/shader/path_tiling_setup.wgsl b/shader/path_tiling_setup.wgsl index 722be1914..466152a2b 100644 --- a/shader/path_tiling_setup.wgsl +++ b/shader/path_tiling_setup.wgsl @@ -5,7 +5,7 @@ #import bump @group(0) @binding(0) -var bump: BumpAllocators; +var bump: BumpAllocators; @group(0) @binding(1) var indirect: IndirectCount; diff --git a/src/shaders.rs b/src/shaders.rs index 668dafac4..91d56db97 100644 --- a/src/shaders.rs +++ b/src/shaders.rs @@ -249,7 +249,7 @@ pub fn full_shaders(device: &Device, engine: &mut WgpuEngine) -> Result Result