Commit Graph
2510 Commits
Author SHA1 Message Date
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 ada21454ee Pooled class: the host-texture count and the unplaced image name it, as no texture over host pages
(cherry picked from commit abca36b828f0147f2a1043ff34ac84a492ccacc3)
2026-11-08 03:29:51 -08:00
Anees Iqbal 99f47fb7e8 In place: a texture over the runtime's pooled memory whose rows the device's linear image lays out otherwise takes a DRM_FORMAT_MOD_LINEAR image at Metal's pitch, where the device's check passed
A texture over a buffer of the runtime's own memory aliases it only where the device's own
linear image lies at the buffer's pitch. ANV lays linear rows tight, so a padded row (the
guest's device caches at 64-aligned pitches, rows ending mid-line) never aliases on the Iris
and every such texture is a shadow, copied in at each command buffer that uses it after a
write.

Where the device makes DRM_FORMAT_MOD_LINEAR images, such a texture now takes one with an
explicit plane at Metal's pitch (VkImageDrmFormatModifierExplicitCreateInfoEXT), no external
memory, bound in the buffer's memory. The image is made by the builder dma_buf.rs already has
(ModifierMemory gains Own: no external chain, no import check). Binding it to memory of no
external handle type is valid (VUID-VkImageCreateInfo-tiling-02261 asks only the modifier's
create info; VUID-vkBindImageMemory-image-01445 only a dedicated allocation where required,
which the runtime refuses), and a DRM_FORMAT_MOD_LINEAR image is linear, so in GENERAL it
aliases the buffer's bytes as host-accessible subresources do. It is made UNDEFINED
(VUID-VkImageCreateInfo-initialLayout-12478: PREINITIALIZED is for linear tiling alone), and a
move from UNDEFINED may discard the bytes: so the device's check gains a class for its pooled
memory (PagesClass::Pooled: a Shared buffer under half a pooled block that declares its padding
unobserved, its textures' images at Metal's pitch alone), and the image is taken only where its
verdicts pass for the texture's accesses, under HostPageTexturePolicy (Shadow turns it off).
CHECK_VERSION 11; the record holds 48 verdicts. The placement query answers a texture over the
device's own memory by the making's steps up to the bind (Device::alias_image_made): an
aliasing image (NotHostPages), or the shadow's cause. Counted: WorkCounts::pooled_pitched_images.

Verified so far: cargo fmt only; builds, tests and the device evidence follow.

(cherry picked from commit 25aa0cfda816f91a8148d4afbf81b19e7c870c07)
2026-11-08 03:29:50 -08:00
Anees Iqbal 7a562f0522 reserved_queues: a raw copy whose fill's signal was reached as it asked waits for nothing
a_raw_copy_on_a_reserved_queue_moves_the_runtime_s_own_buffers asked
SharedEvent::vk_wait(10) once the first command buffer was scheduled and
panicked unless it answered Counter. On an RTX 5080 the two 4 KiB fills can
complete before the question, and vk_wait then answers Reached, which its
contract defines as 'the submission needs no wait'. The test failed so in
2 of 10 runs alone (perdraw6-rawcopy-a, at 37637be4d4) and once in a whole
runtime suite beside the exits lane's making_exit (the 5080 exit entry):
'a submitted signal's counter: Reached' at reserved_queues.rs:279.

The raw copy now waits for counter 0 (none) where the signal was reached, and
for the counter as before where it was not; its line names which it saw. Only
NotYet, which a scheduled signal never answers, still fails the test.

Verified: pending, the test 30 times on the RTX 5080 (b5080 c entry), its
line counting Reached and Counter runs; clippy in the m2v_gpu cfg.

(cherry picked from commit 39b2a53adcb6e2b61dffef7f9d342c39e999dd1e)
2026-11-08 03:10:19 -08:00
Anees Iqbal dcaf3085a0 Container: functions of a shared-module library may share one empty metadata record
macOS 11's own Core Image libraries (file type 1, format 2.5; reims's 11.7.11 guests, 118977 and
320632 bytes) name one 8-byte private-metadata record, a size word and ENDT, from every function, over
the one module they share; the parser refused the second function's entry with BadOffset (at 245 and
223), so the guest's Core Image got "Invalid library file". In a library whose functions share a module
(Core Image kernel, dynamic), a function may now name exactly the record the previous one did when it
holds no tags; a shared record holding a tag, and any sharing in an executable library, stay
BadOffset, so parsing stays linear in the file size. Test: a 2.5 Core Image library sharing one empty
private record parses with no private tags; the tagged and executable variants are refused.

(cherry picked from commit 200ca7984d84dde9aba214115e4df5745ade5123)
2026-11-08 03:06:55 -08:00
Anees Iqbal 563ddcdaab host_import_counts: wait for the in-place check's imports' frees before reading a gauge
tests::host_import_counts::copies_between_a_buffer_and_a_texture_never_read_apart failed once in
development's lavapipe leg on msi-laptop at edde5779b1 (lavapipe of LLVM 23.1.1): at its first
copy (host_import_counts.rs:268) left (23, 0, 1), right (23, 0, 2): an import live as the test read
its gauges before that blit, besides its own buffer's, went during it. settled_device waited for
the device's in-place check to settle and for host_imports_read_apart to reach 0. A buffer of the
check's counts its import's read apart off as it goes, but where a keep-alive alone waits for the
import's free, that free goes to a handler thread (HostImport::drop, buffer.rs), and
host_imports_live falls only once it ran; the check settles right after its last class's buffers
went. settled_device now also waits until no import is live and no posted release is pending: a
device made just now holds no import of its own.

Verified (lavapipe, --cfg m2v_cpu_icd, homelab-um790-xtx-1, Mesa 26.2.6 with LLVM 23.1.4):
- A posted release was still pending as the check settled in every run printed (16 of 16, a
  scratch print at 96ba9a104c, m3-max-7851). There it was the dma-buf class's, whose memory
  host_imports_live does not count (an import of the class's own exported allocation), so the
  gauges the test reads did not move: the failure did not reproduce there (0 of 424 runs at
  dc064aec27 under four runs of the freed_memory in-place check test, eight of this one and 20
  busy loops, m3-max-7902; 0 of 498 at 96ba9a104c). On msi-laptop's lavapipe the check made
  fewer commits that used its imports before it settled (22, against 40 on um790), and the
  import whose free was still pending was one host_imports_live counts.
- this change: 0 of 784 runs under the same load (m3-max-7985).
Not run: the test on msi-laptop's lavapipe, where it failed (msi-laptop takes no CPU jobs of
ours now).

