Commit Graph
320 Commits
Author SHA1 Message Date
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
Anees Iqbal 8e1383b1b6 In-place check: an unchecked verdict whose cause lasts is kept; one that may pass is checked again
The previous commit kept every unchecked verdict out of the record, so a driver that truly
lacks what a class needs (an extension, a feature, an import, a format or an image of the
shape, such as lavapipe's DmaBuf and Pooled rows-in-lines, which RuntimeDriverDefect::
ExplicitPlaneRowsPastHeight refuses) would be checked again by every device. Such a cause is
fixed for the driver's identity, as stable as a passed or failed verdict, so it is kept; only an
unchecked verdict from a cause that can change between runs is kept unmeasured and checked
again.

- in_place_check::Unmade: the reason the check made no pages, pass or image, and whether its
  cause lasts. ClassPages::make, ExportedPages::make and Round::NotMade carry it.
  Lasting: no host import (VK_EXT_external_memory_host), no dma-buf images, export only as a
  dedicated allocation, no host-visible coherent type, no DRM_FORMAT_MOD_LINEAR images, and a
  placement answer the image's making decides before it binds (Refused Rows, Image, Pitch,
  Placement, DmaBuf; another route of the shape), and an error that is the device's gap or
  Metal's refusal (Error::Unsupported, Error::Invalid).
  May pass: pages, memory or mappings not made, an export failing, a no-copy buffer copied or
  imported otherwise on a device that imports host memory, an answer in place that only the
  bind refused (the dma-buf's import), detached or sourceless pages, the writer thread not
  started, a first move, pass or kernel's stores failing, the kernel's buffers refused, any
  other error (out of memory, a lost device, a Vulkan failure, the runtime's own gap).
- check_class answers, by row ends, whether an unchecked verdict met a cause that may pass;
  run writes those verdicts pending in the record and the rest as given. encode writes the
  verdicts as given; decode reads every verdict byte (unchecked among them).
- Notes say which cause it was, "(a cause that lasts, kept)" or "(a cause that may pass,
  checked again)": the first of each kind per class and access.
- CHECK_VERSION stays 12 (the bump the previous commit made, not landed): a record of 11 may
  hold unchecked verdicts whose cause may pass, which no device takes now.
- Tests: an_unchecked_verdict_is_checked_again_where_its_cause_may_pass_and_kept_where_it_lasts
  (device test, replacing the previous one: the pointer class's failed import is noted as a
  cause that may pass and checked again by the next device; every measured verdict is recalled,
  each unchecked one recalled unchecked or checked again; on a driver with
  ExplicitPlaneRowsPastHeight the DmaBuf reads of rows inside lines are recalled unchecked).
  The record round trip holds passed, failed, unchecked and pending verdicts. The in-place
  textures lane's record test takes measured <= recalled <= VERDICTS.
  narrow_writes_device and freed_memory read only the report's verdict lines, not the notes
  after them (20 narrow lines counted where 16 were due on lavapipe, job 9303).
- Docs: in_place.rs, in_place_check.rs, WorkCounts::in_place_checks_recalled,
  settle_in_place_checks, docs/API.md, docs/FAST-PATHS.md (the in-place row).

Verified: cargo fmt; builds and tests run as potluck jobs after this commit.
(cherry picked from commit b420f97f56237fc0bf153691e9ac7e5a8e923386)
2026-11-08 12:15:38 -08:00
Anees Iqbal aa188702ad In-place check: an unchecked verdict is no measurement, kept unmeasured and checked again
On the Iris Xe (ANV) reims' arm-s boots made 890 shadows over guest RAM imported as dma-bufs,
every one "the device's check made no image over host pages imported as dma-bufs" (Unchecked),
small ShaderRead textures at offset 0 on whole pages among them, where a fresh check of the
same driver passes the class's reads (aafecf768a, job 7667). The record kept every verdict the
check gave, Unchecked among them, and every later device of that driver and check version
recalled it and checked nothing: a refusal of the class's pages (or of its rounds' images) in
one process, a transient one or one of that device's setup, answered for every boot after.
And the check kept no reason for it: the class's pages and rounds that made no image returned
unchecked with no note.

- in_place::encode writes an unchecked verdict as unmeasured (a pending verdict's byte);
  decode reads that back pending and refuses an unchecked byte (never written).
  recall_in_place_checks recalls the measured verdicts (passed or failed, counted as recalled)
  and settles only where none is pending: the first texture that asks a pending one starts the
  check, which runs only the classes and accesses still pending, and its record replaces the
  old one.
- CHECK_VERSION 12: a record of 11 may hold unchecked verdicts as answers, which no device now
  takes; reims' stale records are dropped by it.
- Reasons, noted in the check's report after the verdicts: ClassPages::make answers why it made
  no pages (each step of ExportedPages::make for the dma-buf class: no host import, no dma-buf
  images, an export only as a dedicated allocation, no host-visible coherent type, the
  allocation, map or export failing; a no-copy buffer refused, copied, or imported otherwise),
  and a round that made no image says why (its making's error, the placement's answer for a
  texture not in place, its first move or pass failing), the first per class and access.
- Tests: a_class_whose_pages_the_check_could_not_make_is_checked_again_by_the_next_device
  (device test: the pointer class's first import fails, so its reads are Unchecked and noted; the
  next device of the cache recalls every measured verdict, finds those reads pending, checks
  them again; the device after recalls them). Before this change the second device recalled the
  reads as Unchecked. The record round trip reads unchecked back pending; the in-place textures
  lane's record test recalls the measured verdicts and checks the rest again.
- Docs: in_place.rs, in_place_check.rs, WorkCounts::in_place_checks_recalled,
  settle_in_place_checks, docs/API.md, docs/FAST-PATHS.md (the in-place row).

Verified: cargo fmt; builds and tests run as potluck jobs after this commit.
(cherry picked from commit 29f3114ca990382776e795f35ea9b81f8345399a)
2026-11-08 12:15:38 -08:00
Anees Iqbal a3fb1283e6 FAST-PATHS: the first clip's allocations stay open, with their cause and why no block is made ahead
(cherry picked from commit 4d2833ae3d662006101e3be98bfba4c7da58603e)
2026-11-08 11:49:37 -08:00
Anees Iqbal 186d327fe7 Memory: kept blocks past their quiet period go within a second at the next creation call; FAST-PATHS records the kept memory
A kept empty block was looked at only when a release came in its own pool, so a
pool whose resources stopped coming and going kept its blocks, up to its heap's
budget, until its next release. The device's creation calls (keep_room) now
also free every pool's kept blocks past KEPT_EMPTY_FOR, at most once every
KEPT_SWEEP_EVERY (1 s): the memory is held at most about 11 s past a working
set's dip wherever the program still makes resources.

docs/FAST-PATHS.md, known gaps: the NVIDIA memory block row, with the bound
(an eighth of a heap, at most 2 GiB, 10 s), what it holds per device, why it
has no switch (no answer of Metal's changes), and the RTX 5080 measurement of
tests::clip_bursts (poolwait-burst, NVIDIA 615.71.09, two runs each): clips 2
and 3 took 41 and 40 allocations and 89 to 102 ms with 2 to 5 commits held
1 ms or more (longest 8.8 to 9.4 ms) before, none and 64 to 71 ms with no
commit held (longest 0.39 to 0.67 ms) after; a first clip 44 allocations
before, 16 after.

Not yet built: the sweep builds and runs next on lavapipe.

(cherry picked from commit b31e221ee4cfba1861320e8c674a01ea83614013)
2026-11-08 11:49:37 -08:00
Anees Iqbal 48cfac5cb3 HostRam lists kept: the docs say the lists outlive their copies, with same-host numbers
HOWTO, the runtime README and FAST-PATHS still said a copy's lists were
freed with its command buffer and that every copy pays its lists'
imports. They now say each list is kept past its copy for the copies of
the same pages after it (at most 64 MiB and 16 lists, released once no
copy took one for 2 s), and they give the numbers.

The numbers come from tests/host_ram_listed_bench.rs on the Radeon 780M
of one host (um790, RADV, kernel 7.3.1). The kept tip was run with a
timing probe that never lands, then again with the bound sabotaged to
(0, 0), which keeps nothing, back to back. Medians are commit to
completion, then encode:
- A 5 MiB device cache filled again: 0.37 to 0.43 ms and 0.2 to 0.4 ms,
  against 3.0 to 3.2 ms and 0.7 to 1.0 ms with no list kept. Over an
  imported chunk it takes 0.37 to 0.40 ms and 0.12 to 0.14 ms.
- A surface-shaped tile's download after its fill: 0.53 to 0.60 ms,
  against 4.0 to 4.2 ms.
- A scattered tile's download: 0.46 to 0.50 ms, against 0.98 to 1.04 ms.
- A copy that imports pays the lookup through the kept lists: 48 to
  63 us for a surface tile, 250 to 290 us for 1,800 scattered runs
  against 16 lists.
- The scroll's 24 visible tiles pass the 64 MiB bound (about nine
  tiles), so a third to a half of their repeated fills took a kept list.
- Residency is the same with and without kept lists: 4028 of 8192 MiB,
  and 8300 of 16384 MiB.

(cherry picked from commit ee030ba7ed497aeb4bf0c92653cc33078e987379)
2026-11-08 09:42:35 -08:00
Anees Iqbal ecddb49936 FAST-PATHS: the NVIDIA pool block gap with its sizes, its frees and making ahead
The RTX 5080's measurement of its own (an exclusive window, 12 blocks a
size): vkAllocateMemory of a pool block's memory takes about 0.16 ms a
MiB, idle or beside another process's GPU work (medians 5.5, 11.0, 20.4
and 40.6 ms for 32, 64, 128 and 254.7 MiB), vkFreeMemory about 0.035 ms
a MiB, and every vkQueueSubmit another thread calls during either
returns once it does. Frames every 16.7 ms met a 254.7 MiB making 28.6
to 48.6 ms late on their own thread (23 of 23 over 1 ms), and up to 67.5
ms with the making on another thread, spread over the frame or right
after a submission (11 of 23 either way). So no block is made ahead on
a thread of the device's own: it would not keep frames from the hold.
A smaller block would shorten it in proportion, at the cost of each
command buffer's pool capacity, which is the orchestrator's call.

