Commit Graph
3208 Commits
Author SHA1 Message Date
Anees Iqbal 2daafe221e Memory: plain blocks made smaller where their making is slow
On RADV a block of plain memory (allocated with no export: the blocks of images, of heaps, of
buffers that declare their padding unobserved) shares the reservation of the process's buffer
objects, and its vkAllocateMemory holds every submission of the process while the kernel fills
its pages. On a Radeon 780M with the kernel's page pools empty, a 64 MiB block took 8.9 to 9.6 ms
at the median on a quiet host and up to 23.1 ms (slowest 30.4 ms) with its free memory in single
pages, and a texture made every frame left 13 to 33 turnarounds of 8 ms or more a phase (the
slowest 42.3 ms).

Now a making of such a block that took longer than MAKING_BOUND (8 ms, half a frame at 60 Hz)
makes the device's later pooled blocks of plain memory the largest power of two that making's
rate makes within the bound, at least 16 MiB (Memory::plain_block_made); a placement larger than
such a block takes a pooled block of the power of two that holds it (up to half of BLOCK_BYTES,
past which it is dedicated as before). The size is never made larger again. Exportable blocks
keep 64 MiB: each is a buffer object of its own reservation, whose making holds nothing.

Each made Block records how long its making took (Block::took, zero for imports); add_block
feeds the plain ones to plain_block_made. place, keep_room, ready_if_growing, ready_ahead and
sweep_stale size a pool's blocks through pooled_bytes, and add_ready takes the size of the block
it adds.

tests::plain_blocks: the size rule and the pooled block sizes on the bookkeeping alone, and on a
device told of a slow making, 1 MiB textures in 16 MiB blocks and 20 MiB ones in 32 MiB blocks.
tests::reclaim_submit_bench: an images arm (a 1024x1024 texture a frame) and a mixed one (with
2560x1440 and 3840x2160 textures), the blocks of images made, pooled and dedicated, and the plain
block size reached.

(cherry picked from commit 0bec0583b042c1f2c05b98e97d080e6426d13619)
2026-11-09 12:29:02 -08:00
Anees Iqbal c6243bbd5e blocks_ahead: the hurried-making test holds a use of the queues open
The test of a creation call that cuts a making's wait for quiet short kept the device's queues
in use with three threads that each committed a one-word fill and waited for it. A making's wait
reads the holds of the device's queue locks (device/queue_quiet.rs), not the GPU's work, so a
pause of 1 ms between two of those threads' submissions ends it; on a loaded host the threads
leave such pauses, each making's wait ended before a call needed its block, and the test gave
up after three makings it waited for with none hurried. Pin 30's 5080 runtime half 1 (run
beside half 2) failed so: 0 hurried, 3 made ahead, 28.35 ms at the longest.

Now the test holds one use open (QueueQuiet::began, ended as its guard drops) from before its
first creation, so nothing but the bound (QUIET_MOST) ends a making's wait, and settles the
device's submission checks first, as the first test does, so that no creation call in it makes
the first block of a pool of the runtime's own pages. It stops at the first making a call
hurried, or after three whose wait reached its bound, which only a host slower than 50 ms over
the few creation calls between a making's start and its block's need reaches; it prints those
and the makings waited for.

The exportable pools made ahead (9e663b770c) are not a factor: the test makes no exportable
buffer, so no pool of them grows and that commit's makings never start, and the old test at its
parent failed the same way under load (below).

Verified (debug, --cfg m2v_gpu; load = a busy loop on each of 16 logical CPUs, or four runners
of the whole runtime suite, each test alone):
- Radeon 780M (RADV PHOENIX, Mesa 26.2.6, gem10, MESA_VK_DEVICE_SELECT '1002:15bf!'; job
  m3-max-12248): this test 3 of 3 alone, 10 of 10 under the busy loops, 8 of 8 beside the suite,
  each run 1 making hurried, 0 past its wait, creation calls 2.4 ms at the longest. The old test
  at 9e663b770c's parent failed 1 of 10 under the busy loops (0 hurried, 3 made ahead), and at
  development passed 10 of 10 and 8 of 8. Negative control, ready.rs's wait for quiet ended by
  STOP alone rather than by a call's wait: 0 of 3 (0 hurried, 3 past their wait, 49.6 to
  59.3 ms).
- lavapipe (llvmpipe, LLVM 23.1.4) under --cfg m2v_cpu_icd (job m3-max-12250): 2 of 2 alone,
  10 of 10 under the busy loops; the negative 0 of 2.

Correction at landing: the creation calls took 2.4 ms at the longest in every run but one, an
otherwise idle host's, at 8.0 ms. RTX 5080 (b5080 nvreds-ahead-5080-120327): the new test 3/3
alone, 20/20 beside a suite, 10/10 under busy loops; the old test failed 10 of 20 beside a
suite there (0 hurried, 3 made ahead).
(cherry picked from commit 3691633773)
2026-11-09 12:26:07 -08:00
Anees Iqbal 9b00cd81d6 RUNTIME_VERSION 1983 and the runtime-sources pin for listed plans that ask the driver first
77f336e98c changes the runtime's guest RAM: run-list imports consult the device's remembered
dma-buf refusal (and remember the driver's own refusal of a list), and a use whose plan would be
listed first asks the driver with one page of the RAM (Device::ram_takes_dma_bufs), listing only
where the driver took it, so a taxed NVIDIA keeps 64 MiB chunks by pointer. The host_ram_dma_buf
tests force the tax held and read the plan the device chose. Pin 30's 5080 red
copies_over_a_listed_ram_make_no_untouched_page_of_it_resident was this.

Verified by the branch: RTX 5080 (b5080 exitcrash-follow-112525) dma-buf module 10/10 twice, the
driver refusing the use's question for real; the old tests with the tax forced held fail 3 of 4
there; gem10 lavapipe 12205 (suite 2007/2007, clippy x3, rustdoc), 12213 fast_paths/docs 27/27;
780M 12209 module 10/10 twice (listed, run lists used). Negative controls for each part fail.
Here: signatures --check, REFUSALS and coverage docs regenerated, fmt.
2026-11-09 11:40:32 -08:00
Anees Iqbal 7d17fb1882 Guest RAM: a refused dma-buf keeps run lists and listed plans off the driver
Three follow-ups to remembering a driver's refusal of a guest RAM's dma-buf
(3fe18c4efd):

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

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

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

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

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

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

(cherry picked from commit 77f336e98c2a31aa56e45c5eb7659fa28f6f3ad6)
2026-11-09 11:39:45 -08:00
Anees Iqbal 0d45d4f9d5 RUNTIME_VERSION 1982 and the runtime-sources pin for a kernel end stamped at the submit call
58e674d802 changes the runtime's kernelEndTime: the host time read right before the last batch's
vkQueueSubmit is called, not after it returned. Pin 30's lavapipe replay (6efa9fe7b9, beside the
suites' load) read gpu-ends-no-earlier-than-the-kernel false once: a scheduler thread parked after
the call let the GPU finish before the stamp. Exact 10/10 alone (gem10 12182).

Verified by the branch: kernel_end_device's paused-scheduler test 12/12 on lavapipe (gem10 12184:
suite 2003/2003, clippy x3, rustdoc), its negative control failing (GPU end 199.6 ms before the
kernel end); M3 MoltenVK 3/3 and the gpu_time, unsubmitted, completion and command_buffer tests
82/82 (12187). Not run on NVIDIA. Here: signatures --check, REFUSALS and coverage docs regenerated,
fmt.
2026-11-09 11:11:20 -08:00
Anees Iqbal 4499666bd6 Kernel end: the host time the last batch's vkQueueSubmit was called, never after it returned
Pin 30's lavapipe replay (6efa9fe7b9, on msi beside the suites and lint) answered
command-buffer-facts' gpu-ends-no-earlier-than-the-kernel false where Metal answers true: a command
buffer's GPU end before its kernel end. The scheduler took the kernel end after Group::submit
returned (submit.rs, and group.rs for the held batches), so a driver that runs the work before the
call returns, or a scheduler thread held once it returned while the GPU ran the work, put the
kernel end past the GPU's (calibrated) end. tests/completion.rs already records an RTX 3090 whose
submission returned 57 to 64 ms after its work ran.

