Commit Graph
363 Commits
Author SHA1 Message Date
Anees Iqbal af1dd85b66 Blend-source notes state their bound and the device compiler's regrouping; padded rows on the 5080 and the Iris Xe
ExtendedRangeBlendSource and ExtendedRangeFloatBlendSource (their docs, the API
catalogue entries and the FAST-PATHS device-gap row) now say what the suite
measured: the device's compiler may contract and regroup the in-shader blend
(MoltenVK on the M3 Max and NVIDIA's driver on the RTX 5080 compute
S·F + D·(1 - F) as D + F·(S - D)); a stored channel lands within two codes of
Metal's on a linear format and within six near zero on an sRGB twin; and where
the compiler regroups a padded format's blend, an infinite second source stores
an end code where Metal's sum is NaN, stored as 0. The FAST-PATHS row names the
padded formats, which it lacked, and no longer says 'not measured'.

known-gaps.tsv: the 168 extended-range rows (xr-blend, xr-gamut, xr-gradient,
xr-masked) whose Open item was the blend notes' documentation are closed (Open:
nothing, the recorded bound covering the difference); every one is within the
bound (survey of the rows' largest differences). The padded-blend rows are
regenerated for five venues: the M3 Max, RADV PHOENIX and llvmpipe as before,
and the RTX 5080 (b5080 entry xrblend2-padded-replay-5080) and the Iris Xe
(job m3-max-13386), 17 each. The 5080's second-source cases differ by the whole
code range as the M3's do, and its counts are exactly a model of
D + a·(S - D) over an unnarrowed float destination (971 on R10Unorm_X6, 1850 on
RG10Unorm_X12); the Iris's are exactly the sum as written over the half
destination (844, 1607), as RADV's; llvmpipe's the sum as written over a float
destination (962, 1831). No venue's largest difference exceeds the M3's, the
780M's or llvmpipe's.

engine_padded_blends: a fetch of a padded attachment makes the whole pipeline
on every committed profile that orders fetch (storage form or input
attachment) and names the device gap elsewhere; a bfloat fetch stays
NotImplemented(Format), the negative control. Not yet run.

(cherry picked from commit c923b6d49c36c8354f375f6dababfd5f81f1ffbc)
(cherry picked from commit e3a2b226d7f5938811d1d251172088baf05c15cb)
(cherry picked from commit 85a2473cc6ea6a2c9165e2614d1e87ca77c1627e)
2026-11-10 02:59:18 -08:00
Anees Iqbal 962aa365dd FAST-PATHS: the fill decision's evidence on um870 and gem10
The fill row gains the decision's measurements: the images arm of
tests::reclaim_submit_bench, two runs each of the base (every block filled),
the decision (cf5561bb5d) and the arm with no fill, interleaved, the TTM
page pools emptied through the shrinker's debugfs before each arm and before
its pressed phase.

um870 (RADV, Mesa 26.2.6, Linux 7.3.1-1-cachyos), pressed, base / decision /
no fill: turnarounds of 8 ms or more 19 and 4 / 5 and 11 / 11 and 17, of
17 ms or more 1 and 1 / 1 and 2 / 8 and 9; the ready thread's makings 419
and 461 / 379 and 343 / 494 and 292 ms, in compaction 269 and 299 / 215 and
203 / 374 and 179 ms; block-sized buffer objects 2.0 / 2.0 and 1.5 / 1.0 a
making. Quiet: the decision filled every block (1 miss alone in 26) with no
turnaround of 8 ms or more; no fill had 12 a run. gem10 (quiet in both
phases): the decision made no block plain, no turnaround of 8 ms or more.

Also: the misses' free times (17 of 18 quiet misses freed in 0.06 to
0.20 ms, the pages left to the kernel's deferred delete; 44 of 47 pressed
ones in 2.7 ms or more), the fill's CPU shares (91 to 99% and 85 to 100%),
the page-table buffer objects a fill's mapping adds, and the block_fills
misses as now measured (0 or 1 of 5).

(cherry picked from commit 58bff1328f25ca7f96f4c82bab23d46ff5a40b1b)
2026-11-10 02:11:07 -08:00
Anees Iqbal 15c596f09a Memory: a device stops its fills once 3 of its last 4 missed
On gem10's 780M, quiet (12 GiB of free memory left beside the bench), a
tip of 2 of the last 4 stopped once: two fills in a row whose frees
returned in 0.14 and 0.17 ms, the pages left to the kernel's deferred
delete, each block then filling its own (8.0 and 10.9 ms); the 2 plain
makings that followed held the submissions 10.0 ms. Of the misses the
benches' quiet phases saw on um870 and gem10, 14 of 15 had such a fast
free; of those under um870's pressed phase, 30 of 33 freed in 2.7 ms or
more, in runs of up to 6.

Replayed over the always-filling base's phases, stopping at 3 of the last 4
fills 6 to 8 of 12 under um870's pressure (2 of 4: 5 to 7) and none on a
quiet host.

Verified so far: the CPU test is rewritten for the threshold; its run and
the device evidence follow.

(cherry picked from commit cf5561bb5d95b659debfeeedc3454188cda701b3)
2026-11-10 02:11:07 -08:00
Anees Iqbal 09e4afdba6 Memory: a device stops its fills once 2 of its last 4 missed, not after a lone miss
On um870's 780M (pools emptied before each arm and again before its
pressed phase), a quiet phase's fills missed alone: 1 of 13 and 1 of 5 in
the always-filling base, each the fill's free returning in 0.06 to 0.15 ms
where a free that hands its pages to the kernel's pool takes 2.7 to 3.5 ms,
so that the block's allocation ran before the pages were back. Backing off
after each such miss (837c461b2b) made the next 2 makings plain on the
quiet host, each holding the submissions 9.0 to 9.6 ms: 3 turnarounds of
8 ms or more in a quiet phase where the base had none.

Now a device keeps the outcomes of its last 4 fills (FILL_RECENT) and
stops filling once 2 of them missed (FILL_STOP_MISSES); the backoff after
that is as before (2, doubling with each missed probe up to 32), and a
probe that saves clears the record. Misses under pressure come together
(the same base, pressed: 8 of 12 and 3 of 12, runs of up to 5).

Verified so far: the rule's CPU test is rewritten for it
(tests::memory::fills_stop_once_two_of_the_last_four_miss_and_a_saved_probe_brings_them_back);
its run and the device evidence follow.

(cherry picked from commit bc3338dee50f9627b799cf68c747bef1b36a4672)
2026-11-10 02:11:07 -08:00
Anees Iqbal 261af18a27 Memory: after a fill misses, a device makes its next plain blocks plain, probing with backoff
The fill rule of 6da2c8c1dc kept a device filling while each fill spared
its block's allocation half its time, so on a host short of free memory it
kept making a second block-sized allocation for each block, the kernel
compacting and reclaiming for both: the consumer's scroll on um870's 780M
(pin 33) waited longer on host compaction than pin 30 did, with no fill.

Now a fill that missed (its block's own allocation took 1 ms or more,
FILL_SAVED_BELOW, as WorkCounts::plain_block_fills_missed counts) leaves the
next 2 makings plain, then fills one, a probe; each further miss in a row
doubles the plain makings between probes, up to 32; a probe that saves
brings filling back for every making (Fills, FILL_BACKOFF_FIRST,
FILL_BACKOFF_MOST). The module docs, the skipped count's docs and the
ledger row say the rule.

Verified so far: tests::memory::fills_back_off_after_a_miss_and_a_saved_probe_brings_them_back
is the rule's CPU test (not yet run: the build is next). Device evidence
follows in a later commit.

(cherry picked from commit 837c461b2b1aa716622237afc48870307282dbf8)
2026-11-10 02:11:07 -08:00
Anees Iqbal 34310d93f7 Reads through a sampler: a texture buffer's border by its t axis, the ledger rows
The read_through conformance family's per-axis states, recorded on the M3 Max,
show a texture buffer's index past its end addressed as the first texel of a
row past its one row: the border texel where t's mode is a border mode, else
texel 0, whatever s and r are; a runtime sampler whose s mode is
clamp_to_edge clamps it first (s-border reads texel 0, st-border the border,
tr-border clamps). The read took s's mode, which read the border for s-border,
sr-border, s-zero and three mixed states. The border now follows t, and never
applies where the sampler clamps.

The retaken buffer recording; known-gaps rows for the argument-buffer
texture's swizzled transparent border (divergent) and its opaque-border and
runtime-sampler reads (refused), with the swizzle gap in FAST-PATHS.md's known
gaps; the module docs say both.

Verified: the replay on the M3 through MoltenVK (job m3-max-13263) named the
six buffer divergences this fixes; the fix's replay is next.

(cherry picked from commit 22c6817d4074c1b18bbc7c6d166370fe9990c1a5)
2026-11-10 01:30:11 -08:00
Anees Iqbal dbad32bb7b Docs: visibility venues, Metal's subnormal sample coordinates, a shared event's queue rule
Three corrections, each checked against the tree:

- runtime/src/visibility.rs said Metal's visibility-result behaviour was
  measured on an M4, which is not one of our venues. The conformance
  suite's visibility cases record Metal's answers on an Apple M3 Max with
  macOS 27.0.1 (recordings/visibility-*.json); the doc now names that venue.
  The 5300M and UHD 630 answers it cites beside it are unchanged.

- docs/FAST-PATHS.md's DeviceSampling row (and docs/API.md's device-sampling
  entry) said Metal reads any subnormal coordinate as the zero of its sign
  before addressing. That holds for a normalized coordinate (measured on the
  M3 Max on R32Float, PrecisionNote::DeviceSampling's documentation); a
  negative subnormal pixel coordinate addresses texel -1, as the M3 Max's
  recording of pixel-samplers-subnormal-border answers (the border at
  -2^-149, -2^-140 and -2^-127, known-gaps.tsv). Both now say so, and the 27
  known-gaps.tsv rows that quoted the old reading quote the new one.

- SharedEvent::reserve_vk_signal's Safety text lacked the same-VkQueue rule
  that Event::reserve_vk_signal states. A shared event's command-buffer waits
  are held on the host (event_timeline.rs: a settable timeline never hands
  a wait to Vulkan), but a command buffer that signals the event after the
  reservation waits on its VkQueue for the reserved index before its own
  signal (EventTimeline::signal's `after`, the order wait in
  command_buffer/submit.rs), so the caller's signalling submission must not
  go behind it on one VkQueue, and a texture copy on the first VkQueue behind
  it waits for the signal too. The rule is now stated, scoped to those
  signalling command buffers.

Verified: rustdoc and the runtime's degradation_catalogue test over the
edited text; no behaviour changes.

(cherry picked from commit 12bac3fafd3d3e66dc0b88d01231dd30e2694ffb)
2026-11-09 23:49:33 -08:00
Anees Iqbal 05a31354c1 Spares: hold at most 4,096 command buffers, the pools out of them counted
A command buffer keeps what its recording took of the driver's device-wide pools until it is
begun again, reset or freed, and the spare command pools kept each pool's peak over its recent
uses with no bound across pools. On ANV below Xe-HP each command buffer that records a binding
table takes a 64 KiB block of the device's 1 GiB binding-table pool, so a device holds at most
16,384 of them, and the next recording fails with VK_ERROR_OUT_OF_DEVICE_MEMORY with no driver
message. tests::linear_runs::checked_frames_merge_once failed so on ms01's Iris Xe (6 of 79 runs
beside the runtime suite, job m3-max-13027): its frames of 707 and 1,413 render passes, each a
command buffer whose pool kept its peak, left the spares holding 9,716 to 9,771 command buffers
in every failed run (2,786 to 7,747 in sampled passing runs) before the frame that failed. A
probe on the same Iris Xe (job m3-max-13053, twice): one command buffer of render passes, each
a primary and a secondary beside a cleared depth target, failed at the end of its 8,087th pass
with the spares holding 424, 2 x 8,086 + 212 = 16,384.

