Draw width-0 lines as Metal's width 1/16
Metal draws every setLineWidth: width below 1/16 (0, negative widths and NaN among them) exactly as 1/16: the parallelogram reaching 1/32 pixel each side of the segment along its minor axis, after snapping the endpoints to 1/256 pixel. The band drew w' = 0 at a half width of 2^-subPixelPrecisionBits (1/256 on MoltenVK), which lights only the centres the segment passes within 1/256 of: right where the endpoints are on pixel centres, as every earlier probe case had them, and short of Metal's pixels anywhere else (a consumer's scattered draw lit 3 and 5 pixels on Metal and none on the runtime). The runtime's route now pushes the band's half width as w'.max(1/16)/2, so width 0 draws as the band of 1/16 does. Width 0 keeps its route (the band; the device's lines never draw it), and every other width is unchanged. The translator's band is unchanged but for its docs. Docs: line_width.rs and band.rs state Metal's rule (snapping to 1/256, a half rounded up; width 0 as 1/16) in place of "the centres on the segment"; the runtime README and set_line_width say "at 0 as at 1/16". RUNTIME_VERSION 1714 (a width-0 draw lights other pixels); the runtime-sources pin recomputed. Verified: runtime_lane::line_widths on MoltenVK (Apple M3 Max, macOS 27.0.1), both policies: 117 cases, 115 match Metal pixel for pixel and 2 refused as documented (triangle edges), 61 draws by the band; the 11 width-0 maps that differed at the parent now match (offset rows and columns 256 pixels, scattered lists 31, the strip 33, the clip-space list and strip 3 and 5). Runtime line_width unit tests (the band's half at 0 is 1/32), tests::engine_line_band, golden_hashes_match_the_table, the engine inventory parts, tests::fast_paths and the runtime-sources guard pass; clippy clean on all features and on --cfg m2v_gpu. (Carried to development from steelbrain/reims-graphics-kext 9ada26c9fa.)
This commit is contained in:
1 parent
2ee9856fa1
commit
7ebe50a2bc
7 files changed
+20
-22
No files matched your search
@@ -454,9 +454,9 @@ Apple's private `setLineWidth:` (`RenderCommandEncoder::set_line_width`) takes e
|
||||
measured on an Apple M3 Max (macOS 27.0.1), Metal draws `w' = floor(16 w) / 16` clamped to
|
||||
`[0, 16]` (NaN and negative widths as 0), the encoder's from 1 at its start: at `w' = 1` its
|
||||
ordinary lines, at every other `w'` the parallelogram Vulkan's non-strict wide lines may be (its
|
||||
minor-axis edges `w'` long through the endpoints, the ends not extended), at 0 the pixel centres on
|
||||
the segment. A strip or loop draws one parallelogram per segment; triangles in fill mode `Lines`
|
||||
draw their edges so. The runtime draws each draw at `w' != 1` by one of two routes, counted
|
||||
minor-axis edges `w'` long through the endpoints, the ends not extended), at 0 as at 1/16. A strip
|
||||
or loop draws one parallelogram per segment; triangles in fill mode `Lines` draw their edges so.
|
||||
The runtime draws each draw at `w' != 1` by one of two routes, counted
|
||||
(`WorkCounts::device_wide_line_draws`, `line_band_draws`):
|
||||
|
||||
| Device | Route |
|
||||
|
||||
@@ -349,7 +349,7 @@ impl RenderCommandEncoder {
|
||||
/// macOS 27.0.1): `floor(16 width) / 16` clamped to `[0, 16]`, NaN and every width not
|
||||
/// above 0 as 0. At 1 a line is Metal's ordinary one; at any other width the parallelogram
|
||||
/// whose minor-axis edges pass through the endpoints, each that width long, a strip's
|
||||
/// segments each their own; at 0 the pixel centres on the segment. Points and filled
|
||||
/// segments each their own; at 0 as at 1/16. Points and filled
|
||||
/// triangles do not change. Every width is accepted. A draw at another width than 1 runs the
|
||||
/// device's own lines where they draw it (announced `device-wide-lines` where they differ
|
||||
/// from Metal's, or under `WideLinePolicy::Exact` the band below where they do), else the
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
//! x on a tie; its two minor-axis edges through the endpoints, each `w'` long and centred on
|
||||
//! its endpoint; its other two edges parallel to the segment; the ends not extended; a pixel
|
||||
//! drawn where its centre lies inside, by the polygon rules' ties (top and left edges in). The
|
||||
//! width is not rounded to whole pixels. At `w' = 0` a line draws exactly the pixel centres on
|
||||
//! the segment, by the same end rule.
|
||||
//! width is not rounded to whole pixels. The endpoints are first snapped to 1/256 pixel, a half
|
||||
//! rounded up. At `w' = 0` a line draws exactly as at 1/16, pixel for pixel: the centres within
|
||||
//! 1/32 pixel of the segment along its minor axis, not only those on it.
|
||||
//! - A strip or loop draws one parallelogram per segment, with no joins: where two overlap a pixel
|
||||
//! takes two fragments (at `w' = 1` a shared vertex is drawn once, as the diamond rule's).
|
||||
//! - Triangles whose fill mode is `Lines` draw their edges by the same rule; in fill mode `Fill`
|
||||
@@ -40,9 +41,8 @@
|
||||
//! `pipeline::link::band`), two triangles per line over Metal's parallelogram, through a
|
||||
//! tessellation control and evaluation stage (`tessellationShader`). It is every other width's
|
||||
//! route: no `wideLines` (MoltenVK), `w'` outside the range, and `w' = 0`, which the band draws
|
||||
//! at half a width of `2^-subPixelPrecisionBits` (a pixel centre on the segment inside, one
|
||||
//! off it by more than the rasterizer's snapping outside). A strip or a loop is drawn as the list
|
||||
//! of its segments (`render/restart.rs`); a flat input under the last provoking vertex reads the
|
||||
//! at 1/16, as Metal does. A strip or a loop is drawn as the list of its segments
|
||||
//! (`render/restart.rs`); a flat input under the last provoking vertex reads the
|
||||
//! list led by each line's last vertex (`render/provoking.rs`), which covers the same pixels, as
|
||||
//! the parallelogram is the same either way. Refused (`Unsupported`, `Feature::WideLines`,
|
||||
//! needing `tessellationShader`) without it.
|
||||
@@ -221,10 +221,8 @@ fn route(
|
||||
false => Error::NotImplemented(RuntimeGap::WideLines),
|
||||
});
|
||||
}
|
||||
let half = match width.0 {
|
||||
0 => (-(limits.sub_pixel_precision_bits as f32)).exp2(),
|
||||
_ => w / 2.0,
|
||||
};
|
||||
// Metal draws `w' = 0` as 1/16 (the module docs).
|
||||
let half = w.max(1.0 / 16.0) / 2.0;
|
||||
Ok((LineRoute::Band { half }, false))
|
||||
}
|
||||
|
||||
|
||||
@@ -59,8 +59,7 @@ fn cell(
|
||||
}
|
||||
}
|
||||
Ok((LineRoute::Band { half }, false)) => {
|
||||
let bits = profile.limits().sub_pixel_precision_bits as f32;
|
||||
assert_eq!(half, if w == 0.0 { (-bits).exp2() } else { w / 2.0 });
|
||||
assert_eq!(half, if w == 0.0 { 1.0 / 32.0 } else { w / 2.0 });
|
||||
Cell::Band
|
||||
}
|
||||
Err(Error::Unsupported(u)) => {
|
||||
|
||||
@@ -1 +1 @@
|
||||
917329994b4d1bf088ec621e98b42dcf7289ea19e1e827d64538e7bfea319004
|
||||
ba8e79dee4017e7c8127e6fa8bac164894f1a1cd1929ea1fbf2e35ee252e11d7
|
||||
Vendored
+1
-1
@@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 480;
|
||||
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
|
||||
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
|
||||
/// keeps no history.
|
||||
pub const RUNTIME_VERSION: u32 = 1713;
|
||||
pub const RUNTIME_VERSION: u32 = 1714;
|
||||
|
||||
/// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex,
|
||||
/// of the manifest, the build script, and exactly the files the crate roots' module tree compiles
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
//! `nonStrictWideLinesUseParallelogram`): the segment's major axis is the larger of its
|
||||
//! framebuffer extents, x on a tie; the parallelogram's two minor-axis edges pass through the
|
||||
//! endpoints, each `w` long and centred on its endpoint, and its other two edges are parallel to
|
||||
//! the segment; a pixel is drawn where its centre lies inside, by the polygon rules' ties (Metal
|
||||
//! probes on the Apple M3 Max, macOS 27.0.1). At width 0 Metal draws exactly the pixel centres on
|
||||
//! the segment, by the same end rule.
|
||||
//! the segment; a pixel is drawn where its centre lies inside, by the polygon rules' ties, the
|
||||
//! endpoints first snapped to 1/256 pixel (Metal probes on the Apple M3 Max, macOS 27.0.1). Metal
|
||||
//! draws width 0 exactly as 1/16.
|
||||
//!
|
||||
//! The variant's pipeline draws each line as one patch of two control points (a `PATCH_LIST`,
|
||||
//! the line's vertices in order) through two stages link adds between the vertex and fragment
|
||||
@@ -29,8 +29,9 @@
|
||||
//! cover the parallelogram exactly and wind alike in every direction ([`LineBand::FRONT_FACE`]).
|
||||
//! The offset is taken to clip space through the draw's Vulkan viewport 0, whose half extent
|
||||
//! `(sx, sy)` the draw pushes beside `h` (`PushField::LineBand`, the stage's own push range).
|
||||
//! Width 0 takes `h = 2^-subPixelPrecisionBits`, one unit of the device's subpixel grid: a pixel
|
||||
//! centre on the segment lies inside, one off it by at least that much outside.
|
||||
//! The rasterizer snaps each corner to the device's subpixel grid, where Metal snaps the
|
||||
//! endpoints to 1/256 pixel and then offsets them: on a grid of 1/256 the two agree, `h` being a
|
||||
//! multiple of 1/32 pixel.
|
||||
//!
|
||||
//! An endpoint at `w < 2^-20` (at or behind the eye) is first moved along the segment to `w =
|
||||
//! 2^-20`, its clip distances and float varyings with it, so the band's direction is the visible
|
||||
|
||||
Reference in new issue
Block a user