The time is now taken inside the submission's closure, just before raw.queue_submit, and returned
by Group::submit and submit_alone; the direct path and the group's held batches stamp their kernel
end with it, only on success. Nothing reaches the GPU before the call, so its end is never earlier.
The held-in-a-group, unsubmitted and hang paths already stamp before any submission. The start,
the GPU times' placement and the other ordering facts are unchanged; the docs of kernel_end_time,
KernelTimes and gpu_time.rs's kernel times say what the end is now.

Test: kernel_end_device::the_gpu_end_is_never_before_the_kernel_end_when_the_scheduler_pauses_after_the_call
pauses the scheduler 200 ms each time a submission returned (completion::trace::pause_after_submit,
a test stand-in under the device tests' cfg, called in submit.rs after the call) while a 1 MiB fill
runs, and asserts GPU end >= kernel end and GPU start >= kernel start over four command buffers.

(cherry picked from commit 58e674d802a70a7e5573edd900fcb96e2d9ed7ca)
2026-11-09 11:10:36 -08:00
Anees Iqbal c148f594ff RUNTIME_VERSION 1981 and the runtime-sources pin for guest RAM's remembered dma-buf refusals
a6ccb78810..abddf2d2f1 change the runtime: a guest RAM span's dma-buf that fails on a device that
imports dma-bufs is counted (WorkCounts::host_ram_dma_buf_imports_failed); a driver's refusal of
one is remembered for the device's life, so its later chunks take their pointer without asking the
source (NVIDIA refuses every udmabuf import and lets go of one descriptor each time); and an import
tax Holds short of TAX_MARGIN answers Fails for the device's life, unrecorded, as split tries
short of it do since 4acfbee03b. Pin 29's 5080 runtime half failed the route test when that
process measured the tax held (the driver refused, the pointer took it, nothing counted it).

Verified by the branch: gem10 lavapipe 12177 (suite 2004/2004, the translator's surface and
fast_paths tests, clippy x3, rustdoc; the new test fails with the remembering removed, the source
asked twice); RTX 5080 release (b5080 exitcrash-taxroute2-104522): the route test with NVIDIA's
refusal 15/15 (3 quiet, 12 loaded beside 35 host-RAM tests a loop), every loaded device measuring
the tax not held; before the fix the forced route failed 2/2 (ERROR_OUT_OF_DEVICE_MEMORY). Here:
signatures --check, REFUSALS and coverage docs regenerated, fmt.
Open: run-list imports and a RAM's Plan::listed do not consult the remembered refusal; three other
host_ram_dma_buf tests still expect dma-buf imports wherever the measured tax holds.
2026-11-09 11:06:03 -08:00
Anees Iqbal 3fe18c4efd Guest RAM: a driver's refusal of a span's dma-buf is remembered for the device's life
Counting the refusal left its cost: on a device whose import tax holds and whose driver refuses
every udmabuf (NVIDIA 615.71.09, FAST-PATHS), every guest-RAM chunk asked the source for a dma-buf,
failed vkAllocateMemory, let go of one descriptor (the driver closes the clone it was handed) and
only then took its pointer.

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

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

(cherry picked from commit abddf2d2f1ed16a5ee6407cae04f7e10dfffb736)
2026-11-09 11:05:12 -08:00
Anees Iqbal c6be8ef2d8 Submission checks' report: an import tax Holds short of its margin is named
The report showed only the Fails it answered, beside floors that may pass the bound; the flag says
the margin's rule ran (the evidence for the change before this one's path).

(cherry picked from commit deccce5b26744b591df0dc9988d4827adef30b16)
2026-11-09 11:05:12 -08:00
Anees Iqbal a7dde1cba9 where_the_import_tax_holds_a_chunk_takes_its_dma_buf_first: the report read before the force
The report printed after the force named the forced Holds beside the measured floors (lavapipe
12153: "measured not held: ... import tax Holds (0.7 ... against 0.7 us)").

(cherry picked from commit 72e91bb5df25293f1a5257ebe29ea427d01bd35c)
2026-11-09 11:05:12 -08:00
Anees Iqbal 178ace2529 where_the_import_tax_holds_a_chunk_takes_its_dma_buf_first: print the checks' report beside the measured verdict
The verdict the device measured, with its floors, is the evidence of which route its process
would have taken; the forced route no longer shows it.

(cherry picked from commit a7afbb370f689fd3d75e664099083905a3a2fd6f)
2026-11-09 11:05:12 -08:00
Anees Iqbal ee7a6e2e22 Import tax: a Holds short of its margin answers Fails for the device's life, unrecorded
A loaded process concluded a tax its quiet ones never see. On the RTX 5080 Laptop GPU (615.71.09),
the route test run 3 times quiet and 5 times beside a loop of the host-RAM and host-residency
device tests (b5080 t entry exitcrash-dmabuf-100324, probe 3f3ca70d32): every quiet device answered
Fails, 2.1 to 2.2 us a submission with the 32 imports held and without alike; the first loaded one
answered Holds from 3.4 against 1.9 us, both halves agreeing, past the 1 us bound but short of
TAX_MARGIN (2 us), and so took the routes of a taxed device (its guest RAM dma-buf first) for its
life. lavapipe's loaded Holds (1.4 against 0.2 us, in the module docs) was the same shape. The
margin already kept such answers out of the records; now a Holds short of it answers Fails, as the
taxsplit change made tries that all split short of it answer, and the next device measures again.
A Holds past the margin stands, recorded only where its repeats pass it again, as before. The taxes
the probe measured (RADV, ANV with 32 imports held) pass the bound six times over and more.

The unit test an_import_tax_holds_short_of_its_margin_answers_fails_unrecorded takes the 5080's and
lavapipe's loaded floors; without this change both answer Holds. The lavapipe case leaves
an_import_tax_holds_is_recorded_only_past_its_margin_and_repeated, which asserted the old answer.
Module docs, TAX_MARGIN's and tax_tried's docs updated; no record changes (CHECK_VERSION stays).

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

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

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