(cherry picked from commit ef98c2917e32e77d79f1cbf91bcacc80ef09acf8)
2026-11-08 03:06:03 -08:00
Anees Iqbal c1bd13193e freed_memory: the in-place check test bounds each step of the check, not its whole run
tests::freed_memory::the_in_place_check_s_buffers_delay_no_deallocator_behind_batches_in_flight
keeps a batch of 16 fills of 64 MiB in flight from its first command queue until the device's
in-place check settled and its imports went, and failed once 60 s (WAIT) had passed since it
began. On a device of one queue (lavapipe) each of the check's submissions waits behind such a
batch, so the check runs as long as its submissions times a batch, which a loaded host
stretches: 27 to 29 s alone, and past 60 s in development's lavapipe leg on msi-laptop at
edde5779b1 (FAIL at 60.3 s, "the check's buffers never went"). Nothing was stuck: the check was
still going.

The bound now holds for each step of the check the test sees: a new verdict, an image of one of
its rounds (ObjectChurn::vk_images_made, which the fills on a private buffer never move), a
release of its imports posted (host_import_releases_posted) or one of them freed
(host_imports_live). A step must come within 60 s of the one before. The test prints its longest
step.

Verified (lavapipe, --cfg m2v_cpu_icd, homelab-um790-xtx-1, 16 threads, Mesa 26.2.6; each run
a process, under the same load each time: four runs of this test at once, eight of
host_import_counts::copies_between_a_buffer_and_a_texture_never_read_apart and 20 busy loops):
- development dc064aec27, m3-max-7902 (the two trees' loops side by side, two and four runs of
  each): 16 of 20 runs failed ("the check's buffers never went"); the four that passed took
  53 to 60 s.
- this change, m3-max-7985: 0 of 40 failed, in 51 to 63 s; longest step 3.1 s; delayed 0 and
  posted 8 in each run.
- The same at 96ba9a104c with 12 busy loops, m3-max-7783: 44 of 48 failed.
Not run: the test on a GPU (its steps are the same counters there).

(cherry picked from commit efda039eef9ab6c165f192785d81c8c6ff30a15b)
2026-11-08 03:06:03 -08:00
Anees Iqbal fed6316115 Bump RUNTIME_VERSION to 1882: a tiled texture's later levels copy nothing, its merges fetch, and a detach keeps its image
amdperf-33 (the three tiled-mips follow-ups): a command counts as a use of a multi-level tiled
texture's level-0 shadow only where its range touches level 0, so generate_mipmaps and blits or passes
into levels 1+ copy level 0 in and out no more; the multi-level image takes the level-0 unorm and word
views, so its merges fetch instead of copying back by dispatch; while its bytes are detached, the tiled
texture keeps its own image (levels 1+ unchanged, level 0 its bytes' last texels) where a texture over
the pages alone reads zeros. Verified by amdperf: M3 320/320 (7858) with the negative control failing
the 4 new tests (7865); 780M (7898). Clippy, rustdoc and lavapipe run on development after the merge.
2026-11-08 02:58:28 -08:00
Anees Iqbal e925a35d5d Print every shape's level-1 blit and generate_mipmaps counts before asserting them
The later-levels test asserted the level-1 blit's counts before it ran
generate_mipmaps, so a build without the fix (the negative control) printed no
generate_mipmaps counts. It now runs both for each shape, prints them, checks the
texels, and asserts the counts after the loop.

(cherry picked from commit 565fa393e25d2c3078a9b61a171dbcd29b1e84a8)
2026-11-08 02:57:36 -08:00
Anees Iqbal 6800ca6838 Fix two warnings of the runtime's device-test build on macOS
- tests/in_place_check.rs imported RuntimeDriverDefect for its Linux-only dma-buf
  test alone, so a macOS build under --cfg m2v_gpu warned of an unused import
  (pre-existing on development; Linux builds use it). The import is now Linux-only.
- tests/tiled_texture_device.rs: the render encoder of the later-level pass test
  needs no mut.

Seen in the M3 build m3-max-7840 (cargo test --lib under --cfg m2v_gpu).

(cherry picked from commit 82c6f2b219142814c349ac43b2606b44cd935725)
2026-11-08 02:57:36 -08:00
Anees Iqbal 3feb4b3a55 Keep a tiled texture's own image through a detach, its first level the bytes' last texels
A tiled texture of more than one level (Buffer::new_tiled_texture) over a no-copy
buffer presented the shared zero stand-in at every level while the bytes were
detached, and refused CPU access at every level (DetachedTexelAccess). On a Mac its
later levels are the texture's own memory, which a detach leaves, and its first
level the pages it took, whose last bytes its CPU access reaches.

The texture's image is its own, so it now keeps presenting it: noted with keeps
(NotedTexture::keeps), it takes no stand-in at the detach (TexturesOver::images
leaves it out, and so do the stale-reach notes) nor at its making over detached
bytes. Before anything is detached, the detach loads its first level with the
bytes' texels as they are then (keep_first_levels, Texture::keep_first_level: a
get_bytes of the pages, then a write into the image), so an unnamed read and
get_bytes read the last texels, those the CPU wrote after the last copy in
included; a replace_region of that level stays refused. The later levels are read
and written in the image as before. Once the bytes lie in pages again the first
level copies them in at its next use. The load reads the level's texels once on
the host (11.7 KB for WindowServer's 54x54) and stages one copy for the next
submission, at a detach only.

Docs: the item's rustdoc says the difference (its first level reads its last bytes
while detached, where a texture over the pages alone reads zeros), with its other
levels' rule and the copies of item 1 and 2; detach.rs, stand_in.rs,
DetachedTexelAccess's doc and docs/API.md. REFUSALS regenerated (unchanged), api
signatures checked (no change).

Verified by the device tests: see the tip's evidence.

(cherry picked from commit 87435362577424f2e7757ff69bcb292b401dc9ed)
2026-11-08 02:57:26 -08:00
Anees Iqbal 73e7638e4c Give a tiled texture's shadow the word and unorm views of its first level
with_word_view and with_unorm_view required a one-level image, so the shadow of a
tiled texture of more than one level (Buffer::new_tiled_texture) took neither: its
merges copied the texels out instead of fetching them through the BGRA8/RGBA8
unorm view (every device), and on ANV its copies back stayed copies where a
dispatch is measured faster. Both views are of level 0 alone, and its copies are
one region of level 0, so a multi-level image takes them as a one-level one does.
The condition is now one slice. sRGB and the other formats keep copying out, as
every shadow's do (unorm_read), or take the word view where it is made.

Verified by the device tests: see the tip's evidence.