Verified: docs only; the numbers are entry
poolwait-poolwait-sizes-063031-063031 (7eb0aab5e5's allocation_holds).

(cherry picked from commit f3e209f7ea255d79ef6b524bd1dcd176e9792589)
2026-11-08 09:33:19 -08:00
Anees Iqbal bfcd71e5d6 Record the short last row's shadow among the known gaps
A texture over host pages whose buffer ends inside its last row's pitch is a shadow
(Refused(Placement)): a linear image's last row takes the whole pitch, so the image's memory
requirements reach past the buffer's bytes, over an import of the caller's pages and over a copied
host buffer's copy alike, whose placement is the buffer's length. Metal reads such a texture in
place, so it is a runtime cost above the driver's: docs/FAST-PATHS.md's known gaps now say so, and
InPlaceRefusal::Placement's doc names the case.

Seen on the Iris Xe (ANV) and the 780M and RX 550 (RADV) by a probe at the guest's shape, which
stays on a branch of its own.

Verified: cargo fmt; scripts/api-signatures --check (signatures unchanged; a doc change).
(cherry picked from commit 9493894b26cee3b1a525d9a0916a83f3fc6a594f)
2026-11-08 09:08:35 -08:00
Anees Iqbal da896c5a1f Textures over a device-allocated copy: the caller's pages' verdicts, the pooled check only for the pitched image
On RADV (the RX 550, job 8832) every texture over a copied host buffer whose copy lies in memory
the device allocates stayed a shadow: the route asked the runtime's pooled class's verdicts, which
the check leaves unchecked there, though the image over such a copy is mostly the driver's own
linear image, which starts PREINITIALIZED and so keeps the copy's bytes at its first move. The
pooled class judges only the DRM_FORMAT_MOD_LINEAR image made UNDEFINED at Metal's pitch where the
driver lays its rows otherwise.

So the route asks the caller's pages' class (Pointer) for texels as they lie in the copy and as they
lie in the pages (a rebind may import them), and fresh pages' where the copy lies in them;
copy_unplaced refuses the pitched image for its pitch where the pooled check did not pass for its
accesses. The wider plans of a texture over a copy (the usages its descriptor lacks) take the
caller's pages' verdicts too, as the route does. Texels::over_caller_pages answers only over a
copied buffer.

The device test now asserts an image over the copy where both checks passed and none where the
pages' did not.

Verified: cargo fmt; builds and tests run as potluck jobs after this commit.
(cherry picked from commit 7911bb167b88661f3d4b8b6a4431145ff22a143c)
2026-11-08 08:51:02 -08:00
Anees Iqbal 1cf4730839 Textures over a copied host buffer: an image over the copy where the check passed, not a shadow
Every texture made over a copied host buffer (a no-copy buffer whose import the caller's gate
refused, or that failed) was a shadow, refused as `Refused(Placement)` ("a copy of the caller's
pages in memory of the device's own"), whatever its usage: each command buffer copied the copy's
texels into the shadow's image, and merged writes back, on top of the copy's own copy-in and merge.
A consumer whose views of guest memory pass the host's mapping budget gets copies of its large
window surfaces (reims's Iris census: 112 gate copies, 1.9 GB), and every texture over them is
such a double copy: the boots' 491 refused-placement shadows.

The GPU uses the copy in the pages' stead, so a texture's image can lie there, as a rebind onto a
copy already makes one (`in_place_over_copy`):

- route.rs: a copied buffer's class is its copy's memory's (Fresh in fresh pages the runtime
  imported, else Pooled); the in-place decision asks that class's verdicts and the caller's pages'
  (Pointer: a rebind may import them), each for texels that lie in lines as they lie there
  (`Texels::line_start` reads the copy's offset in its memory; `over_caller_pages` the pages').
- in_place_image.rs: `unplaced` over a copy makes the image in the copy's memory: in fresh pages
  the host-allocation one, as over the pages; in memory the device allocates `own_unbound`, the
  driver's linear image (PREINITIALIZED) where it lays the rows at the pitch, else the
  DRM_FORMAT_MOD_LINEAR one of no external memory (`unbound_in` serves both, and
  `in_place_unbound`). The image is watched for rebinds and its first move holds the pages, for any
  no-copy buffer's pages (the class no longer decides it). A rebind onto a device-allocated copy
  takes the DRM_FORMAT_MOD_LINEAR image too where the pooled class passed for its accesses
  (`class_takes`, from `fresh_pages_take`).
- The image's identity is the buffer's, so its uses name the copy: commits copy the CPU's writes
  in, completions merge the GPU's back, as for the buffer.
- Counted: `WorkCounts::copied_textures_in_place` (also in `host_textures_in_place`); a shadow's
  notice names the copy.

Tests (copied_device.rs): a sampled and a rendered texture over a gate-refused copy take an image
over the copy exactly where the verdicts of the copy's memory and the pages pass (before this,
every one was a shadow, so on a device whose check passes the test fails), read the caller's
texels and a CPU write before a commit, and their blit and clear reach the texels' bytes in the
pages alone; such a texture follows rebinds to another copy and back to an import.

Docs: copied.rs, in_place.rs, in_place_image.rs, route.rs, HOWTO (copied host buffers),
FAST-PATHS (the in-place row), TexturePlacement::InPlace; api_signatures blessed.

(cherry picked from commit e6573e3f1b942d11bda3063f5477745018cf9239)
2026-11-08 08:51:02 -08:00
Anees Iqbal 15c72b1690 GPU pools: a block a queue lets go is the device's spare for the next queue
A queue's pool block that went (its queue went, or no lease held it for
QUIET) was released, and the next queue to need a block of that kind
made one again: on the RTX 5080 a 254.7 MiB vkAllocateMemory of 4.9 to
189.5 ms beside other GPU work, during which the driver holds every
vkQueueSubmit of the process (docs/FAST-PATHS.md, known gaps).

Now the block becomes the device's spare of its kind where the device
holds none (else it is released, as before), a made-meanwhile block too,
and a queue holding no block takes the spare at its first lease before
it makes one. A device so makes no more blocks of a kind than the most
queues that held one at once, and none as queues come and go or rest.
The cost is one block of each kind beyond the queues' own until a queue
takes it or the device goes: 254.7 MiB of device memory on the RTX 5080
Laptop GPU, 1 GiB of host memory kept wired on the M3 Max. The spare is
safe to hand on: no lease holds a block that goes, so no command uses
it, and nothing reads a pool's bytes before its own command buffer wrote
them.

QueueBlocks::drain pops the slots instead of taking the map.

Tests: the pool CPU tests cover the spare from both releases, the
made-meanwhile block, the teardown and queue churn (eight queues one
after another make one block); the device tests see a later queue and a
rested one take the spare without a making, and the handler test makes
each round's block after a holder queue took the spare.

Verified: cargo fmt only, here; the runtime and validation suites, clippy
and the device runs follow as potluck jobs.

(cherry picked from commit dcc2bc0cb49f391b7d14c135d7aae97f1a93795b)
2026-11-08 08:48:27 -08:00
Anees Iqbal 9024d9ee5f index_pools: count a completed handler's lag from its submission's return too
runtime_lane::index_pools::a_completed_handler_waits_for_no_pool_block_made_meanwhile
failed on the RTX 5080 (round 5ce05e1908, lane ln07): the handler ran 37.2 ms
after its command buffer completed, during a 50.5 ms making of the other
queue's index pool block.

What it waited on is the driver, not the completion path. A probe on the
5080 (NVIDIA 615.71.09; 40 rounds of the lane's draw, with and without the
validation layer, completion trace, b5080 entry poolwait-probe1) found:
- the making is nearly all vkAllocateMemory of the 254.7 MiB block, 3.1 to
  35.7 ms beside another process's GPU work;
