Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
Minor cleanup of the multisampling logic, and switch default to Area.
  • Loading branch information
raphlinus committed Oct 12, 2023
1 parent 2f36411 commit 2c0ef60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions shader/fine.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,7 @@ fn fill_path_ms(fill: CmdFill, wg_id: vec2<u32>, local_id: vec2<u32>) -> array<f
workgroupBarrier();
sh_count[th_ix] = count;
}
#ifdef have_uniform
let total = workgroupUniformLoad(&sh_count[slice_size - 1u]);
#else
workgroupBarrier();
let total = sh_count[slice_size - 1u];
#endif
for (var i = th_ix; i < total; i += WG_SIZE) {
// binary search to find pixel
var lo = 0u;
Expand Down Expand Up @@ -180,15 +175,15 @@ fn fill_path_ms(fill: CmdFill, wg_id: vec2<u32>, local_id: vec2<u32>) -> array<f
// One alternative is to compute it in a separate dispatch.
let dx = abs(xy1.x - xy0.x);
let dy = xy1.y - xy0.y;
// TODO: apply numerical robustness and optimization
let dy_dxdy = dy / (dx + dy);
let a = dx / (dx + dy);
let is_positive_slope = xy1.x >= xy0.x;
let sign = select(-1.0, 1.0, is_positive_slope);
let xt0 = floor(xy0.x * sign);
let c = xy0.x * sign - xt0;
// This has a special case in the JS code, but we should just not render
let y0i = floor(xy0.y);
let ytop = select(y0i + 1.0, ceil(xy0.y), xy0.y == xy1.y);
let ytop = y0i + 1.0;
let b = dy_dxdy * c + a * (ytop - xy0.y);
let x0i = i32(xt0 * sign + 0.5 * (sign - 1.0));
// Use line equation to plot pixel coordinates
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ enum AaConfig {

/// Configuration of antialiasing. Currently this is static, but could be switched to
/// a launch option or even finer-grained.
const ANTIALIASING: AaConfig = AaConfig::Msaa16;
const ANTIALIASING: AaConfig = AaConfig::Area;

/// Renders a scene into a texture or surface.
#[cfg(feature = "wgpu")]
Expand Down

0 comments on commit 2c0ef60

Please sign in to comment.