A flagged fan-out draw is drawn in parts: only its flagged range region by region

Under DevicePolicy's RateMapRegionPolicy::FanOut the probe flags a draw that has a triangle
crossing w = 0 or reaching more regions than the geometry stage's copies. The whole draw was then
recorded region by region, once per region of the map (2074 for a 61 by 34 map), however few of
its triangles were flagged.

The probe now also records each flagged draw's first and last flagged triangle. A flagged list of
triangles of one instance, whose pipeline reads no [[primitive_id]] and writes no memory (the
conditions under which a draw is already cut into index ranges), is drawn in up to three parts in
its place: the triangles before the first flagged one fanned out, those from it to the last
region by region, and those after fanned out. Each part is a range of the draw's vertices or
indices, so each triangle keeps its vertices, vertex_id and order. Parts of a 16-bit index list
begin at even triangles, so their ranges start 4-byte aligned as the draw does. Any other flagged
draw is drawn region by region whole, as before.

The probe words grow from 1 + 2*32 to 1 + 4*32 per draw (bind::fan_out::PROBE_DRAW_WORDS). For a
flagged triangle the probe raises one of 32 words to u32::MAX - PrimitiveId and one to
PrimitiveId + 1, picked by PrimitiveId as the counts are, so no single word takes every atomic.
The wide marks that choose the variant of four copies now come only from triangles the probe does
not flag, so the fanned-out parts can take that variant.

Also: WorkCounts::rate_map_probe_wait_nanos sums the host's wall time from each probe's
submission until it saw it complete, so a walk can split host_step_nanos into the probe's round
trip and the host's own recording. rate_map_parted_draws and rate_map_parted_region_triangles
count the draws in parts and their triangles drawn region by region.

An earlier attempt drew a flagged draw through a geometry stage of 32 invocations, each taking a
block of up to 16 regions, in 5 passes over the map. On the pieces lane's frame with wide
triangles it made no GPU gain on an RTX 2080 (41.0 against 42.9 ms warm). On a Radeon 780M (RADV)
it went from 182 to 1900 ms, with one piece of 1.1 s. That attempt is not in this change.

Tests: render::fan_out's unit tests check that the parts take each triangle once, in order, with
no flagged triangle in a fanned-out part, and that the probe's words decode to the first and last
flagged triangle. The link test checks the probe's two atomic raises. The runtime's
rate_mapped_fan_out test adds two commands that draw the grid with one triangle over half the
target, one indexed and one without indices, and a triangle across w = 0 over the whole target.
Under FanOut all four flagged draws are drawn in parts and the frame is compared pixel for pixel
with the encoder's region-by-region frame. The pieces lane's wide frame checks that every flagged
draw is drawn in parts.
This commit is contained in:
Anees Iqbal committed 2026-11-13 02:43:42 -08:00
1 parent 0eb9f73862
commit dad0470c2e
15 files changed
+677 -191

No files matched your search

+10 -5
View File
@@ -5774,11 +5774,16 @@ each item named states the rule in full.
triangles is drawn once instead where a probe finds that none of its triangles crosses `w = 0`
or touches more regions than the fan-out's copies: its variant's geometry stage emits a copy of
each triangle for each region it touches (`VariantKey::region_fan_out`), a pixel centre within a
rounding error of an edge possibly covered otherwise (`docs/FAST-PATHS.md`). The probe costs
the host step a submission it waits for before the pass, which runs each probed draw's vertex
function and geometry stage once and shades nothing (`WorkCounts::rate_map_probes`,
`rate_map_probe_gpu_nanos`); a fanned-out draw runs its vertex function once where region by
region it runs once per region (`rate_mapped_pass.rs`, **Fan-out**).
rounding error of an edge possibly covered otherwise (`docs/FAST-PATHS.md`). A draw the probe
flags, a list of triangles of one instance whose pipeline reads no `[[primitive_id]]` and
writes no memory, is drawn in parts in its place: its triangles from the first the probe
flagged to the last region by region, those before and after fanned out
(`WorkCounts::rate_map_parted_draws`); another flagged draw is drawn region by region. The
probe costs the host step a submission it waits for before the pass, which runs each probed
draw's vertex function and geometry stage once and shades nothing (`WorkCounts::rate_map_probes`,
`rate_map_probe_gpu_nanos`, the host's wait `rate_map_probe_wait_nanos`); a fanned-out draw
runs its vertex function once where region by region it runs once per region
(`rate_mapped_pass.rs`, **Fan-out**).
- **A pass over a map of a zero screen extent is refused**, `RegionError::RegionExtent` on that
axis: the layer has no physical pixel there, so no attachment of the map's physical size can be
made, and what Metal rasterizes in such a pass is not measured.