- in 25 rounds the scheduler thread's vkQueueSubmit of the first command
  buffer was called during that allocation and returned 0.01 to 0.25 ms after
  it, twice after the GPU had ended the batch (23.9 ms into a 29.4 ms making;
  0.3 ms into a 3.7 ms one: the failure's shape). The runtime watches a batch
  from its submission's return on, so it completed as the making ended;
- in the other 15 the submission returned before the allocation began, and
  the handler ran during the allocation in all 15;
- in all 40, the handler ran 0.07 to 1.44 ms after the later of the GPU end
  and the submission's return;
- raw, another thread's vkWaitSemaphores (no wait), vkGetSemaphoreCounterValue
  and vkGetFenceStatus took at most 0.03 ms during allocations of that size
  (1.9 to 213.6 ms): host waits are not held, submissions are.

So the claim is now exact: the lag counts from the later of the GPU end and
the kernel end time (the last vkQueueSubmit's return), and a round tells only
where both fall in the making's first half. One round told about one time in
four on the 5080, so the test runs 12, each with a queue of its own, and
prints each. The driver's hold of the submission is a known gap
(docs/FAST-PATHS.md), and gpu_pools.rs says what a making costs there.

(cherry picked from commit 438b4ec928dc1d44d2003a20537fea77a768d731)
2026-11-08 08:23:36 -08:00
Anees Iqbal 384ce01a32 HostRam lists: HOWTO, runtime README and FAST-PATHS with the 780M's numbers
HOWTO section 6 gains HostRam::with_dma_buf_of_runs: what the source answers,
where copies take lists, what they differ from (a chunk's import pins every
page of it, for good, and later copies import nothing; lists pin the copy's
pages while it runs, and every copy pays its imports), and the Radeon 780M's
numbers from tests/host_ram_listed_bench.rs at 4f30c38a77 (before the rebase
onto development; the list path is unchanged by it): 4028 MiB of an 8 GiB
guest's file held where whole chunks would make 8192 MiB resident, 8300 of
16384 for 16 GiB; a surface-shaped tile 4.1 to 4.5 ms from the commit to the
completion, a scattered one 0.9 to 1.25 ms, against 0.39 to 0.48 ms over an
imported chunk. The copy paragraph says where lists replace the staged and
alone paths. The runtime README names the call; FAST-PATHS's row on idle
dma-buf imports gains the trade (memory for per-copy time, the consumer's
choice, no accuracy).

(cherry picked from commit c6f08a396cc2e4713dedfae06ad0648019e9e22d)
2026-11-08 08:18:42 -08:00
Anees Iqbal 5640e17560 Document the model's linear sample of planes read in place
FAST-PATHS.md gets the ledger row for ycbcr_in_place_reads (Model default,
Exact switch, the 780M's exact-form cost measured at development's tip),
the device-gaps row and the in-place section name the choice; API.md's
policy list and the half/float filter and ycbcr-filter-not-exact catalogue
entries name the model; PrecisionNote::HalfSampleFilter/FloatSampleFilter
and Degradation::YCbCrFilterNotExact docs say the model records and
announces them.

(cherry picked from commit 5f83699d296386c3b0b357f2baa63cfefc086096)
2026-11-08 06:29:47 -08:00
Anees Iqbal 016c09572a Pooled moves: docs and API signatures
TexturePlacement::Pending: over the device's own memory, a texture made while the pooled check
is pending now moves to its image at Metal's pitch the same way (it no longer stays a shadow for
good). Texture::vk_image, docs/FAST-PATHS.md (row 41), docs/API.md (the shadow reasons over the
device's own memory) and docs/HOWTO.md (the padding-unobserved paragraph) say so, naming
WorkCounts::pooled_textures_moved_in_place and pooled_texture_shadows_freed_after_move.

API signatures: the two new WorkCounts fields (scripts/api-signatures/signatures.py --bless, two
lines added).

(cherry picked from commit 4c1beda492dcc4af16923df09724b7fbf0e7387a)
2026-11-08 05:22:32 -08:00
Anees Iqbal 7e5821d9d1 In place: renders over padding a buffer declares unobserved take a verdict that lets that padding change (Access::UnobservedRenders)
What: a new check access, UnobservedRenders, that the renders rounds answer beside Renders, as the
storage-write rounds answer BufferWrites beside Writes. Where a shape's rows' padding is free
(Shape::padding), a renders round that changed no byte but of that padding (after a row's last
texel, before its pitch, the last row's included) fails Renders for its row ends and keeps
UnobservedRenders. A byte past the last row's pitch, or a texel, fails both. A new Padding variant,
Unobserved (Free padding over a buffer that declares padding_unobserved, Texels::padding), makes
in_place() ask UnobservedRenders in the stead of Renders (Access::rendered); the wider render-target
plan of an image in place asks the same. The check's SHAPES gain 172x67 BGRA8 at a 704-byte pitch,
whose last row's pitch ends 64 bytes past a multiple of 128 and 256, so a device that writes back
more than a line around a row's last texels changes a byte past the image and fails both.
VERDICTS 48 -> 56 (7 accesses), the record 56 bytes; CHECK_VERSION stays 11 (unlanded).

Why: on the Iris Xe (job 7965 at c4eeeba7e8), the pooled class's Renders verdict failed for rows
ending mid-line (the clear and store, and draws, write back the 64-byte line holding a row's last
texels whole), so none of the 93 device caches went in place (93 shadows, frame 4145 us declared
and undeclared alike), and the item's case (a padding-unobserved texture at a 64-aligned pitch, rows
ending mid-line, rendered) stayed a shadow (CheckFailed{Renders, InLines}). The declaration already
lets a render pass's load and store write those bytes; no byte past the last row's pitch may change,
and Padding::of guarantees the last row's pitch ends on a line.

Also: a padding-unobserved buffer in fresh pages takes the same rule; BufferDescriptor's doc says so.

Tests: unit cases for the compare (the line write-back of each row's padding is Padded; a 128-byte
write-back past the last row's pitch, a byte past it or a texel is Changed), Padding::declared, the
tally (Renders answers two), the decision test over Unobserved padding, the shadow-cause words; the
device test asks the UnobservedRenders verdict and asserts the texels' padding is Unobserved. Device
evidence follows on the Iris.

(cherry picked from commit 990d744ec71269663e292c7f2f3e4148d166bacb)
2026-11-08 03:29:51 -08:00
Anees Iqbal 703eca0dba Pooled class: tests and docs
The padding-unobserved device test settles the check and holds the answer to the making's
(NotHostPages exactly where the texture aliases, else the shadow's cause); a new device test
renders textures of the guests' cache shapes (64-aligned pitches, rows ending inside a 64-byte
line) over declared buffers and checks that a pitched image appears only where the pooled
class passed for reads and renders, that the CPU's texels read back through the texture, that a
clear reaches the buffer's rows, and that the bytes after the last row keep the CPU's. The
validation lane reads 48 verdicts. Docs: in_place.rs and in_place_check.rs module docs,
FAST-PATHS row 41, API.md (placement answers, the shadow reasons), HOWTO's padding-unobserved
paragraph, the runtime README, BufferDescriptor::padding_unobserved, TexturePlacement's
NotHostPages and Pending (a pooled texture made before its verdicts stays a shadow).

Verified: cargo fmt only; builds and the device runs follow.
(cherry picked from commit ae31d0fd3841b136c692897cbdf425633e9344c3)
2026-11-08 03:29:51 -08:00
Anees Iqbal 20360b6038 In-place check: the narrow rounds' large surface is 1024x64, not 1024x1024
The last of the narrow store shapes was a 1024x1024 R8Uint surface at a 1024-byte pitch. On the
M3 (release, job 7745's probe) its three rounds took 7.5-8.4 ms of each class's 14-16 ms of
narrow rounds, and the narrow rounds put the whole check 30 ms past the base's (0.33 s to
0.36 s; the base's spread is about 7 ms). A sixteenth of its rows keeps its 1024-byte rows, the
row width of the largest such guest texture, and the many workgroups of its dispatch, and cuts
its fill, word-per-texel source and compare by sixteen.

Verified: cargo fmt; the shape tests read NARROW_STORE_SHAPES and name no size. The check's
time is measured again on the M3 in the next jobs.

(cherry picked from commit 3927363fbd5883c78cf2835255ae145e2f1541f3)
2026-11-08 01:47:32 -08:00
Anees Iqbal b1e2f06e9e Docs: a written texture over host pages is a shadow by width only outside 1, 2, 4, 8 and 16 bytes
Two passages still said a shader's writes of 1- or 2-byte texels keep a texture over host pages a
shadow: the shadowed-texture entry of docs/API.md's degrade-notice catalogue and the host-pages
bullet of docs/FAST-PATHS.md's costs. The device's check now stores those widths too; a texture
is a shadow by its width only for a width outside the ones it stores.

Verified: docs only; grep finds no other passage that names 1- or 2-byte written texels as a
shadow's cause.

(cherry picked from commit 90bd51d7a55257a40e115c55da2a53c7bb0b4f80)
2026-11-08 01:47:32 -08:00
Anees Iqbal 6575c031f5 In place: 1- and 2-byte texels a shader writes, checked apart by the device's check
In every guest session reims measured (Iris Xe and Radeon 780M, macOS 26.7.2 guests),
host_texture_shadows_store_width was 114, from 23 distinct R8Unorm, A8Unorm and R16 textures a
shader writes (32x32 at 256-byte rows among them). They were shadows because the in-place
check's write kernel stored only 4-, 8- and 16-byte texels (STORED_TEXEL_BYTES,
ShadowCause::StoreWidth), so no check covered a driver's writes of narrower ones.

What changes:
- in_place.rs (from selfread's parked 0c587bcad5): Access gains NarrowWrites and
  NarrowBufferWrites, with 36 verdicts instead of 24. Access::written picks the writes check of
  a texel width and padding. STORED_TEXEL_BYTES holds 1, 2, 4, 8 and 16; NARROW_TEXEL_BYTES
  holds 1 and 2. in_place asks the written check in place of Writes. The report names
  "narrow writes" and "narrow buffer writes". CHECK_VERSION goes to 9 (development's dma-buf
  import fix took 8).
- in_place_check.rs: NARROW_STORE_SHAPES, rounds of their own for the narrow accesses, through
  the copy-in kernel's R8_UINT and R16_UINT views (a801dac7d7). The shapes are packed R8 256x16
  and R16 128x16 at 256; R8 61x37 and R16 45x29 at 256, whose rows end inside a word and whose
  heights are odd; the 16- and 64-byte tight pitches; and an R8 1024x1024. The source buffer
  holds a word per texel, the texel's bytes low and zeros above, since CopyIn takes 4*words()
  bytes a texel. A narrow round's change fails only the narrow verdicts, never a 4/8/16-byte
  texture's. A device whose kernel or image is not made (no shaderStorageImageExtendedFormats)
  leaves them unchecked.
- in_place::storable: one helper for a render target's storage usage, used by route.rs and
  storage_form.rs. It asks Access::written(texel, Padding::Kept) instead of Writes, so a narrow
  render target never takes the 4-byte verdict. writes_reach (the storage usage an image that
  does not render takes beyond its usage) and fresh_pages_take ask the written check of the
  texels' width; InPlaceWatch carries the width.
- InPlaceAccess::Writes covers the narrow accesses. Docs (in_place, the check, API.md, HOWTO,
  FAST-PATHS row, runtime README, WorkCounts, HostPageTexturePolicy, TextureShadowReason) say
  1, 2, 4, 8 and 16 bytes, with narrow writes checked apart. The lane's VERDICTS goes to 36.

Tests:
- The decision test runs every width, 3 bytes for StoreWidth among them, against narrow answers
  that differ from their wide twins'. It also checks storable.
- Shape tests cover the narrow set: tight pitches, row ends at 16/64/128/256, free padding.
- New: each_check_of_storage_writes_stores_its_texels_width. A narrow tally case.
- New device test narrow_writes_device: the guest's 32x32 R8Unorm and A8Unorm (and RG8Unorm and
  R16Unorm) at 256-byte rows over a no-copy buffer. Each takes its narrow verdict's path, its
  placement query agrees, a kernel's writes reach the bytes, and the padding and the bytes past
  the last row are kept.
- in_place_storage adds an R8Unorm render target.

Verified: not yet built; the build, clippy, unit and device runs follow as jobs.
(cherry picked from commit dbb985df199b1c46bb783aafbd50efd40bcab187)
2026-11-08 01:47:31 -08:00
Anees Iqbal c73e4b36a8 Document learned coverage's measured costs and the spare pools' effect
FAST-PATHS' attachment-read paragraph and render/snapshot.rs now state what learned coverage
does where the device measures readers, and the measured results against the build before the
area rule (pre) and the spare-pool scratch (q4):

- Iris Xe (job 7575, pre from 7439): crossover rows at most 1.03 times pre, except 320x180
  readers covering 1.5% or 12.5% (both builds snapshot) at 1.05-1.07, the query's own cost;
  readers that learned a dense coverage now split (area lane 0.99-1.01 of the split).
- RX 7900 XTX (7578, pre from 7481): 0.68-1.05 of pre after the control's drift between runs;
  per-round spread up to 1.4x.
- Radeon 780M (um870, 7628): dense readers 1.00 of pre; readers over 12.5% of a scissor their
  pass filled whole 1.15-1.26 of pre, as the area-rule control takes too.

The spare-pool doc states the Iris measurement: from pools made a pass, the measured readers
took 1.07-1.19 times the same forms unmeasured, and from spare pools 1.00-1.06.

(cherry picked from commit 1978c9008cf2ee9a7d90033e940a93ba24680fbe)
2026-11-08 01:41:31 -08:00
Anees Iqbal 3f8b07c044 In-place check: a kernel's writes of a texture over a buffer may change its rows' padding
What: a second verdict for a kernel's writes, Access::BufferWrites, taken by a texture over a
buffer's rows (no IOSurface plane's) whose buffer holds its last row to its pitch and whose rows,
each to its pitch, start and end on a line of the device's memory (in_place::Padding::Free). The
same Writes rounds give it: the writer and the compare tell a change of a byte of the shape's
rows' padding (after a row's last texel, before its pitch, the last row's included) apart from
any other change. A round that changed only such bytes (Round::Padded) fails Writes for its row
ends, as before, and counts as kept for BufferWrites, and the rounds go on through every shape;
any other change (a texel, a byte past the last row's pitch) fails both and ends the class's
rounds. in_place() asks BufferWrites in the stead of Writes for such a texture; renders, an
IOSurface plane's rows and a render target's storage usage (storable) keep the strict verdict.
The rebind's choice of fresh pages carries whether the padding is the buffer's own. 24 verdicts,
CHECK_VERSION 7; the report adds `{class} buffer writes` lines.

Why: real Macs disagree on those bytes, so Metal leaves them to the GPU. The probe
(row_padding_writes.m) found an Intel UHD Graphics 630 under macOS 26.7.1 writing older values
back over the CPU's writes to the padding of textures over a buffer under a kernel's writes
(10,197 and 28,162 bytes in 100 rounds of 3662x64 and 61x64 BGRA8, 304 and 307 in the last row;
m3-max-7240, m3-max-7269), keeping them over IOSurfaces and under clears, stores and draws; an M3
Max under 27.0.1 (arm64 and x86_64, m3-max-7241) and a Radeon Pro 5300M (static check, 7269) kept
every byte. The owner's ruling: follow the x86 Macs' envelope and remove the shadow copy where
possible. On the Iris Xe, whose writes write back the 64-byte line holding a row's last texels,
written textures over a buffer whose rows end inside a line now take the image in place.

Docs: in_place.rs and in_place_check.rs module docs, docs/API.md (the in-place paragraph, the
shadowed-texture notice, section 10 Kernels with the three probe results), FAST-PATHS row 41, the
runtime README. Lanes: in_place_textures' VERDICTS 24 and its written-texture checks ask the
buffer writes verdict where the padding is free (in_place_rows::padding_free/writes), the
padding bytes of a texture in place with free padding no longer held to the pattern.

Tests: tests::in_place's decision test over both paddings; Padding::of cases (the guest's
3662x2039 surface at a 14656-byte pitch is free, 416x51 at 64-byte lines kept, slices apart);
Bytes::compare telling a change of each row's padding (the last row's last byte included) apart
from one past the last row's pitch or of a texel, and from padding that is not free; Tally's
verdicts for the Iris's walk and the others.

Verified: pending.
(cherry picked from commit 200f2a9e2b26eeaff45c1cc5ec71decf42d8437e)
2026-11-07 23:57:05 -08:00
Anees Iqbal 46013629ca Give the area rule's measured costs on the Iris Xe and with the split weighed by its copy
The rule's doc (render/snapshot.rs) and FAST-PATHS's attachment-read paragraph now give what the
lanes measured at 2fb3261df0 (copies b9db87767a on ms01, 226fb24902 on gem10):

- snapshot_area_costs, no scissor (the rule against the split on a device withholding
  fragmentShaderPixelInterlock): a reader over 1.5% of the target 0.09-0.33x on the Iris Xe
  (m3-max-7079), 0.09-0.23x on the Radeon 780M (7077), 0.25-0.43x on the RX 7900 XTX (7076); over
  the whole target 1.03-1.20x, 1.95-2.30x and 1.30-2.10x.
- snapshot_crossover over a private 1920x1080 target, against the build before the rule
  (5a216c19b0; 0950c1a0ab on the Iris): 320x180 and 960x540 split, 1280x720 and the whole target
  take the snapshot. Through those, a reader covering 1.5% of its scissor 0.36-0.64x on the Iris
  (7079) and 0.28-0.97x on the 780M (7077, 7202), one covering the whole scissor 1.12-1.18x and
  1.97-2.34x. On the XTX 0.69-1.09x and 1.5-2.6x (7076, 7201): its times for one binary varied up
  to 1.75x between runs (7292: two copies of the same control binary, 180-317 us a pass on the
  same row, and self_reads 0.285-0.542 ms a frame).

Doc only.

(cherry picked from commit 2548a362de7c38b4354bb8106c0e6218c3975103)
2026-11-07 23:05:20 -08:00
Anees Iqbal 37875af7f3 Weigh a self-read's split by the texels its copy moves
The area rule (render/snapshot.rs) weighed the split as a copy of every texel of the color's
level. The split's copy for a draw that reads at its own pixels is cut: for a one-level,
one-slice color it moves only the texels inside the rectangle bounding the draw's scissors, a
pixel wider each way (render.rs's bound_own_pixel_reads, ShadowCopies::cuts). So the rule
overstated the split for readers through scissors smaller than the target, and since 61a367cb51
those took the snapshot where the split was the cheaper worst case: on the snapshot_crossover
lane's 1920x1080 private target, readers through 960x540 and 1280x720 scissors covering them
whole took up to 1.93x and 1.97x their split time on the Radeon 780M, and 1.32x and 1.41x on the
RX 7900 XTX (jobs 6872, 6871 against their own before runs).

The rule now weighs the split by what its copy moves, computed by the same two functions the copy
bound uses, now shared (scissors_bound, own_pixel_loads): a one-level, one-slice color's texels
around the scissors, else every texel of the level, as before. A reader through no scissor, the
consumer's self-reads, weighs as before and keeps the snapshot. By the rule a 4-byte color's
reader takes the snapshot through scissors whose rectangle holds about 786,432 pixels (1024x768)
or more and splits through smaller ones: on the crossover's target, 320x180 and 960x540 split,
1280x720 and the whole target snapshot.

Tests that relied on a small reader taking the snapshot now draw through scissors large enough:
- runtime_lane::snapshot_reads: a 1024x1024 target, the readers through the whole target's
  scissor (snapshot where the device takes the path); through QUARTER an RGBA8Unorm reader splits
  and an RGBA16Float one takes the snapshot; R8Unorm and RG8Unorm readers split; the
  feature-withheld and depth/stencil readers through the whole target, so their split is the
  feature's or the attachment's, not the rule's.
- tests::self_read_storage: a 1024x1024 target, the reader through no scissor.
- tests::snapshot_area: 8x8 scissors (copy of 10x10 texels): 4-byte split, 8-byte snapshot;
  960x540 split and 1280x720 snapshot over 1920x1080.
- attachment_read_costs: the composite workload's window readers split again; its docs say so.

docs/FAST-PATHS.md's attachment-read paragraph and the module docs carry the landed
snapshot_area_costs lane's numbers (rule against the split with fragmentShaderPixelInterlock
withheld): reader over 1.5% / the whole target, Radeon 780M 0.08-0.23x / 1.8-2.3x (job 6872),
RX 7900 XTX 0.25-0.43x / 1.3-2.1x (6871).

(cherry picked from commit ed15457d04c98f767511374ff4d368a0373a4361)
2026-11-07 23:05:20 -08:00
Anees Iqbal 902002273d Narrow RADV's first-write-after-suspend gap to moved and dedicated memory
Measured on the RX 7900 XTX (gem10, Mesa 26.2.6) with tests::zeroed_start's busy
test, five processes each started with the GPU in runtime suspend (job
m3-max-7290). The first replace_region into a texture made behind about 1.5 s of
fills took 55 to 114 us with the blocks host copies place in made ready ahead,
each run readying 1 block and making 0 in place. With that readying off
(negative control: 5ee5d0e582's keep_room change) it took 553 to 654 ms, and the
test failed on its readied-block assertion. Awake it took 58 to 63 us, against
68 to 96 us without.

What stays open, from the in-process probe on the same card: a texture placed
before a mid-process suspend waited 86 ms for the kernel's moves back, and a
texture of its own block (4096 x 4096) waited 73 ms.

(cherry picked from commit 065f04d7f3016469a01d9148aba4dc9e991dfd79)
2026-11-07 23:03:55 -08:00
Anees Iqbal 532fc35b7a In-place verdicts by row ends: texels that share a line of the device's memory with bytes beside them, and texels that share none
On the Iris Xe (ANV) a pass that clears and stores a linear image, and a draw into it, write back
whole the 64-byte line that holds a row's last texels. That puts an older value back over a CPU
write beside the texels, so the check fails render targets over host pages there, and every such
texture is a shadow. The write-back cannot reach a CPU write when no line holds both a texel and
a byte beside the texels: the probe read 0/100 for rows that end on a line, and 0/25 for a
3840x2160 surface of tight rows. A 3840x2160 BGRA8Unorm surface's 15360-byte rows are 240 lines
each.

The check's verdicts are now kept per class, access and row ends (in_place::RowEnds):
- The line is the device's nonCoherentAtomSize. vkspec defines it as "the size and alignment in
  bytes that bounds concurrent access to host-mapped device memory".
- RowEnds::of reads the texels' address, offset and pitches. Texels are OnLines where their first
  byte and their end lie on a line, and so do each row's (or slice's) start and end where bytes
  lie between rows (or slices). Elsewhere they are InLines.
- The check runs the shapes whose texels share no line first (Shape::rows; seven of SHAPES at
  64-byte lines). A byte changed beside one of them fails both row ends. A byte changed beside a
  shape that shares a line fails InLines alone, since the OnLines rounds have already run (the
  verdicts function). A device that fails InLines now also runs its OnLines shapes.
- SHAPES gains two shapes whose rows end inside a 16-byte line, at the 16-byte pitch a driver
  that lays rows tight uses: BGRA8Unorm 101x51 at 416 bytes and RGBA16Float 33x17 at 272, the
  same shapes STORE_SHAPES already holds. MoltenVK makes no linear image with bytes between rows
  except at that pitch, and its line is 16 bytes. Without these two, none of its shapes whose
  texels share a line was made, so its reads and renders were Unchecked for those texels: on
  the M3, a probe of this change without them gave Pointer and Fresh reads and renders Unchecked
  5/5 for InLines (m3-max-6750).
- SHAPES and STORE_SHAPES gain the same widths at the 64-byte pitch of a driver that lays rows
  at the next multiple of 64: BGRA8Unorm 101x51 at 448 and RGBA16Float 33x17 at 320, and
  RGBA8Uint 101x51 at 448 and RG32Uint 33x17 at 320. On lavapipe (llvmpipe's linear images take
  64-byte rows, its line 64 bytes) no shape whose texels share a line was made without them:
  tests::in_place_check::the_in_place_check_checks_fresh_pages_where_held_imports_cost_submissions
  read the Fresh verdicts Unchecked for all three accesses of those texels (m3-max-6991). The
  shape test now holds that drivers whose rows lie at the next multiple of 16, 64, 128 or 256
  bytes each have such a shape, for each access.
- The record holds 18 verdicts. CHECK_VERSION goes to 6, so a record of the old check is not read.
- The report keeps its nine lines, now the InLines verdicts (the old verdict exactly, since an
  OnLines failure fails both), and adds nine ", rows on lines" lines after them.
- The texture's own row ends decide, everywhere a texture asks for its verdict: its making
  (Texels::rows), a shadow's move in place (MoveWait, move_wanted) and a copied rebind into fresh
  pages (fresh_pages_take_images, from the watch's place in its pages). ShadowCause::CheckPending,
  CheckFailed and Unchecked name the row ends, and the notice says them.
- Device::in_place_check_line (doc-hidden) answers the line. The lanes that hold a texture to its
  verdict compute its row ends themselves (runtime_lane::in_place_rows, apart from the runtime's
  reckoning) and read that row ends' line.

Docs: FAST-PATHS row 41 and the API guide describe the row ends. The ShadowedTexture notice
docs name them. The known gap for rows that end on a line is closed and deleted.

Tests: RowEnds::of covers an offset, an address, a pitch and slices off a line, tight rows that
do or do not end on a line, a 1-byte line, the 3840 and 3662-wide surfaces, and the check's
shapes per class. The verdicts function: a change beside OnLines texels fails both row ends, a
change beside InLines texels fails InLines alone, and a forced failure and an unchecked class are
covered. The decision test runs every class with both row ends. The record test covers 18
verdicts.

Verified, the whole check on fresh caches (the probe test, this change plus the test alone;
the Iris Xe and RADV runs at 5beb0be2a5, before the 64-byte shapes, on development 0950c1a0ab):
- Iris Xe (RPL-P), ANV, Mesa 26.2.6, 64-byte line (m3-max-6892), 20 runs, every run the same:
  reads Passed for both row ends, Pointer and Fresh; renders and writes Failed for texels that
  share a line and Passed for texels that share none, Pointer and Fresh; DmaBuf Unchecked for
  all six. The failures are a byte between two rows: a clear and store or a draw of R8Unorm
  61x37 at 256 bytes a row (renders), and storage writes of RGBA8Uint 101x51 at 512 (writes).
  323-383 ms a check (median 345), against 156-342 ms before (m3-max-6226): a class that fails
  for texels that share a line now runs its rounds for texels that share none to the end, as a
  passing device's do. A build job ran on the same host meanwhile.
- M3 Max, MoltenVK 1.4.2, 16-byte line: Pointer and Fresh Passed 5/5 for reads, renders and
  writes, for both row ends (12); DmaBuf Unchecked for all six (no dma-bufs on macOS). 290-304
  ms a check at 5beb0be2a5 (m3-max-6804); with the 64-byte shapes, at 19a7c36f69 on
  development ee5d3cfab9 (m3-max-7142), the same verdicts and 306-311 ms, the first run 548 ms.
  Before this change, 299-582 ms (m3-max-6160). That earlier run had six verdicts Passed and
  the three DmaBuf ones Unchecked, not all nine Passed as 31b19fa7f0's body says. No M3 cost
  record's case changes path: every verdict the M3 passed before passes for both row ends.
- RX 7900 XTX, RADV, Mesa 26.2.6, 64-byte line (m3-max-6817): all 18 Passed 5/5. 535-561 ms a
  check, against 626-642 ms before (m3-max-6523).

Verified, self_reads on the Iris Xe (m3-max-6892, release, each process on a cache of its own),
the previous commit's lane alone (before) against this change (after), two rounds each, GPU
ms per frame (median) of the baseline and of 30 self-read pairs:
- 3840x2160 surface over host pages, InPlace policy: before a shadow, 3 shadow copies a frame,
  8294400 texels copied in, 1 keep and 1 merge; baseline 3.487 and 3.526, self-reads 4.994 and
  5.014. After in place: no shadow copy, no texel copied in, no keep or merge; baseline 1.676
  and 1.674, self-reads 4.544 and 4.559 (30 snapshots a frame, as before).
- 3662x2039 surface, InPlace policy: a shadow before and after (its rows end inside a line);
  self-reads 4.141 and 4.187 before, 4.168 and 4.205 after.
- Private targets, unchanged: 3662x2039 self-reads 11.48 to 12.12, 3840x2160 14.68 to 15.04
  (30 splits a frame, before and after, on development 0950c1a0ab). Under 61a367cb51's area
  rule, landed since, these readers are expected to take snapshots instead (not run here).
- The check, as the lane's device ran it: 202.6 and 193.8 ms before, 411.5 and 369.7 after.
The lanes that hold a texture to its verdict passed on the Iris Xe under validation
(in_place_textures 7, linear_attachments 25, snapshot_reads 7, linear_alignments 3,
first_use_writes 1, device_copies 5; m3-max-6892).

Checked at b0043502d1 (this change before the 64-byte shapes, on development ee5d3cfab9;
homelab-gem10-1, m3-max-6991): clippy with --cfg m2v_cpu_icd and with --cfg m2v_gpu, all
targets and features, clean; rustdoc with -D warnings clean; the API tables, the ledger test,
check_draw and tests::in_place (44) passed; on lavapipe 306 of the 307 touched tests passed, and
the one that failed is the fresh-pages test the 64-byte shapes fix (above). That test and the
runtime's in-place tests on lavapipe at this commit: m3-max-7152 (homelab-um870-1). The RADV
probe at this commit plus the probe test: m3-max-7153, then its run on the RX 7900 XTX.

(cherry picked from commit f815203f074e1b2f922cd2a2d337ba31ea51e02f)
2026-11-07 22:13:59 -08:00
Anees Iqbal b6c025c12b Free a moved shadow's image once the command buffer that took the move completed
A texture over host pages made before its in-place verdict is a shadow, and moves in place at a
commit once its class's verdicts pass (`texture/storage_form.rs`). The shadow's image then stayed
with the texture until it went, so a long-lived surface kept an unused texel-sized image and its
merges' scratch buffers for the session.

The switch's last part now writes the shadow's image (a tracked transfer write of every level and
layer), so hazard tracking orders the committing command buffer after every use of the shadow
committed before it, on any queue, and that command buffer holds a ShadowAfterMove. Once it
completed, where the texture moved in and only the texture's storage and this hold the shadow's
image, the image's VkImage, views and memory go (`Image::let_go_unused`, the release a drop runs,
at most once), and its merges' kept scratch buffers. Nothing names the shadow by then: every later
command presents the image in place. A view of the texture made before the move, a shadow made
over the shadow's image (which holds it as its truth, `shadow::ImageTruth`), and an untracked
texture keep it until those and the texture go. The in-place counts are unchanged.

New WorkCounts field: host_texture_shadows_freed_after_move. FAST-PATHS (the in-place row) and
HOWTO say when the shadow goes.

Verified:
- runtime_lane::in_place_textures::a_texture_made_before_its_verdict_moves_in_place_once_it_passes
  now requires as many shadows freed as moved (polled up to its wait): "moved 1, in place 1,
  shadows freed 1" on lavapipe (gem10 m3-max-7070, at this base; msi m3-max-7019 at fa17b6ada4)
  and on the M3 Max (m3-max-7027 at fa17b6ada4; the patch is the same at this base).
- Touched runtime tests (in_place, storage_form, shadow, fetch, self_read, usage and view
  shadows, heap_set_copies): 73/73 on lavapipe (m3-max-7070); 71/71 on the M3 (m3-max-7027);
  the in-place lane 7/7 on both.
- Negative control a68e9f2e91 (ShadowAfterMove does nothing) on lavapipe (m3-max-6973): the lane
  test fails, "after the move: 0 shadow images freed, where 1 moved".
- clippy -D warnings for the runtime and validation crates, plain, --cfg m2v_cpu_icd and
  --cfg m2v_gpu (msi m3-max-7019); signatures blessed; refusal surface unchanged.

(cherry picked from commit ea33a4ce5c909723a5c425a7e1dd8ce0fc4a8d5f)
2026-11-07 21:41:11 -08:00
Anees Iqbal 61a367cb51 Weigh a self-read's two forms at the coverage least favourable to each
A draw that reads its pass's private texture at its own pixels after a barrier takes a snapshot
drawn in its subpass or splits the render pass instance; both are exact. The area rule weighed the
snapshot as if the draw covered its whole scissors (20 bytes of the split's copy a pixel) against
the split's copy alone, so a reader through no scissor over a large target always split. The
consumer's guest draws its self-reads that way: on the Iris Xe its 3662x2039 desktop's 30 readers a
frame took 10.9 to 17.4 ms of GPU time split (selfread's jobs 6068 and 5702), against about 1 ms
through snapshots.

What a draw covers is unknown when it records. Measured with both forms forced (a scratch build,
e3792c8f2e, never landed; 30 readers a frame over private BGRA8Unorm targets of 1280x720 to
3662x2039, no scissor):
- A split costs a fixed 5 to 18 us besides its copy, which is every texel here: the cut is the
  readers' and fills' scissors, the whole target (30 x W x H texels copied a frame, job 6674).
- A snapshot costs a fixed 9 to 16 us (two barriers and the second draw) and then grows with the
  pixels the draw covers.
- Snapshot over split, reader covering 1.5% / 100% of the target: Iris Xe 0.09-0.33 / 1.04-1.28
  (jobs 6656, 6674, ms01); Radeon 780M 0.11-0.24 / 2.4-2.8 (6758, um790); RX 7900 XTX
  0.25-0.43 / 1.3-2.1 (6822, gem10).

The rule now weighs each form at the coverage least favourable to it and takes the one whose cost
there is the smaller multiple of the other's: the snapshot where
READER_COST * (READER_COST + pixels * SNAPSHOT_PIXEL_COST) <= (READER_COST + bytes)^2, with the
fixed cost READER_COST a mebibyte of the copy (both forms' measured fixed costs on the iGPUs) and
SNAPSHOT_PIXEL_COST still 20 (measured about 14 on the Iris Xe, 20 on the 780M, 21 on the XTX).
Every reader the old rule gave the snapshot keeps it (the old rule is the case where the snapshot
over its whole scissors costs no more than the copy). New snapshots: a 4-byte color's readers
through scissors of up to two fifths of the target at any size (was a fifth), and at any area from
1024x768 (786,432 pixels; an 8-byte color's from 256x256). By the measurements above the rule
picks the snapshot in every no-scissor cell on all three GPUs, the form whose worst case is the
smaller multiple there; the cost is up to 1.28x (Iris Xe), 2.8x (780M) and 2.1x (XTX) for a reader
covering the whole target, against 3x to 11x saved for sparse ones. Small scissors covered whole
keep the snapshot they had, up to 2.1x on the Iris Xe (FAST-PATHS says so).

Both forms are exact, so this is a cost choice with no accuracy side: no ledger row, the
attachment-read paragraph of docs/FAST-PATHS.md restated.

- render/snapshot.rs: snapshot_within and READER_COST; the module docs' area rule.
- tests/snapshot_area.rs: the consumer's shape, the size thresholds (786,432 and 65,536 pixels
  exactly), two fifths at any size, and every old snapshot kept. Fails on the old rule.
- runtime_lane::snapshot_reads: an RGBA8Unorm reader through a quarter of the 32x32 target now
  takes the snapshot where the device takes the path (was a split).
- runtime_lane::attachment_read_costs::snapshot_area_costs: the measurement, the rule's form on
  the default device against the split with fragmentShaderPixelInterlock withheld. The composite
  workload's window readers now take the snapshot; its docs say so.

(cherry picked from commit 65d58b231d38ad2c2ac22f8e448be3a48491bf9a)
2026-11-07 20:50:32 -08:00
Anees Iqbal 31b19fa7f0 In-place check: the writer sweeps the bytes beside the texels until the step ends, and a draw round
On the Iris Xe the verdict for render targets over pages imported by their pointer flipped from
run to run. Devices without validation layers Failed 7 of 7 checks; devices under validation
Passed 3 of 3 (m3-max-6011, 6068).

A probe ran each step alone over the check's pattern, 100 rounds a step (m3-max-6080). One step
changed a byte beside the texels: a render pass that clears and stores the image. It did so in
77 of 100 rounds of a 100x50 BGRA8Unorm image with rows 512 bytes apart, and 51 of 100 of a
33x17 RGBA16Float image at that pitch. The changed bytes were the ones after a row's last texels
in their 64-byte line (columns 400-409 of a 400-byte row, 284-314 of a 264-byte row). Each read
back the pattern where the CPU had written its complement during the step: the device wrote the
line back as it had read it before the CPU's write. Nothing changed in 100 rounds each of the
first move, the feedback loop moves, a pass that loads and stores, or a pass that clears and does
not store. Rows that end on a line never changed (RGBA32Float 20x9 at 320 bytes, BGRA8Unorm 64x16
at 256), and neither did a 3840x2160 surface with tight rows (25 rounds).

The old writer wrote each byte once, as the step began, so it caught the write-back only where
one of its writes fell between the device's read of the line and its write. A step that begins
later, as under validation layers, finds every write already made. The writer now sweeps the
bytes beside the texels, in the stride's order, until the step ends. Each sweep writes the
pattern changed by a value of its own (mark), reading each byte first, which must still hold the
previous sweep's value. The compare then wants each byte's last sweep's value.

A draw round: after the clear-and-store pass, each render round draws zero through a scissor of
the image's last column in a pass that loads and stores the image. The draw is the crate's own:
bind::check_draw_modules provides the planes merge's triangle and a fragment stage that writes a
vec4 of zeros; the runtime's check_draw.rs keeps a render pass and pipeline per color format for
the class's rounds. A device whose draws write back the line that holds a row's last texels now
fails the check whatever its clears do, and the Iris Xe's draws do.

ROUNDS stays 3, sized from the measured rate (its doc comment): four shapes' rows end inside a
line, so there are twelve chances. CHECK_VERSION 5, so records of the old check are not read.
FAST-PATHS: the in-place row says what the render rounds run and how the writer writes. Known
gaps gains the finer class this leaves open: on the Iris, rows that end on a 64-byte line read
0/100 and could take the image in place there.

Verified on the Iris Xe (ANV, Mesa 26.2.6), m3-max-6226, at the probe branch's 39a5dd1ccd (this
code, with CHECK_VERSION 4, plus a probe test):
- Per step, 200 rounds each, the old writer against the new one:
  - clear and store: 96 and 14/200 against 169 and 192/200;
  - draw alone: 188 and 183/200 against 200 and 200/200;
  - the whole render round: 160 and 1/200 against 198 and 200/200;
  - load and store, and the first move: 0/200 each under both writers.
- The whole check on 20 fresh caches without validation: Pointer and Fresh renders Failed 20/20,
  writes Failed 20/20, reads Passed 20/20, 156-342 ms a check.
- runtime_lane::in_place_textures::a_failed_check_keeps_the_shadow_and_no_record 20 times, a
  fresh check under validation each: renders Failed 20/20, passed 20/20.
- Correct devices stay in place with the new writer and the draw round, the whole check on 5
  fresh caches each: M3 Max, MoltenVK 1.4.2 (m3-max-6160, at 733cb8a13b, this check before the
  rebase), all nine verdicts Passed 5/5; RX 7900 XTX, RADV, Mesa 26.2.6 (m3-max-6523, this commit
  plus the probe test, steelbrain/selfread-tipprobe c3b241244e), all nine Passed 5/5, 626-642 ms a
  check.

(cherry picked from commit 0cff30259ed6a7cba9bfcabb02643650204c1e79)
2026-11-07 19:55:50 -08:00
Anees Iqbal aeb74087b3 Zero-initialized images: pooled blocks of images, a zeroed start only over bytes no resource used
The draft gave each Shared or Managed texture that copies on the host a vkAllocateMemory of its
own (Fit::Zeroed), so allocations grew with the textures. The Vulkan specification ties
VK_IMAGE_LAYOUT_ZERO_INITIALIZED_EXT to the image's memory being zero, "either from being
explicitly set to zero by an application or from being allocated with
VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT", with no rule on binding offsets or dedicated
allocations, and any image may move out of UNDEFINED in place of its layout
(VUID-VkHostImageLayoutTransitionInfo-oldLayout-09229). So:

- memory.rs: on a device that enabled zeroInitializeDeviceMemory, every block of images is
  allocated with VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT (Memory::zero_image_blocks), pooled
  as before. Each pooled block keeps the end of the furthest range ever placed in it
  (PoolBlock::placed_to); a place past it in a zeroed block reads zero (Pool::place_fresh,
  Placement::fresh). Fit::Zeroed, make_zeroed and allocate_image_zeroed are gone.
- texture.rs: such a texture's image is made in ZERO_INITIALIZED and placed as any image; over
  fresh bytes it moves out of that layout on the host (counted images_started_zeroed), else it
  takes today's path: moved out of UNDEFINED and its zeros written on the host.
- The XTX probe (job 6317, release, tests::zeroed_start, 3 rounds after runtime suspend plus one
  awake): development's making waited for the queued fills (180, 521, 342 ms after suspend,
  1.09 s awake); the zeroed start took 0.26 to 0.32 ms. After suspend the texture's first CPU
  write waited instead (442 to 572 ms, until the fills ended), 71 us awake: recorded in
  FAST-PATHS' known gaps.
- tests: memory.rs a_place_reads_zero_only_past_every_range_placed_in_a_zeroed_block (CPU);
  zeroed_start.rs many_shared_textures_made_in_turn_take_pooled_blocks (1000 made, kept, let go,
  1000 again: times, blocks, no dedicated block, zero texels).
- Docs: host_copy.rs, README, API.md, WorkCounts::images_started_zeroed.

Not yet built.

(cherry picked from commit b0cf11a49e44b8530b84e664d231c928421ddf93)
2026-11-07 19:14:46 -08:00
Anees Iqbal ec9706e6e3 Survive the loss of the VkDevice: the device is a line of generations
Metal's MTLDevice survives a GPU recovery; the runtime's device refused every
call with DeviceLost from the first loss on, and the consumer ends its VM at
the first refusal. Now a device the runtime made is a line of generations
(device/line.rs), each a DeviceShared over its own VkDevice, and the first call
that needs the device after a loss makes a new VkDevice of the same physical
device, options, queue families and extensions.

- Two kinds of handle. The program's device (and its clones) is a root handle:
  it holds the line, pins no generation, and every public Device call goes to
  the generation that serves (each public method forwards to its *_now body).
  Objects hold generation handles, so their Vulkan calls, drops included, reach
  their own VkDevice alone. A generation handle's check is one relaxed load of
  the line's generation (Device::generation_serves).
- A draw pays nothing for it. A command buffer takes its generation once, as
  it is made (CommandBuffer::generation); its encoders' per-draw reaches (work
  counts, fresh-unwritten and alias records, sampler-slot changes, attachment
  read notices) read it there, not through a device handle's kind. A bind's
  device check is one compare of the cells the two handles hold, inlined, its
  refusal (Device::foreign) out of line.
- The state machine (Live, Lost, Failed): the claiming call recovers, every
  other call waits (a notice past 10 s, waiting on); threads command buffers'
  completion depends on never wait. Recovery: the lost generation's command
  buffers in flight fail through its completion path, its queues drain under
  their locks, create_on makes the next VkDevice, the queues are retired.
- Command-buffer answers, as a real loss is one more hang: the oldest
  incomplete batch's command buffer fails GpuHang (exact on one VkQueue; on two
  or more the queue whose oldest incomplete batch was submitted first, said so
  in the notice), counted against its queue so the second revokes it
  (AccessRevoked); the others GpuRecoveryVictim; one committed on the hang's
  queue before the recovery runs nothing and completes with no error; one made
  before and committed after fails GpuRecoveryVictim. One loss names one hang:
  a batch that went to the driver just before the loss and reached the lost
  device's completion after the loss took the pending batches fails with it,
  as a victim (its own wait need not fail: the test hook's VkDevice runs it),
  and no later failure of the lost device names a second hang.
- Command queues survive: a queue is a root handle and a cell of its place on
  one generation (VkQueue, slots, pools, hangs), which a recovery retires and
  the next command buffer re-makes; label and GPU-error count go on.
- Objects made before a recovery are refused where they meet the new VkDevice
  or need their lost one: RuntimeGap::MadeBeforeRecovery, at the 38 lost-device
  checks (Device::lost_refusal) and at every foreign-object check of one line
  (Device::foreign). DeviceLost stays for a device the consumer made.
- Carried across generations: the address space, resource IDs and the passing
  holds a making waits out before it takes one, unique identifiers, counters
  and the announced notice kinds.
- A device handle is an enum of the two kinds (24 bytes, was 16): the shadow
  merge's copy-back dispatch, which holds handles, is boxed (clippy's
  large_enum_variant).
