Skip to content

Commit

Permalink
Pass the return of fill_path in a pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Oct 12, 2023
1 parent 4edf786 commit 02b8305
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions shader/fine.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ fn span(a: f32, b: f32) -> u32 {
let SEG_SIZE = 5u;

// New multisampled algorithm.
fn fill_path_ms(fill: CmdFill, wg_id: vec2<u32>, local_id: vec2<u32>) -> array<f32, PIXELS_PER_THREAD> {
//
// 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<u32>, local_id: vec2<u32>, result: ptr<function, array<f32, PIXELS_PER_THREAD>>) {
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));
Expand Down Expand Up @@ -334,7 +336,7 @@ fn fill_path_ms(fill: CmdFill, wg_id: vec2<u32>, local_id: vec2<u32>) -> array<f
#endif
}
}
return area;
*result = area;
}
#endif

Expand Down Expand Up @@ -430,7 +432,9 @@ let PIXELS_PER_THREAD = 4u;
//
// This is currently dead code if msaa is enabled, but it would be fairly straightforward
// to wire this so it's a dynamic choice (even per-path).
fn fill_path(fill: CmdFill, xy: vec2<f32>) -> array<f32, PIXELS_PER_THREAD> {
//
// FIXME: This should return an array when https://github.com/gfx-rs/naga/issues/1930 is fixed.
fn fill_path(fill: CmdFill, xy: vec2<f32>, result: ptr<function, array<f32, PIXELS_PER_THREAD>>) {
let n_segs = fill.size_and_rule >> 1u;
let even_odd = (fill.size_and_rule & 1u) != 0u;
var area: array<f32, PIXELS_PER_THREAD>;
Expand Down Expand Up @@ -482,7 +486,7 @@ fn fill_path(fill: CmdFill, xy: vec2<f32>) -> array<f32, PIXELS_PER_THREAD> {
area[i] = min(abs(area[i]), 1.0);
}
}
return area;
*result = area;
}

// The X size should be 16 / PIXELS_PER_THREAD
Expand Down Expand Up @@ -516,9 +520,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;
}
Expand Down Expand Up @@ -680,7 +684,8 @@ fn main(
}
#else
let tile = tiles[tile_ix];
let area = fill_path(tile, xy);
var area: array<f32, PIXELS_PER_THREAD>;
fill_path(tile, xy, &area);

let xy_uint = vec2<u32>(xy);
for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
Expand Down

0 comments on commit 02b8305

Please sign in to comment.