(cherry picked from commit 0d124cfc62ab10bb4be87ff5909f8602ff28db05)
2026-11-08 02:57:26 -08:00
Anees Iqbal beaa159d4f Count a tiled texture's shadow as used only where a command uses its first level
shadow::copies_used matched a command's uses to a shadow by its key alone, and
render/shadows.rs took every attachment of a shadowed texture as a use of its
shadow. A tiled texture of more than one level (Buffer::new_tiled_texture) is one
image whose first level alone is a copy of the bytes (shadow_range levels 0..1),
so a command that used only its later levels was planned as a use of the first:
a blit into or out of level k copied level 0 in, and after a write copied it back
or, over a Shared buffer, kept and merged it; generate_mipmaps' chain (read N,
write N+1) left level 0 dirty and merged it back at the end of the encoder, a
merge that stored nothing. WindowServer makes such textures in its first seconds.

ShadowCopies::holds: a use names the shadow where it holds a copy of the truth,
its key in a range that meets shadow_range. copies_used counts only those uses
(and writes only theirs); attachment_shadows and count_colors take an attachment's
shadow only where the attachment's level and layers meet it (held_shadow). Every
other shadow's range covers its whole image (or, for a heap's two-plane texture,
its first level, whose later levels likewise lie in the image alone), so nothing
else changes.

Verified by the device tests of the commit before: see the tip's evidence.

(cherry picked from commit 35d39664702c4d34219226ca2bee6755365737e3)
2026-11-08 02:57:26 -08:00
Anees Iqbal 3c42dff011 Test that a tiled texture's later levels copy nothing, its merges fetch, and a detach keeps it
Four device tests in tiled_texture_device.rs, for the three tiled-mips follow-ups
(Buffer::new_tiled_texture):

- uses_of_the_later_levels_alone_copy_nothing_of_the_first: a blit into level 1
  takes no shadow copy, and generate_mipmaps copies level 0 in and nothing back,
  keeps nothing and merges nothing.
- a_render_pass_into_a_later_level_copies_nothing_of_the_first: a pass into level 1
  takes no shadow copy.
- a_merge_of_the_first_level_fetches_through_its_view: a blit into part of level 0
  over a Shared buffer merges back through a view (shadow_merges_fetched 1), the
  bytes outside the part kept.
- detached_bytes_leave_the_first_level_s_last_texels_and_the_later_levels: over a
  no-copy buffer, detached, the texture keeps its VkImage, get_bytes of level 0
  reads the CPU's last write (made after the last copy in), the later levels read
  and take writes, a level-0 write is refused; a rebind gives level 0 the new
  pages and keeps the later levels.

Each prints its counts before asserting. They fail on this commit alone, where
the fixes that follow are absent: the negative control.

(cherry picked from commit e873588a623425c2cc8137296b4b5ec3dcd87432)
2026-11-08 02:57:26 -08:00
Anees Iqbal 72390d486b Re-pin the runtime sources after the offset-only rebind cut, which changes no behaviour
perdraw-11 (e318666636) changes how a buffer slot whose offset alone moved tests for a reshape
(BoundBuffer::same_shape instead of comparing two whole shapes); the answer is the same by construction
(tested over every pair of 184 bindings at 3 alignments), and the work counts are equal on both sides
(draws_rebound 239952, bound_offsets_moved 239040), so RUNTIME_VERSION stays. Instructions per draw:
gem10 lavapipe 5037 -> 4973, M3 5184 -> 5132. Verified by perdraw: M3 cost --check 0 and MoltenVK suite
1834/1834 (7883), lavapipe suite 1864/1864 (ms01 7960), clippy x3 + rustdoc + bind_shape_of (gem10 7881).
2026-11-08 02:56:22 -08:00
Anees Iqbal e318666636 Offset-only rebinds compare bind offset classes without classing the length
A rebound draw whose buffer slot moved only its offset (refresh_offset) asked
Reshape::replace whether the slot's shape changed by making both bindings'
BufferShapes: two length_class calls (u128 arithmetic) for a length the two
bindings share by construction. The fp call graph of draws.10k on lavapipe
(release, line tables, frame pointers) put BoundBuffer::shape at 1.24% of the
process, 0.78% in length_class, all of it under refresh_offset.

BoundBuffer::same_shape answers as the two shapes compare, skipping the class
of a length or offset the two bindings share; Reshape::replace_by takes such a
predicate, and replace is written over it. refresh_offset uses same_shape.

Test: bind_shape_of's new test checks same_shape against shape equality over
every pair of 184 bindings at three view base alignments. API signatures
blessed (one new method).

(cherry picked from commit 29fc8605db0229f0e2d7ca5522bb2e56855ee86d)
2026-11-08 02:55:36 -08:00
Anees Iqbal dc064aec27 Bump RUNTIME_VERSION to 1881: the Iris's dma-buf pages take the in-place check, and a store failure carries across its classes
selfread dmabuf7: the check's dma-buf export carries the device-address flag every runtime import carries
(ANV refused the import otherwise, so DmaBuf was Unchecked on the Iris and the guest's dma-buf textures
were shadows); compares read in wide loads (ANV maps exported BOs uncached: 2.7 s a 4K round byte-wise);
a store-path failure (renders, writes, buffer writes, narrow writes) seen beside the texels, with that
class's reads passing, fails every class's verdict; verdicts are given together at the check's end.
CHECK_VERSION 10. Verified by selfread on the Iris (ms01 7779 at the rebased tree): the rule's unit test
passes and fails with the rule taken out; device test 3/3 with the guest's 234x18 BGRA8 texture at
1024-byte rows in place; 6 fresh checks of 1.21-1.41 s (18.9 s with the flag fix alone, 7688) with
identical verdicts, the carry firing for DmaBuf narrow writes in 3 of 6. Clippy, rustdoc and lavapipe
suites pending (gem10 7780), then the 780M A/B.
2026-11-08 01:57:03 -08:00
Anees Iqbal 6280b71169 In-place check: narrow stores carry as the others do; CHECK_VERSION 10
On development the check has rounds of 1- and 2-byte texels a kernel stores (NarrowWrites, and
NarrowBufferWrites for a free padding), and CHECK_VERSION 9 is theirs. Those rounds store as
the storage-write rounds do, so a failure of theirs beside the texels, where the class's reads
of those row ends passed, carries across classes as theirs does: carried_store_failures counts
them among the store-path accesses. The unit test takes every access and adds a narrow case: a
narrow-writes failure of one class and a narrow buffer-writes failure of another each fail the
other classes' passes of theirs.

CHECK_VERSION 10: the dma-buf class's export and imports (commit 1), and the carried failures
and verdicts given together (commits 2 and 3), change what the check answers on ANV, whose
records of 9 hold the dma-buf class unchecked.