- Device::recover_for_test (public, documented) runs the whole path with no
  GPU fault; RuntimeGap::AdoptedDeviceRecovery on an adopted device.
- Degradation::DeviceRecovered (device-recovered), announced at each recovery
  with the culprit and its time. WorkCounts::vk_devices_live, vk_devices_made,
  device_recoveries: two VkDevices while objects of the lost one live, one
  after.

Docs: docs/API.md catalogue entry, the runtime README's device-loss section,
FAST-PATHS known gap (a make whose own submission first meets the loss is
refused DeviceLost), docs/REFUSALS.md regenerated (refusal_surface.py names a
forwarded body's sites by its public method), api_signatures blessed.

Tests: runtime_lane::device_recovery (hang and victims, command buffers on
their way to the driver at a recovery, MadeBeforeRecovery and the VkDevice
bound, revocation at the second hang, a command buffer made before fails as
victim, all under the validation layer; a recovery that finds nothing of the
queue scheduled names no hang, its command buffers victims),
tests::device_recovery (the hold of the hang's queue between a loss and the
recovery), detach_lost and the MoltenVK lost-device lanes updated to the
recovery's answers.

Verified:
- lavapipe: runtime suite and touched validation tests 1850/1850, surface
  19/19 (m3-max-5695, gem10, before the rebase onto 7e039f062a); on
  7e039f062a, before the one-hang fix, 1853/1853, surface 19/19, clippy clean
  (m3-max-6150, ms01). This tree: clippy clean (m3-max-6278, msi).
- RADV RX 7900 XTX: 81/81 touched device tests (m3-max-5709). Iris Xe (ANV):
  80/81 (m3-max-5766), the 81st kept_images, which fails so at development
  too and the last of these three commits fixes; the recovery tests alone 3
  rounds of 3 (m3-max-5852). RTX 5080 Laptop GPU: 80/81 (b5080 entry
  devloss-devloss-tip1-nine-163410), the 81st the test's own 20 s bound on
  the recovery, which took 39.5 s beside another entry; the test now prints
  the recovery beside the device's first making and bounds neither.
- MoltenVK on the M3 Max: the device_recovery tests 8 rounds of 8
  (m3-max-6135); with the one-hang fix 12 of 12 (m3-max-6242), where without
  it 3 rounds of about 20 failed with a command buffer Completed after the
  hang (m3-max-6219, m3-max-6233). The RTX 5080 failed the second-hang test
  so in 2 runs of 3 (devloss-devloss-rec-alone-170457).
- Recovery time, alone, under the validation layer: llvmpipe 29.9 ms, RX 7900
  XTX 20.4 ms, Iris Xe 15 to 21 ms (its first making 30 to 41 ms), M3 Max
  (MoltenVK) 35 to 40 ms (42 to 50 ms), RTX 5080 530 to 559 ms (602 to 635
  ms). VK_EXT_device_fault listed: llvmpipe 0, XTX 1, Iris 0, 5080 1.
- Per draw (draw_costs, release, --heap, M3 Max, base 7e039f062a and the tip
  alternating, 4 rounds, m3-max-6121): instructions a draw ws +0.03%, many
  -0.05%, 10k -0.31%; draw_primitives +10, +8 and -26 of 17,172, 11,245 and
  7,736 a call; each set_* call +3 to +4 (of 425 to 860); a command buffer's
  creation +170 to +370, an encoder's end +120 to +390.

(cherry picked from commit 3d7758c074fc9895d5d6c9766604c6c4eae9166d)
2026-11-07 18:38:26 -08:00
Anees Iqbal 78e58c370f Guest RAM: listed chunks stop at 512 MiB, not 256
On a device whose held imports add to the cost of every submission (RADV), a guest RAM's chunks
now run up to 512 MiB. reims's 16 GiB guest on the Radeon 780M (their job 5584, two boots of each
setting) had less of QEMU's RAM resident with 512 MiB chunks than with 256 MiB ones: 0.45 GiB more
than without the source at its desktop against 0.94 GiB, and 0.15 against 0.25 GiB at the end of
its run, with at most 11 to 12 chunks live against 15 to 18. The probe's per-submission cost falls
too: an 8 GiB RAM's submission median was 32 to 33 us in 32 chunks of 256 MiB and 24 us in 16 of
512 MiB (job 5411).

