Commit Graph
899 Commits
Author SHA1 Message Date
Anees Iqbal ac0ffe1c25 Probe measurements and the API guide for reads dead after specialization
dead_ordered_and_unattached_reads.m records what it measured on the M3
Max under macOS 27.0.1 (potluck job m3-max-13241): dfr_color,
dfr_buffer and dfr_output are made and drawn, dead and live, every texel
the closed form's, with the debug layer silent; dfr_lacks has no state,
dead and live ('Shaders reads from a color attachment whose pixel format
is MTLPixelFormatInvalid'). Its header names the tests and the lane that
read it.

docs/API.md's color-group refusal list now names a raster order group on
a color output or on a parameter the function uses; one on a parameter
it never uses orders nothing and is not refused.

(cherry picked from commit 93aaa9c6685770db04032b710ec7b36950b56f89)
2026-11-10 00:55:27 -08:00
Anees Iqbal e51d85e18d API guide: a color input of another group is refused only where it is read
docs/API.md's color groups paragraph lists what each group's draw would
read from another group as the pipeline's limit refusal; a
[[color(n)]] input of another group is that only where the specialized
function reads it, as pipeline::compile::color_group::entry now decides.

(cherry picked from commit 1df7b9589dc6bda472d3faaa14bf432677647658)
2026-11-10 00:11:07 -08:00
Anees Iqbal c42e63e64b Record DevicePackConversion where a heap read decodes a raw-held texture
A float or half read, sample or gather through an argument buffer that
decodes a texture the heap holds by its raw texels alone (BGR10_XR,
BGRA10_XR, R10Unorm_X6, RG10Unorm_X12 and the bfloat formats; the
heap_raw routine) converts by the device's arithmetic, as a slot's decode
of the same texel does, but recorded no PrecisionNote: a reader of the
module alone saw no near-equivalent, against AGENTS.md's "allowed only
when the artifact records it".

The decode is planned in one place now, texture::heap_raw::plan, which
both the read (select_read_as) and the emulated sample or gather
(heap_raw_sample) call. It records DevicePackConversion as a specialized
note with one clause on a new bound-value key, SpecKey::HeapRawTextures
(stage): a texture the stage's handles can name is held raw. The binding
plan gives the key from the command's heap members (resident or bound
textures, as for HeapYCbCrTextures), so the note is in the module's
notes, holds under precision_notes_bound exactly where the command can
name such a texture, and the runtime announces it at that draw or
dispatch (degrade_bound_values) and never at the pipeline's making. A
stage that records the note outright for another conversion keeps it
outright. Heap accesses that reach no such texture (queries, integer
reads, storage reads, samples the function does not emulate) record
nothing.

NoteOn::HeapTextures is renamed HeapYCbCr beside the new HeapRaw.
bind::heap::raw_held is pub(crate) for the plan. The heap set's own
announcement naming the texture (heap_sets::RawRead) stays.

SEMANTICS_VERSION 2008 (heap-reading modules gain the note);
ARTIFACT_FORMAT_VERSION 498 (a SpecKey variant). api_signatures blessed;
REFUSALS.md regenerated (unchanged). docs/API.md's catalogue and the
runtime's Degradation docs say where the note is recorded and announced.

Tests: heap_decodes_record_the_device_pack_conversion now also asserts
the one HeapRawTextures clause; the new
a_heap_decode_s_note_holds_where_its_command_can_name_a_raw_texture checks
the plan's key and the bound note on every committed profile; the lane
a_heap_decode_s_stage_note_is_announced_where_its_command_can_name_a_raw_texture
checks the runtime's announcement under announce_each.

