Wide lines: no device's own lines are taken as Metal's parallelogram

RADV fails wide_lines_draw_metal_s_parallelograms and its exact-answers twin at the lane's
"scattered lines width 2.5, fragments" map, 628 pixels where Metal's has 622: on the Radeon RX
7900 XTX (homelab-gem10-1, m3-max-10724) and on the 780M (homelab-um870-1, its only GPU,
m3-max-10773), at this branch's base and at development alike. The runtime took RADV's lines as
Metal's there, unannounced: RADV is the one driver of the committed profiles stating non-strict
parallelogram lines (strictLines unset, nonStrictWideLinesUseParallelogram set), and 2.5 lies on
its 1/8 granularity above 1, so the route was the device's lines under both policies.

Cause, measured: a probe on the XTX (m3-max-10800, a scratch branch, never merged) drew each of
the 48 scattered lines alone and printed its pixels. 21 of them lie a row or a column off Metal's
parallelogram at an end: one more past the first vertex, one fewer before the last. A model of
Metal's rule (endpoints on the 1/256 subpixel grid, the parallelogram whose minor-axis edges are
w' long through them, the ends not extended, pixel centres by the top-left rule) reproduces
Metal's map pixel for pixel; the XTX's ends fit no constant shift of it. Vulkan leaves where a
non-strict wide line's ends fall to the implementation, and no driver is measured to place them
as Metal does.

Change: the device route has no exact form any more (render/line_width.rs route). Every draw the
device's own lines take is announced device-wide-lines, the notice naming "parallelograms, whose
ends and endpoints' snap the driver places as it draws them" where the width is on the grid above
1, and under WideLinePolicy::Exact (exact_answers) the band draws it wherever the device has
tessellationShader. On RADV, widths above 1 on the 1/8 grid move from silent device lines to
announced device lines under the default, and to the band under exact answers. No other profile
changes route: lavapipe and NVIDIA (strict) and ANV (not stated as parallelograms) were announced
already.

Tests: the runtime's route table reads A or B where it read E for the three RADV profiles (Cell::
Exact removed). The validation lane drops LineFacts::draws_as_metal, and asserts per case that
the draws of the device's own lines announce device-wide-lines one for one, which fails without
this change on RADV (width 2.5 drawn by the device's lines with no notice); the edges test
asserts the notice at each device-line draw.

Docs: render/line_width.rs's module docs, DeviceWideLines' rustdoc and docs/API.md's entry and
policy text, WideLinePolicy's and DevicePolicy::wide_lines' docs, the runtime README's route table
(its "exactly Metal's" row folded into the announced one), docs/FAST-PATHS.md's row (no device's
lines are taken as Metal's; the cost adds a row or a column at an end), docs/RUNTIME-PORTING.md's
SetLineWidth row. The announced cost string is unchanged.

Notices: one device-wide-lines per device (once per kind, unless announce_each names it) on a
RADV run that draws wide lines only at widths above 1 on the 1/8 grid, where it announced
nothing; a run that already drew a width below 1 or off the grid announced it already.

Needs the runtime-sources pin and a RUNTIME_VERSION (the orchestrator's numbers).

Verified: cargo fmt. The XTX, 780M, lavapipe and M3 runs follow through potluck.
(cherry picked from commit be88ae03f199d5a485abcc546d0d52b181290e7b)
This commit is contained in:
Anees Iqbal committed 2026-11-08 22:45:29 -08:00
1 parent 242539b584
commit de5a77cc06
10 files changed
+153 -171

No files matched your search

+18 -17
View File
@@ -206,16 +206,15 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
recording. `pipeline_waits = PipelineWaitPolicy::Exact`, which `exact_answers()` selects, makes
the predicted pipeline before the creation returns, as Metal compiles there, and waits for
every draw's and dispatch's until made.
- **A wide line the device's own** (`WideLinePolicy::Device`, the default; the runtime's choice,
no pipeline's code differs). A line Apple's `setLineWidth:` widens, and a triangle's edge in fill
mode `Lines`, is drawn by the device's own lines wherever it draws the width (`wideLines`,
inside `lineWidthRange`), exact where they are Metal's parallelogram (`strictLines` unset,
`nonStrictWideLinesUseParallelogram` set, the width on `lineWidthGranularity` and above 1),
announced `device-wide-lines` where not. `wide_lines = WideLinePolicy::Exact`, which
`exact_answers()` selects, draws those as the pipeline's band variant instead (section 4), on a
device with `tessellationShader`. Every other width other than 1 is the band under either value,
and what neither draws the device's lines at the nearest width they draw, announced
`lines-at-nearest-width` (the runtime's README, line widths).
- **A wide line the device's own** (`WideLinePolicy::Device`, the default; the runtime's choice, no
pipeline's code differs). A line Apple's `setLineWidth:` widens, and a triangle's edge in fill
mode `Lines`, is drawn by the device's own lines wherever it draws the width (`wideLines`, inside
`lineWidthRange`), announced `device-wide-lines`: no device's lines are taken as Metal's
parallelogram, a driver's parallelograms included (their ends are the driver's). `wide_lines =
WideLinePolicy::Exact`, which `exact_answers()` selects, draws those as the pipeline's band
variant instead (section 4), on a device with `tessellationShader`. Every other width other than 1
is the band under either value, and what neither draws the device's lines at the nearest width
they draw, announced `lines-at-nearest-width` (the runtime's README, line widths).
- **A compressed extended-range texture's blits keep the bytes** (`ExtendedRangeBlitPolicy::Kept`,
the default; the runtime's choice, no pipeline differs). Metal's GPU blit into, out of or between
`BGRA10_XR` or `BGRA10_XR_sRGB` textures it keeps losslessly compressed
@@ -3301,13 +3300,15 @@ bound.
draw nothing, and some a few of the points or a box.
- `metal2vulkan-degrade-device-wide-lines` (precision). `DeviceWideLines`: A draw of lines at a
width other than 1 (Apple's `setLineWidth:`), or of a triangle's edges in fill mode `Lines` or of
a mesh draw, drawn by the device's own lines where they are not Metal's parallelogram: strict
lines (the rectangle the width spans across the segment, square ends), lines Vulkan does not
state as parallelograms (`nonStrictWideLinesUseParallelogram` unset, or a width below 1), or a
width off the device's `lineWidthGranularity`, which rounds it. Under `WideLinePolicy::Exact` a
draw of lines or of a triangle's edges takes the band variant there instead, on a device with
`tessellationShader`. Cost: the lines can cover pixels Metal's parallelogram does not, and miss
others, at each end and along each edge.
a mesh draw, drawn by the device's own lines, which no device's are taken to draw as Metal's
parallelogram: strict lines (the rectangle the width spans across the segment, square ends), lines
Vulkan does not state as parallelograms (`nonStrictWideLinesUseParallelogram` unset, or a width
below 1), a width off the device's `lineWidthGranularity`, which rounds it, and a driver's
parallelograms, whose ends and endpoints' snap are the driver's (RADV on the Radeon RX 7900 XTX
draws 21 of 48 scattered lines at width 2.5 a row or a column off Metal's at an end). Under
`WideLinePolicy::Exact` a draw of lines or of a triangle's edges takes the band variant instead,
on a device with `tessellationShader`. Cost: the lines can cover pixels Metal's parallelogram does
not, and miss others, at each end and along each edge.
- `metal2vulkan-degrade-lines-at-nearest-width` (precision). `LinesAtNearestWidth`: A draw of lines
at a width other than 1 (Apple's `setLineWidth:`), or of a triangle's edges in fill mode `Lines`
or of a mesh draw, that neither the device's own lines at that width nor the band variant draws,