LONGEST_LISTED_CHUNK, the module and use_host_ram docs, HOWTO, the FAST-PATHS row and the
chunk-length probe (now up to 512 MiB) say 512 MiB.

(cherry picked from commit 003382bdc921fa8e7901fa00c7896f29439d7907)
2026-11-07 16:40:58 -08:00
Anees Iqbal 406b379515 FAST-PATHS: the copied-rebind gap is where the check did not pass fresh pages, which it now checks on RADV too
The known gap said RADV's check gave fresh pages no verdict, so a rebind under a texture in place
at another pitch than RADV's linear image's was refused there. The check now makes its fresh-pages
buffer wherever the device takes such pages: on the Radeon 780M (RADV, 5640 and 5667) every Fresh
verdict passed, where the control left them Unchecked. The gap stays where the check failed fresh
pages or the device takes none, and the entry says so.

Verified: 5640/5667 on um790's 780M (1002:15bf) and lavapipe; see the branch's earlier commits.
(cherry picked from commit 756b83b22c97cc13b822cba31752d0906adb93c9)
2026-11-07 16:25:24 -08:00
Anees Iqbal 54647162d4 Record the copied rebind a texture in place is still refused for in FAST-PATHS' known gaps
Where the device's in-place check gave fresh pages no verdict (RADV: no new buffer lies in them
under the import tax) and the driver's own linear image lies at another pitch than the texels',
a gate-refused or moved rebind under a texture in place is refused (NotImplemented
(RebindTextures)), which Metal accepts. Recorded where a user reads it until the fresh-pages
check runs wherever fresh_page_buffer works.