(cherry picked from commit 1ab403b671f18773a10c8572ffbe0a73b56f5bbc)
2026-11-09 23:54:15 -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 ab10b3cbcf Runtime: say what a decoded twin's CPU decode makes replace_region wait for
The cpu-block-decode notice said the call waits for the decode where a
command buffer that may read the texture is submitted and not yet complete,
or the texture is untracked. The call has waited for no GPU work since the
decode moved to the device's decode thread (texture/twin_decode.rs): it waits
only for room, while 256 MiB of written blocks wait for the thread (a 4:2:2
carrier's partial-row write also reads its rows back first), and the
scheduler holds the first command buffer that may read the texture, every
command buffer where the texture is untracked.

The declaration's rustdoc, its announced cost and docs/API.md's catalogue
entry now say that. A test ties the stated bound to the queue's QUEUED_BYTES
(made pub(crate) for it), so the text follows the constant.

Verified: tests::degradation::the_cpu_block_decode_cost_states_the_calls_
only_wait and tests::degradation_catalogue (the catalogue states the cost).

(cherry picked from commit f128722f1b2197f52833080eca738fd498cf6ce5)
2026-11-09 23:49:33 -08:00
Anees Iqbal b1625c535c Translator: note a mesh function's point size only where it outputs points
A mesh function that writes a vertex's point size recorded
PrecisionNote::DevicePointSize whatever primitive its mesh outputs. The
rasterizer reads a vertex's size for points alone, so a line or triangle
mesh's size draws nothing on any device, and the runtime already announces
the note only at draws that rasterize points (7715a47be3). The note is now
recorded only where the mesh type's topology (air.mesh_type_info) is points,
a structural test, so the artifact carries no note its draws can never meet.

Apple's compiler refuses [[point_size]] in a triangle mesh's vertex, so the
case arises only for AIR not compiled from MSL. The test derives the
triangle mesh from the owned fixture's point mesh (mesh_outputs_points) by
its topology word alone.

SEMANTICS_VERSION 2008: an artifact's precision notes change. docs/API.md's
catalogue entry and the note's rustdoc say which mesh functions record it.

Verified: engine_mesh::a_mesh_point_size_is_noted_only_where_the_mesh_
outputs_points on every committed mesh profile with the largest point set
below Metal's: the point mesh is noted, the triangle mesh is not, both store
the size; the test fails with the topology check reverted.

(cherry picked from commit adc0435c64495e2f3a3355becf055941fc529fc3)
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 25401533b9 Docs: a fast-math NaN constant beside a run value stores the NaN; the fold's wording
API.md, section 10, Function constants: an fadd, fsub, fmul or fdiv under
nnan whose operand is a function constant bound to a NaN is poison in the
AIR. The translation answers the NaN operand unchanged, as it does without
fast math, where that NaN is Metal's answer. On the M3 Max, Metal drops a
kernel's store of it.

Measured in job m3-max-12877 with case 2d9a7e3091e1f9d9..., which is the
fixture sfold_fast_poison in a scratch corpus:
- Metal on apple-m3-max-macos27.0.1 left every poison row's float and
  half store at the 0xCD fill, and wrote the run-value row.
- MoltenVK with the folds wrote the NaN operand unchanged in every poison
  row (ffc12345, 7f800321, fd21).
- MoltenVK with the base translator dropped the float rows, and wrote ff21
  and 0 in the half rows.
The case is not committed: the corpus compares exactly.

ARCHITECTURE.md: the canon row now says a NaN operand is as it is beside a
value the run computes, and quieted where every operand is a constant.

(cherry picked from commit cddef968a3a8a971341fafcc5469e141fb97b434)
2026-11-09 20:44:24 -08:00
Anees Iqbal f12af61da9 ARCHITECTURE: SCCP's float folds in the canonicalization summary
The canon row names what SCCP settles; it now names the float operations a constant operand
decides (a NaN operand, the first in order, quieted; a product by a zero under nnan and nsz).

(cherry picked from commit f6b2db494f2aabdb2a875c5a49651abc2e28803b)
2026-11-09 20:44:23 -08:00
Anees Iqbal b83d35f35a Clear reach: a pass without a draw call clears before itself where its own clear would overreach
On MoltenVK, a pass's own Clear load in a pass without a draw call reaches
the whole attachment. Where the reach is the render area itself (an
uncompressed attachment whose render area ends on 32x32 tiles, now that only
a compressed one is cleared whole), the pass's own clear was used and reached
the whole 128x128 texture over a 64x64 area: lane fresh_clear_reach on the M3
Max (MoltenVK), 3 of 150 cases, BGRA8Unorm, RGBA16Float and RG16Float.

ReachClears now clears such a stored attachment before the pass by a render
pass of its own and the pass loads it (own_clear_overreaches: no draw call,
an attachment larger than the render area), color and depth/stencil alike.
The pass's render area stays Metal's, so a DontCare or Load attachment beside
it keeps its texels.

Docs: MacClass and docs/API.md cite arm64metal's tileclear2 jobs: the M3's
answer (m3-max-12716, 12735) and the x86 Macs' disagreement (5300M whole,
UHD 630 from the area to the whole texture: m3-max-12736, 12737), where the
runtime keeps the whole level, the 5300M's answer.