A give-back now counts the spares, the pool given back, and what each pool out of the spares
held as it went out (taken by a command buffer, out for frees, or beginning a primary ahead:
CommandPools::out, kept under the spares' lock). Past HELD (4,096) the oldest spares that hold
any shed all their command buffers on the free thread as an idle spare does and go back as the
oldest; where that is not enough, the pool given back frees its last made past the bound, a
secondary kept, never the primary begun ahead (past_held, CommandPool::past). On ANV the frees
do not trim, as before, so kept barriers stay valid. HELD leaves three quarters of the binding-
table pool to the command buffers committed and in recording.

Tests: tests::spares::the_spares_and_a_pool_given_back_hold_at_most_held_command_buffers (the
policy, no device) and tests::spares::device::
command_buffers_alive_at_once_leave_the_spares_holding_at_most_held (three command buffers of
2,112 blit encoders alive at once, each in a pool of its own). docs/FAST-PATHS.md records the
remaining ceiling: one command buffer of about 8,000 such passes still fails on ANV below Xe-HP.

Verification follows in the next commits' messages and the report: build and clippy, the
spares tests on lavapipe, the M3 and the Iris Xe with a negative control, and a loaded Iris run.

(cherry picked from commit 8ab6915d698cdaf29e2aa8bfd50c77cd8922d507)
2026-11-09 23:18:09 -08:00
Anees Iqbal c120cdf105 Docs: the fill misses often, not mostly, in a process that submits nothing
tests::block_fills on the Radeon 780M (RADV PHOENIX, Mesa 26.2.6) missed 4 of its 5 fills in job
12841 and 2 of 5 in job 12891 (at the rebased tree of this branch); the fill row said "mostly"
from the first run alone. Documentation only.

(cherry picked from commit caa2b45263277b2696184602298e329291c8b5dd)
2026-11-09 20:49:31 -08:00
Anees Iqbal ee0b8af622 Docs: the fill row's fragmented phases at 68 MiB blocks of images, 0 to 4 and 0 to 2
The row said a fragmented phase had 1 to 4 turnarounds of 8 ms or more and 1 or 2 missed fills;
job 12852's second run of the bursts arm had neither (0 and 0), so the ranges are 0 to 4 and 0 to
2. Documentation only.

(cherry picked from commit e20985fc7ff241c40edcd55b3c21506b715bb899)
2026-11-09 20:49:31 -08:00
Anees Iqbal 6f4f45f1a8 Docs: the fill with 68 MiB blocks of images, measured; its misses where nothing is submitted
The fill row's numbers were of 64 MiB blocks of images. With the 68 MiB ones made now, on the
Radeon 780M (RADV PHOENIX, Mesa 26.2.6), the kernel's page pools drained before each run, the
reclaim bench's arms (jobs 12852, two runs, and 12860, one run with the fill-window print): a
quiet phase 0 or 1 turnarounds of 8 ms or more, no fill missed, the makings' vkAllocateMemory
1.2 to 2.0 ms in all; a fragmented phase 1 to 4 (the slowest 33.1 ms, behind a missed block
whose allocation took 29.4 ms), 1 or 2 of its 12 or 13 fills missed. Of the 957 submissions
begun while a fill ran (12860), 1 turned around in 8 ms or more (14.0 ms, fragmented); in 12852
a 24.0 ms one began within a 32 ms fill on the fragmented host. The row also says that in a
process that submits nothing the fill mostly misses (tests::block_fills on the 780M, job 12841:
of 5 fills, 1 saved and 4 missed), the cause not measured, and the fill's cost for a 68 MiB
block (about 16 ms on the quiet host, at most 17.3 ms).

(cherry picked from commit 30108c53759b9f76e25c0994e7db3cd4f7de7731)
2026-11-09 20:49:30 -08:00
Anees Iqbal 314263e447 Docs: the 2048x2048 packing measured, the slack's reason; the fill's other devices by the test
Verified at the tree of "Memory: pooled blocks stay 64 MiB, 68 MiB for images" (job 12840 on
ms01, the Iris Xe; job 12841 on gem10, the 780M) and at that of "Memory: a block's making time is
the tests' alone" (job 12851 on ms01, the Iris Xe and lavapipe):
- tests::blocks_ahead::a_block_of_images_holds_four_textures_of_a_quarter_block_each passes on
  the Radeon 780M (RADV PHOENIX, Mesa 26.2.6; 12841), on the Iris Xe (ANV; 12840 and 12851) and
  on lavapipe (12851): eight RGBA8Unorm textures of 2048x2048 lie in 2 blocks of 68 MiB. Each
  took 16842752 bytes at an alignment of 65536 on the 780M and the Iris Xe, 16777216 at 64 on
  lavapipe. With the slack taken out (a negative control, image blocks of 64 MiB), the test fails
  on the 780M (12841) and the Iris Xe (12840): the eight lie in 3 blocks. So the sixteenth stays,
  for images.
- tests::block_fills passes on all three: the 780M fills every block of images first (types
  0x15864: of 3 blocks of images, 5 plain blocks filled first, 1 made under 1 ms and 4 not, in a
  process that submits nothing; 12841); the Iris Xe and lavapipe fill none (types 0x0, 0 fills;
  12851).
- The memory, blocks_ahead, zeroed_start, clip_bursts, exported and freed memory,
  device_recovery and host_copy tests pass on the 780M (51 of 51; 12841) and the Iris Xe (51 of
  51; 12840); blocks_ahead and block_fills on the Iris Xe (8 of 8; 12851), and blocks_ahead,
  block_fills and memory on lavapipe under --cfg m2v_cpu_icd (27 of 27; 12851).
- clippy with no cfg, with --cfg m2v_gpu and with --cfg m2v_cpu_icd, the runtime's Rustdoc, the
  API signatures and the driver-fact tests (9 of 9): clean (12851). The conformance crate's suite:
  1029 of 1029 (12840).

(cherry picked from commit 458aa4a23c3359cc6b44f01812d53a88260f29ba)
2026-11-09 20:49:30 -08:00
Anees Iqbal 930e3aa49e Memory: pooled blocks stay 64 MiB, 68 MiB for images; the making-rate rule goes
The rule that made a device's later pooled blocks of plain memory smaller once a making took
longer than 8 ms (MAKING_BOUND, MIN_PLAIN_BLOCK_BYTES, Memory::plain_block_made) is removed,
with what existed only for it: placements larger than a pool's small blocks taking blocks of
their own power of two (pooled_block_bytes, Pool::large, took_large), the block's worth of small
blocks kept ahead (ahead_sizes' count), the call's upper bound on the blocks it takes
(ready::Need's most; a call now takes a block of its least bytes or more), and nearness by the
largest block a pool holds (Pool::ahead_room). Every pool's blocks are one size: 64 MiB, or the
device's largest allocation, and a pool of images' 68 MiB, a sixteenth besides
(IMAGE_BLOCK_SLACK, formerly PLAIN_BLOCK_SLACK, now on images alone): a driver's image takes more
than its texels, so that four images of a quarter of a block fit in one.

The hold that rule shortened is taken away by the exportable fill of the commit before, where
the driver holds submissions in plain makings, with the blocks kept at 64 MiB: the 17 MiB blocks
made 45 to 55 makings a phase on the 780M against 13 to 15, holding 138 to 230 ms against 125 to
201 ms, and put every texture past 17 MiB in a block of its own (docs/FAST-PATHS.md).

Tests: tests::plain_blocks goes; blocks_ahead's small-blocks tests go (the reserve of four small
blocks, the large placements' block, the mixed-sizes run made smaller partway); its packing test
now packs four RGBA8Unorm textures of 2048x2048 (a quarter of 64 MiB) to a block of images;
the first-block test runs on 64 MiB blocks. A new device test, tests::block_fills, holds that a
device with DriverFact::PlainAllocationsHoldSubmissions fills every block of images it makes
exportable first, counted, and that a device without it fills none. The reclaim bench's
small-blocks arms go. The conformance cost gate gates device_memory_allocated again (the
BLOCK_SIZE reason goes): block sizes no longer follow how long earlier makings took.

docs/FAST-PATHS.md: the RADV plain-blocks row is rewritten (blocks stay 64 MiB, the hold
measured), a row for the fill is added (its kernel dependency, its counters, the 780M A/B and
its cost), and the NVIDIA memory-block row says one block is kept ahead.

Verified: not yet compiled; the clippy, Rustdoc and device runs follow.

(cherry picked from commit 2cc9b21cb99b3fa7ac3b4199ae2aca88a99e014e)
2026-11-09 20:49:29 -08:00
Anees Iqbal f066aaf587 Blocks made ahead: a pool near its next block by three quarters of the largest block it holds
tests::blocks_ahead::mixed_sizes_find_their_blocks_made_ahead failed in
two of five runs of the memory tests on the Radeon 780M (gem10, jobs
12627 and 12669): "creation calls waited for a block of images at
textures [11]". In both, a slow making of the host's (the tests beside
it) made the device's blocks of plain memory smaller early in the run,
while its pool of images still filled its first block of 64 MiB, made
before. A pool that has not grown keeps its next block made ahead once
it is near it (Pool::near_next), which was measured by three quarters of
its blocks' size now: 12.75 MiB of a 17 MiB block (12 MiB of 16 MiB
before the blocks' sixteenth). The 64 MiB block had 12.4 MiB left, so
the pool kept none ahead, and texture 11 (2560 x 1440, 15,790,080 bytes
on RADV) found no room and waited for its block. Told of a slow making
before its fourth texture (a scratch of the test, job 12687) the 780M
waited at texture 11 in two runs of two; before its seventh or eleventh,
by which the pool had grown or was near its next block, in none.

A pool is now near its next block below three quarters of the largest of
its blocks' size and the pooled blocks it holds (Pool::ahead_room), so a
pool still filling a block made before its blocks were made smaller
keeps its next block ahead as it did for that block; the sweep of blocks
made ahead and unused reads the same measure. A pool whose blocks are
all of one size is unchanged.

New test: mixed_sizes_after_blocks_made_smaller_find_their_blocks_made_
ahead, the mixed run told of a slow making before its fourth texture.
memory/ready.rs and docs/FAST-PATHS.md's blocks-made-ahead row say the
measure.

Verified on the 780M (job 12692): the new test without this change
waited at texture 11 in three runs of three; with it, the memory tests
(66) pass in three runs of three, the new test with no wait (7 blocks of
images made ahead), and in one of them the existing mixed test's own
blocks made smaller at texture 15 by a slow making of the host's, with
no wait. The memory tests pass on the RX 550, lavapipe (job 12693) and
the Iris Xe (job 12694); clippy plain and under m2v_gpu and
m2v_cpu_icd, and the runtime's Rustdoc, clean.

(cherry picked from commit c3fd622421584dfcc0b34ca133dbae22f53203e6)
2026-11-09 17:52:06 -08:00
Anees Iqbal 6346da2609 Small blocks: a sixteenth besides the power of two, so four quarter-block images fit
A pooled block of plain memory made smaller after a slow making
(Memory::plain_block_made) was a power of two, 16 MiB at the least. A
driver's image takes more than its texels: a Private RGBA8Unorm texture
of 1024 x 1024, sampled and rendered to, is placed in 4,210,688 bytes on
a Radeon 780M (RADV PHOENIX) and an Iris Xe (ANV, RPL-P) and 4,210,712 on
an RX 550 (RADV POLARIS12), each at an alignment of 64 KiB, so the second
starts at 4 MiB and 64 KiB and a 16 MiB block holds three, not four
(lavapipe: 4,194,304 bytes at 64, four).

The blocks are now made of that power of two and a sixteenth of it
besides (PLAIN_BLOCK_SLACK): 17 MiB at the least, holding four images of
a quarter of the power of two with up to 256 KiB of metadata and
alignment each, two of a half with up to 512 KiB, one of the whole with
up to 1 MiB. plain_block_made picks the largest power of two whose block
with its sixteenth the slow making's rate makes within MAKING_BOUND, so
the 8 ms bound holds for the block as made (64 MiB in 16 ms: 16 MiB, not
32, as 34 MiB would pass it). A placement larger than such a block takes
the least power of two so made that holds it (a 20 MiB texture: 34 MiB).
Blocks of plain memory not made smaller keep their 64 MiB, and the
blocks of exportable buffers theirs. The reserve a pool keeps ahead is
as many of its blocks as come to a 64 MiB block or more (four of 17 MiB,
68 MiB), at least what it kept before.

Verified, tests::blocks_ahead::small_blocks_hold_four_textures_of_a_
quarter_block_each (16 such textures, one at a time, on a device told of
a slow making): before, 6 pooled blocks of 16 MiB held them on the 780M
and the RX 550 (failing, jobs 12602 and 12590); after, 4 blocks of 17 MiB
hold them on the 780M, the RX 550, the Iris Xe and lavapipe (a fifth
made ahead). The memory tests (blocks_ahead, plain_blocks, zeroed_start,
memory, clip_bursts, host_copy) pass on the RX 550, lavapipe and the
Iris Xe, and on the 780M but for mixed_sizes_find_their_blocks_made_
ahead in two runs of five: a wait older than the sixteenth, which the
branch's last commit fixes. Clippy plain and under both cfgs, and the
runtime's Rustdoc, clean.

tests::reclaim_submit_bench on the 780M (gem10, Mesa 26.2.6), the
small-blocks arms, pooled blocks made a phase before -> after (two runs
each, release):
- images, 1024 x 1024 one a frame: quiet 64 (1024 MiB) -> 48 (816 MiB),
  pressed 67 (1072 MiB) -> 51 (867 MiB);
- images of mixed sizes: quiet 36 (576 MiB) -> 30 (510 MiB), pressed 39
  (624 MiB) -> 33 (561 MiB);
- images in bursts: quiet 64 (1024 MiB) -> 48 (816 MiB), pressed 64-67
  (1024-1072 MiB) -> 51 (867 MiB); calls that waited for a block made
  ahead 23 -> 15 quiet, 20-23 -> 15 pressed.
The three blocks made ahead and freed unused in each pressed phase stay
(48 MiB -> 51 MiB).

docs/FAST-PATHS.md's known gap (blocks made smaller, down to 17 MiB) and
its blocks-made-ahead row change with it.

(cherry picked from commit 532d06c2359fb2756f5514ba2821f959cf48293b)
2026-11-09 17:52:06 -08:00
Anees Iqbal 40831926fd Blocks made ahead: the reserve counted in bytes with the pool's room, made again at large placements
The trigger of a pool's blocks made ahead skipped the pool while it had room for a whole block
(`ready_if_growing`'s `has_room(bytes)`). A call that takes a block from the reserve leaves the
pool a whole block of room and none made ahead, so nothing was made again until a later creation
call found the pool short of a whole block; by then the placements had taken the room, and the
next call that needed a block waited for a making it started itself. On an RX 550 (64 MiB
blocks, textures of 4, 14.1 and 31.6 MiB one at a time, every making ended between two) the call
after each 31.6 MiB texture waited so, at textures 8, 16 and 24 of 32 (job 12539,
`tests::blocks_ahead::mixed_sizes_find_their_blocks_made_ahead`, with made-ahead empty from
texture 6 on). On a Radeon 780M the bench's mixed arm waited for 8 and 6 of its blocks with
none hurried (job 12513).

- The reserve counts its own blocks in bytes together with the pool's room (`Memory::lacking`,
  the longest free range, `Pool::room`): none lacks while those made ahead and the room come to
  their worth (a block's worth, as before), and once they come to less, as many as bring those
  made ahead back to it. The trigger no longer skips a pool with room for a whole block: a pool
  that grew or is near its next block keeps what it lacks. The large block's rule is unchanged.
- A placement of a quarter of a block or more in a pool whose blocks are made ahead runs that
  trigger there and then (`ready_after_placing`, in `place`), not at the next creation call,
  which may need the block at once: a quarter of a block is the lead `ahead_room` gives the next
  block's making before the half block `keep_room` keeps, so such a placement can use it up in
  one step. (A threshold of half a block would miss the 31.6 MiB texture, just under half of
  64 MiB, and pooled placements are at most half a block.) Room is cached
  (`Pool::room`), so the check derives it where the next creation call would have.
- A call whose waited making ended without its block waits once more, on a making that counts
  it from its start (`take_ready`), before it makes the block itself. A thread ends so without a
  failure: a reserve making no call waited for as it began makes no block within the device's
  allocation margin (`Allocations::room_ahead`), and its ending drops the sizes queued behind
  it, the waiting call's among them. This is the hole the M3 cost records' selection-only image
  and buffer blocks made in place point to (not measured here).

Measured on a Radeon 780M (RADV PHOENIX, gem10, exclusive; job 12560, two runs each, the
reclaim bench's images arms; RT 1991 is development with the ready threads' rename):
- Mixed sizes, 64 MiB blocks: blocks waited for, quiet and pressed, RT 1991 8 and 6 in both runs
  (none hurried), with this change 0 and 0 in both. Slowest creation call in the pressed phase
  8.5 and 5.8 ms at RT 1991, 3.6 and 1.9 ms with it (RT 1987: 5.2 and 1.5 ms, with 8 and 6
  blocks of images made in place, none since). Blocks made, 13 and 14 a phase, unchanged.
- Bursts of 16 textures, 16 MiB blocks: waited for, quiet 24 and 25 at RT 1991, 20 and 21 with
  it; pressed 27 and 27, then 23 and 23; hurried 11 to 12 at both (RT 1987: 60 a phase).
- Images one a frame and mixed sizes on 16 MiB blocks, and the 64 MiB images and bursts arms:
  no wait at either, none in place, the same blocks made.
On an RX 550 the mixed-sizes test waited at textures 8, 16 and 24 without this change and at
none with it (job 12556); lavapipe, whose slow makings made its blocks 16 MiB, waits only at
texture 7, the first texture larger than its blocks.

The mixed-sizes test allows the one wait it should: where a device's slow makings made its
blocks of images smaller (lavapipe, 16 MiB), the first texture larger than them waits for a
block of its own size, which nothing foretold.

Work counts expected to move: blocks_ahead_waited_for down (the mixed and burst arms' waits on
makings started late become blocks made ahead and found ready); image/buffer_blocks_made_ahead
about the same in total, with makings started earlier; blocks_ahead_hurried down where those
makings would have been cut short; image/buffer_blocks_made_in_place down to 0 in the M3
selection where the room_ahead ending was the cause (expected, unmeasured). The bytes kept ahead
are bounded as before: a block's worth a pool, plus the large block.

(cherry picked from commit 384c96121f7fa1ff8dec80ccfbf98f401ab77a74)
2026-11-09 16:55:06 -08:00
Anees Iqbal f79bf9a144 Blocks made ahead: calls for a pool's own blocks leave its large block alone, and a taken block is waited for again
1. The large block kept ahead was not kept for the large placements. While a pool's placements
   past its 16 MiB blocks are recent, it keeps one 32 MiB block ahead (074d8e762e). But
   add_ready and the waits took the smallest made block of the needed size or more. So a burst of
   textures that ran through the pool's own 16 MiB blocks before their refill took the 32 MiB
   block too, and the next large placement waited for a new one. Shown at d562bd4148 by the new
   burst phase of tests::blocks_ahead (24 textures of 4 MiB back to back with a queue use held
   open): the burst took the 32 MiB block, nothing made ahead was left (lavapipe and the RX 550),
   and the pool ended with 5 and 6 blocks of 32 MiB against 4 large textures.

   Fix (memory.rs, memory/ready.rs): a call takes a block within a range (ready::Need). Below the
   pool's recent large size it takes no block of that size or more. The waits and the "will a
   block come" check use the same range. The pool's own blocks are kept at a full block's worth
   again (4 of 16 MiB), and the large block is kept besides them. Before, the large block was
   inside the 64 MiB but could already come on top of four small ones. So a pool of 16 MiB blocks
   with placements past 16 MiB in the last 10 s keeps up to 64 + 32 MiB ahead; every other pool
   keeps 64 MiB, as before 1984. ready.rs and FAST-PATHS' kept-blocks row say so.

2. A call that waited for a block made for it could still make one itself, if another call took
   that block first: take_ready then returned false and keep_room made the block in place. Now
   Waiter::wait says whether a fitting block was made, and take_ready waits again when one was
   but another call took it. Found by reading the path for the 5080's first-growth red at RT 1987.
   A call now makes a pool's block itself only where no making serves it: a host-copies placement
   while that pool's thread reads pages, a making that failed or a thread that did not start, or a
   placement before the device's first creation call.

3. The test placements_past_a_pool_s_small_blocks_find_a_block_of_their_size_made_ahead checked
   the device's count of waits, which also counts other pools' blocks. On the RX 550 (job 12498)
   it went red with the filtered suite running: 7 waits, 1 after the first 20 MiB texture. Alone,
   d562bd4148 passed 3 of 3 with the memory log on (job 12514): 5 waits, 0 after. It now reads the
   image pool's made blocks before each later 20 MiB texture, and it adds the burst phase.

Work counts expected to move against 074d8e762e: none in the cost cases. Their pools' blocks are
64 MiB and they place nothing past half a block, so the range is unbounded there and the reserve
is the same. Only a device whose blocks shrank and that places past them keeps the large block
ahead through a burst: fewer blocks_ahead_waited_for, and pooled_memory_blocks_made rises by the
small blocks the burst waits for instead of taking the large one.

(cherry picked from commit b38f14b41a45a152453358a9f6dd5459bf74f3cd)
2026-11-09 15:45:26 -08:00
Anees Iqbal 074d8e762e Blocks made ahead: a block's worth of bytes per pool, a block for large placements, and calls wait instead of making
The problem, from reims's pin 31 scroll round on um870's 780M. After slow makings, its plain
blocks were made at 16 MiB (RT 1984). Over two boots:
- 250 and 264 pooled blocks were made;
- 114 and 82 image blocks were made in place on the guest's threads;
- 110 and 159 blocks made ahead were waited for (91 and 122 hurried);
- direct compaction on guest threads took 833 and 306 ms.

Two causes:
- The ready thread kept one block ahead per pool. With 16 MiB blocks that is a quarter of the
  reserve that one 64 MiB block used to give. A call that found no block made and no making under
  way made its own.
- A placement larger than a 16 MiB block takes a 32 MiB block of its own size
  (pooled_block_bytes). No block made ahead could hold it, so it was always made in place.

What changed (memory/ready.rs, memory.rs):
- A pool keeps a block's worth of bytes ahead: as many of its blocks as one 64 MiB block holds
  (4 of 16 MiB).
- While the pool's placements larger than its blocks are recent (the last within
  KEPT_EMPTY_FOR), the reserve also holds one block of the largest such size. The pool's own
  blocks fill the rest of the 64 MiB (32 MiB + 2 x 16 MiB).
- One thread per pool makes them one after another, one vkAllocateMemory each, after a single
  wait for a burst's end. A block a call or a top-up queues while the thread runs joins its queue;
  a waiting call's block goes first.
- A call that finds no made block of the size it needs no longer makes one itself. It waits for
  the block being made or queued, or queues one first and waits. If the pool has no thread, it
  starts one. The waited block's pages are not read.
- The host copies' pool is now waited for too, except while its thread reads a block's pages
  (whose first touch may wait behind the program's GPU work). The waiter counts itself before it
  checks a reading flag; the thread sets the flag before it checks for waiters.
- A block is made in place only in these cases: a host-copies placement while that pool's thread
  reads pages; a making that failed or a thread that could not start; a placement before the
  device's first creation call.
- A placement over half of BLOCK_BYTES stays dedicated, as before.
- keep_room's per-pool step moves into keep_pool_room.

Resting cost (bytes kept ahead per pool, counted against the kept-blocks budget):
- Against pre-1984 (one 64 MiB block per growing or near-next pool): unchanged at 64 MiB.
- Against RT 1984 and RT 1987 (one block of the pool's size): unchanged for 64 MiB pools. A pool
  of 16 MiB blocks keeps up to 48 MiB more while it grows or is near its next block.
- At the device's first creation call, a pool of 16 MiB blocks also makes 3 blocks ahead after
  its first. If the pool never nears its next block they go after KEPT_EMPTY_FOR
  (blocks_ahead_unused). Pools of 64 MiB blocks, the default before any slow making, make none
  extra.

Work counts expected to move, for the cost records:
- buffer_blocks_made_in_place and image_blocks_made_in_place fall to 0, except in the cases above.
  That includes each kept pool's first block at a device's first creation call, which the call
  now waits for on the ready thread.
- buffer_blocks_made_ahead and image_blocks_made_ahead rise by as many. So does
  blocks_ahead_waited_for, since a call waited for each of them. These are not hurried: the
  making started at once for the call.
- host_copy_blocks_readied rises, and host_copy_blocks_made_in_place falls, where a host-copies
  placement found no making at all.
- pooled_memory_blocks_made is unchanged with 64 MiB blocks. With 16 MiB blocks the extra reserve
  blocks count there when added. When swept unused they count as blocks_ahead_unused and
  pooled_memory_blocks_freed.
- Kept-ahead bytes against the heap budget: a block's worth per pool, as above.

Docs: memory/ready.rs, memory.rs, the WorkCounts fields, and FAST-PATHS' kept-blocks row, which
now describes the 64 MiB reserve and the large block.

Tests (tests::blocks_ahead), on lavapipe under --cfg m2v_cpu_icd:
- a_pool_of_small_blocks_keeps_a_block_s_bytes_ahead_and_no_creation_call_makes_one: 16 MiB
  blocks, 4 MiB textures. 0 in place, 64 MiB kept ahead. The base fails it: 1 in place, 16 MiB
  ahead.
- placements_past_a_pool_s_small_blocks_find_a_block_of_their_size_made_ahead: a 20 MiB texture
  every 4. 0 in place, four 32 MiB blocks, 0 waits after the first 20 MiB texture. The base fails
  it: 5 in place, four of them 32 MiB.
- The memory, blocks_ahead, plain_blocks, zeroed_start, clip_bursts, exported/freed memory,
  device_recovery and host_copy tests passed, 78 of 78 (jobs 12486 and 12491).
- The 780M bench before and after (images, mixed and burst arms, fragmented) is running on gem10
  (job 12492). Its numbers go in the pin notes.

(cherry picked from commit 096241d0964536db875ab2957c64b40922e7fa8e)
2026-11-09 15:19:28 -08:00
Anees Iqbal 05dcfce04e Memory: a pool near its next block gets it made ahead, its first growth among them
Blocks were made ahead (memory/ready.rs) only for a pool that grew lately:
a second or later pooled block added within KEPT_EMPTY_FOR. So a pool's
first growth, and its first after a pause, was always made in place by
the creation call whose keep_room found no room for half a block: in a
guest's scroll on a Radeon 780M, the buffers' pool's first growth block,
made on the guest's thread.

A pool made ahead for now also gets its next block made ahead, grown or
not, once it is near it (Pool::near_next): it holds a pooled block and
its longest free range is below three quarters of a block (ahead_room), a
quarter of a block before the half block keep_room keeps. The pools of
exportable buffers take the same rule (exported_growing lists those near
their next block too). A block made ahead for a pool that stopped growing
goes after KEPT_EMPTY_FOR only once the pool has room for three quarters
of a block again, so a pool that rests near its next block keeps that
block, one at most a pool, counted against the kept empty blocks'
budget, and makes none over and over. That is the resting cost, written
in docs/FAST-PATHS.md's row on kept blocks and in ready.rs. The other
option, a block ready for every pool in use, holds one at rest for every
pool, not only those near their next.

Tests: blocks_ahead's growing-pool test now asserts its first growth is
made ahead too (renamed). reclaim_submit_bench gains a scroll arm:
Private buffers of 7471104 bytes (a scroll's, eight to a block) every 30
ms, 64 a phase.

Verified on um790's Radeon 780M (RADV PHOENIX) and lavapipe (jobs 12337,
12354):
- blocks_ahead, 780M: first growth 1 made ahead, 0 in place (lavapipe
  the same). Negative, development's memory.rs and ready.rs: 0 ahead, 1
  in place, the test fails.
- Runtime suite: 780M 2011/2011, lavapipe 2014/2014; clippy with
  m2v_gpu, m2v_cpu_icd and no cfg clean; rustdoc clean.
- reclaim_submit_bench_scroll, release, three runs each, alternating:
  development made 7 blocks ahead and 1 in place in each phase, quiet and
  fragmented (compact_stall about 2500 in the pressed phase), every run;
  with this change 8 ahead and 0 in place in every phase. The slowest
  creation call: development 0.2 to 0.4 ms, this change 0.1 to 0.2 ms.
  The in-place makings were fast in this bench's fragmenting; the
  consumer's trace had the same making under the kernel's compaction.

(cherry picked from commit 35c4231506652a454e43e703b162384a0a2f71cc)
2026-11-09 13:37:57 -08:00
Anees Iqbal 7a50011e74 Memory: the plain-block rule's ledger row; the cost gate reports device_memory_allocated
docs/FAST-PATHS.md gains the known-gaps row for the measured-rate size of plain blocks: what a
making holds on RADV, the rule, the 780M's numbers against the base (turnarounds, creation calls,
vkQueueSubmit per call, block counts), what a single slow making costs for the device's life, the
drivers left unaudited, and the M3 Max's makings over the conformance cost measurement.

The conformance cost gate reports device_memory_allocated (a new race-rule reason, BLOCK_SIZE)
rather than gating it, because the bytes a case allocates now follow how long the device's
earlier makings took. Measured on the M3 Max, `conformance cost --check` over eight runs of the
whole set (1233 cases): at this tip rc 0, no 64 MiB making past 1.61 ms, the rule never fired;
with the size held at its 16 MiB floor, rc 1 on one case's device_memory_allocated
(201326592 in the record, 50331648 measured), with no gated bound or ceiling of
pooled_memory_blocks_made moving and no case over a bound, so that count stays gated. The
fold test that used device_memory_allocated as a count with no MONOTONE row now uses
owned_kernel_spirv_bytes.

(cherry picked from commit a4246707ec6da2b49342feca48bf9a931e152675)
2026-11-09 12:29:03 -08:00
Anees Iqbal 7d17fb1882 Guest RAM: a refused dma-buf keeps run lists and listed plans off the driver
Three follow-ups to remembering a driver's refusal of a guest RAM's dma-buf
(3fe18c4efd):

1. Run-list imports consult the remembered refusal. ram_runs_as_dma_buf now
   returns not-importable, the source of run lists unasked, once the device
   remembers a refusal, and remembers the driver's own refusal of a list's
   dma-buf the same way a span's is (the source's failures stay the list's
   alone). Before, every copy over a chunk not imported asked the source of
   run lists again and paid a udmabuf and a failed import.

2. A RAM's plan asks the driver before it lists the RAM. Plan::listed means
   the RAM's chunks are its dma-bufs; it was chosen from the import tax alone,
   so on a taxed driver that refuses udmabufs (NVIDIA 615.71.09) the RAM got
   512 MiB chunks imported by pointer, none ahead. ram_plan now, where the plan
   would be listed, asks the driver with the RAM's first host page
   (Device::ram_takes_dma_bufs: ram_span_as_dma_buf over one page, released at
   once, the precedent being shared_refused's one-page question), and lists the
   RAM only where the driver took it. A refusal there is counted and
   remembered, so the RAM and every RAM after it keep 64 MiB chunks imported
   ahead by pointer. Re-choosing a live RAM's plan was rejected: its chunk
   geometry and its thread are fixed when the use begins. discard_import takes
   the raw VkBuffer so the question's import can be released.

3. The listed tests (where_each_listed_import_costs..., where_the_ram_fits...,
   the two tile tests through copies_by_lists) no longer expect dma-buf imports
   wherever the measured tax holds. They force the tax held, so the listed path
   runs on every device in every run, and read the plan the device chose
   (Device::host_ram_chunks), asserting it is listed exactly where the device
   imports dma-bufs and the driver took the use's page. The resident test now
   allows the use its one page.

Tests:
- a_driver_s_refused_dma_buf_sends_copies_past_the_source_of_run_lists (new):
  stand-in refusal set after a listed use; the first copy asks the source of
  run lists once and the source of dma-bufs not at all, the second asks
  neither (fails without the consult or without remembering a list's refusal).
- a_driver_s_refusal_as_the_use_begins_keeps_the_ram_s_chunks_short (new):
  stand-in refusal before the use; the RAM is not listed, the source asked for
  the first page only, the refusal counted once (fails without 2).
- a_driver_s_refused_dma_buf_sends_the_device_s_later_chunks_to_their_pointer:
  the stand-in now refuses after the use; a RAM used after the refusal is not
  listed and its source is unasked.
- The route test reads the use's question and the plan.

Docs: host_ram module, use_host_ram, WorkCounts, HOWTO and the FAST-PATHS
NVIDIA dma-buf row describe the question and the remembered refusal.

Verification: in the follow-up message (gem10 lavapipe suite and negative
controls; 5080 release).

(cherry picked from commit 77f336e98c2a31aa56e45c5eb7659fa28f6f3ad6)
2026-11-09 11:39:45 -08:00
Anees Iqbal 3fe18c4efd Guest RAM: a driver's refusal of a span's dma-buf is remembered for the device's life
Counting the refusal left its cost: on a device whose import tax holds and whose driver refuses
every udmabuf (NVIDIA 615.71.09, FAST-PATHS), every guest-RAM chunk asked the source for a dma-buf,
failed vkAllocateMemory, let go of one descriptor (the driver closes the clone it was handed) and
only then took its pointer.

ram_span_as_dma_buf now tells the source's failures (an error, or an answer of other lengths:
that span's alone, counted) from the driver's (anything once the source answered one dma-buf of
the span: its memory types, the buffer, the import, the bind). A driver's refusal is counted once
and remembered in the device's RamSource; every later span is refused at once, unasked and
uncounted, and takes its pointer. The decision reads the device's own answer, never its identity.
A transient failure of the driver's (memory that ran out) is remembered the same way, recorded in
FAST-PATHS' NVIDIA row.

Tests: a_driver_s_refused_dma_buf_sends_the_device_s_later_chunks_to_their_pointer forces the tax
held and refuses every dma-buf import through a test stand-in for the driver (Memory::import_refusal,
cfg(test), answered where the driver's import would run), on every device that imports dma-bufs:
two chunks, the source asked once, the failed count 1, the second chunk by its pointer. The route
test, where the driver itself refused (NVIDIA's), makes a buffer over the RAM's second chunk and
asserts the same with the real driver. Without the remembering both ask the source a second time.

(cherry picked from commit abddf2d2f1ed16a5ee6407cae04f7e10dfffb736)
2026-11-09 11:05:12 -08:00
Anees Iqbal 98729ad0de Guest RAM: a chunk's dma-buf the driver refuses is counted; the route test forces the tax held
On the RTX 5080 (NVIDIA 615.71.09) pin 29's runtime half failed
host_ram_dma_buf::a_ram_with_a_source_takes_the_route_its_device_s_checks_choose: that process's
import tax answered Holds, the chunk went dma-buf first, the source was asked, and no dma-buf was
imported. A probe printed the refusal: vkGetMemoryFdPropertiesKHR gives the udmabuf types 0x9,
the buffer takes 0x1f, and vkAllocateMemory answers ERROR_OUT_OF_DEVICE_MEMORY (the refusal
FAST-PATHS already records for NVIDIA). import_chunk dropped that error and took the pointer, as
it should, but nothing counted it, and the test held every taxed device to a dma-buf import.

- WorkCounts::host_ram_dma_buf_imports_failed counts a guest RAM span's dma-buf that failed on a
  device that imports dma-bufs (the source failed or answered other lengths, or the driver
  refused it); ram_span_as_dma_buf counts it past its device check.
- The route test (now where_the_import_tax_holds_a_chunk_takes_its_dma_buf_first) forces the tax
  held, as the pointer-first test forces it not held, so the taxed route runs on every device in
  every run, not only in a process whose check measured a tax. It asserts the source asked once
  for the chunk, and the dma-buf imported or refused and counted, the pointer then taking it; it
  prints the verdict the device measured beside it.
- HOWTO, FAST-PATHS' NVIDIA dma-buf row, host_ram's docs and the API signature table name the
  count.

Verified: the probe at 3f3ca70d32 on the 5080 (b5080 t entry exitcrash-dmabuf-100324): with the tax
forced held, 2 of 2 runs failed the old assertion with the refusal above; quiet runs measured the
tax not held (3 of 3). This commit's own runs are in the next evidence.

(cherry picked from commit a6ccb78810867a4d567892feee4b3b56ba1af834)
2026-11-09 11:05:12 -08:00
Anees Iqbal 9e663b770c Memory: the pools of exportable buffers get their growth blocks made ahead
A creation call that places an exportable buffer (new_exportable_buffer, an exportable buffer
descriptor, the in-place check's buffers) in a pool with no room made the pool's 64 MiB block
itself, on the program's thread. keep_room made blocks ahead (memory/ready.rs) only for the
pools the runtime's encodings and commits place in and for the host copies' pool, so every
growth block of Holds::Exports and Holds::DmaBufs was made in place.

Now each pool of exportable buffers that grew within KEPT_EMPTY_FOR and lacks room for a whole
block gets a block started ahead at each creation call's keep_room (Memory::exported_growing,
ready_if_growing, the kept pools' tail of keep_room moved into it), made right after a burst of
the device's submissions ended, as the kept pools' blocks are. makes_ahead covers those pools,
so the placement that finds no room takes the block made ahead or waits for its making
(place, take_ready) and counts a block it makes itself in buffer_blocks_made_in_place.
keep_room makes no block for such a pool in place: its placements are the creation calls.

The reclaim bench gains an arm of exportable buffers made by the runtime (24 of 32 MiB a phase,
one every 400 ms) and prints blocks_ahead_waited_for. The citation of a consumer's wait is
replaced by these measurements; FAST-PATHS's row on kept blocks says blocks are made ahead for
pools that grew, the exportable ones among them.

Verified, on a Radeon 780M (RADV PHOENIX, Mesa 26.2.6, gem10, MESA_VK_DEVICE_SELECT
'1002:15bf!'):
- reclaim_submit_bench_exportable in release under --cfg m2v_gpu, exclusive, two rounds each,
  the negative being memory.rs and memory/ready.rs as on development (job m3-max-12103): the
  creation calls that made blocks in place took 10.0 to 10.8 ms (quiet, round 1), 12.9 to
  15.0 ms (fragmented: free memory in single pages, round 1) and 12.0 to 13.7 ms (fragmented,
  round 2; 0.3 ms at most in round 2's quiet phase). With the change no creation call took over
  0.3 ms in any phase: 10 blocks made ahead and 2 in place (the pool's first two) in each quiet
  phase, 12 ahead and 0 in place in each fragmented one, 0 waited for. Turnarounds of 8 ms or
  more: 0 in every phase both ways (an exportable block holds no submission).
- blocks_ahead's new test a_growing_pool_of_exportable_buffers_gets_its_new_blocks_made_ahead:
  6 of the pool's last 6 blocks made ahead, 0 in place; with memory.rs as on development it
  fails, 0 of 6 made ahead (job m3-max-12111).
- The whole runtime lib under --cfg m2v_gpu (debug): 1997 of 1997 passed (job m3-max-12109);
  clippy on the runtime crate, all targets and features, clean.
And on lavapipe (llvmpipe, LLVM 23.1.4) under --cfg m2v_cpu_icd: blocks_ahead and clip_bursts
pass (the later clips allocated nothing: [(0, 0), (0, 0)]; job m3-max-12110), clippy clean, and
the new test fails, 0 of 6, with memory.rs as on development (job m3-max-12112).
Not run: NVIDIA, MoltenVK.

(cherry picked from commit 5a862c6ab9ebf0a6f2effeb8776aaac6de3bed16)
2026-11-09 09:44:38 -08:00
Anees Iqbal 97afeae593 Kept room: the runtime's own buffers' pools first, the exportable ones only while they lie there
keep_room kept room in every kept pool in the order Buffers, FdBuffers, Images, whatever kind
of block the runtime's own buffers took. On a device near its count of allocations the plain
Buffers pool's block spent the last allocation the program's buffer, placed in the FdBuffers
pool once the device's in-place verdicts were known, then needed:
tests::host_ram_device::the_ahead_thread_leaves_the_allocation_limit_to_the_objects made no
buffer (Vulkan -10) on RADV PHOENIX at 97f92139dd, where the base made one.

Device::keep_room now asks which kind the runtime's own buffers take (Memory::own_buffers of
Device::fd_blocks_taken, the verdicts as fd_blocks_checked reads them, counting nothing and
starting no check), and keep_room keeps that kind's pools first and the FdBuffers pools only
when that kind is FdBuffers. The FAST-PATHS row on exportable blocks says so.

Verification: the failing test and the runtime gpucfg suite on RADV PHOENIX follow.
(cherry picked from commit 916073fc374888e44f203e7f1c00abbf55497af5)
2026-11-09 01:44:42 -08:00
Anees Iqbal 33f1fecac1 fd blocks: a buffer's making starts no in-place check
The full runtime gpucfg suite on PHOENIX at e03275c440 (job 11224, release) had 16 failures in
completion_here, draw_again, host_residency, teardown_threads, waiter_submits and
pointer_residency. The fd set itself passed 3/3. The failing tests count device-wide state
(recorded commands, host-import residency, threads at teardown, completions).

With this branch the first buffer a device made asked fd_blocks_checked, which went through
in_place_verdict and started the in-place check in the background wherever its verdicts were
pending: on every program's first run on a driver, and in every test with a fresh shader cache.
The check's own buffers, imports and command buffers then ran among the program's, as
tests::recycle showed exactly (472 vs 490-505 recycled under load).

fd_blocks_checked now reads the verdicts without starting the check. The runtime's own buffers
lie in exportable blocks once the verdicts are known: from the check's record as the device is
made, or once a check that a texture over host pages or Device::settle_in_place_checks started
has answered. Until then they lie in plain blocks, counted fd_blocks_awaited, as before.

The recycle tests' settle (3297613ce2's) is removed: it would now start a check the tests have
no use for.

Docs:
- in_place.rs, memory.rs, WorkCounts::fd_blocks_awaited and the bench's arm doc say who starts
  the check.
- The FAST-PATHS Private row drops the unsettled-runtime numbers (taken while a buffer started
  the check): until the verdicts are known the blocks are plain, as the base's. The settled
  numbers stand.

Verification is pending: the full suite at this tip and at development, side by side on
PHOENIX.

(cherry picked from commit 289b04fae4ce20bed3b2ebe92e6b693e7d4a8e0b)
2026-11-09 01:44:42 -08:00
Anees Iqbal cd3676b4f3 FAST-PATHS: the Private row's runtime numbers at the split
From the bench at 73312dc63e on gem10 (RADV PHOENIX, '1002:15bf!', job 10985), two runs of
each runtime arm against the base binary: base 13/12 turnarounds of 8 ms or more quiet and
103/17 fragmented (slowest 40.4/49.0 ms, 350/311 ms of kernel-lock wait); tip fresh 1/1 quiet
(3 plain blocks made while the first check was pending) and 0/0 fragmented (21/24 ms waited);
tip settled 0/0 in both phases (4/10 ms waited).

Verified: docs only.
(cherry picked from commit e5816df55531a25ec0730d82e962f87e9cc17f52)
2026-11-09 01:44:41 -08:00
Anees Iqbal 829a68129b FAST-PATHS: the Private row names the split by padding, the first turnaround and what stays plain
The heading and body say buffers that declare their padding unobserved keep plain blocks
and why (a DRM_FORMAT_MOD_LINEAR image over exportable memory needs a dedicated allocation
on RADV); the made-before arm's 57.0 ms first turnaround against 2.4 to 8.1 ms with 64
exportable blocks held (reclaim-10514/10615); what still makes plain blocks
(WorkCounts::plain_buffer_blocks_made) and the second pool's held block; the planes over an
unobserved buffer take the conversion image as before. The RUNTIME_ARMS placeholder is gone;
the runtime arms' numbers follow once the bench at the split has run.

Verified: docs only.
(cherry picked from commit 3619d8e8783039e8568afc4c0e75fb9b943bfd76)
2026-11-09 01:44:41 -08:00
Anees Iqbal 5e020e43bd fd blocks: buffers that declare their padding unobserved stay in plain blocks
A texture over a buffer whose rows lie apart is in place only where the buffer declares
its padding unobserved, and there, over a plain block, it may take a DRM_FORMAT_MOD_LINEAR
image at Metal's pitch, which RADV makes for exportable memory only as a dedicated
allocation. The placement test at b48d8fae41 counted 15276 such textures lost over
exportable blocks for padding-unobserved buffers and 0 for padding-kept ones. So the split:

- BufferDescriptor's padding_unobserved reaches the placement (Made, buffer_of_length,
  NewBufferOf::Unobserved): such a buffer lies in a plain block (Holds::Buffers) wherever;
  every other buffer of the runtime's buffer path lies where the device's own buffers do.
- The recycler's BufferMaking keys on the block kind, so a parked buffer in an exportable
  block is never handed to a padding-unobserved one.
- fd_blocks_cover's second guard asks what a padding-kept texture can take: rows one after
  another at a multiple of 16 bytes where the device's own linear image lies otherwise, at
  every width of linear_alignment::WIDTHS, every backed format and usage; any
  DRM_FORMAT_MOD_LINEAR image of its own memory made there refuses the blocks. The linear
  layout comparison runs at every width too.
- WorkCounts::plain_buffer_blocks_made counts plain blocks of buffers, beside
  fd_buffer_blocks_made, so a lane can read the share of block makes on each side; the bench
  prints it.
- The placement test tries rows rounded to 16 too, makes the program's buffer through
  new_buffer_with_descriptor for each padding, asserts where it lies, and asserts 0 lost for
  both kinds. The nv12 test checks a padding-unobserved picture lies in a plain block while a
  parked exportable one of its making exists.
- Docs: memory.rs, in_place_check.rs, the FAST-PATHS in-place row, the descriptor field and
  the runtime README.

Verified: cargo fmt only; builds and device tests are dispatched next.
(cherry picked from commit 6e5c80ac3caaa2ad26c0456ecfc0801bca4ccd42)
2026-11-09 01:44:41 -08:00
Anees Iqbal 005a54ea8d fd blocks: opaque fd only, every image there the device's linear image, behind a cover check
RADV PHOENIX asks a dedicated allocation of a DRM_FORMAT_MOD_LINEAR
image made for an opaque fd or a dma-buf (requiresDedicatedAllocation=1
for formats 9/16/37/44/64/97, m3-max-10880), and its image format query
takes a dma-buf for no linear-tiling image: the dma-buf blocks of
6798cf39a2 held no texture at all (all 1824 in-place layouts of the
placement test lost, m3-max-10884), and the FdBlocks check made nothing.
The one image such a block can hold there is the device's linear image
made for an opaque fd, and over a plain block's buffer no texture took a
DRM_FORMAT_MOD_LINEAR image at Metal's pitch (0 of 1824 over 20736
layouts): the driver takes no explicit pitch but its own.

So the blocks are exportable as an opaque fd again (FD_BLOCKS_HANDLE),
every texture over such a buffer the linear image made for it, gated on
the FdBlocks first-move verdict, and no pitched image there.

Guards, from documented queries and made-and-released images, never a
driver name:
- memory::fd_image_types, at device assembly: per memory type of the
  system heap, kept where a 64x4 linear image made for an opaque fd
  (R8, RG8, RGBA8, RGBA16F; format query exportable and not
  dedicated-only first) takes it wherever the plain linear image does,
  and not asking a dedicated allocation; the memory log names the kept
  types and why the others stay plain.
- Device::fd_blocks_cover (texture/fd_blocks_cover.rs), in the check's
  FdBlocks class: for every backed pixel format and the read, write and
  render usages, the opaque-fd linear image wherever the plain one is
  made, laid out the same (pitch, offset, size, alignment, types); and
  no DRM_FORMAT_MOD_LINEAR image of the device's own memory at a pitch
  other than its linear image's (probed at +256 and twice it). Else the
  class is unmade (lasting, so recorded), fd_blocks_take refuses, and
  the memory log says why.

Removed: the dma-buf block path, Device::modifier_takes_linear, the
probe-then-DRM linear slot, pooled_pitched_image's class parameter.
CHECK_VERSION 16.

Verified: nothing yet.
(cherry picked from commit 0b59a1700f0911b1024f83ed3be30f99fb5e23d8)
2026-11-09 01:44:40 -08:00
Anees Iqbal cb6c971456 fd blocks: dma-buf only, every image there a DRM_FORMAT_MOD_LINEAR one
The validation layer on RADV PHOENIX reported
VUID-VkExportMemoryAllocateInfo-handleTypes-09860 at every bind of a
linear-tiling image into a block allocated exportable as opaque fd and
dma-buf (32 reports over three exported_textures tests, m3-max-10768):
the handle types of an allocation must be supported for the resources
in it, and RADV's image format query takes a dma-buf for no image of
linear tiling (ERROR_FORMAT_NOT_SUPPORTED for formats 9, 16, 37, 44,
64, 97), while it takes an opaque fd for a DRM_FORMAT_MOD_LINEAR image
only from a dedicated allocation (VUID-VkMemoryAllocateInfo-pNext-00639).
No dual-handle block holds either image kind validly.

So the blocks are dma-buf only (FD_BLOCKS_HANDLE), taken where the
device exports a pooled dma-buf for both buffer usages and enables
VK_EXT_image_drm_format_modifier. Every image there is a
DRM_FORMAT_MOD_LINEAR one naming that handle type: where the device's
linear image (made to be measured, never bound) lies on Metal's
layout, one of that layout, gated as before on the FdBlocks first-move
verdict for the texture's row ends and free of the pitched cost bound,
as base's linear form is; else the pitched path at Metal's pitch under
the FdBlocks verdicts. Both count as pooled pitched images.
fd_blocks_take is unchanged. CHECK_VERSION 15, as the class's images
changed. FdExport::compatible and Memory::fd_handles are gone.

Verified: nothing yet; built on gem10 next.
(cherry picked from commit 2b4919bd9e54635c7192b425bb740d9a77f57ec7)
2026-11-09 01:44:40 -08:00
Anees Iqbal ecfe8dc225 reclaim bench: a 16 MiB system-heap arm, for the image pools' growth blocks
Verified: not yet built.
(cherry picked from commit 5a97a25ce536f91d5d95840dd1d1afef1a66111c)
2026-11-09 01:44:40 -08:00
Anees Iqbal 6962de9cdc FAST-PATHS: the NVIDIA exit fault's known gap as the gap and its bound alone
A known gap states what is true now and one bound; the evidence stays here. A correction to
d35c43feaf's message: the exit hunt stopped on the orchestrator's call, not the owner's word.

The evidence behind the line (NVIDIA 615.71.09, RTX 5080 Laptop GPU, Linux):
- exitcap-162601 (probe 7f851ced8c): 1 of 94 runtime children, each making a device on libtest's
  test thread and returning with it kept live, took SIGSEGV after their test passed. The faulting
  thread was an NVIDIA worker (libnvidia-eglcore into libnvidia-glvkspirv+0x363b2, address 0x18)
  named after the ended test thread, while the main thread ran libEGL_nvidia's exit handler (an
  ioctl in libnvidia-glsi). The runtime's 30-odd threads were all waiting, none in a section of
  the exit guard or a making. A consumer saw the same fault twice in a suite of about 1900 tests,
  in a test that keeps its device in a static.
- nvexit, a Vulkan program without the runtime (an instance, the NVIDIA device, one compute
  pipeline, a return from main), beside the same 14-minute load of the runtime's device suite:
  1550 runs, 0 faults. 1028 destroyed everything first (507 + 262 on the main thread, 259 on a
  thread joined before the return); 522 kept the device live (263 made on the main thread, 259 on
  a joined thread, whose two driver workers named after it still ran at the return).

(cherry picked from commit be87171f9ecb74c3b695ceb9501cc4435144728f)
2026-11-09 01:35:53 -08:00
Anees Iqbal 31cef63d20 FAST-PATHS known gaps: NVIDIA's SIGSEGV in the exit of a process whose device is live
The exit hunt stops here, on the owner's word, with the cause not found. What is known:
- exitcap-162601 (probe 7f851ced8c): 1 of 94 runtime children took SIGSEGV after their test passed
  with the device kept live. In the core the fault is in an NVIDIA worker (eglcore into
  libnvidia-glvkspirv+0x363b2, address 0x18) named after the ended test thread, while the main
  thread ran libEGL_nvidia's exit handler (an ioctl in glsi). The runtime's 30-odd threads were
  all waiting, none in a section or a making.
- nvexit, a Vulkan program without the runtime (instance, NVIDIA device, one compute pipeline,
  return from main), beside the same 14-minute load of the runtime's device suite:
  - exitcrash-nvexit-201854: 507 with everything destroyed on the main thread, 0 faults;
  - exitcrash-nvexit-203651: 262 destroyed and 263 kept live, on the main thread, 0 faults;
  - exitcrash-nvexit-thread-230656: 259 destroyed and 259 kept live, made on a thread joined
    before the return, whose driver workers (named after it) still ran at the return, 0 faults.
The line goes where a user of the runtime reads open gaps.

(cherry picked from commit 5c6971ade39abb0ec1a92ad1c2a8fe80e112951e)
2026-11-09 01:35:53 -08:00
Anees Iqbal 051de6ce39 submit_stalls: the driver's stall is told by the thread's CPU time in the call, not its length
The 5080's submit_stalls_idle test failed in round 064's rt2 beside the runtime's device suite
(idle_submits 0, submit_stalls_idle 0, submit_stalls_on_work 20) after passing alone. A probe of
the queue's place (STALLPROBE counts and events, probe branch steelbrain/exitcrash-stallprobe
1227ec7423, entry exitcrash-stallprobe-225855) reproduced it 3 of 3 beside the suite and passed
2 of 2 alone:
- The driver's stalls came every 1024 counted calls (calls 760 and 1784 in every run) and spent
  1998 to 3880 us of the calling thread's CPU, within 0.5% of their length.
- Beside the suite, 25 to 29 other calls a run took 1.3 to 40.8 ms but spent 8 to 884 us of CPU:
  waits. Each, taken as the stall while the place was unconfirmed, moved the place off the
  stalls (the second stall came 354 to 551 calls after the last wait), so no stall was ever due
  at an idle (idles_due 0) and every one fell on work.
- The submit checks' uncounted uses forgot the place 114 times a run, alone and beside the
  suite, all within the device's first ~120 calls, before its first stall: not the cause.

So a call is the driver's stall only where its thread spent STALL_NANOS of CPU in it
(CLOCK_THREAD_CPUTIME_ID read before and after each timed signalling call, on a device whose
driver has DriverFact::SignallingSubmitsStallEvery1024 alone; elsewhere nothing more is read and a
call's length counts as before). The fact's own doc already names the cost as the submitting
thread's CPU.

Tests: calls_that_wait_long_beside_other_work_are_no_stall models the failing run (a wait of
1.5 ms every 250 to 410 calls, 15 in 5000): taken by length it gives the failure's counts
exactly (20 on work, 0 idle, 0 empty); by CPU, 1 on work and every later stall idle.
a_long_call_short_of_a_stall_is_none now also holds a 10 ms wait with under 1 ms of CPU to no
stall. The device test's doc states its calls on the 5080 (about two periods, its batches
merged), not five. FAST-PATHS' row says what a stall is.

(cherry picked from commit 5c8295ac235da7492861bc255e7d53874bfaaac7)
2026-11-09 01:35:53 -08:00
Anees Iqbal 8bd103fc8e Record RADV's extrapolated perspective reads at a sample or offset as the device's answer
On the Radeon 780M (RADV, Mesa 26.2.6) runtime_lane::pull_model_interpolation read 1700
values off Metal's, up to about 1.0 in lane 3. The lowered pm_offset is straight-line code (a
uniform offset, its move and clamp, InterpolateAtOffset per input), so no control flow is at
fault. Every miss is a perspective input's read at a sample or an offset; the no-perspective
inputs' same reads were Metal's. A model with the lane's own geometry gives the driver's form:
the pixel center's value extrapolated along the quad's coarse derivatives,
f(center) + (f(tr) - f(tl)) * dx + (f(bl) - f(tl)) * dy. It reproduced all 52 one-sample offset
misses within 0.004 and all 1061 four-sample sample and sample_id misses within 0.005, where the
fine-derivative form was up to 0.98 off. Metal's value plus that form's error (first-order less
exact) matched each of RADV's within 0.2 of the lane's device bound.

Vulkan states no precision for interpolation, so under rule 1 the device's interpolation is the
answer: no form computes it otherwise. The fix records it.
- DriverWorkaround::PerspectiveReadsExtrapolated, a measured row keyed on RADV
  (driver_facts::DEFECTS, no vendor), as InterpolationNeedsTheWholeQuad is.
- PrecisionNote::ExtrapolatedInterpolation (extrapolated-interpolation). stage_io::plan records
  it structurally: an interpolant with the perspective qualifier read at a sample or an offset,
  or a perspective sample-qualified varying a looping function reads at each pass's sample
  (InterpolateAtSample), on a profile with that fact. A no-perspective read, the pixel-center
  form (offset 0), a center or centroid read and an absent interpolant record nothing.
- The pull-model lane: on such a device each perspective lane read at a sample or an offset is
  held to the device bound of Metal's value plus the extrapolation's error, computed from the
  lane's geometry (extrapolation_error), and the pipelines that read so, and those alone, must
  record the note.
- The engine tests over every committed profile assert the note where the RADV profile reads a
  perspective interpolant at a sample or offset, and nowhere else: pm_linear, a new fixture
  function reading the no-perspective interpolant alone at a sample and an offset, must not
  record it. The coverage-loop test asserts it for the looped perspective varyings on RADV.
- docs/API.md's device-interpolation entry and docs/FAST-PATHS.md's row no longer cover RADV's
  sample and offset reads with the 1.5e-4 figure. The new entry and row state the form and the
  measured size.
- SEMANTICS_VERSION 2000 (the RADV profile's pull-model and looping modules gain a note),
  ARTIFACT_FORMAT_VERSION 497 (the codec gains the note), api_signatures blessed. The refusal
  surface regenerated with no change.

The fixture's AIR companions for pm_linear come in the next commit, from the regen script on the
M3. The golden tables and the air_input snapshot are re-blessed on development.

(cherry picked from commit f4eb92a9bc4c099f9020fde2c2da40580514ec20)
2026-11-09 00:16:01 -08:00
Anees Iqbal ad451a5334 Scheduler: a held group never waits behind another queue's submission handlers
What. A pass that ends with batches held for one kernel submission keeps them held while their
VkQueue runs two or more earlier submissions (Group::keeps). It now sends them instead where a
submission handler the thread runs once its passes end (scheduler::round) is of a command
buffer of another logical queue (Metal command queue) than a batch held:
scheduler::holds_back_another_queue, over the round's handler list and the batches held with
their logical queues. The handlers of the held batches' own queue still keep the group held.
CommandBufferShared::logical_queue reads a command buffer's queue identity for it.

Why. A submission handler runs on the scheduler thread, and a held batch's handlers run as it
is held, before its group goes to the driver. Where two command queues share one VkQueue on a
driver that merges, a batch of one queue held and kept behind running work, and a batch of the
other queue with a handler that waits for the first one's completion joined the group: the
group stayed held until the handler returned, so the handler waited for work its own return let
go (the deallocator lane test on the Iris Xe hit it once, its handler waiting 60 s). Metal does
not do that: on an M3 Max under macOS 27.0.1 (probe cross_queue_handler_waits), a command
buffer's completed handler reached another queue's scheduled or completed handler that waited for
it in each of 30 runs, 7.6 to 9.3 ms after the wait began, b committed before a included. On one
queue it never did (the 5 s bound in each of 10 runs): Metal runs one queue's handlers one at a
time, so the runtime keeps the group there and promises nothing more than Metal.

Cost: a group mixing two queues' batches is no longer kept past a pass in which a submission
handler of one of them runs; it goes then, the batch that joined last included, in one
submission. Measured on a lane (frame_costs_over_imports, the guest's shape) in the runs that
verify this commit.

Docs: group.rs ("Kept while its queue runs earlier work", Group::keeps),
CommandBuffer::add_submission_handler ("Keep it short"), the runtime README's handler entry,
and FAST-PATHS.md's grouped-submission row.

Verified: cargo fmt. Build, clippy and runs (the previous commit's test, without and with this
change; the deallocator lane test as it was) are potluck jobs on the Iris Xe and the XTX.

(cherry picked from commit 8d04b2d15d3cb745363428fdc9acbbb9ca2eb868)
(cherry picked from commit 2cbd8a970905d931b7be39c92fbdd18d6024f62a)
2026-11-08 23:56:34 -08:00
Anees Iqbal de5a77cc06 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)
2026-11-08 22:45:29 -08:00
Anees Iqbal 81abe49dad Attached reads of the levels before the attached one read the texture's own image
A draw's sampled slot of a texture its render pass instance renders at level k (counted from the
texture's own first level) took the texture's usage shadow, a whole copy of every level, even
where its reads reach only levels before k. Such a slot now binds the texture's own image
through a view of its levels 0..k, the same first level, so an explicit level of detail selects
the same level, and names those levels in its uses (`binding::NarrowedSlots`): no copy is taken
for it. The copy would hold the same texels: nothing the instance does writes those levels
where the texture is an image of its own the bind reads in place (not sparse, no decoded twin,
the sampled usage), no attachment of the instance is at them, no earlier draw wrote them since
the instance's last barrier (a draw after one records into a new instance), and no write of the
draw's own meets them (else every narrowed slot of the draw takes its copy, its uses made
again). Which levels a read reaches is the translator's fact (`StageModule::level_reads`)
through the samplers the draw binds: level-count and level-of-detail queries, computed fetch
levels and samples without a sampler-bounded level keep the copy.

A draw rebound works its narrowed slots out again and is rebound only where they are its kept
draw's; a draw again binds as its kept draw did.

WorkCounts: attached_read_slots_below becomes attached_read_slots_apart (the own image cannot
serve them), attached_read_slots_written (something writes those levels) and
attached_read_slots_narrowed.

Verified: cargo fmt only; the build, clippy, a device test of an explicit read of level k - 1
while level k is attached and the touched suites follow as potluck jobs.

(cherry picked from commit 7ba814a2e2f419643c2f9e68b9768709658cbe94)
2026-11-08 21:48:37 -08:00
Anees Iqbal e67c617756 Visibility past an early-tests mask: announced where the device may count after the mask
runtime_lane::sample_coverage::the_sample_coverage_applies_after_the_fragment_function fails on
the Iris Xe (ANV, RPL-P) at its three early-tests draws: a full-screen draw of coverage 0.3
under psc_early counts 0 of 256 samples at 1 sample, 80 of 512 at 2 and 140 of 1024 at 4
(iris-B at 6cb37f2c86), where Metal counts every sample the early tests pass and masks the
colors alone. Its colors and depths are Metal's. The translator applies Metal's private masks
under early tests in the fragment function's SampleMask output, which Vulkan orders after
sample counting only where the device states earlyFragmentMultisampleCoverageAfterSampleCounting
(VkPhysicalDeviceMaintenance5Properties). ANV's capture on the Iris Xe of RPL-P states false;
RADV on the 780M, NVIDIA's on the RTX 5080 Laptop GPU, lavapipe and MoltenVK on the M3 Max
state true.

- metal2vulkan: Limits::early_fragment_multisample_coverage_after_sample_counting, read from the
  maintenance5 structure (false without the extension), and
  GraphicsState::writes_sample_mask, the fragment function's SampleMaskOut builtin (its own
  [[sample_mask]] return or the private masks it applies). SEMANTICS_VERSION 1998,
  ARTIFACT_FORMAT_VERSION 495 (a new encoded field).
- metal2vulkan-runtime: a draw under a visibility result (Counting or Boolean) whose fragment
  function declares early tests and writes its sample mask, on a device without the property,
  runs announced as Degradation::VisibilityPastEarlyMask
  (metal2vulkan-degrade-visibility-past-early-mask) and is counted in
  WorkCounts::draws_counted_past_early_masks. Keyed to the documented property alone, never to
  a driver or vendor.
- No structural form keeps Metal's count at no cost to uncounted draws: the colors' masks are
  the SampleMask output or a discard, both fragment operations such a device may count after, so
  only a second draw of each counted draw without the mask would count as Metal does. The
  announcement is the proportionate answer.
- The lane: on a device without the property, the early draw's colors and depths are still
  Metal's, its count at most Metal's, the draw counted once and the kind announced; elsewhere the
  count is Metal's and nothing is announced.
- docs/API.md's catalogue entry, docs/FAST-PATHS.md's device-gap row, visibility.rs's module docs,
  the api_signatures rows, and validation's limit bound (Execution). docs/REFUSALS.md
  regenerates unchanged.

Not done here: the runtime-sources pin and RUNTIME_VERSION (the orchestrator's number), and the
golden tables, which development re-blesses.

Verified: cargo fmt; the device description test reads the property from RADV's and ANV's
captures. Builds, lint and lanes follow through potluck.

(cherry picked from commit 4aa2896af563c41fec7d8129f15fb86b5dc4e418)
2026-11-08 20:41:07 -08:00
Anees Iqbal 12f7267750 Depth comparisons record RestrictedDepthRange on every device without VK_EXT_depth_range_unrestricted, MoltenVK included
Without the extension Vulkan gives a depth image no value outside
[0, 1]: a copy may take none (VUID-vkCmdCopyBufferToImage-pRegions-07931),
and a render write is clamped to the viewport's depth range. MoltenVK's
driver was measured to keep such values
(DriverFact::DepthImageKeepsValuesOutsideUnitRange), and its depth
comparisons required that property in place of the note; the owner's
rule is never to rely on undocumented Vulkan behaviour, so the fact
follows the extension and nothing else. With the extension a comparison
records nothing already, so the fact, the
VkProperty::DepthImageKeepsValuesOutsideUnitRange it derived and the
texture plan's kept_depth_range are removed: depth_comparison records
RestrictedDepthRange wherever the extension is not enabled (ANV, RADV,
MoltenVK), a precision note, logged and never fatal.

SEMANTICS_VERSION 1995: MoltenVK's comparing stages record the note and
no longer require the property. The codec drops the variant by name (no
format bump: a removed variant's tag stays unused). docs/API.md's
restricted-depth-range entry, FAST-PATHS rows 79 and 80, the note's and
the measurement table's docs, engine_depth_range's test (the note on
MoltenVK too, no module requiring the extension), driver_facts' MoltenVK
row and api_signatures (three variants) follow. The compare-clamp lane
predicts restricted-depth-range by the extension alone again.

Verification follows in the lane jobs; the golden tables and the
authored compile census are re-blessed on development.

(cherry picked from commit 90d231de945294c8428c05f79946f09bbb426819)
2026-11-08 18:15:23 -08:00
Anees Iqbal afb53192f7 Depth uploads clamp on every device without VK_EXT_depth_range_unrestricted, MoltenVK included
Vulkan takes no copied depth outside [0, 1] without the extension
(VUID-vkCmdCopyBufferToImage-pRegions-07931), and a driver measured to
keep one (DriverFact::DepthImageKeepsValuesOutsideUnitRange, MoltenVK's)
does not make the copy valid: the owner's rule is never to rely on
undocumented Vulkan behaviour. MoltenVK 1.4.2 does not expose the
extension, so ImageFacts::depth_clamps is now the extension's absence
alone: MoltenVK's uploads (replace_region, blits from buffers, copies from
colour textures, a heap's tiled copy in) clamp as ANV's do and announce
restricted-depth-upload. The fact stays for the translator's depth
comparisons (lower/texture/slot.rs depth_comparison, through
VkProperty::DepthImageKeepsValuesOutsideUnitRange) and for the validation
executor's own raw copies (candidate/platform/compute.rs).

The lanes follow the rule (degrade_notices::clamps_depth_uploads, the
heap lanes, texture_blits::depth_images_keep_what_their_drivers_claim,
which checks the clamp where the device lacks the extension, and
buffer_depth_samples). The combined-format blit lane counts apart the
GPU-assisted check's reports at offsets off a depth's 4 bytes: layer
1.4.363 reads a D32_SFLOAT_S8_UINT depth aspect's buffer at 5 bytes a
texel, where the spec lays it out as D32_SFLOAT's.

Verification: Iris, lavapipe and the M3 lanes follow in their jobs.
(cherry picked from commit 6dfbc9c0dd0b4b3690ce2824d16fb561afc51047)
2026-11-08 18:15:23 -08:00
Anees Iqbal 460a608d1b Depth uploads clamp into [0, 1] on devices that take no other: replace_region, blits from buffers, copies from colour textures
On a device without VK_EXT_depth_range_unrestricted whose driver is not
measured to keep a depth outside [0, 1] (ImageFacts::depth_clamps, ANV on
the Iris Xe), a copy into a D32_SFLOAT or D32_SFLOAT_S8_UINT depth plane
took Metal's bytes as they are, which breaks
VUID-vkCmdCopyBufferToImage-pRegions-07931 for any value outside
[0, 1]. The heap's tiled copy-in already clamped (TiledLevelMove::
clamps_depth); every other upload now goes through the same clamp, on
the bits: a NaN of either sign 1.0, -0.0 kept, other negatives 0, above
1.0 (+inf too) 1.0, the rest as they are, no denormal flushed.

- Translator: bind::clamped_depth (the CPU rule) and
  bind::depth_clamp_module (DepthClampModule), an in-place clamp over a
  buffer's words in the extended-canonical kernel's shape (first, width,
  row and image pitches). The tiled kernel's clamp now shares the module's
  SPIR-V helper.
- Runtime, depth_clamp.rs: clamps_depth (one test of format, aspect and
  device facts, which heap_tiled now uses too), the CPU clamp of packed
  bytes, and BlitCommandEncoder::clamp_depths / clamped_depth_copies: one
  dispatch a region (split into images or rows past the device's storage
  range or workgroup counts), each its own command so the tracker orders
  it between the copies.
- replace_region clamps the packed bytes on the CPU before any route (a
  host copy, the staging queue, a submission), so no depth image holds a
  value outside [0, 1] that a later copy of its texels moves on.
- A blit from a buffer into such a depth copies the regions' bytes into a
  scratch buffer, clamps them and copies from there; a plan that stages
  its rows clamps its staging buffer in place; a copy from a colour
  texture through the encoder's scratch clamps the scratch before the
  copy into the depth.
- WorkCounts::depth_uploads_clamped counts each clamp.
- restricted-depth-upload stays announced where it was; its doc, the
  replace_region message, docs/API.md, the blit and replace_region docs
  and the FAST-PATHS device-gap row say the upload clamps.
- MoltenVK (DepthImageKeepsValuesOutsideUnitRange) and devices with the
  extension are untouched.

Lanes, runtime_lane::depth_upload_clamps, under the validation layer's
GPU-assisted buffer-copy check: replace_region, a blit from a buffer (as
it is, through its plan's staging at an offset of 2, and into
Depth32Float_Stencil8's depth) and a copy from an R32Float texture, each
checking no VUID-07931, the clamp counted, and each texel read back
clamped (or as written where the device keeps it). The heap lane now
shares the lanes' device and message checks. Unit tests: the clamp rule,
the kernel under the interpreter, the region splitting, the CPU clamp.

api_signatures blessed (+16), api_surface table updated; REFUSALS.md
unchanged on regeneration.

Verified: not yet (Iris, lavapipe and Linux clippy are queued).
(cherry picked from commit a63c3646dd5e3fad8b24e387c4adb0f94d635ac9)
2026-11-08 18:15:22 -08:00
Anees Iqbal 99453e91d8 Images bound over exported memory name its handle type; a check class per export handle
A texture over an exportable buffer (exported_memory.rs) was a PREINITIALIZED linear
image, or a DRM_FORMAT_MOD_LINEAR one, with no VkExternalMemoryImageCreateInfo, bound in
memory allocated with VkExportMemoryAllocateInfo: VUID-vkBindImageMemory-memory-02728
("it must include at least one of the handles set in
VkExternalMemoryImageCreateInfo::handleTypes"). RADV and NVIDIA tolerate it; the layer
does not.

What changed:
- memory.rs: Memory::bound_memory reads a placement's own record (the block's export,
  import, own pages or read-only view, a guest RAM chunk's handle, a dma-buf import) and
  answers the handle type an image bound there names: none for memory of no export, the
  export's handle for a shared exported block, HOST_ALLOCATION or DMA_BUF for imports, and
  no image for a buffer's dedicated allocation (VUID-vkBindImageMemory-memory-10926) or the
  caller's memory. Buffer::bound_memory answers it for a buffer (a heap buffer's, its heap's).
- texture.rs alias_unbound decides the image from that record, not the route: over exported
  memory the device's linear image made for the handle type (external_linear_image, the
  former host_linear_image generalized), else the DRM_FORMAT_MOD_LINEAR one made for it
  (ModifierMemory::Exported). Either is made UNDEFINED (VUID-VkImageCreateInfo-pNext-01443),
  so its first move may discard the bytes, which only the device's check may vouch for.
- in_place.rs: two check classes, PagesClass::ExportedFd and ExportedDmaBuf. Their buffer
  is an exportable Shared buffer of that handle type in a shared block; their textures take
  the product's image. A texture over exported memory takes its image where the policy and
  those verdicts pass for its accesses; before them it is a CheckPending shadow that moves
  in place at the next quiet commit, as over the pooled memory (storage_form.rs now moves
  any class over the runtime's own memory). No LinearCost bound there: another API writes
  those bytes.
- The image format query (VkPhysicalDeviceExternalImageFormatInfo) must answer the handle
  type exportable (importable for imports) without DEDICATED_ONLY, for the linear and the
  DRM_FORMAT_MOD_LINEAR image alike; else the texture is a shadow, its notice naming the
  query's refusal. A dedicated allocation keeps the shadow, its notice naming 10926.
- ycbcr_planes.rs: the two-plane image is PREINITIALIZED with no handle type, so it takes
  only memory whose record says no export or import (KeptTexels::Memory elsewhere).
- in_place::CHECK_VERSION 12 -> 13: the record holds two more classes, so every driver's
  check runs once more.

Checked and unchanged: heap.rs's images (heaps are never exported; over host pages they are
HOST_ALLOCATION images, over a copy in device memory a shadow or an Own linear image), the
in-place images over host pages and copies (HOST_ALLOCATION over imports, Own over device
copies), and the runtime's own images in Holds::Images/Buffers blocks.

The placement rule (in_place.rs, "The runtime's exported memory"): per texture (per plane),
the texels' offset in the memory (the buffer's first byte, or its aligned_byte, at a
multiple of 256 there, plus the texture's offset) must be a multiple of
VkMemoryRequirements::alignment from vkGetImageMemoryRequirements for the image made for the
handle type of the texture's format, extent and usage; vkGetImageSubresourceLayout of its
first subresource must answer offset 0 and Metal's rowPitch; its size must stay inside the
buffer. The linear image first, then the DRM_FORMAT_MOD_LINEAR one with its own alignment.

Test: tests/exported_textures.rs, an NV12 picture's R8 3840x2160 and RG8 1920x1080 planes at
32 and 8294432 of an exportable buffer laid with aligned_byte(32), opaque fd and dma-buf,
Private and Shared, under the validation layer: a shadow first, both moved in place after
settle_in_place_checks, readback equal, in place at once after, no layer message.
dma_buf_export settles the checks before its plane textures. Not yet run: this commit is
for the build and the device runs.

(cherry picked from commit 40872fbb4748cbd228c06c27dc0cd63ca2d0a5ec)
2026-11-08 17:00:47 -08:00
Anees Iqbal ee3f269fa3 Heap depth textures: the copy in clamps a 32-bit float depth into [0, 1] where the device takes no other
A heap's 32-bit float depth texture whose shadow copies the heap's bytes
into its image went through vkCmdCopyBufferToImage with whatever float the
bytes held. On a device without VK_EXT_depth_range_unrestricted that is
invalid usage for a value outside [0, 1]
(VUID-vkCmdCopyBufferToImage-pRegions-07931); ANV stored it clamped, and
the runtime only announced it (restricted-depth-upload).

The tiled texel kernel (metal2vulkan::bind) now clamps a level's elements
on the way into the tight buffer where the level says so:
- TiledLevelMove::clamps_depth, set with TiledLevelMove::clamping_depth;
- the shape's level record grows to 14 words;
- the clamp compares the word's bits, so no denormal is flushed: a
  negative value becomes 0.0, one above 1.0 (and +inf) becomes 1.0, a NaN
  of either sign becomes 1.0 (as nan_clear.rs clears a NaN depth), and
  -0.0 and every value inside [0, 1] keep their bits;
- the move back is unchanged.
HeapTiledCopies::new takes the image's format and marks the 4-byte depth
planes' levels of a D32_SFLOAT or D32_SFLOAT_S8_UINT image where
ImageFacts::depth_clamps holds: exactly where restricted-depth-upload is
announced. MoltenVK, whose driver is measured to keep such values
(DriverFact::DepthImageKeepsValuesOutsideUnitRange), keeps its copies as
they were. The clamp is the device's own answer, so the notice stays and
its text now says the copy in clamps.

Tests:
- bind::tiled_texels::tests::clamped_depths_move_into_the_image_inside_0_1,
  run through the CPU interpreter;
- lane heap_textures::a_heap_depth_texture_s_copy_in_takes_no_depth_outside_0_1,
  which turns on the layer's GPU-assisted buffer-copy check
  (gpuav_buffer_copies), asserts no VUID-07931 message, and checks a blit
  reads the clamped values where the device clamps, else the bytes as
  they are.

Docs:
- the restricted-depth-upload declaration, docs/API.md's catalogue and its
  docs/FAST-PATHS.md device-gap row say the copy in clamps;
- docs/FAST-PATHS.md's known gaps gain one entry: a heap texture Metal
  keeps uncompressed lies in its driver's layout where its image fits
  Metal's answer (heap-texture-untiled-layout);
- api_signatures.tsv is blessed for the two new public items.

Verification in the tip report.

(cherry picked from commit de683c02ce08d337e8281dd752c2519f863bbe39)
2026-11-08 15:41:19 -08:00
Anees Iqbal dae9923446 Heap refit docs: which textures an image in place serves, and what the shadows of Metal's tiles cost
HeapTextureHostTransfer and HeapTextureLinear (and docs/API.md's catalogue)
say the refit takes an image of host-transfer usage only for a texture Metal
compresses or whose layout is not modelled, and of one Metal keeps
uncompressed only a linear image whose every element lies where Metal's tiles
place it. docs/FAST-PATHS.md's costs record the shadow of Metal's tiles kept
for every other such texture, with the 1x1 shadow's GPU time measured on the
Iris Xe at RUNTIME_VERSION 1909 (35.9 us against 8.1 us a frame); the
compositor's 3x3 to 10x10 shapes are not measured apart.

(cherry picked from commit dc30f3c6c8768ab3780bad861bba9db1ad9f4b84)
2026-11-08 13:32:36 -08:00
Anees Iqbal ec94c62dce heap depth textures: a merge's keep holds the heap's bytes, not the image's
A 2-slice Depth32Float 64x64 x2 multisample texture in a Shared placement heap
on ANV (Iris Xe, RPL-P, Mesa 26.2.6) lost the samples a blit wrote into one
slice: 16384 of 16384 were off Metal's tiles after the merge back, while a
read straight from the image matched. The heap's bytes held 0xee before the
blit. The copy in hands the image 0xeeeeeeee, a float outside [0, 1], which
Vulkan leaves undefined in a depth image without
VK_EXT_depth_range_unrestricted, and ANV stores 0.0. The merge's keep was
moved out of the image (only drivers announced drawn-depth-copy kept the
heap's bytes), so it held 0.0, and the merge kept the heap's 0xee in every
byte of a written sample that equals 0.0's: a probe found 9155 0xee bytes
left in the slice, the 9134 zero bytes of the samples plus 21 sample bytes
that are 0xee, and no sample whole.

Now a heap's tiled texture with a depth aspect, of any sample count, keeps
the heap's bytes: the staging buffer its copy in filled where the keep
follows it (WorkCounts::shadow_keeps_from_staging), else the heap's bytes
themselves, and plans no moves out of the image for the keep. Every byte a
command wrote is merged whatever the copy in changed; a value the copy in
changed in a texel no command wrote is written back as stored, as a copy back
writes it.

That clamp is the device's: a heap's 32-bit float depth texture whose shadow
copies the heap's bytes into its image now announces restricted-depth-upload
as it is made, on a device without VK_EXT_depth_range_unrestricted whose
driver is not measured to keep such a value (ANV; not MoltenVK, NVIDIA or
lavapipe with the extension). Its declaration, docs/API.md's catalogue and a
device-gap row in docs/FAST-PATHS.md say so.

The measured drawn-depth-copy flag a multisample texture held for its keep
is gone with its one reader; the announcement at making stays.

heap_multisample_textures_keep_their_samples_in_metal_s_tiles now also
checks, for each counted 32-bit float depth texture, restricted-depth-upload
as it is made where the device clamps, and that a blit into one slice or
aspect keeps from staging. Verification in the tip report.

(cherry picked from commit 688e1dcc00ff67979833fdcbaf2f5484057e18a6)
2026-11-08 13:16:59 -08:00
Anees Iqbal e106dbf2c7 FAST-PATHS: the 780M's later clips at one budget for its heaps made no allocation and took 122 and 119 ms
m3-max-9499 at 9bc836c2e9 on um790's Radeon 780M alone (RADV PHOENIX,
MESA_VK_DEVICE_SELECT 1002:15bf!): tests::clip_bursts' later clips made
0 and 0 allocations (16 in the first) in 121.5 and 119.2 ms, against 4
each and 237/245 ms with the placements in the system heap and a budget
per heap, and 132/126 ms with them device-local. The bullet said the
unified budget keeps every block; it now carries the measurement.

(cherry picked from commit f2e2063f1ff7050d7eeefd6ecdc26ace0c4bc29c)
2026-11-08 13:02:13 -08:00
Anees Iqbal 6be762136b Memory: with unified memory the heaps keep one budget of empty blocks
With the UMA placement, a Radeon 780M's Private placements take its
5.53 GiB system heap, whose eighth (707 MiB) kept all but 3 of a video
clip's 16 blocks: each later clip made 4 again (tests::clip_bursts,
m3-max-9454: [4, 4]) and took 237/245 ms to make against 132/126 ms with
the placements device-local (m3-max-9448). With unified memory every heap
is the same memory: the budget is now an eighth of all the heaps, at most
KEPT_EMPTY_BYTES, and the empty blocks of every heap count against it, so
the 780M keeps 2 GiB as one budget where it kept 707 MiB and 1414 MiB
apart (2.1 GiB in all). Devices without unified memory keep a budget per
heap as before.

Tests: tests::memory::unified_memory_keeps_one_budget_for_its_heaps (the
780M's heaps, a discrete card's, one heap). FAST-PATHS: the kept-memory
row's 780M figures, and the UMA row's clip-burst cost.

Verified: not yet run; lavapipe and the 780M follow as potluck jobs.
(cherry picked from commit 9bc836c2e9cac4b43b86380e4c53ee3a02133214)
2026-11-08 13:02:13 -08:00
Anees Iqbal 40a634d351 FAST-PATHS: unified memory's Private placements in the system heap first, and what they cost
The 780M runs before and after the placement (m3-max-9103 at the base,
m3-max-9157 at the change, um790, RADV PHOENIX): copies of 256 MiB at
23.9/28.8 GB/s device-local against 28.5/29.0 GB/s in the system heap's
type; a 259-tile scroll beside 1 GiB of another allocation's local memory
at median frames 1.31/1.29 ms before and 1.87/1.30 ms after (frames 300
and 600), alone 2.87/4.87 ms before and 1.33/1.31 ms after; no
amdgpu_bo_move eviction traced in either. Recorded under the costs of
matching Metal: no cost measured, no switch, not announced.

(cherry picked from commit 3d1f49072ca66c9976835da4df54773f50a7f283)
2026-11-08 13:02:13 -08:00