(cherry picked from commit 9de4ad66cde6d12a58d35eed359a9246d170e31c)
2026-11-07 15:36:07 -08:00
Anees Iqbal 801f35bf19 Name the interlocked race's causes, record the split's cost, and count the memoryless lane per pass
DriverFact::InterlockedDrawsRaceUnderLoad's doc now names its causes.
- MoltenVK 1.4.2 turns render pass barriers off for every Apple GPU family
  (its device setup: Apple's GPUs do not support them). The by-region
  memory barrier between_storage_draws records therefore encodes no Metal
  barrier and orders nothing. The measurements agree: 16 of 20,790 passes
  lost with the barrier, 6 of 7,560 without it, the same rate.
- MoltenVK's shaders of the lanes' fetches, dumped with
  MVK_CONFIG_SHADER_DUMP_DIR (m3-max-5436), declare every interlocked
  storage image access::read_write, memory_coherence_device and
  raster_order_group(0), and read and write it there alone. Metal's raster
  order groups are what failed to order the draws under load, not a form
  the translator emits.
So no translator-side fix applies, and the split stands.

The measurement now holds both A/B runs. m3-max-5349 and m3-max-5414 ran
six processes at once, the builds in turn: 16 of 20,790 passes failed
with the barrier and 0 of 20,790 with the split.

docs/FAST-PATHS.md: the barrier row names the MoltenVK split, and a known
gap records its cost on the M3 Max (m3-max-5414, tile_path_costs,
release, four runs each). The other tile path cases kept their instances
and times.
- wide blended in the function: 11.5 to 12.9 ms a frame against 1.8 ms,
  243 instances a frame against 9.
- extended range: 11.8 to 12.4 ms against 2.5 to 2.6 ms, 234 instances
  against 9.
- extended range, wide attached: 10.7 to 12.4 ms against 2.5 to 2.7 ms.

a_memoryless_attachment_fetched_after_a_plain_inline_draw_starts_from_zero
now counts each pass apart. Each pass records inline, splits before a
write of the memoryless color through inputs, splits 3 times before draws
after interlocked writes where the device does so (none elsewhere), and
records at least its first split's instance inline. On the M3 Max the
first pass's later instances recorded in secondaries and the second's
inline (1 and 4, m3-max-5436), which the inline rule decides; the test
does not hold it.

Verified: cargo fmt. The lanes run next.
(cherry picked from commit f47897d1a80cf2e959211a883707df169011104c)
2026-11-07 15:16:42 -08:00
Anees Iqbal f9bc470d7c Move a shadow made before its pages' in-place verdict in place once it passes
A texture over host pages made before its class's in-place verdicts were
known is a shadow (CheckPending): an unknown, not a lack. Under the owner's
11-07 ruling a shadow is only for accesses that cannot be done in place, so
such a shadow must not stay one for life because it was made early.

Each such shadow now waits for its class's verdicts (StorageForms::moves).
The check's thread, at each verdict, decides from facts stored with the
wait (class, usage, texel bytes) and takes no handle of a program's
texture. Where the verdicts take an image in place, the texture waits for
the storage-form switch. At the commit of the device's only uncommitted
command buffer, the switch makes the image in place exactly as the
texture's making makes it: the declared plan, with feedback loop and
storage usage where the device makes them so, and noted for a rebind and
its first move. Where every encoder ran, the texture presents it from then
on (TextureShared::moved; every storage read goes through
Texture::storage). It is counted in host_textures_in_place and in the new
WorkCounts::host_textures_moved_in_place, and its slots are written again.

No texel is copied: between encoders the shadow holds nothing the buffer
lacks, and the image in place is the buffer's bytes, whose uses hazard
tracking orders after earlier copies back and merges. A view made before
the move keeps the shadow. A shadow with a usage or render shadow, over
detached or copied bytes, or whose image the device refuses stays a
shadow. The shadow's image is kept with the texture until it goes.

Test: runtime_lane::in_place_textures::a_texture_made_before_its_verdict_moves_in_place_once_it_passes
(under the validation layer). Docs: storage_form.rs and in_place.rs module
docs, FAST-PATHS in-place row, HOWTO, API.md.

(cherry picked from commit 605d0444de1ad1a9b93e02649db7e1b2fda18e93)
2026-11-07 15:14:38 -08:00
Anees Iqbal be1f1c141b Take the storage form for a private target whose self-read splits for want of STORAGE
A draw that reads its pass's color attachment at its own pixels after a render-target barrier
takes the snapshot only where no later fetch could render the attachment through a stand-in
(`keeps_own_attachment`: the image has STORAGE). A private texture whose device lays an image
out otherwise with STORAGE (with_free_usage leaves it off: the Iris Xe's optimal BGRA8Unorm,
as the orchestrator relayed from the 4845 A/B, 12-15 ms a frame of 30 splits for the private
selfread target) split at every such read, every frame, for good.

The fallback now notes the texture for its storage form (texture/storage_form.rs), the switch a
fetching pass's scratch already takes: at a later commit its image is made again with STORAGE
and its texels copied in once, announced as fetched-target-storage, and its later passes'
readers take the snapshot. A texture noted already returns before its plan is asked again, as
a reader that splits notes it at each such draw.

Test: tests/self_read_storage.rs (device test), with a test-only switch that makes STORAGE
cost every image (DeviceShared::storage_costs_forced, read in Device::if_free): a private
BGRA8Unorm target's first pass splits and takes the form at its commit, its later passes'
readers take the snapshot, each pass's texels Metal's; where the device does not take the path,
every reader splits and nothing swaps. Docs: the fetched-target-storage declaration and its
API.md entry, the FAST-PATHS attachment-read row.

(cherry picked from commit e0444b4029c9372197faf8c5bab3d967cb9bb543)
2026-11-07 15:14:06 -08:00
Anees Iqbal c34d5ad97a Record the chunk-length probe's numbers where the listed chunks' cap is described
The lane probe submit_per_ram_chunk_length ran on the Radeon 780M (RADV, Mesa 26.2.6, Linux
7.3.1) before the cap, two rounds, over an 8 GiB memfd RAM in 2 MiB pages with one 2 MiB object
in each chunk (job m3-max-5411 on the test copy a20f678c2e of e0e069f6bf).

Submission p50, round 1 / round 2:
- no RAM: 14.7 / 14.0 us
- 128 chunks of 64 MiB: 91.1 / 59.5 us
- 64 chunks of 128 MiB: 50.3 / 36.1 us
- 32 chunks of 256 MiB: 31.8 / 32.8 us
- 16 chunks of 512 MiB: 23.9 / 23.5 us
- 8 chunks of 1 GiB: 18.6 / 19.3 us

That is 0.34 to 0.66 us per live chunk. At every length the first submission that listed the
chunks took 52 to 56 ms, and the RAM was resident whole: 8192 of 8192 MiB, its objects over 16
to 256 MiB.

The FAST-PATHS entry and the host_ram module docs now carry these numbers. The paragraphs
touched are reflowed to 100 columns.

(cherry picked from commit 9aafb46d7b86f5834c821a25bc6ad1ec1b9b935e)
2026-11-07 15:03:11 -08:00
Anees Iqbal 6aff9aaa3c Stop a listed guest RAM's chunks at 256 MiB: a chunk's import pins every page of it
Where each listed import costs every submission (RADV with a source of dma-bufs), a guest RAM
was imported in chunks as long as the source's dma-bufs and the device's limits took: about
2.5 GiB on a consumer's 16 GiB guest on the Radeon 780M. A chunk's import pins every page of the
chunk, and udmabuf allocates the pages of the memfd the guest never touched, which stay
allocated once the chunk is freed. So each chunk an object lies in made all its bytes resident:
the consumer measured QEMU's Pss_Shmem at 7.86 GiB without the source and 12.31 GiB with it.

listed_chunk_bytes now stops at LONGEST_LISTED_CHUNK, 256 MiB, on every device and kernel. It
is a structural bound, not tied to udmabuf's size_limit_mb, which stays an upper bound through
HostRam::with_largest_dma_buf. The trade is speed against memory, with no accuracy change and
so no switch. Each live chunk costs every submission about half a microsecond (an 8 GiB RAM on
the 780M: 128 chunks of 64 MiB took a submission's median from 14 us to 60-88 us; 3 chunks of
2730 MiB, to 16 us). At 256 MiB, a 16 GiB RAM lists at most 64 chunks.

The kept-chunk rule (releases_idle_chunks) is unchanged, so the first-gather win of kept chunks
stays. The docs (the host_ram module, Device::use_host_ram, HOWTO section 6, and the FAST-PATHS
"Idle dma-buf imports are released" entry, edited in place) say where the chunks stop and why.
The lane probe submit_per_ram_chunk_length now measures only the lengths the plan can make (64,
128 and 256 MiB). Its run before the cap measured 64 MiB to 1 GiB.

Verified: the unit test listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib fails
without the cap (a 2.5 GiB source gave 2560 MiB chunks) and passes with it (job ids in the tip).

(cherry picked from commit 9a158941e94173b4e0dc53b89f3b15c9b59f60c2)
2026-11-07 15:03:11 -08:00
Anees Iqbal 442dcd08c9 Copied host memory: a copy that drops the GPU's writes takes its guest RAM's log, and a draw that only reads through loaded addresses leaves unnamed copies uncompared
A copy of memory of Metal's private option bit 24 (on a system that maps no read-only view of
the pages) skipped the routing of its guest RAM runs, so it kept no log: every commit compared
every byte of it, and every completion of a command buffer with a root table compared every
copy. In consumer boots that is about 29.5 MiB per commit and per completion over 37-44 objects.