(cherry picked from commit ea34c273885ff00633c3afe983fdb3a7a398dd03)
2026-11-09 19:20:24 -08:00
Anees Iqbal 44e51b5081 Docs: how far a Clear reaches without a draw call, by the Mac class
MacClass and docs/API.md's accepted differences (the Mac a device presents)
state the answer: on a device presenting an Apple silicon Mac, a Clear load in
a pass of one layer without a draw call clears a compressed texture's whole
level and slice and any other texture's render area rounded up to 32x32
tiles; on one presenting a Mac with an Intel or AMD GPU, the whole level and
slice whatever the texture, unmeasured there and kept as it was. The lane's
clear_reach docs name the compressed textures their whole-level cases use.

Docs only; no behaviour change.

(cherry picked from commit 5591cc4b71a9458fef7a3773ed99d1bf0eeb1dcd)
2026-11-09 19:20:24 -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 513d792675 REFUSALS: MadeBeforeRecovery's pooled buffers are those in memory the device allocated
A recovery now carries a pooled Shared or Managed buffer that lies in a block of the runtime's own
pages, so the reach note names the pooled buffers left refused as those in memory the device
allocated. docs/REFUSALS.md regenerated (scripts/refusal-surface/refusal_surface.py); no refusal
changed.

(cherry picked from commit b11909130479dbdb8c42c8d6c3950ffa1d9414ed)
2026-11-09 09:51:55 -08:00
Anees Iqbal 73545f6afc Page blocks only where the fresh pages' verdicts give textures what plain blocks do
A texture over a buffer in a block of the runtime's own pages takes the route
over fresh pages: its image is made for host allocations and starts UNDEFINED,
so it lies in place only where the in-place check's verdicts of fresh pages
pass, where over a plain block's buffer the device's linear image starts
PREINITIALIZED and needs none. So the program's buffers now lie in such blocks
only where those verdicts give every access and row ends a texture over a plain
block's buffer takes in place (by the pooled class's verdicts) the same, as
the blocks allocated exportable already do: fd_blocks_take is now blocks_take
of a pages class (FdBlocks or Fresh), its enum BlocksTake, and
Device::page_blocks_taken asks it for Fresh, starting no check. Pending
verdicts leave the buffers in plain blocks.

The memory lock is no longer held while the verdicts are read as a buffer is
made.

Docs: memory.rs's module docs, device/carry.rs, the runtime README, docs/API.md
and the recovery notice's cost name the condition.

Verification: the suite follows.
(cherry picked from commit 8c50d54d9871bce0e80865ac4916e7da0c192a8a)
2026-11-09 09:51:54 -08:00
Anees Iqbal 3d0ece2f7a Page blocks: kept() asks the page buffers' address types before it borrows the families; docs
kept() asked address_types for Holds::PageBuffers while a Sharing borrowed
the families, which the borrow checker refused (job 11930). The query now runs
before that borrow.

Docs: memory.rs's module docs get "Buffers in the runtime's own pages";
device/carry.rs, Buffer::carry, the runtime README and docs/API.md's recovery
cost say a recovery carries the Shared and Managed (unified memory) buffers in
blocks of the runtime's own pages, and leaves those in memory the device
allocated.