(cherry picked from commit a6ccb78810867a4d567892feee4b3b56ba1af834)
2026-11-09 11:05:12 -08:00
Anees Iqbal 8c36a3e1e5 Re-bless the authored compile census at 6efa9fe7b9
Its product fingerprint follows development's versions at 6efa9fe7b9. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit e7d054f4c02a6de837056aad659cb800e8b0a7c9)
2026-11-09 10:57:55 -08:00
Anees Iqbal 6efa9fe7b9 RUNTIME_VERSION 1980, the runtime-sources pin and the API table for recovery 1c
1c (eac07b1f9a..e64d7a7e7a, 14 commits) puts the program's host-visible buffers in blocks of the
runtime's own pages where the device's checks give them what plain blocks do (the import tax
answered Fails and the fresh pages' texture verdicts hold), and a recovery carries those blocks to
the new VkDevice, so pooled Shared and Managed buffers are no longer refused as MadeBeforeRecovery
there. While a verdict is pending, and under exact_answers' Shadow policy, plain blocks serve.

API table: two WorkCounts fields added, page_buffer_blocks_made and page_buffer_blocks_plain
(additions only; nothing a consumer used moved).

Verified by the branch at 951f9244cc (the same product code on 47e072ccd3): M3 percall gate with
holds green at base and 1c, allocs/call identical, both-orders A/B with no row past 15% in both
orders (m3-max-12032); RTX 5080 percall gate green in all four runs, allocs/call identical but one
first-run row, padding_unobserved / hand_out_waits / device_recovery_carry pass; one more pooled
block at rest (the page block beside the plain one, lavapipe 12062). Open: on the 5080
use_resource_read_write and use_resources_read_1 read x1.25 and x1.32 in both orders, unexplained;
an M3 runtime-suite window test failed once in 10 runs at 1c (hunt running). Here: signatures
blessed, REFUSALS and coverage docs regenerated, fmt.
2026-11-09 09:52:56 -08:00
Anees Iqbal 76d5571193 padding_unobserved: print where each undeclared buffer lies and the checks that decide it
On the M3 the test's undeclared Shared buffers lay in plain blocks at every pitch (m3-max-12032)
while the recovery test's pooled buffer lay in a block of the runtime's own pages. The line each
pitch prints now names the block the undeclared buffer lies in, and a line before them says
whether the device's submission check found a held import costs nothing and whether it takes
those blocks. Diagnostics only.

(cherry picked from commit e64d7a7e7aa8189f3b878299afb2268d12f66920)
2026-11-09 09:51:55 -08:00
Anees Iqbal 6083ac1e4c texture_placement_device: no block of the runtime's own pages under the exact form's policy
Under HostPageTexturePolicy::Shadow (DevicePolicy::exact_answers) no in-place check runs, so its
verdicts stay pending and in_place.rs's blocks_take never takes the blocks of the runtime's own
pages: a Shared buffer lies in the device's own memory and its texture is the device's linear
image, as before such blocks, whatever the submission checks found. The test now holds that on
its exact-policy device: the buffer in no page block, the placement NotHostPages as made, and no
page block made.

Verification: lavapipe (which takes such blocks under the default policy) in the job that
follows.

(cherry picked from commit 73a667fc42878e629ac3c6641882738cb236a302)
2026-11-09 09:51:55 -08:00
Anees Iqbal f168b9b645 RuntimeGap::MadeBeforeRecovery: what a recovery carries, as it carries it now
The variant's docs listed the events, the Private buffers and the buffers in fresh pages as all a
recovery carries, and every no-copy buffer and pooled Shared or Managed buffer among what it does
not. A recovery also carries the uses of guest RAM and the no-copy buffers (made again over the
same pages; a detached one stays refused), and, where the device takes them, the pooled buffers in
blocks of the runtime's own pages. The docs now say so, as the runtime README's recovery section
does. docs/REFUSALS.md regenerated: its row reads the variant's first sentence, unchanged.

(cherry picked from commit 5db8726121b2ff46f89b793adb3a5f354d505758)
2026-11-09 09:51:55 -08:00
Anees Iqbal 513d792675 REFUSALS: MadeBeforeRecovery's pooled buffers are those in memory the device allocated
A recovery now carries a pooled Shared or Managed buffer that lies in a block of the runtime's own
pages, so the reach note names the pooled buffers left refused as those in memory the device
allocated. docs/REFUSALS.md regenerated (scripts/refusal-surface/refusal_surface.py); no refusal
changed.

(cherry picked from commit b11909130479dbdb8c42c8d6c3950ffa1d9414ed)
2026-11-09 09:51:55 -08:00
Anees Iqbal 669e2247c7 padding_unobserved: an undeclared buffer's page block may refuse the image at the pitch
On the M3 (MoltenVK) the first pitch's undeclared Shared buffer lay in a plain block, made before
the device's submission checks answered, and the next pitch's in a block of the runtime's own
pages, whose texture's placement the test held to InPlace, Unchecked or CheckFailed. A texture
over such pages takes the host route, where the making's own steps may refuse the image at the
pitch (TextureShadowReason::Refused); over a plain block an undeclared buffer's texture is the
BytesBetweenRows shadow, so a shadow either way.

The test now settles the submission checks before it makes the buffers, so every pitch's
undeclared buffer lies where the device's buffers lie once they answered, accepts the making's
refusal there, and prints each pitch's undeclared answer, not a constant.

Verification: the M3's runtime suite follows on this commit.
(cherry picked from commit e1713ded5148bda7d727d37a8cbb08eb4b8d0bb8)
2026-11-09 09:51:54 -08:00
Anees Iqbal 2ea44c4884 keep_room: its comment on the page pools within the line width
The comment the rebase onto the in-place keep_room wrote ran a character past the 100 the tree
wraps at. Comment only.

(cherry picked from commit 1419bdca90bbc498737193596f5e509e4c4c3eca)
2026-11-09 09:51:54 -08:00
Anees Iqbal 96297c3588 Runtime README: the recovery's refused objects listed in one sentence again
The 1c change put the cases of pooled buffers in device memory between semicolons, which ran into
the list of the other refused objects. The cases go in parentheses, the list reads as before, and
the paragraph above is rewrapped. Docs only.

(cherry picked from commit 05c67001faf3253b6b184dae243bd50d94ca9fad)
2026-11-09 09:51:54 -08:00
Anees Iqbal a8515c0c9a device_recovery_carry: two pooled buffers of one block carried in one import of its pages
The carry of a pooled `Shared` buffer in a block of the runtime's own pages imports the block's
pages again once and places each buffer of the block at its own offset there. The test carried
one such buffer; it now carries two of one block and checks both keep their `contents` pointers
and bytes, the host's writes after the recovery reach the GPU, both lie in one memory on the next
generation, and both keep their offsets. Where the device takes no such blocks, both stay refused
and the notice counts two. The module docs said every pooled `Shared` buffer stays refused; they
now name the ones carried.

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

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

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

Verification: the suite follows.
(cherry picked from commit 8c50d54d9871bce0e80865ac4916e7da0c192a8a)
2026-11-09 09:51:54 -08:00
Anees Iqbal bda5799682 padding_unobserved: the undeclared buffer in a page block goes on to the declared one
The test's branch for an undeclared buffer in a block of the runtime's own
pages ended its pitch's round, so no declared buffer took an aliasing image and
the test failed at its last assertion (job 11947). It now asserts that branch
and goes on, as the other does.

Verification: the suite follows.
(cherry picked from commit fcd5dc709d45961631cd0f7bdbfd09db14e46e62)
2026-11-09 09:51:53 -08:00
Anees Iqbal 4fdeddae01 Page blocks: the tests that meet them, the recovery notice's cost, the placement docs
On lavapipe the page blocks are taken (job 11936: seven tests failed, each on
a premise they change):

- blocks_ahead: the pools of page blocks join the kept pools once the
  submission check answers, their first block made in place then; the test
  settles that check before its first creation.
- device_recovery: a Shared buffer a call made on the generation lost under it
  is carried by its maker where it lies in a page block; refused as before
  elsewhere.
- device_recovery_carry: the pooled Shared buffer is carried (contents pointer
  and bytes kept, a host write after read by the GPU) where it lies in a page
  block; a texture, which no recovery carries, holds the lost VkDevice instead.
  The notice's counts follow.
- exported_textures, padding_unobserved, texture_placement_device: a Shared
  buffer in a page block binds images for host allocations and takes the route
  over fresh pages (in place where the check passed, else a shadow it decided).
- degradation_catalogue: DeviceRecovered's cost names the buffers in the
  runtime's own pages, as docs/API.md does.

TexturePlacement's docs name the pages the runtime imports among host pages.

Verification: the suite follows.
(cherry picked from commit b7279d58a05a396815f3d34293ff1c6fc4b30253)
2026-11-09 09:51:53 -08:00
Anees Iqbal 4206b724d1 Page blocks: kept() asks the page buffers' address types before it borrows the families
The commit before this one says so, but its edit did not apply: kept() still
asked address_types for Holds::PageBuffers while a Sharing borrowed the
families, which the borrow checker refuses (job 11930). The query now runs
before that borrow.

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

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

Verification: the build follows.
(cherry picked from commit e5df53c305b27909f4cca460a4910c12861d20aa)
2026-11-09 09:51:53 -08:00
Anees Iqbal 72f37612a4 The program's host-visible buffers lie in blocks of the runtime's own pages, which a recovery carries
On a device whose submission check found that a held host-pointer import costs
its submissions nothing, the Shared, write-combined and Managed (unified
memory) buffers placed_new_buffer makes now lie in blocks of a new kind,
Holds::PageBuffers: anonymous pages the runtime maps (OwnPages) and imports by
their pointer, the block's host address theirs. Each such buffer is made for
host allocations (VUID-vkBindBufferMemory-memory-02985), and so is a block's
buffer of addresses. The memory types are those the driver imports such pages
as (vkGetMemoryHostPointerPropertiesEXT, asked once as the device is made) that
are host-visible; a class takes the blocks where its best type for such a
buffer is among them. Where the system or the driver refuses the pages, the
block is made as any block of buffers. Until the check answers, and where it
found a tax, the buffers lie where they did.

A recovery now carries such a buffer instead of leaving it on the lost
generation (Left::Pooled): the pages of its block are imported again on the
next generation, once for every buffer carried from that block, into a block
that takes no other placement and goes once those buffers do; the buffer is
bound at its offset there, its contents pointer and bytes as they were.

A texture over such a buffer takes the route a texture over fresh pages takes
(PagesClass::Fresh): its image is bound in imported memory, so it is made for
host allocations and starts UNDEFINED (VUID-VkImageCreateInfo-pNext-01443).

WorkCounts::page_buffer_blocks_made and page_buffer_blocks_plain count the
blocks.

Verification: none yet; build and tests follow.
(cherry picked from commit eac07b1f9a7b405ce2d486e5d8c080e79bfe267b)
2026-11-09 09:51:52 -08:00
Anees Iqbal 7b5490de37 RUNTIME_VERSION 1979 and the runtime-sources pin for import-tax tries that all split
4acfbee03b changes the runtime's submission checks: where every import-tax try splits and the last
try's floors fall short of the tax's bound TAX_MARGIN times over, the device answers Fails for its
life (unrecorded) instead of Unchecked. On the M3 Max one device in six answered Unchecked under
its neighbours' load (m3-max-12078) and so took no fresh pages or page blocks where the others did.

Verified by the branch: tests::submit_check 9/9 with the new test; the new test fails (Unchecked)
with the change taken out (um790, 12092 / 12104); clippy and rustdoc. Here: signatures --check,
REFUSALS, coverage docs regenerated (no change), fmt.
2026-11-09 09:49:20 -08:00
Anees Iqbal ca86565599 Import tax: tries that all split short of the margin answer Fails for the device's life
In three runs of the runtime's device tests on the M3 Max (m3-max-12078, MoltenVK 1.4.2), one of
the six devices that printed their submission checks' verdicts had all three of its import tax
tries split, under the load of the tests beside it, its last try's floors 2.5 against 1.2 us over
all its phases; the other five answered Fails (1.1 to 2.6 against 1.2 to 3.0 us). That device
answered Unchecked, so its long buffers took no fresh pages where the others' did: the same host
and driver took one form or the other by the load around one process's check.

Tries that all split now answer Fails for the device's life, unrecorded (the next device measures
again), where the last try's floors over all its phases fall short of the import tax's bound
TAX_MARGIN times over: the margin a Holds must pass to be recorded, and a cost no try told from the
load beside it. Past the margin they stay Unchecked, unrecorded, as before; a merge's split tries
are unchanged, and no record changes, so CHECK_VERSION stays.