- Commit (copy in): a no-copy buffer, heap or rebind whose GPU writes are dropped has its runs
  asked as a writable one's are (routes_runs), so its copy takes the RAM's log and copies in only
  the pages the log reports written. It is still never bound in the RAM's chunk: the in-chunk
  binding is filtered on drops_writes. macOS keeps its read-only view and asks no runs.
- Completion (merge back): State::writes_unnamed narrows reaches_unnamed to commands whose
  functions may write memory. A draw's root table writes only where the vertex or fragment
  function may store or update memory (GraphicsState::vertex_writes_memory,
  fragment_writes_memory) or the pipeline has another stage; kernels, tile functions, replay
  tables and records resolved by host steps stay as they were (every copy compared). The compare
  itself stays: in a dropping copy it is what restores the dropped bytes, so later command
  buffers read the pages' bytes.

Tests: host_ram_copy_device a_private_bit_copy_over_the_pages_copies_in_only_the_pages_the_log_reports
(one page written: length - page bytes not compared, the GPU's fill dropped) and copied_device
a_merge_back_skips_a_copy_when_a_draw_only_reads_through_loaded_addresses (root table noted,
merge back compared 0). Docs: copied.rs, FAST-PATHS known gap, HOWTO section on copies.

(cherry picked from commit 61a9a4f4603a4c080ba5a4f2e204668ae621cf41)
2026-11-07 14:28:18 -08:00
Anees Iqbal c6e1d5a9fd Make a BC1 or BC4 texture over a surface's plane at an offset or pitch off 16
The runtime refused a BC texture over a plane of a surface with planes
whose offset or bytesPerRow is off 16 bytes, as
NotImplemented(SurfacePlaneShape). The M3 Max answers nil for every BC
texture over a surface, so the x86 Macs are the reference (job
m3-max-4779 on macbook-pro-2019: an AMD Radeon Pro 5300M and an Intel
UHD 630 under macOS 26.7.1, surface_texture_envelope.m's bgraat8.bc1 at
offset 8 and bgrarow264.bc1 at 264 bytes a row). Both GPUs' blits and
samples take block row j at the plane's offset + j x bytesPerRow, with
no rounding to 16.

linear_plan::blocks_off_sixteen makes a BC texture of 8-byte blocks
(BC1, BC4) at an offset and bytesPerRow that 8 divides, at least 16
bytes a row. Every BC plane now lies at the CPU's layout on the GPU too
(plan_iosurface_plane's blocks flag): at multiples of 16 the two were
already equal. The CPU calls take the plane's own offset, as the
5300M's getBytes does, while the UHD 630's getBytes and replaceRegion
take a plane at offset 8 from byte 0. That difference is recorded in
docs/API.md's accepted differences. BC4 was not measured off 16; it
takes BC1's 8-byte block rows. BC textures of 16-byte blocks (BC2,
BC3, BC5, BC6H, BC7) off 16, and 8-byte ones off 8 or under 16 bytes a
row, stay refused. SurfacePlaneShape's doc names them, and so does its
reach mark in REFUSALS.md.

Tests: tests::linear_plan makes bgraat8.bc1, bgrarow264.bc1, BC4 at
(8, 264) and BC1 at offset 40, with the GPU layout equal to the CPU's.
It refuses BC3, BC5 and BC7 off 16, BC1 at offset 4 and at 260 bytes a
row, and BC4 at 8 bytes a row. tests::surface_shapes (a device test)
gains bgraat8.bc1, bgrarow264.bc1 and bgraat8.bc4 on every path.

docs: linear_plan.rs's Block-compressed surfaces, the plane call,
SurfacePlaneShape, BufferRefusal::PlaneShape, the FAST-PATHS known gaps
and the API.md accepted differences. Regenerating REFUSALS.md changes
only the reach mark. CONFORMANCE-COVERAGE.md and the API signatures are
unchanged.

(cherry picked from commit ff454bd8b269fff6abf590da85cd050862d539a9)
2026-11-07 14:23:18 -08:00
Anees Iqbal 0c621da77a Make a texture over a surface's plane whose rows are wider than its pitch
Metal makes a 2D texture over a plane of a surface with planes whose
rows are wider than the plane's bytesPerRow, and a 1D texture wider than
one row; the runtime refused both as NotImplemented(SurfacePlaneShape).
On the M3 Max every path reads row y whole from the plane's offset plus
y times bytesPerRow (surface_texture_envelope.m's bgra1x2.65x64,
bgra1x2.128x32, 420v.p0.65x64, 420v.p1.33x32 and bgra1x2.1d.128), so
the texels lie in one place and the 2D texture's rows overlap, on the
GPU and the CPU alike.

linear_plan::wide_rows makes such a texture of a colour format over a
plane whose offset and bytesPerRow are multiples of 16, its GPU layout
its CPU one. A 1D texture is one row from the offset. A 2D texture's
overlapping rows are held as the rows of a pitch off 16 are: a shadow
whose copies reproduce the sharing, refused where a render pass stores
into it, blits into it refused (NotImplemented(OverlappingSurfaceRows)),
announced as CollidingSurfaceRowWrites. What is new is that the shared
head can be wider than the pitch (a byte shared by three rows or more),
so plane_copy_regions copies it in in pieces no wider than the pitch,
and copies row 0's head back as one row. plane_rows_share_bytes asks the
GPU layout alone, as a wide plane's CPU rows share bytes too. Other
formats, and planes off 16, stay refused: nothing measured them.

The write orders come from overlapping_plane_row_writes.m, extended in
the previous commit and run on the M3 Max (macOS 27.0.1, job
m3-max-5088, three processes a case), and recorded in its header. The
GPU gives the shared bytes the answers it gives the rows of the same GPU
pitch and row at a pitch off 16: no one order for blits, and for a
kernel the earlier row's within the first threadgroup's rows. Where
three rows share a byte, the kernel at 8 x 4 keeps the earliest row's.
replaceRegion writes the rows in order, so the latest row's bytes stand,
in every shape and process. So the runtime's copy back, which keeps the
earliest row's bytes, is one of Metal's kernel answers. Its CPU writes
go row by row, as Metal's do. The notice's cost now says "the earliest
row's" in place of "the earlier row's", and docs/API.md's catalogue says
the same.

Tests:
- tests::linear_plan: the probe's wide shapes are made, with their
  layouts. Wide rows off 16, of a depth format or of a 1D texture off
  16 are refused. A render target over wide rows is OverlappingRows.
- A new sweep: 2232 wide planes, 1302 of them sharing more than a
  pitch, over five texel sizes, pitches of 16 to 64 and 2 to 4 rows.
  It holds plane_copy_regions to what Vulkan allows and to the
  earliest-row rule (hold_the_copies, which now allows the head's
  pieces and a bufferRowLength of 0).
- tests::buffer_texture: its sweep now holds that only a wide plane's
  CPU rows share bytes, its CPU layout its GPU one.
- tests::surface_shapes (a device test): the probe's five wide shapes
  read as Metal reads them on every path, with a blit into the 2D ones
  refused.

docs: linear_plan.rs's Beyond the plane's rows and Rows that overlap;
SurfacePlaneShape, the plane call and BufferRefusal::PlaneShape; the
CollidingSurfaceRowWrites declaration and its API.md entry; and the
FAST-PATHS known gaps. REFUSALS.md, CONFORMANCE-COVERAGE.md and the API
signatures are unchanged when regenerated.

Checks: job ids are in the tip's report.
(cherry picked from commit 344cd110f8f612907f26dd9a30b0871e299ddb27)
2026-11-07 14:23:18 -08:00
Anees Iqbal 6b6a7f522b Make mipmapped, 3D, multisample and sliced textures over a surface's plane
What. Buffer::new_texture_with_iosurface_plane over a plane of a surface
with planes makes three shapes it answered
NotImplemented(SurfacePlaneShape) for:
- a 2D texture of more than one level, a 3D texture and a 2D multisample
  one, of a colour format (linear_plan::apart_from_plane: is_linear and
  tail_held): a texture of the device's own memory
  (Device::surface_texture_apart), zero when made in every storage mode,
  a Private one's too (texture.rs's new Fresh::Zero start, which skips
  Metal's fresh pattern and the uncounted held start), announced by the
  new Degradation::SurfaceTexelsApart ("surface-texels-apart",
  precision). A Memoryless one stays MemorylessSurfacePlane.
- a 2D array of more than one slice, of a colour format, over a plane
  whose offset and bytesPerRow are multiples of 16
  (linear_plan::slices_apart): its first slice over the plane as a 2D
  texture's rows, its others in a tail of the texture's own. The planner
  lays the slices one image apart and gives Placed::kept, the second
  slice's first byte (or the buffer's length where that comes first);
  Texels::kept cuts the tail there instead of at the buffer's length
  (with_tail, past, staging), so the shadow's copies, blits and CPU
  calls take slice 0 from the plane and the rest from the tail.
  Announced by SurfaceTexelsTail, whose doc and cost now name both
  cases.