Verification: the build follows.
(cherry picked from commit e5df53c305b27909f4cca460a4910c12861d20aa)
2026-11-09 09:51:53 -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 2ef8af3abe A pass-start read takes the copy cleared by MoltenVK's clear command, which is Metal's clear
What: on MoltenVK (DriverFact::ColorClearIsMetals) a draw that samples a colour its pass clears,
after a memory barrier at the pass's start, split the pass again (attachment_read_splits, a
second render pass instance, the render-pass-split notice) instead of reading a copy of the
attachment cleared to the clear before the pass (attachment_read_clears). Texture::cleared_copy
refused a clear whose device-color-conversion note the load operation withholds
(ColorTarget::withheld_clear), because the copy is cleared by vkCmdClearColorImage and only
the load operation was measured to store Metal's texel there. Since 876cfd1402 every clear of
a normalized channel off a whole code is in question (the spec's rule), so the pass-start
clears of the lanes and the conformance cases became withheld on MoltenVK and split.

The driver's clear command is measured to store Metal's texel too, so the fact now covers it:
- Texture::cleared_copy takes a withheld clear (no note owed: the clear command's texel is the
  load operation's, Metal's).
- A memoryless attachment's backing cleared after the first instance, and an attachment the
  first instance leaves out cleared before the pass by the clear command (cleared_ahead), owe no
  note either; the same clear by a render pass of the attachment alone, or as sample planes,
  still announces it.
- DriverFact::ColorClearIsMetals, ColorTarget::withheld_clear, texture/attached_reads.rs and
  docs/API.md's device-color-conversion entry say so.
Elsewhere withheld_clear is None (the note is announced as the pass is laid out), so nothing
changes on other drivers.

Why, measured on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2):
- The cause, by a probe of each condition of cleared_copy over 22,482 runs of
  attachment_reads::a_draw_after_a_barrier_at_the_pass_start_reads_the_clear on development at
  1571c220d7: every run failed the same way, (cleared copies, splits, begun) = (0, 1, 2), with
  withheld_clear Some([200, 40, 120, 160] / 255) the only condition that refused (not load, not
  timing).
- The clear command: each of the 71 colour clears Metal was measured with
  (renders.rs COLOR_CLEARS: ties of 8-, 10- and 16-bit unorm and snorm channels, sRGB, packed
  16-bit, half and small floats, shared exponents, NaNs) by a plain fill of a whole 1x1 texture,
  which is vkCmdClearColorImage of the load operation's clear value (blit_fill.rs): 71 of 71
  Metal's bytes, and equal to the load operation's 71.
  runtime_lane::renders::clears_are_the_device_s_conversion_of_the_clear_value now checks this
  on a driver with the fact.

Ran on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2) at this change over 693fd3f96d, under --cfg
m2v_gpu: the whole validation suite, 3398 of 3400 passed (attachment_reads and renders among
them); the two failures are the runtime-sources pin, which the landing sets, and
degrade_notices::a_creation_s_notices_and_messages_reach_the_sink_on_the_asking_thread at
device creation (creation_heard_checked), before any pass is recorded. conformance cost --check
over the whole set: no gated count and no ceiling moved (the pass-start-barrier cases read the
cleared copy again, as recorded); conformance replay of the 14 pass-start-barrier cases: rc 0,
each difference an accepted one. On this base only driver_facts.rs merged (beside
ClearedDepthAtStandardPositions); the other five files are unchanged since 693fd3f96d.

RUNTIME: the runtime's pass-start reads on MoltenVK change (a cleared copy instead of a split).
(cherry picked from commit 25063af705d28d07b7332cc1b35a5cf1beedc6bb)
2026-11-09 07:53:32 -08:00
Anees Iqbal 462934908e RUNTIME_VERSION 1974, the runtime-sources pin and the API table for recovery 1b
exitcrash 1571c220d7..4b9b7ed8b0 (11 commits): a device recovery carries the
program's no-copy buffers (made again on the new VkDevice over the same pages,
same contents pointer, Metal address and bytes: pointer imports, buffers in
another's import, gate-refused copies, runs of guest RAM) and its uses of
guest RAM (HostRamUse, carried before the buffers). The caller's deallocator
still runs once, after every generation's import of the pages is freed; a
detached no-copy buffer stays on the lost generation (MadeBeforeRecovery).
Runtime behaviour changed: RUNTIME_VERSION 1973 -> 1974, pin recomputed,
docs/REFUSALS.md regenerated (two refusal sites renamed: ram_use_on,
buffer_over_host_parts).