Verified: pending (the rule's unit test and the Iris device test at this tree).
(cherry picked from commit f50901a1fb49cacdcb770b82f6eb92e423b7610f)
2026-11-08 01:56:14 -08:00
Anees Iqbal f81db308cd In-place check: carry only a store failure whose changed bytes lay beside the texels
carried_store_failures carried any failure of renders, storage writes or buffer writes of a
class whose reads of those row ends passed. A round that reads a texel other than the stores
left it fails those accesses too, and that is the class's own: whether the CPU sees the GPU's
stores depends on the class's mapping and import, as whether the GPU sees the CPU's bytes does
for reads. What carries is the GPU's write-back of a line beside the texels, which every class
shares.

check_class now returns, with its verdicts, whether every byte its rounds found changed lay
beside the texels (after a row's texels, or after the image; a padding change is); the run keeps
it in each Found (now a struct), and a failure carries only where it holds. The unit test adds a
store failure at a texel, which carries nowhere, and the same failure beside the texels, which
carries to both other classes.

Verified: pending (with the commit before's runs: the unit test with and without the rule, the
780M and lavapipe verdicts against development's, the Iris check again at this tree).

(cherry picked from commit 196b3f4f42046e265910e90d71255d6cad775f2c)
2026-11-08 01:56:14 -08:00
Anees Iqbal aadc115900 In-place check: a store failure fails every class's pass; compares read in wide loads
With the dma-buf class's pages imported on the Iris Xe (the commit before), two things showed,
both from one cause: ANV maps its exported memory uncached for the CPU, whatever the memory type
(job 7706: types 1 and 2 alike), so each byte the check reads there is a bus read of about 80 ns.

1. A flaky pass. The check's writer reads each byte before it rewrites it, sweep after sweep,
   while the GPU stores; a sweep of a 101x51@512 window there takes about 2.7 ms, against a store
   step of 0.1 to 0.8 ms, so it revisits a row's last line about 40 us apart instead of under a
   microsecond, and rarely lands a write between the GPU's read of the line and its write-back.
   The storage-write rounds of rows that end inside lines saw the padding change in 3 of 18
   dma-buf rounds against 10 and 14 of 18 of the pointer and fresh-pages classes (job 7706), and
   the dma-buf class passed storage writes inside lines in one fresh check of three (job 7688),
   where its pass would have put a kernel's writes in place over kept padding on a guest's pages.
   In that run every round agreed (none saw a change).

   carried_store_failures: a class's failure of an access whose rounds store (renders: the pass's
   clear and store, and the draw; storage writes and buffer writes: the kernel's stores), where
   that class's reads of those row ends passed (so the failure is the stores', not the first
   move's), fails the other classes' passes of that access and row ends. The line write-back
   belongs to the store path every class's images share; how often a class's rounds see it does
   not. A reads failure (whether the GPU sees the CPU's bytes depends on the class's mapping and
   import), an unchecked verdict and a class whose pages could not be made carry nowhere. Each
   carried failure is noted. To change no verdict a texture already took, the check now gives
   its verdicts together once every class is done, not per class.

2. A 19 s check. Bytes::matches compared the window byte by byte: 2.7 s for each round of the
   3840x2160 surface over the dma-buf pages (the fill took 4 ms). It now compares each period
   whole first (slice equality, in wide loads) and looks for the byte only where one differs; a
   cleared row's texels likewise, a chunk of zeros at a time.

CHECK_VERSION stays 9 (the commit before, not yet released).

Docs: the module's verdicts paragraph and run's, API.md's in-place check paragraph.

Test: a_store_failure_fails_the_other_classes_passes_and_nothing_else_carries (tests/in_place.rs),
the Iris's verdicts of the flaky run: the dma-buf class's pass of storage writes inside lines
alone fails, as the pointer class's failure; a failure of the dma-buf class's own carries to the
others; reads failures, an unchecked verdict and a store failure of a class whose reads failed
carry nowhere.

Verified: pending (the unit test with and without the rule, the Iris check time and verdicts in
release, the device test repeated, the 780M and lavapipe verdicts against development's).

(cherry picked from commit f2f0e284c2b62980bbc3f1e1881e01b2c8ce9227)
2026-11-08 01:56:14 -08:00
Anees Iqbal aafecf768a In-place check: the dma-buf class's export carries the device-address flag its imports carry
On the Iris Xe (ANV, Mesa 26.2.6) the check's DmaBuf class stayed Unchecked for every access
and row end, so a guest's surfaces over dma-buf pages took the shadow (the reims guest counted 756
of 786 shadows there). ExportedPages::make exported its pages fine, but their no-copy buffer was
refused (Unsupported, HostMemory, NotRepresentable) both pointer-first and dma-buf-only (probe
job 7595), so the class had no pages to check.

The cause, measured by a matrix of exports and imports of a dma-buf of the device's own memory
(probe job 7667, every host-visible type, 1, 2, 5 and 6, against every other, each with and
without VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT): ANV takes the import exactly where its
device-address flag matches the allocation's, and refuses it with
VK_ERROR_INVALID_EXTERNAL_HANDLE where it differs, whatever the memory types. The export was
allocated without the flag; import_dma_buf imports a buffer's dma-buf with it (bufferDeviceAddress
is enabled there), and every block of the runtime's own carries it (BlockMaker::make_as).

- ExportedPages::make allocates with the device-address flag where the device enables
  bufferDeviceAddress, as every allocation of the runtime's does.
- import_dma_buf gives an image's dedicated import the flag too, so every import of one dma-buf
  (the check's buffer and its textures' images share one) and the device's own allocation of it
  agree.
- ExportedPages::make takes a host-cached type first, system memory before device-local: on the
  Iris every host-visible type is device-local, so the old rule (cached system memory, else
  system memory, else the first) took type 1, which is uncached, and the whole check took 19.0 s
  there (job 7667). RADV and NVIDIA, whose cached types are system memory, keep the type they
  had.
- CHECK_VERSION 9: a record of 8 holds the DmaBuf class unchecked on ANV, which the check now
  answers.
- The check's device test (the_in_place_check_imports_its_dma_buf_pages_as_dma_bufs) passed where
  the device exported pages it then refused to import, as "exports no dma-buf pages"; such a
  refusal now fails it. Before this fix that is what the Iris did (job 7595: both imports
  refused).
- The module doc no longer says ANV takes its own mapped allocation's pointer: lavapipe does
  (job 7573), ANV refuses it (job 7667).

Verified with the flag fix alone (job 7667, ms01 Iris, release --cfg m2v_gpu at the probe tree
c2e854b698): the device test passed, with "pointer-first import over the dma-buf true, dma-buf-only
true; the DmaBuf verdicts [Passed, Failed, Failed, Passed, Passed, Passed, Passed, Passed]" (rows
inside lines: reads, renders, writes, buffer writes; then rows on lines) and the guest's 234x18
BGRA8Unorm texture at 1024-byte rows in place. A fresh check answered DmaBuf as Fresh and Pointer
answer (renders and writes Failed only for rows inside lines). The cached type and the test's
refusal check: pending (next Iris run).

(cherry picked from commit 8bbc7686c038ae7ca309361aced2219e434f5d1c)
2026-11-08 01:56:14 -08:00
Anees Iqbal 5afaff4b8e Bump RUNTIME_VERSION to 1880: 1- and 2-byte texels a shader writes lie in place where their own check verdict passed
inplace narrow stores: Access::NarrowWrites and NarrowBufferWrites, checked apart by the device's in-place
check (CHECK_VERSION 9, 36 verdicts), so R8/A8/RG8/R16 textures a shader writes over host pages are no
longer shadows by store width (the guest had 23 such textures). A narrow failure never fails the wider
verdicts. Verified by inplace on the M3: 44/44 (7736), clippy m2v_gpu (7726); check time in release
0.36-0.77 s base against 0.37-0.45 s tip (7773), narrow rounds 9 ms of a 289 ms check. MoltenVK refuses a
256 pitch for these textures, so the in-place half awaits lavapipe and the 780M (gem10 7728/7729).
2026-11-08 01:48:23 -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 b98968ca40 Narrow writes device test: the host words through as_chunks, as clippy asks of a constant chunk size
clippy (--cfg m2v_gpu, the M3's job m3-max-7723) refused chunks_exact(4) with a constant size.

Verified: the M3's clippy of the runtime reruns next.
(cherry picked from commit 7f60624041671d7a0d8d5888003a5555f267f938)
2026-11-08 01:47:32 -08:00
Anees Iqbal 4cf73e595c Placement test: an R8Unorm texture a shader writes takes the narrow check's verdict, not the store-width shadow
the_answer_is_the_route_the_texture_takes made an R8Unorm texture a shader writes and required
Shadow(StoreWidth { texel_bytes: 1 }). The device's check now stores 1-byte texels, so the M3
(job m3-max-7687) answered InPlace there, and the test failed. The case now works out the
texture's row ends and padding and the narrow writes check of them (Access::written), and
requires the answer that verdict gives: in place, or refused by the image, where it passed; the
shadow naming the failed or unchecked writes check where it did not; Pending while pending.
made_as_asked still requires the texture made to match the answer.

Verified: cargo fmt; the M3 run follows.
(cherry picked from commit ef07355d5f25ffb3e158fdfb1ac2fc5d2695dc78)
2026-11-08 01:47:32 -08:00
Anees Iqbal d7b3dba9d4 In-place check test: name RuntimeDriverDefect where the Linux-only dma-buf test reads it
The import served only the_in_place_check_imports_its_dma_buf_pages_as_dma_bufs, which is
cfg(target_os = "linux"), so the macOS build of the runtime's device tests (--cfg m2v_gpu)
warned that it was unused. Warnings are errors in clippy. The test now names the type by its
path, and the import is gone.

Verified: the M3's --cfg m2v_gpu test build (job m3-max-7676) printed the warning before this
change; the rebuild follows in the M3 run.

(cherry picked from commit 568d5b3bb6abf2af449c670b51661c0c0d4fae30)
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 f1a1758046 In-place check test: count the Fresh verdicts from the accesses and row ends, not a fixed 6
the_in_place_check_checks_fresh_pages_where_held_imports_cost_submissions compares a device's
Fresh verdicts (each access for each row ends) with all-unchecked where the device lays no long
buffer in fresh pages. It wrote that as [Unchecked; 6], the count from when three accesses
existed (532fc35b7a). Since BufferWrites there are 8, and with the narrow accesses 12, so that
branch could never pass. The count now comes from RowEnds::ALL and Access::ALL. The DmaBuf test's
printed legend names the narrow accesses too.

Verified: cargo fmt; the test runs in the device jobs that follow (lavapipe, M3, Radeon 780M).
(cherry picked from commit 8c28280b17d260effe202cc90fb0f2353b9889d6)
2026-11-08 01:47:32 -08:00
Anees Iqbal 31db5c6b13 In-place check docs: wrap the narrow rounds' paragraph, naming NarrowBufferWrites with BufferWrites
Two lines of the module docs ran past 100 columns after the narrow rounds were added; rewrapped,
and the free-padding verdicts name the narrow form beside the wide one.

Verified: cargo fmt; no line of in_place_check.rs passes 100 columns.
(cherry picked from commit 47b865ab1de2318db21192d724062d1fee27f9f4)
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 c35d95b08f Shadow kernels: views of 1- and 2-byte texels (R8_UINT, R16_UINT), a word per texel
The device's in-place check stores every texel of an image a shader writes through the
crate-owned copy-in kernel (Texture::store_in_place), whose views covered texels of 4, 8 and 16
bytes alone, so a texture of 1- or 2-byte texels that a shader writes (R8Unorm, A8Unorm, RG8,
R16) had no check of its writes and stayed a shadow (host_texture_shadows_store_width: 114 in a
guest session on the Iris Xe and on the Radeon 780M, 23 distinct R8, A8 and R16 textures). This
gives the check a kernel that stores such texels.

ShadowTexelView gains R8Uint and R16Uint (storage formats R8ui and R16ui, extended formats like
Rg32ui). A narrow texel takes a whole word of every shadow kernel's word buffers, its bits low and
zero above them, as an unsigned fetch returns it: words() is 1, so every module's addressing is
unchanged. The copy-in kernel keeps the word's low byte or bytes for the texel it stores and the
word it keeps alike (a stored value its format represents, and a kept word a fetch reads back
equal); copy back and the merges move the fetched word as for any one-word view. Such a view's
kernels move narrow texels through buffers of a word per texel, never through a narrow texture's
own rows, whose texels share their words: the runtime's shadows keep picking views of 4, 8 and 16
bytes alone (shadow_copy_back::word_format), and the kept images' formats name the two new views
for exhaustiveness. ShadowMergeRead::ALL lists their word reads; api_signatures.tsv follows.

Tests: the copy-in, copy-back and image-merge interpreter tests run through every view, a narrow
view's image texel x + 0x1d * y in its bits so its rows differ; the copy-in validity test skips
the three extended views where a profile lacks the formats; owned_divisions builds every view.

Verified: pending (the translator's unit tests and the runtime build run in the stacked checks).
(cherry picked from commit c1ebd43750bce173bb0e6ab3c16cb5696718bfbd)
2026-11-08 01:47:31 -08:00
Anees Iqbal 9be2070082 Bump RUNTIME_VERSION to 1879: a reader of its pass's color is weighed by the coverage it measured in its last pass
amdperf-32: the snapshot-or-split choice for a draw that reads its pass's color now follows that
reader's coverage, measured by an occlusion query in its last pass (readers only, no query inside an
app's counting visibility query or an instance of views), with up to 16 spare query pools a device.
New WorkCounts: reading_draws_by_coverage, coverage_queries, coverage_pools_made. Verified by amdperf:
tests::learned_coverage and the reader tests 41/41 on the Iris (7575), XTX (7578), 780M (um870 7628),
lavapipe (7727) and the M3 (7584); clippy x3 and rustdoc on gem10 7576. Cost: lavapipe +37
instructions a draw (0.11%); query cost 1.00-1.06 Iris, 1.00-1.01 780M, 1.00-1.08 XTX. Crossover against
pre-amdperf-30: Iris learned sparse rows 0.37-0.85, self_reads 3662x2039 11.10 -> 1.74 ms; XTX 0.68-1.05;
780M dense 1.00, self_reads 9.57 -> 2.33 ms.
2026-11-08 01:42:30 -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 1d2905c787 Hold a pass's reader state behind one pointer, allocated at its first reader
A pass without readers of its own colors now keeps a null pointer for them instead of the
state's vectors and options, so the lowering of every pass grows by one word. lavapipe's
frame_costs_plain (job 7482) counted 30 more instructions at a pass's opening, 66 at a draw and
59 at a pass's end for the build before, against the build without learned coverage.

(cherry picked from commit b3d187f0ced28dc3a67dc72e0f5ddf46b6eeb271)
2026-11-08 01:41:30 -08:00
Anees Iqbal a06c5f123c Keep a device's coverage query pools as spares instead of one made and released a pass
The Iris Xe A/B (job 7439) put the coverage queries at about 15% of the GPU time of
snapshot_crossover's private passes, with the same forms as the build before (q scratch against
ctl, and tip against ctl where they took the same form), while the area lane (one command buffer
a frame, waited for) showed 0.2-0.5% and self_reads 2%. The crossover commits four command
buffers back to back, so each pass's pool was released while the next pass ran on the GPU.

A device now keeps up to 16 pools no pass holds (render/coverage.rs SparePools): a pass that
measures a reader takes one, reset on the host, and gives it back as its command buffer
completes; a pass makes one only where none has come back. Released as the device ends.
Counted: WorkCounts::coverage_pools_made; tests::learned_coverage asserts at most two pools over
its seven passes.

(cherry picked from commit f1e328796c8218553c5834e4044a71bdebaf9be5)
2026-11-08 01:41:30 -08:00
Anees Iqbal 853e4cb37b Fix the coverage build: one Texture::root, the replay's readers, read only the measured queries
The view shadow's Texture::root already walks a view to the texture it was made from; the copy
in texture.rs duplicated it. The replay lowering (render/executions.rs) builds a RenderLowering
of its own and now starts with no readers. Readback reads the results of the queries its
readers took, the pool's first ones, not all 64.

(cherry picked from commit 599984b2e727c986e50ec59bd0f83dea63a3cc61)
2026-11-08 01:41:30 -08:00
Anees Iqbal 3f5c8bfa27 Record no coverage query in an instance of views
A precise occlusion query begun in a subpass with a view mask uses one query of the pool for
each view (VUID-vkCmdBeginQuery-query-00808), which would overlap the next reader's query. The
snapshot path refuses passes of more than one layer, so no measured reader draws views today;
the filter makes the query's recording not depend on that.

(cherry picked from commit d7b0e5652610fb46d5288d53e7c514c8258860cf)
2026-11-08 01:41:30 -08:00
Anees Iqbal 26d00a396c Weigh a reader of its pass's color by what it covered in its last measured pass
The area rule weighs a reader through no scissor at the share least favourable to each form,
since a draw's recording cannot know what it covers. A 1280x720 or 1080p reader covering the
whole target therefore took the snapshot, 1.97-2.34x the split's GPU time on the Radeon 780M,
while the consumer's readers over 3% of a 3662x2039 target need the snapshot (Iris 12.8 ->
1.7 ms a frame). Both shapes weigh the same at recording, so no static rule serves both.

Now, on a device with occlusionQueryPrecise that resets queries on the host, each reader the
rule would weigh records its drawing commands inside a precise occlusion query of its pass's
own pool (render/coverage.rs). As the command buffer completes, the count is kept on the
reader's first color's texture, keyed by the pipeline state and the reader's place among that
state's readers of the texture in the pass. Later passes weigh that reader at its count: the
snapshot where SNAPSHOT_PIXEL_COST per covered pixel per color costs no more than the split's
copy. A device without precise queries or host reset, a reader inside an app's visibility
query (already refused the snapshot), a pending pipeline's draw and a replay record no query
and keep the area rule. Instances recorded inline after a split keep the query's begin and end
with their draws. Both forms are exact; a stale count costs the form it chose until a pass
after the change completes.

Counted: WorkCounts::coverage_queries and reading_draws_by_coverage. The crossover lane runs
each cell once untimed so its timed frame is weighed by the learned count.

Tests: tests::learned_coverage (forms and bytes across a sparse -> whole -> sparse change;
an app's Counting visibility query keeps its count with a reader inside), coverage unit tests.

(cherry picked from commit 1108cd1bdebfb15f9da91b39ed80d91d8624bc28)
2026-11-08 01:41:29 -08:00
Anees Iqbal a335824604 Record host_copy_blocks_readied in indirect-mesh-commands-object-threadgroup-lengths
wake's readied host-copy blocks (20038c5c45) added WorkCounts::host_copy_blocks_readied:
a block for color host-copy images made ready off the program's thread. The case's first
host-copy texture now lands in a readied block (1); its record predates the count, so the
replay held it to 0 (round at 9bd38c7994, m3-max-7680: that case, that field alone over
bounds; 35333 counts gated within bounds otherwise). Recorded on the M3 at 12b73cfe04 (s37-pl.sh
record: the whole-set write, every other record put back, then cost --alone --write and
times over the one case). Records outside it touched: 0.

(cherry picked from commit 322a3752ecc68396fcccd92152ee05d2f53fae0d)
2026-11-08 01:30:33 -08:00
Anees Iqbal 1c4c445111 Bump RUNTIME_VERSION to 1878: every pipeline making registers the exit hook again once its driver call returns
The exit hook now runs ahead of the destructor of anything a returned pipeline making registered (a static
of the driver's compiler, or a library loaded at its first compile), and it still waits for makings in
progress. This closes the NVIDIA exit-time crash in the driver's SPIR-V compiler racing teardown.
Verified by perdraw: fork tests with a negative control on msi 7686 (43 vs 42 with the registration
removed, pass restored), and the exits lane making_exit case 10/10 on the M3 (7685, 7695: pool_busy=1,
at_makings=1, clean exits in 18-22 ms) and 10/10 on lavapipe (7686). Clippy in three cfgs and rustdoc on
7686. A 5080 entry is queued.
2026-11-08 01:30:29 -08:00
Anees Iqbal 91bedcf4a8 exits lane: making_exit says its pool's pieces and the hook's registrations as it exits
The parent prints the child's line and holds it to a registration after a making:
the evidence that the program's thread's making registered the hook again, and
whether the pool's making was still in progress at the exit (pool_busy).

Verified: cargo fmt only locally.
(cherry picked from commit 37637be4d47b303840e65c810997f582bb31b8ff)
2026-11-08 01:29:28 -08:00
Anees Iqbal 5f6bd96ec9 exits lane: bring AirLibrary into scope for making_exit's library
The msi build (m3-max-7675, 7684) failed: new_library_with_air is the lane's
AirLibrary trait's.

Verified: cargo fmt only locally.
(cherry picked from commit b03288d9c38231e2a1106d0e958d9a16b82c9198)
2026-11-08 01:29:28 -08:00
Anees Iqbal 9f01e3ce07 Register the exit hook again after every pipeline making's driver call
A consumer's 5080 run (reims-vgpu job 7350, at 0e420a1834): a runtime test printed
'test result: ok', then its process ended with SIGSEGV at 0x18 inside
libnvidia-glvkspirv.so during exit, on a thread the test's had started; alone it
passes 3/3. The hook waits for makings in sections (up to MAKING_BOUND), so the
compile it found running had lost a static of the driver's compiler to a
destructor that ran before the hook: one registered after the hook's last
registration, by a making (a static made at a compiler path's first use, or a
compiler the driver loads only at its first compile). Sections registered again
only after an entry point's first call and at powers of two, and the program's own
makings never.

Each vkCreate*Pipelines the runtime makes goes through device/compiles.rs's routed
entry points (every platform); each now calls exit_guard::pipelines_made after the
driver's call returns, which registers the hook again where it is registered in
this process and the guard is open (counted in Registrations::at_makings). So every
destructor a making that returned registered runs after the hook, which waits for
the makings in progress. A making takes milliseconds to seconds; one more entry in
the C library's exit list (32 bytes) per making is nothing beside it. The hole left:
a static first made by the making in progress as the exit begins.

Tests:
- exit_guard: a_pipeline_making_that_returned_registers_the_hook_again (a destructor
  registered inside the making runs after the hook) and
  an_exit_mid_making_waits_for_it_before_an_earlier_making_s_destructor (a forked
  child exits while a pool-style making is in progress, an earlier making's
  destructor registered; it must see the making ended). Both read 43 without the
  registration.
- exits lane: making_exit / an_exit_mid_making_is_clean: a state made on the
  program's thread, then a dispatch whose region's making goes to the pool, both of
  opcodes from the clock so the driver compiles them, and an exit at once.
- devices_made_again_register_the_exit_hook_no_more: the sections' bound check
  leaves the makings' registrations aside.

Verified: cargo fmt only locally; builds, clippy and tests are potluck jobs.
(cherry picked from commit 6368538b94a9fc607f926d2856b504e7f0c770a7)
2026-11-08 01:29:28 -08:00
Anees Iqbal 96ba9a104c The unshared-queue test bursts on until a choice withholds a join
tests::queue_share_device::no_queue_joins_an_unshared_queue_s_vk_queue_and_
one_placed_there_leaves asserts that, where the device shares VkQueues, at
least one of the choices its three other queues make after the unshared
queue's 16 bursts withheld a join from the unshared queue's VkQueue
(WorkCounts::joins_withheld_from_unshared), so that its check that no
queue landed there is not empty. A choice withholds one only while that
VkQueue is busy and its oldest batch young (queue_share.rs), which a choice
made right after a burst finds unless the host comes back late: each burst
is 24 command buffers of a 1 MiB fill, done on the RTX 5080 within some
tens of microseconds. On a development round's RTX 5080 suite partition
(dv-rt1-221823, at 7e9acd5e73) none of the 48 choices withheld one, and
the test failed at its assertion.

The test now goes on bursting past the 16, where the device shares, until
a choice withheld a join, for at most its WAIT (20 s), and prints the
bursts and the choices' counts. Nothing else changes.

Verified, RTX 5080, entry holds-holds-unshared-1-010148 (c, beside a
development lane), eight copies of the test at once for 5 min each:
- development's test with the counts printed (scratch, 16 bursts): 72 of
  72 passed; in each Adaptive leg every choice either withheld a join or
  found no other VkQueue busy (the burst seen complete before it),
  withheld 1 to 42 of the 48, the least 1 against 47 found idle: the
  choices that withhold none find the burst done, the failure's case, not
  a busy VkQueue passed over unseen.
- this change: 80 of 80 passed, each within the 16 bursts there (withheld
  3 to 44 of 48), so the longer run is taken only where a choice missed
  them all.
- its build under --cfg m2v_gpu: no warning (msi, m3-max-7629).

(cherry picked from commit 0af88b819edb4977a9a67911bfd0dbb3d9e859d3)
2026-11-08 01:16:06 -08:00
Anees Iqbal 3738986cb0 Bump RUNTIME_VERSION to 1877: in-place images take the usages their textures lack; a declaration that the bytes between rows are unobserved
selfread stack (7 commits): the in-place check imports the dma-buf class's
pages only as their dma-buf (CHECK_VERSION 8); an in-place image takes the
storage or attachment usage its texture lacks where the check passed for
what they reach, so an undeclared kernel write or render pass reaches the
texels in place with no copy; the shadow notice names in-place images;
lane rows for the guest's 3664x2039 surface at 256-byte and 16-px pitches.

selfread unobserved2: BufferDescriptor::padding_unobserved (refused with
no-copy contents, Invalid(PaddingUnobservedNoCopy)): a texture over such a
runtime-owned buffer lies in place where only the bytes between its rows
(and slices) could change; TextureShadowReason::BytesBetweenRows where it
may not; WorkCounts::unobserved_padding_aliases. For the consumer's device
cache (780M desktop surface, ~1 G texels/s of shadow copies in a drag).

Evidence for the stack (at base edde5779b1, same patches): gem10 7573
clippy cpuicd/gpucfg and rustdoc clean, lavapipe 283/285 with both failures
fixed (ed7f182441, cb4dfa3bbe); Iris 7635 in_place_textures 8/8,
IN-PLACE-USAGE in place with 0 texels copied in for kernel and pass at
1024/512-byte rows (shadows before, 7387); in place vs shadow 31.0 vs
1019.9 us (3840x2160 top 32 rows). The declaration: fmt and generators
only; build, clippy, lavapipe and the 780M lane pending (gem10 7652, M3
7653). The Iris DmaBuf class stays Unchecked (its import is refused;
separate fix).
2026-11-08 01:12:47 -08:00
Anees Iqbal b136c2531a Buffers: a declaration that the bytes between a texture's rows are unobserved
A consumer's cache buffer of the runtime's own memory (the 780M guest's 3662x2038 desktop
surface, more guest-page pieces than udmabuf takes) holds textures whose rows lie 14848 bytes
apart, 14648 bytes of texels each. linear_plan::holding shadows every such texture, since an image
at that pitch holds the bytes between rows and Vulkan lets its layout moves and a render pass's
load and store write them; the consumer's download copies each row's texels alone, so it never
reads those bytes, and the shadow's copies cost it about 1 G texels/s in a Finder drag.

BufferDescriptor::padding_unobserved (with_padding_unobserved) is the maker's declaration that
nothing reads the bytes between a texture's rows over the buffer (each row's bytes after its
texels to its pitch, the last row's included) nor between its slices. A runtime extension with
no Metal counterpart, only for the runtime's own memory: refused, Invalid
(PaddingUnobservedNoCopy), with NoCopy contents. The buffer keeps it (Buffer::padding_unobserved).

- The route (texture/route.rs) decides it for a buffer of the device's own memory:
  Route::Device { holds } carries linear_plan::holding's answer, which with the declaration
  holds rows and slices that lie apart (rows that share bytes stay refused). The making and the
  placement query share it: the query answers NotHostPages where an image may hold the texels,
  and the new TextureShadowReason::BytesBetweenRows where it may not (it answered NotHostPages
  for both before).
- aliases takes the declaration: the image's subresources may then hold the padding
  (linear_plan::within_padding: each subresource ends at its slice's last row's pitch or before,
  slices at Metal's stride), never a byte past the last row's pitch, nor memory past the
  buffer's. A byte of the image's memory past every subresource is reached by no operation on
  it, the reading texels_alone already rests on, so no new check class is needed.
- WorkCounts::unobserved_padding_aliases counts the aliasing images that hold such bytes.
- A buffer the runtime lays in fresh pages (a long one where pointer imports cost submissions
  nothing) keeps the in-place check's route: the declaration lets nothing more there (documented).

Docs: the field and builder, NotHostPages and BytesBetweenRows, HOWTO's paragraph on textures
over the runtime's own memory, API.md's shadow reasons and placement answers, the runtime
README; REFUSALS.md and api_signatures.tsv regenerated.

Tests: linear_plan's unit tests of the declared holding and aliasing (padding to the last row's
pitch held, past it or past the buffer refused, slices at Metal's stride alone, shared rows
refused); the route's placement test of both Route::Device answers; a device test
(tests/padding_unobserved.rs): a 101x48 BGRA8Unorm texture at 416, 448 and 512 bytes a row over
an undeclared buffer answers Shadow(BytesBetweenRows) and is a shadow, over a declared one answers
NotHostPages and is an aliasing image wherever the device lays one at the pitch (counted), at
least one pitch aliasing, its texels read back by a blit; and the declaration refused over the
caller's memory. The in-place lane's unobserved_padding_costs times a frame reading the
consumer's surface shape over a declared and an undeclared buffer.

Verified: pending (lavapipe and MoltenVK device tests, the 780M lane run next).
(cherry picked from commit 430523ce0e4dbd8433eb2b514f837d44ce1c5a9a)
2026-11-08 01:11:45 -08:00
Anees Iqbal 9fdf288419 In-place check test: lavapipe makes no dma-buf image of the shapes whose rows end inside lines
the_in_place_check_imports_its_dma_buf_pages_as_dma_bufs asserted the DmaBuf class's reads
answered for both row ends. On lavapipe (job 7573, llvmpipe of LLVM 23.1.4) the verdicts read
[Unchecked x4, Passed x4]: rows on lines Passed, rows inside lines Unchecked. The cause is
RuntimeDriverDefect::ExplicitPlaneRowsPastHeight: lavapipe renders an explicit
DRM_FORMAT_MOD_LINEAR plane's rows past its height, so dma_buf_image_unbound makes no such image
of a height that is no multiple of 4 (explicit_plane_rows), and every one of SHAPES whose rows
end inside lines has such a height (37, 29, 50, 17, 9, 51). The check rightly leaves the class
unchecked there; the product makes none of those images either.

The test now skips the rows-inside-lines verdict where the device has that defect, and its doc
says why.

Verified: pending (the stacked lavapipe run next).
(cherry picked from commit ed7f1824417145e6a7fe38f957fe1870e1bccee5)
2026-11-08 01:11:45 -08:00
Anees Iqbal 2194a99493 In place: count a usage set's members by its raw bits
The commit that gave in-place images the usages their descriptor lacks sorted the sets of them by
`set.bits()`, a method Metal's option sets (`metal_flags!`) do not have, so the runtime did not
build from it. The sets are sorted by how many usages each holds, most first: `as_raw()`'s bits,
counted.

Verified: the stacked checks dispatched next build it (clippy in both cfgs, rustdoc, lavapipe
tests); job 7532 at the commit before failed on this alone (E0599 at in_place_image.rs:471).

(cherry picked from commit 58aabe1d8f9cf6b5bec95bd546cfade7da468b81)
2026-11-08 01:11:45 -08:00
Anees Iqbal d9e1c2177d In place: writes_reach asks the padding's writes check again, not an unbound render flag
The commit that named in-place images in the shadow notice changed writes_reach's match to
`(texels.padding(line), renders)`, a name not bound in that function, so the runtime did not
compile from it on. writes_reach asks for a texture that does not render (its caller returns
before it for one that does), so its writes check is the padding's alone: BufferWrites where the
rows' padding is free, Writes where it is kept, as the commit before had it.

Verified: the stacked checks dispatched next build it (clippy in both cfgs, rustdoc, lavapipe
tests).

(cherry picked from commit e2edab712370a460b6c9049ae815211cd9ba7b7e)
2026-11-08 01:11:45 -08:00
Anees Iqbal c813bb74fc In-place lane: the guest's 3664x2039 surface at a 256-byte pitch and at its 16-pixel one
What: runtime_lane::in_place_textures::the_guests_surface_lies_in_place_where_its_checks_passed.
A 3664x2039 BGRA8Unorm texture over a no-copy buffer of anonymous pages, at 14848-byte rows (the
next multiple of 256, at which RADV lays linear rows) and at 14656, of ShaderRead usage, with
RenderTarget, and with ShaderWrite. Each is in place only where the device's check passed for its
access and row ends; where it passed, in place or refused by the device's image (counted in
host_texture_shadows_refused_*). A blit reads the pages' texels through it, a pass clears and
stores it, or a kernel writes every texel; the pages then hold those texels, and the bytes between
the rows and past the last hold the pattern but free padding under a shader's writes. It prints
the placement query's answer, the path, the verdict and the refusals (IN-PLACE-SURFACE).

Why: reims pads the guest's pitches to 256 bytes so that RADV (780M) takes the surface in place;
this shows our side takes it the moment the padding ships, and the 14656 case shows what RADV
refuses today.

Verified: pending (the 780M run follows the dma-buf and narrow-store work).
(cherry picked from commit e7efd8b90cfc584f3e327fbd89243f235b9a8d3e)
2026-11-08 01:11:44 -08:00