Why. Metal makes these, and on the M3 Max under macOS 27.0.1
(probes/surface_texture_envelope.m, job m3-max-4776) it lays them out in
no one place: bgra1x2.mips2/mips7, 420v.p0.mips2, bgra1x2.3d.d2,
420v.p0.3d.d2 and bgra1x2.2dms4.private read level 0 or slice 0 by blit
and kernel from other bytes than its blits, replaceRegion and getBytes
put there; bgra1x2.2darray.a2 and .a2.64x64 keep slice 0 over the plane
on every path while slice 1 is read at the plane's offset by blits and
getBytes, one image on by kernels, and written at the plane's offset.
By the rule of 9ee7323e76 what lies in one place stays in place and the
rest goes in memory of the texture's own, announced (the orchestrator's
option A). The x86 Macs under macOS 26.7.1 keep level 0 and slice 0 of
the first shapes over the plane; API.md's accepted differences records
that the runtime does not.

Docs: API.md's catalogue (the new kind, SurfaceTexelsTail rewritten) and
two accepted differences (sliced arrays; mipmapped/3D/multisample);
FAST-PATHS.md's known gap; SurfacePlaneShape's, PlaneShape's and the
plane call's docs; REFUSALS.md regenerated; api_signatures.tsv blessed.

Tests: tests::buffer_tail_device::an_array_over_a_plane_keeps_its_second_slice_in_its_tail
(64x32x2 RGBA8 over a 32768-byte plane: slice 0 the plane's bytes and
slice 1 zero on get_bytes, blit and a kernel through 2D views; kernel,
CPU writes read back on every path; the plane past slice 0 and the
buffers around unchanged; one notice) and
a_plane_s_texture_metal_lays_in_no_one_place_lies_apart (2 levels, 3D of
depth 2, 4-sample Private; level 0 zero, levels and slices written and
read back, no byte of the surface changes, one notice);
validation lane a_mipmapped_plane_lies_apart_and_is_announced, listed in
degrade_notices; linear_plan table rows for apart and sliced shapes,
their kept cut, and the off-16 and depth arrays still refused.

Verified by potluck jobs at this commit (clippy plain and m2v_cpu_icd,
runtime unit tests, lavapipe runtime and validation lanes, a negative
control at the runtime sources before it); results in the tip's report.

(cherry picked from commit 463cd6b9ecccc9e0b4263d8ac2452190f0287241)
2026-11-07 14:23:17 -08:00
Anees Iqbal 32b8a9dfa1 FAST-PATHS: the guest RAM chunk's first-submission stall as the 780M A/B measured it
The row kept the 231 to 275 ms a /proc stack sampler saw (gem10 job 4750). The A/B of the probe
runtime_lane::submit_per_import::submit_per_ram_chunk on the Radeon 780M (gem10 job m3-max-5090,
--exclusive, an 8 GiB memfd RAM with its udmabuf source and with_largest_dma_buf at the host's
limit, 3 chunks of up to 3.94 GiB, two rounds each) measured more:

- the first gather after the idle window, its chunk released and imported again (the plan before
  this branch): 475.7 and 480.1 ms from commit to completion, 453 and 462 ms of it submitting;
  with the chunks kept: 2.76 and 2.58 ms (0.49 and 0.32 ms submitting), no import made;
- a gather at each 64 MiB: 240.7 and 185.3 ms released, 4.6 and 5.9 ms kept;
- steady submission p50 4 s after the objects went: 14.7 and 15.3 us with no chunk live, 16.8
  and 16.2 us with 3 kept.

The row now gives 231 to 462 ms and both gathers' times, and 14 to 15 us with no chunk.

(cherry picked from commit 52f46a21948eee752d2702b42ec171309bd3ab55)
2026-11-07 14:11:16 -08:00