Skip to content

Commit

Permalink
Merge pull request #382 from Zoxc/dx12-tweak
Browse files Browse the repository at this point in the history
Pass the return of `fill_path` in a pointer
  • Loading branch information
Zoxc authored Oct 27, 2023
2 parents c9faf2d + d795e20 commit 1aed7fb
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 @@ -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<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 @@ -343,7 +345,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 @@ -439,7 +441,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 @@ -491,7 +495,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 @@ -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;
}
Expand Down Expand Up @@ -689,7 +693,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 1aed7fb

Please sign in to comment.