Verification: tests::submit_check, its new test of both sides of the margin and of the merge's
tries, in the job that follows.

(cherry picked from commit 4acfbee03bf4a01d902e1e362d60e6577174dcfb)
2026-11-09 09:48:38 -08:00
Anees Iqbal 6caad73bde RUNTIME_VERSION 1978 and the runtime-sources pin for exportable pools' blocks made ahead
5a862c6ab9 changes the runtime's memory: a pool of exportable buffers (Exports, DmaBufs) that grew
gets its next block made ahead on the ready thread, and a creation call that places such a buffer
takes it instead of making a 64 MiB block on the program's thread. A reported guest stall on a
Radeon 780M with fragmented memory (inline makings 31-97 ms) was that path.

Verified by the branch (RADV PHOENIX, gem10): release bench, slowest creation call 12.0-15.0 ms
at the base vs 0.3 ms at most at the tip under fragmentation; blocks_ahead's new test 6 of 6
made ahead, 0 of 6 with development's memory.rs (780M 12111, lavapipe 12112); runtime lib under
m2v_gpu 1997/1997 (12109). Here: signatures --check, REFUSALS, coverage docs regenerated (no
change), fmt.
2026-11-09 09:45:22 -08:00
Anees Iqbal 9e663b770c Memory: the pools of exportable buffers get their growth blocks made ahead
A creation call that places an exportable buffer (new_exportable_buffer, an exportable buffer
descriptor, the in-place check's buffers) in a pool with no room made the pool's 64 MiB block
itself, on the program's thread. keep_room made blocks ahead (memory/ready.rs) only for the
pools the runtime's encodings and commits place in and for the host copies' pool, so every
growth block of Holds::Exports and Holds::DmaBufs was made in place.

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

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

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

(cherry picked from commit 5a862c6ab9ebf0a6f2effeb8776aaac6de3bed16)
2026-11-09 09:44:38 -08:00
Anees Iqbal 5561cbf475 Creation check: the loader's warning that the host lists a layer twice
runtime_lane::creation_heard_checked demands that a device's making
say only its own informational messages, after the loader's message
about a layer it could not provide. A host that lists an instance
layer twice (two manifests of one layer name) makes the Vulkan loader
warn, at vkCreateInstance, "Removing layer <name> (<path>) because it
is a duplicate of <name> (<path>)", with its id name "Loader Message";
the runtime forwards it (its creation messenger takes warnings and
errors), and the check failed on it. The M3 lists the validation layer
twice: Homebrew's manifest names its library by bare name, which
dlopen does not find there, and a copy in ~/.local/share names it by
absolute path. So a_creation_s_notices_and_messages_reach_the_sink_on_
the_asking_thread failed there on every run (20 of 20 alone at
47e072ccd3; the whole validation suite 3399 of 3400, this test the
one failure). The lane's own sink fails on no warning of the general
kind, so no other test saw it.

The check now takes the loader's own messages at the head of
creation's: its duplicate-layer warning (layer_claim's new
loader_duplicate_layer_message: the loader's id name, the text
starting "Removing layer " and holding " because it is a duplicate
of "), and, where the device was made without a layer, its message
about each, as before. The host's listing of its layers is not the
device's, and nothing wider passes.

Ran (gem10, lavapipe under --cfg m2v_cpu_icd, at the scratch twin of
this commit): with a copy of the validation layer's manifest in a
directory VK_ADD_LAYER_PATH names, so the loader lists it twice, the
test failed at the base on the loader's warning (the M3's message,
with lavapipe's name and the two paths) and passed with the change;
with the host's own listing it passed both ways. The matcher's unit
test passed; clippy on the validation crate, plain and under
m2v_cpu_icd, clean.

(cherry picked from commit 7b2005eb914a62421d2e2206837017acaa640367)
2026-11-09 09:15:32 -08:00
Anees Iqbal 13a5136520 Re-bless the cost records at bc7a657890
452 recordings moved, measured on the M3 Max (MoltenVK 1.4.2): cost --runs 8 --write over the
whole set, then cost --runs 8 --alone --write over the changed cases (gate tree commit
be02f2e6c2, jobs m3-max-12055).

Why: pin 29's replay at 47e072ccd3 (m3-max-12046) went over its cost gate on six cases,
fresh-pattern-{12,22,32,62,72,112} (R8, R16, RG8, RG16, RGBA8 and RGBA16 Snorm):
commands_recorded.cmd_copy_buffer_to_image reached 1 where the record said 0. Since 876cfd1402 a
signed-normalized fresh pattern is written by copies of its bytes (heap_tiled::fresh_pattern's
SNORM is None: a clear to -1/127 may store 0), and the records predate it (last written at
b5d9e0b933, 11-07). Every value row of that replay matched known-gaps.tsv and no reading moved
between runs; only the cost gate was red.

Bounds that moved, by family:
- plain_buffer_blocks_made, 2 in 146 cases (new): the counter of plain blocks the opaque-fd block
  split added (92202c5eaf, RT 1963); no record carried it.
- commands_recorded.cmd_copy_buffer_to_image 0 -> 1 in the six Snorm fresh-pattern cases (above).
- buffer_blocks_made_in_place (10 cases), host_copy_blocks_made_in_place (8), image_blocks_made_in_place
  and pooled_memory_blocks_made (3) appear where a case is the first to need a block of its kind
  since the block split and the allocation margin for blocks made ahead (fc60379c1f); not separated
  case by case.
- scheduler_passes / sleeps / wakes_host, heads_held_for_host_steps and the object_churn evictions
  and destroys rose in some cases and fell in as many, as at the last re-bless: they follow timing
  (the recyclers evict past a second of wall time).
- No longer bounded: empty_memory_blocks_live, scheduler_sleep_slices, scheduler_wakes_commit,
  wakes_handler_threads (now reported where the runs disagreed, or moved by no case).

Verification: the write's own runs above. The gate tree's cost --check at this commit was
requeued behind another lane's M3 job; its result is reported with the landing.
2026-11-09 08:45:56 -08:00
Anees Iqbal 7aec1f5047 Re-bless the authored compile census at 880a1f0c08
Its product fingerprint follows development's versions at 880a1f0c08. Blessed on the
M3 (s37-pl.sh censusbless --bless, census-at-dev).

(cherry picked from commit bc7a657890515bb81c48d3cc4646de26a8009ac7)
2026-11-09 08:45:45 -08:00
Anees Iqbal 880a1f0c08 queue_quiet: the burst's end read before it ends, on the wait's own clock
a_wait_ends_once_a_burst_that_began_after_it_ended failed on lavapipe's suite under a loaded
gem10 (m3-max-12030): the wait returned before the burst's end plus SETTLE, as the test reads it.
The test read that end with Instant::now() after QueueQuiet::ended had stored it, so a pause of
the burst's thread between the two of more than SETTLE (1 ms) put the end it read past the one the
wait saw; and it compared Instant (CLOCK_MONOTONIC) against the wait's host clock
(CLOCK_MONOTONIC_RAW on Linux, CLOCK_UPTIME_RAW on macOS).

The thread now reads the host's clock (gpu_time::host_nanos, the clock ended() stores) before
ended(), and the waiter reads it as the wait returns: the end the wait saw is at or after the one
read, so the wait's return is at least SETTLE past it whatever the pauses. The wait itself is
unchanged.

Verification: the test with a 3 ms pause between ended() and the timestamp fails at the old form
and passes at this one, in the job that follows.

(cherry picked from commit 3c6c921005c470f727804c7b05ee8a1209832b26)
2026-11-09 08:24:37 -08:00
Anees Iqbal e0a6edd099 SEMANTICS_VERSION 2006 for sample cells proven apart in a row
nvreds 2f61bceb95 (lockstep/facts.rs): the lockstep analysis could not prove
out[(y*w + x)*n + s] over s < n apart between threads of one row (a counter
needed a constant bound, the sample count had no range, the compiler's
select(y < h, n != 0, false) guard was not split, y*w was not known fixed in
a row), so it kept a barrier and Cluster32 with a multiple of 64, and a
32-thread dispatch on wave64 took the emulated variant and announced
EmulatedSimdgroups. Counters may test a bound computed before the loop,
NumSamples has 0..=64, edge facts split conjunctions, 'fixed' covers uniform
values, size queries and a row's y/z (6 deep). A one-row threadgroup now
records RowLockstep and runs the plain pipeline; multi-row groups keep the
barrier. Kernels with such cells or guards change: SEMANTICS 2005 -> 2006.

Verified by nvreds (msi, same tree over 6d7f59365a): metal2vulkan +
metal2vulkan-air suites 3935/3935, goldens unmoved; clippy both crates; the
new engine_simd_emulated test (RDNA3 profile at wave64: 1/16/32/48 threads
plain, two rows of 16 emulated; three one-change negative controls stay
emulated) fails with facts.rs at the base. Owed: release-mode translation
wall time and peak memory for the largest relevant row and a bounded batch
(the added work is metered and bounded: fixed <= 2^6 visits, edge facts <=
64 dominators). Here: signatures --check and refusal surface unchanged.
2026-11-09 08:16:29 -08:00
Anees Iqbal 50959b2a8e Prove a texel's sample cells apart in a row: a counter below a sample count that scales the row
What: the lockstep analysis took the store of out[(y * w + x) * n + s] over s < n
(wsm_samples's kernels, n = t.get_num_samples()) as a conflict between two threads of a
simdgroup, in the same iteration and across iterations, even where each simdgroup lies within one
row of its threadgroup. The barrier it kept put the kernel on a flattened tier, and on a wave64
device (Cluster32, a multiple of 64 threads) a 32-thread dispatch ran on the emulated-simdgroups
variant and announced EmulatedSimdgroups. The analysis now proves the address apart from the
IR's structure:
- a loop counter may test its next value against a bound computed before the loop (one value
  while it runs), not only a constant; the bound's range stands for it in the counter's numeric
  facts, and where the start is below the bound (by the ranges, or as a branch before the loop
  tested it: `n != 0`, `k < n`, `start < n`) and the branch lets a next value through only below
  it (or, stepping by one, unequal to it), every value of the counter is below it
  (Counter::below);
- a multisampled texture's sample count is at most 64, Vulkan's largest sample count (range);
- the comparisons a branch dominating a block held include each part of a conjunction on the
  edge taken (`select c, d, false` or `and` taken, `select c, true, d` or `or` not taken), as the
  Metal compiler spells `y < h && n != 0` (edge_facts, which guards now reads too);
- a value is one value in every thread of a simdgroup (fixed) where it is uniform, a texture's
  size query of such operands (it reads only the texture and the level), or, where each
  simdgroup lies within one row, a y or z component of a position; integer operations and casts
  of such values too, at most 6 operations deep. An addition with one such operand differs
  between threads as the other does (it took only uniform operands before), so y * w + x
  differs as x does in a row;
- a cell s + p * n, s a counter below n, n fixed and bounded by N, and p differing between
  threads by 1 to S, differs between threads by 1 to S * N + N - 1 (by at least 1 wherever the
  p's differ, at whatever iterations, since |s1 - s2| < n), or not at all where p may not
  differ; across iterations it is settled where p * n is (core_home: the cell's home is p * n's).
In a multi-row threadgroup two threads of a simdgroup may share a pixel (a grid deeper than one),
so the barrier, the Cluster32 tier and the multiple of 64 stay; the kernel now records
RowLockstep, and a one-row threadgroup of any width runs on its one compiled pipeline.

Tests: engine_simd_emulated's
a_texel_s_samples_in_a_row_need_no_emulated_simdgroups_on_wave64, on the RDNA3 description
narrowed to wave64: wsm_samples's wsm_read_f and wsm_read_u, and the same IR with the guard as an
`and`, keep Cluster32 and LocalSizeConstraint { multiple: 64 }, record RowLockstep, and plan 1,
16, 32 and 48 threads on the plain variant (VariantKey::new()), two rows of 16 on the emulated
one. Negative controls, each one change from that IR and each a real collision, record no
RowLockstep and keep every partial threadgroup on the emulated variant: the row scaled by the
width rather than by n, the latch testing the counter rather than the next value (the body runs
at s == n, the next pixel's first cell), and the loop entered without the n != 0 test (at n == 0
every pixel writes cell 0).

Ran on msi-laptop (Linux, llvm-as 23.1.1) at this change over 6d7f59365a (none of these files
changed since): the metal2vulkan and metal2vulkan-air suites, 3935 of 3935 passed (the golden
tables among them, none moved); clippy on both crates, all targets and features, clean; the new
test passed (its kernels assembled, no SKIPPED line), and with facts.rs restored to 6d7f59365a
it fails (wsm_read_f records no RowLockstep).

SEMANTICS: kernels whose cells or conjunctive guards the analysis now proves apart lose
lockstep barriers or gain RowLockstep.

(cherry picked from commit 2f61bceb95e217465e9750ead7320fdf7aecba3e)
2026-11-09 08:15:50 -08:00
Anees Iqbal 47e072ccd3 RUNTIME_VERSION 1977 and the runtime-sources pin for texture makings that allocate no scratch lists
exitcrash c118e602a6 + 5cd3797b49: keep_room read the kept pools by splitting
them into two Vecs on every creation call (97afeae593), and a tiled heap
texture's making built texel_units'/copy_units' Vecs only to read their
lengths; both now read in place (an Arc'd slice, allocation-free iterators).
Runtime sources changed: RUNTIME_VERSION 1976 -> 1977, pin recomputed. No
behaviour change beyond allocations.

Verified by exitcrash: M3 m3-max-11910 at the pre-rebase tip d530fccb3c,
host_ab --only percall exit 0: texture_256_shared 33.3125 (base 77ad0f236e)
-> 30.3125 (bound 32; 31.3125 at 32c3330694); heap_texture_256 19.25 ->
16.25 (bound 17.25; 17.25 at 32c3330694). lavapipe 11911 at d530fccb3c:
runtime suite 2000/2000, clippy x3, rustdoc. The rebase applied both commits
unchanged; m3-max-12006 rechecks lavapipe/clippy/rustdoc at the rebased tip.
Here: signatures --check and refusal surface unchanged.
2026-11-09 07:55:44 -08:00
Anees Iqbal 83691b5ce4 A tiled heap texture's making reads its copy units without collecting them
host_ab's percall gate on the M3 held heap_texture_256 to 17.25 allocations a
call and measured 19.25 once keep_room's two were gone. A trace of the counted
window on lavapipe (base 32c3330694 against 600f3b17f8) put the two in
held_aspect, which every tiled heap texture's making asks
(metal_heap_layout): it built texel_units' Vec and copy_units' Vec to look at
their lengths. image_element, asked just before, built copy_units' Vec too, and
for a depth or stencil format texel_units' beside it.

copy_units' units now come from each_copy_unit, an iterator over the depth,
stencil or colour unit that allocates nothing; copy_units collects it for its
other callers. texel_units is that iterator filtered (its callers only iterate
it). held_aspect and image_element read the units one by one, so a tiled heap
texture's making allocates nothing for them.

heap_texture_256, allocations a call on the M3 (host_ab --only percall, bound 17.25):
- base (600f3b17f8, the previous commit, m3-max-11863): 19.25, past its bound;
- fix (d530fccb3c, m3-max-11910): 16.25, and every other held row within its bound
  (host_ab --only percall exit 0; texture_256_shared 30.3125 against 32);
- the last green commit (32c3330694, m3-max-11910): 17.25.

Measured before the rebase onto 3d5ed3b021 (as d530fccb3c on 600f3b17f8); the change applied
unchanged. Lavapipe: the runtime suite, clippy in three configurations and rustdoc at
d530fccb3c (m3-max-11911).

(cherry picked from commit 5cd3797b49010770b15bb5b25946b80a5015930d)
2026-11-09 07:55:07 -08:00
Anees Iqbal e33fb4f5ab keep_room reads the kept pools in place: no allocation per creation call
97afeae593 had keep_room put the runtime's own buffers' pools first by partitioning the kept pools
into two new Vecs. That is two allocations on every creation call that keeps room, a texture's
among them. host_ab's percall gate on the M3 (m3-max-11816 at 97fd8d0fe8) then read
texture_256_shared at 33.31 allocations a call, against its bound of 32. An allocation trace of
that group's counted window (m3-max-11856) put the only new sites at 32c3330694..development in
keep_room's partition, two a call.

Both orders are now filters over the kept pools, read in place. Memory::kept returns its list as
an Arc<[(Holds, u32)]>, so the clone that every call made before 97afeae593 goes too. The order
and the pools kept are as 97afeae593 made them: the own kind's pools first, then the others but
FdBuffers.

texture_256_shared, allocations a call on the M3 (host_ab --only percall, bound 32):
- base (77ad0f236e, m3-max-11863): 33.3125, past its bound;
- this fix alone (600f3b17f8, m3-max-11863): within its bound (its hold passed; the run then
  stopped at heap_texture_256, which the next commit fixes);
- this fix with the next one (d530fccb3c, m3-max-11910): 30.3125, the whole table green;
- the last green commit (32c3330694, m3-max-11910): 31.3125.

Measured before the rebase onto 3d5ed3b021 (as 600f3b17f8 on 77ad0f236e); the change applied
unchanged.

(cherry picked from commit c118e602a6b8663cb26d3ac93cedb766a4c12977)
2026-11-09 07:55:07 -08:00
Anees Iqbal 451549179b RUNTIME_VERSION 1976 and the runtime-sources pin for MoltenVK's pass-start reads taking the cleared copy
nvreds 25063af705: since 876cfd1402 every normalized clear off a whole code is
'in question'; on MoltenVK (ColorClearIsMetals) the load op withholds its
note, and Texture::cleared_copy refused any withheld clear (its copy is
cleared by vkCmdClearColorImage, only the load op was measured), so a draw
after a pass-start barrier split the pass. Measured on the M3 (MoltenVK
1.4.2): vkCmdClearColorImage stores Metal's bytes for 71/71 clears, the load
op's; ColorClearIsMetals now covers the clear command of a whole level and
layer, and the cleared copy takes it with no note. Other drivers unchanged.
Runtime behaviour changed: RUNTIME_VERSION 1975 -> 1976, pin recomputed.

Verified by nvreds on the M3 (11876, same change over 693fd3f96d, --cfg
m2v_gpu): validation suite 3398/3400 (the pin test, and
degrade_notices::a_creation_s_notices_and_messages_reach_the_sink_on_the_
asking_thread at device creation, seen twice, open); conformance cost
--check over the whole set rc 0 (the pass-start cases back at their recorded
cleared-copy counts); replay of the 14 pass-start-barrier cases rc 0. The
lane test failed 22,482/22,482 before (0,1,2). Here: signatures --check and
refusal surface unchanged.
2026-11-09 07:54:09 -08:00
Anees Iqbal 2ef8af3abe A pass-start read takes the copy cleared by MoltenVK's clear command, which is Metal's clear
What: on MoltenVK (DriverFact::ColorClearIsMetals) a draw that samples a colour its pass clears,
after a memory barrier at the pass's start, split the pass again (attachment_read_splits, a
second render pass instance, the render-pass-split notice) instead of reading a copy of the
attachment cleared to the clear before the pass (attachment_read_clears). Texture::cleared_copy
refused a clear whose device-color-conversion note the load operation withholds
(ColorTarget::withheld_clear), because the copy is cleared by vkCmdClearColorImage and only
the load operation was measured to store Metal's texel there. Since 876cfd1402 every clear of
a normalized channel off a whole code is in question (the spec's rule), so the pass-start
clears of the lanes and the conformance cases became withheld on MoltenVK and split.

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

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

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

RUNTIME: the runtime's pass-start reads on MoltenVK change (a cleared copy instead of a split).
(cherry picked from commit 25063af705d28d07b7332cc1b35a5cf1beedc6bb)
2026-11-09 07:53:32 -08:00
Anees Iqbal 6d7f59365a RUNTIME_VERSION 1975 and the runtime-sources pin for a depth cleared ahead where RADV on the RX 550 clears at the standard positions
nvreds c7061858f8: on RADV POLARIS12 (Mesa 26.2.6) a pass at custom sample
positions whose load op clears its depth stores and tests every sample's
depth at the standard position of its index for every draw (16/16 samples,
Depth32Float, Depth16Unorm, Depth32Float_Stencil8), while a pass that loads
the depth takes the custom positions. New DriverFact
ClearedDepthAtStandardPositions (one row, RADV 0x1002:0x699f): ReachClears
clears that depth before the pass in its own render pass
(vkCmdClearAttachments) and the pass loads it; no notice, the answer is
Metal's. Runtime behaviour changed: RUNTIME_VERSION 1974 -> 1975, pin
recomputed. A DriverFact enters no translation fingerprint, so SEMANTICS
stays.

Verified by nvreds: runtime_lane::sample_positions RX 550 9/9 (validation
layer silent, 'cleared ahead true (1 attachment clears)'), 780M 9/9
('cleared ahead false'), base 3d5ed3b021 RX 550 4 red; clippy plain + gpu;
driver_facts/api_signatures/api_surface 9 pass. Here: signatures --check and
refusal surface unchanged. Not measured: separate depth and stencil textures
at custom positions on the RX 550.
2026-11-09 07:38:03 -08:00
Anees Iqbal 3314bd71b9 Clear a depth at custom sample positions before its pass where RADV on the RX 550 clears it at the standard ones
What: DriverFact::ClearedDepthAtStandardPositions (appended), one row: RADV on the Radeon RX 550
(0x1002:0x699f). On a driver with it, a pass at custom sample positions whose depth Metal clears
has that depth cleared before the pass by ReachClears (a render pass of the attachment alone,
vkCmdClearAttachments), wherever the clear reaches, over the render area alone where the pass
does not store it, a memoryless depth too, and the pass then loads it (load_in_pass). Nothing
is announced: the answer is Metal's. clear_reach.rs and sample_positions.rs (runtime) document
the route; driver_facts.rs documents the fact and its measurement.

Why: runtime_lane::sample_positions failed on the RX 550 (RADV POLARIS12, Mesa 26.2.6) in four
tests (depth_takes_the_custom_positions, custom_sample_depth_store_stores_as_store,
later_passes_keep_the_stored_samples, a_callers_image_takes_the_positions_through_a_stand_in):
plane X drawn at four custom positions stored each sample's depth at the standard position of
its index (stored 0.421875, 0.484375, 0.390625, 0.453125 where Metal stores 0.390625,
0.4140625, 0.453125, 0.484375). Probes through the lane's harness on the RX 550:
- Depth32Float, Depth16Unorm and Depth32Float_Stencil8 4x, cleared by the pass: 16 of 16
  samples at the standard positions, 0 at Metal's; a second draw in the pass, and a DontCare
  load the runtime clears, the same.
- the pass's own test under Less against a clear of 0.4375 drew samples 0 and 2 of each
  first-column pixel (the standard positions'), where Metal draws 0 and 1;
- a pass at four other positions that loaded such a depth drew and stored at its own positions;
- a depth cleared by a pass without a draw, then loaded and drawn at the custom positions:
  16 of 16 at Metal's.
Coverage was at the custom positions throughout (the lane's coverage and stencil tests passed).
So the driver evaluates the depth at the standard positions in a pass whose load operation
clears it, and at the pass's positions in one that loads it. The route reaches that by
documented Vulkan alone (a clear in a pass of its own, then LOAD), selected by a measured fact
like PositionedDepthReadAtStandardPositions's stand-in for NVIDIA. RADV on the Radeon 780M
keeps the custom positions' depths and takes no row.

Tests: driver_facts' a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone gives the RX
550's identity the fact and RADV's driver-wide one alone; the lane's
depth_takes_the_custom_positions holds the route to the fact: where the device has it, its
custom-position pass records an attachment clear (WorkCounts::attachment_clears_recorded), and
it prints whether it cleared ahead. api_signatures.tsv gains the two variant rows.

Ran (um790, at a tree identical to this commit on be59d46240): runtime_lane::sample_positions 9
of 9 on the RX 550 ('1002:699f!', Mesa 26.2.6), "cleared ahead true (1 attachment clears)",
dz_custom4_memoryless included, the validation layer silent; 9 of 9 on the Radeon 780M
('1002:15bf!'), "cleared ahead false (0 attachment clears)". Before it, at 3d5ed3b021, the RX
550 failed the four tests above. clippy -D warnings over metal2vulkan, -runtime and -validation
(all targets, all features), and over -validation and -runtime under --cfg m2v_gpu; the
metal2vulkan tests matching driver_facts, api_signatures and api_surface (9 passed);
signatures.py --check and refusal_surface.py --check.

RUNTIME: clear_reach.rs and sample_positions.rs change (a new route on one driver), so
RUNTIME_VERSION and the runtime-sources pin are the orchestrator's to move.

(cherry picked from commit c7061858f8e8562c2b5dab8dddf0d620c2c5ee29)
2026-11-09 07:37:22 -08:00
Anees Iqbal be59d46240 word_samples_msaa: read the samples in a threadgroup of whole subgroups on every device
What: the sample reads (wsm_read_f, wsm_read_u) are dispatched in one threadgroup of 128
threads (GROUP), whole simdgroups and whole subgroups of every size a kernel's simdgroups run
on (32, or 64 or 128 for wider subgroups split into simdgroups), instead of the row rounded up
to thread_execution_width (32).

Why: on the RX 550 (RADV POLARIS12, 64-wide subgroups) the lane failed with "announced past
[...]: [EmulatedSimdgroups]": "a dispatch of kernel `wsm_read_u`: its threadgroups of [32, 1, 1]
threads are not whole subgroups of the size the kernel's simdgroups run on". The kernels have
no simdgroup operation or barrier in their source, but their translations carry one
OpControlBarrier and LocalSizeConstraint { multiple: 64 } there (printed by a probe): the
lockstep pass orders each thread's stores in its loop over the samples, whose index the
analysis does not prove apart between threads, so a 32-thread group is a partial subgroup and
runs on the emulated-simdgroups variant, announced. The lane's comment already meant to avoid
that route; whole simdgroups are not whole subgroups on a 64-wide device.

Ran on the RX 550 (um790, MESA_VK_DEVICE_SELECT=1002:699f!) at this change on 3d5ed3b021:
runtime_lane::word_samples_msaa passed (announced: ShaderResolve, WordResolve,
DeviceRoundedResolve and the allowed kinds; no EmulatedSimdgroups), with
runtime_lane::shader_stencil's four tests in the same run.

(cherry picked from commit b9e255758cedde5b27b079c75938000b446c172f)
2026-11-09 07:15:41 -08:00
Anees Iqbal ce1fca855a uniform_varyings: a half denormal may read as the zero the device's noted rounding answers
What: the flat read's compared words must be Metal's, but now a `half` denormal (Metal's word is
the denormal itself) may read as a zero where a stage of the pipeline records the device's own
`half` rounding: of either sign under PrecisionNote::NativeHalfQuantize (the device's
OpQuantizeToF16, which the SPIR-V specification lets answer a zero below the smallest normal
`half`), of the denormal's sign under NativeHalfConversion. Those words are counted apart
(`device-rounded denormals` in FLT-LANE, "the device's" in FLT-LANE-WORD), not as differences.

Why: on the RX 550 (RADV POLARIS12, no shaderFloat16) the lane failed with 24 differing
constants: the three `half` denormal constants 2 (0x0001), 3 (0x83ff) and 21 (0x0200) read
0x0000 in hp and hn at every qualifier and sample count (3,672 words each at 1x), where Metal
keeps them. The flat read rounds each `half` lane after Metal's word for it by the device's
quantize and narrows it to its bits by PackHalf2x16 for the store, and both the quantize and
the conversion notes are recorded there; the device's answer is within the quantize note's
bound (rule 1: the device's native rounding, recorded). Every other word stayed Metal's.

Ran on the RX 550 (um790, MESA_VK_DEVICE_SELECT=1002:699f!) at this change on 3d5ed3b021:
runtime_lane::uniform_varyings passed; flat hp/hn 223,992 of 235,008 words Metal's at 1x with
11,016 device-rounded denormals (the three constants), 0 otherwise differing; float varyings
unchanged (cp 216,648/216,648, cn 235,008/235,008). Before the change the same run failed with
those 24 differences.

(cherry picked from commit 48805fe7356f4150c255b9788219aa943c171365)
2026-11-09 07:15:41 -08:00
Anees Iqbal 3d5ed3b021 read_through_views: a view's mipmaps are the device's box filter of each level above, not one format's ties
mipmaps_through_a_view_are_the_formats held the levels generate_mipmaps writes through an
A8Unorm view of an R8Unorm atlas equal to a plain A8Unorm texture's. On the RX 550 (RADV
POLARIS12) the first level through the view read [9, 11, 13, ...] where the plain texture's read
[8, 10, 12, ...] (potluck 11625 and 11635): each texel the average of four codes on a tie, which
the device's blit (device-filtered-mipmaps) rounds up into R8_UNORM and down into A8_UNORM. Vulkan's
conversion to a normalized code takes either of the two codes nearest the value.

Both chains are now held, level by level, to the box filter of the level above as the device wrote
it: the average where it is a code, else one of the two codes around it. The texels where the two
chains differ are counted and printed.

(cherry picked from commit 3dbee7cf7fe3128d8c436dc548a5d265f093d883)
2026-11-09 06:56:12 -08:00
Anees Iqbal 785edff162 alpha_in_red: an A8 edge texel's resolve may round its tie a code from R8Unorm's where the device rounds
a8_resolves_as_r8_unorm held A8Unorm's 4-sample resolve equal to R8Unorm's at every texel. On the
RX 550 (RADV POLARIS12, its own A8_UNORM) every edge texel, whose samples average 114.5, resolved
to 114 in A8Unorm and 115 in R8Unorm (potluck 11625 and 11635), every other texel the same. Where
the device rounds the average (resolve_kind: device-rounded-resolve, whose bound is one code of
Metal's for an 8-bit unorm channel), Vulkan leaves the tie to it, per format; an edge texel may
then lie a code apart, counted and printed. Elsewhere, and where the device's average is
measured to be Metal's, every texel must match as before.

(cherry picked from commit f76c49e82499e02d85e68cdbce20ebdd6a9ffaf1)
2026-11-09 06:56:12 -08:00