API table: HostRamUse is now a tuple struct over a private Arc<RamUseCell>
and its own impl Drop is gone (the cell's use drops it). Nothing breaks for a
consumer: dropping a HostRamUse still lets go of the RAM at once (the
recovery's carry holds only a Weak, upgraded for the carry itself), and
nothing could call the Drop impl directly.

Verified by exitcrash: lavapipe 11782 at a5f0c3be37 runtime suite 1999/2000
(the one red a test bug, fixed), clippy plain/cpuicd/gpucfg, rustdoc, refusal
check; lavapipe 11814 recovery/no-copy/event 30/30 with negative controls A
(deallocator not handed on) and B (lost parts never let go) failing as
designed; rebased tip 4b9b7ed8b0: Iris 11823 51/51 and 780M (RADV PHOENIX)
11824 51/51 over recovery, no-copy, host_ram_device, event_timeline,
detach_lost, the new tests run on both. Not run at the tip: lavapipe whole
suite, clippy, the 5080 (development's checks).
2026-11-09 06:02:36 -08:00
Anees Iqbal 15923d88c0 Docs: a recovery carries no-copy buffers and uses of guest RAM
The DeviceRecovered cost text (and docs/API.md's catalogue entry, which states
it), the runtime README's recovery section, new_buffer_with_bytes_no_copy, and
the contracts of the import gate, the run resolver and the dma-buf source now
say the following. A recovery carries a device's uses of guest RAM and its
no-copy buffers. Each buffer is made again over the same pages. The caller's
callbacks are asked again on the thread that recovers, before the new device
serves, so they must make no call on the device. The deallocator runs at the
buffer's release once no VkDevice's import of its pages is left (the
keep-alive's contract says the same). Detached no-copy buffers and a no-copy
heap's buffers stay refused. HostRamUse's doc says the use goes on.

(cherry picked from commit 58ba0931b857a9dcf9a6124138c81fc31a259552)
2026-11-09 06:01:13 -08:00
Anees Iqbal 742e320bee REFUSALS.md for what a recovery carries; the carry test's notification sends plainly
REFUSALS.md is regenerated by scripts/refusal-surface/refusal_surface.py in job m3-max-11457, and its --check passes. MadeBeforeRecovery's row now says what the recovery does not carry and lists the exportable-event carry site. The carry test's notification no longer drops a Copy Result, which the CPU-ICD clippy rejected.

(cherry picked from commit ef076009e82d2bde7f29ff9a81608ec40e94cb6a)
2026-11-09 04:26:05 -08:00
Anees Iqbal 33675e87f1 Carry tests, and docs for what a recovery carries and leaves refused
New device tests (tests/device_recovery_carry.rs, under the CPU-ICD and GPU
cfgs):

- One recovery carries a Private buffer (same address, zero after) and a
  buffer in fresh pages. The fresh-page buffer keeps its contents pointer and
  bytes, and the host's writes through that pointer after the recovery reach
  the GPU's copy. It also carries a shared event: its value, its listener's
  notification and a GPU signal after the recovery.
- A pooled Shared buffer stays refused, and the notice counts it. It keeps the
  lost VkDevice, which then holds no empty block and less memory than before
  the loss. Dropping it takes the line back to one live VkDevice.
- Seven recoveries with a carried buffer and event in use between them end
  with one live VkDevice, and eight made.

The device_recovery helpers are shared with the new file.

Docs: RuntimeGap::MadeBeforeRecovery, the DeviceRecovered catalogue entry and
its consequence (runtime and API.md), the runtime README's lost-device
section, line.rs's module and recover_for_test docs, in_place.rs, the
validation lane's docs and the refusal surface's reach mark now say what is
carried and what stays refused. REFUSALS.md is regenerated in the next commit.

Not yet built.

(cherry picked from commit 68d68cdfbdbbac979e5097a8ad286416450790bf)
2026-11-09 04:26:04 -08:00
Anees Iqbal 2cbe8ce595 Volume resolves: NVIDIA's leaves plane 1 unwritten, so it resolves through the scratch copied into the planes too
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09)
runtime_lane::view_attachments::a_resolve_writes_the_volume_plane_it_names failed at base and tip
alike, 3/3 each (t3d_resolve_plane1: byte 64 is 0x11, Metal's 0x33). Its VOLUME-RESOLVE lines and a
probe of resolve orders (scratch branch, never merged) show a 4x multisampled RGBA8Unorm attachment
resolved into the 2D view of a 4x4x4 or 4x4x8 volume that begins at depth plane 1 writes no plane:
the volume keeps every byte it had. Into the views at planes 0, 2 and 3 it writes that plane alone,
in every order tried (1023, 3210, 0123) and three times over into plane 1. A draw into plane 1
through the same kind of view writes it (a_volume_s_plane_is_an_attachment passes), and the
validation layer reports nothing, so the usage is the valid one RADV's defect row already cites.

Fix, the RADV fix's shape (c1a825d748): RuntimeDriverDefect::VolumeResolveFirstPlane gains an
NVIDIA_PROPRIETARY row, every NVIDIA GPU until a probe finds one clean. Its meaning is stated for
both drivers: the resolve is written where the view begins only at the image's first plane (RADV
writes plane 0 whatever plane the view begins at; NVIDIA's writes no plane from plane 1). There a
color resolve into a 3D texture's planes past its first, or into more than one, goes into the
scratch image of the pass's layers that is copied into the planes after the pass, announced as
resolve-scratch with the defect named. The variant, the table's doc, the resolve module's docs, the
notice's reason and docs/API.md's catalogue entry say so.

Tests: tests::driver_defects lists the defect for every committed NVIDIA profile (the RTX 5080
Laptop GPU's and the others'), so it fails without the row.

Verified: cargo fmt. The lane on the 5080 at this commit and at its base follows through potluck.
(cherry picked from commit 93795eaaa29dba62257ca9b4c569394e23c269da)
2026-11-09 04:15:29 -08:00
Anees Iqbal 876cfd1402 Colour clears and fills take either code on every device but where a measured row says Metal's
The orchestrator's decision: Vulkan lets a clear of a normalized channel store either of the two
codes closest to its scaled value ("returns one of the two ... closest ... Implementations should
round to nearest"), so every device takes that rule, not only the three devices measured to take
the farther code (DriverFact::ColorClearTakesEitherCode's rows: NVIDIA's on the RTX 5080 Laptop
GPU, ANV on the Iris Xe of RPL-P, RADV on the Radeon RX 550). The one exception stays the measured
DriverFact::ColorClearIsMetals row: MoltenVK on the Apple9 GPUs, whose load operation of an
attachment the render area covers clears as Metal's.

Runtime: clear_value::rounds_apart and fill_value::device_apart lose their `either` argument; a
normalized channel's clear or plain fill is in question wherever its scaled `float` is off a whole
code (the rule the three rows took), which subsumes the old margin of 1/1024 around a midpoint
(and the packed 16-bit formats' wider one). render_pass.rs and blit_fill.rs read no fact for it;
the load operation's exception under ColorClearIsMetals is unchanged. The fresh pattern of a
signed normalized format (code -1) is written by copies of its bytes, not a clear: no `float`
scales onto it (-1/127 is -0.99999999627 codes), so its clear is in question under the rule
(texture/heap_tiled.rs fresh_pattern; the fresh-pattern test allows its 1-byte texel).

Translator: DriverFact::ColorClearTakesEitherCode, its three rows and AMD_RX_550 (only they used
it) are removed; the facts table test and api_signatures.tsv follow. ColorClearIsMetals' doc
and PrecisionNote::DeviceColorConversion's state the spec's rule.

Validation: buffer_texture_blits' IOSurface planes expect the clear's notice on every device but
where the load operation clears as Metal's (degrade_notices::clear_in_question, the former
tie_cleared, now stated for any value off a whole code). color_fills prints how many plain fills
announced device-color-conversion (COLOR-FILLS-ANNOUNCED).

Docs: docs/API.md's device-color-conversion entry is the spec's statement plus the measured
devices and the one exception.

Verified: cargo fmt. Runs follow through potluck.
(cherry picked from commit 9a844f5c5f5ce1499664f77eceb66fccf2dfd9f7)
2026-11-09 03:47:40 -08:00
Anees Iqbal 7ed49fd04d RADV fuses float arithmetic into a half conversion: the pipeline records NativeHalfConversion
On the Radeon 780M (RADV PHOENIX) runtime_lane::half_conversions failed its product kernel:
2.6822087e-7 * 1.0000001 answered half 0x0005 where Metal's half of the float product is
0x0004, with notes only [NativeNanEncoding] (radvruns job 11026, 2 of 2 runs). The module
rounds under the float controls (QuantizeForm::Controlled), which make the conversion Metal's,
so it recorded no conversion note. RADV_DEBUG=shaders on the 780M (job 11121) shows why: ACO
compiles the product's OpFMul and the narrowing, both decorated NoContraction, as one
v_fma_mixlo_f16 v2, v1, v0, neg(0), rounding the exact product to half once where Metal rounds
the float product; the sum kernel's narrowing is one v_fma_mixlo_f16 1.0, a, b too.

That is the device's own rounding (rule 1), so the fix is the note, not Metal's bits:

- DriverWorkaround::HalfConversionFusedWithArithmetic, keyed on RADV on every GPU (the others
  unmeasured), as NVIDIA's HalfConversionPairFolded is keyed on its driver.
- narrow::rounds_arithmetic: whether a module rounds to half, through a conversion pair, the
  result of an f32 OpFAdd, OpFSub, OpFMul, OpFmaKHR or GLSL Fma.
- compile_kept records PrecisionNote::NativeHalfConversion where the module takes the
  controlled conversion, the profile carries the workaround and rounds_arithmetic holds. The
  controlled form itself stays: a loaded float's conversion is exact there and records nothing.
- Tests: radv_carries_the_fused_half_conversion (every committed RADV profile carries it, no
  other does, and RADV keeps the controlled form) and
  a_controlled_rounding_of_arithmetic_is_noted_where_the_driver_fuses_it (a float sum, product
  and fused multiply-add rounded to half record the note on every RADV profile and not on ANV;
  a loaded float narrowed alone records it on neither). Both fail with compile.rs and derive.rs
  at the base.
- The note's doc, the API guide's catalogue entry, HOWTO, the narrow module doc, the lane's doc
  and the signature table name the new variant.

(cherry picked from commit 799d39233c4e0ae2a18a716e794db8f67405ff00)
2026-11-09 03:12:03 -08:00
Anees Iqbal 92202c5eaf RUNTIME_VERSION 1963, the runtime-sources pin and REFUSALS.md for the opaque-fd block split
radvruns' split (43 commits, its fd-blocks-2 branch at dd5e698bff): on a unified device's system
heap, runtime buffers lie in blocks exportable as opaque fds once the device's in-place check
takes them, and buffers that declare their padding unobserved stay in plain blocks. On the 780M
this removes the submit stall behind the kernel's lock (0 turnarounds of 8 ms or more against
11-12; the lock wait 305 -> 2.6 ms). A buffer's making no longer starts the in-place check
(289b04fae4); kept room serves the runtime's own pools first (916073fc37); blocks made ahead stop
at the allocation margin left to the objects (dd5e698bff). REFUSALS.md: BufferLength gains the
pooled_check_buffer site. The runtime changed, so RUNTIME_VERSION 1963.

Verified (radvruns) at dd5e698bff: PHOENIX (um790, release, gpucfg) host_ram_device 22/22, the
seven earlier-red modules 47/47, the full runtime suite 1963/1963 and 1962/1963 (completion_order's
timing test once; base comparison 11395 against tip 11394 running); M3 clippy plain/m2v_gpu/
m2v_cpu_icd and rustdoc clean, runtime 1367/1367, m2v_gpu set 168/168. Open: Iris
in_place_check::the_in_place_check_takes_no_range_of_the_metal_space failed at dccbb9d3d7 (base
vs tip 11363/11364 pending). Here: the API-signature check, REFUSALS.md and
CONFORMANCE-COVERAGE.md regenerated, cargo fmt clean.
2026-11-09 01:45:34 -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