From d795e205f9124bd482626a56fc294a5b6e23525a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Wed, 11 Oct 2023 09:34:54 +0200 Subject: [PATCH] Pass the return of `fill_path` in a pointer --- shader/fine.wgsl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/shader/fine.wgsl b/shader/fine.wgsl index 1cd0784ac..c2e8b6dc2 100644 --- a/shader/fine.wgsl +++ b/shader/fine.wgsl @@ -82,7 +82,9 @@ let ONE_MINUS_ULP: f32 = 0.99999994; let ROBUST_EPSILON: f32 = 2e-7; // New multisampled algorithm. -fn fill_path_ms(fill: CmdFill, wg_id: vec2, local_id: vec2) -> array { +// +// FIXME: This should return an array when https://github.com/gfx-rs/naga/issues/1930 is fixed. +fn fill_path_ms(fill: CmdFill, wg_id: vec2, local_id: vec2, result: ptr>) { let n_segs = fill.size_and_rule >> 1u; let even_odd = (fill.size_and_rule & 1u) != 0u; let tile_origin = vec2(f32(wg_id.x) * f32(TILE_HEIGHT), f32(wg_id.y) * f32(TILE_WIDTH)); @@ -343,7 +345,7 @@ fn fill_path_ms(fill: CmdFill, wg_id: vec2, local_id: vec2) -> array) -> array { +// +// FIXME: This should return an array when https://github.com/gfx-rs/naga/issues/1930 is fixed. +fn fill_path(fill: CmdFill, xy: vec2, result: ptr>) { let n_segs = fill.size_and_rule >> 1u; let even_odd = (fill.size_and_rule & 1u) != 0u; var area: array; @@ -491,7 +495,7 @@ fn fill_path(fill: CmdFill, xy: vec2) -> array { area[i] = min(abs(area[i]), 1.0); } } - return area; + *result = area; } // The X size should be 16 / PIXELS_PER_THREAD @@ -525,9 +529,9 @@ fn main( case 1u: { let fill = read_fill(cmd_ix); #ifdef msaa - area = fill_path_ms(fill, wg_id.xy, local_id.xy); + fill_path_ms(fill, wg_id.xy, local_id.xy, &area); #else - area = fill_path(fill, xy); + fill_path(fill, xy, &area); #endif cmd_ix += 4u; } @@ -689,7 +693,8 @@ fn main( } #else let tile = tiles[tile_ix]; - let area = fill_path(tile, xy); + var area: array; + fill_path(tile, xy, &area); let xy_uint = vec2(xy); for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {