Commit Graph
788 Commits
Author SHA1 Message Date
Anees Iqbal 9024d9ee5f index_pools: count a completed handler's lag from its submission's return too
runtime_lane::index_pools::a_completed_handler_waits_for_no_pool_block_made_meanwhile
failed on the RTX 5080 (round 5ce05e1908, lane ln07): the handler ran 37.2 ms
after its command buffer completed, during a 50.5 ms making of the other
queue's index pool block.

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

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

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

(cherry picked from commit c6f08a396cc2e4713dedfae06ad0648019e9e22d)
2026-11-08 08:18:42 -08:00
Anees Iqbal 27eea49ec5 HostRam: a copy over a listed chunk not imported takes lists of its own pages, of an opt-in source
HostRam::with_dma_buf_of_runs(source, most_runs) gives a RAM a DmaBufRunsSource: one dma-buf of
a list of runs of its pages, their pages one after another (udmabuf's UDMABUF_CREATE_LIST on
Linux, at most list_limit runs a list). Only copies by runs call it, and only where the plan is
Plan::listed (each held import costs every submission and the RAM's chunks are the device's
dma-bufs of its source: RADV) and the device's barriers order blits through two imports of the
same pages. There RamOnDevice::for_copy, for a chunk not imported, takes RamOnDevice::run_lists:
the copy's ranges of the chunk by address, widened to whole host pages and joined where those
share or touch a page (copy::page_runs), split into lists of at most most_runs runs and one
dma-buf's bytes (copy::run_lists), each imported as one dma-buf of the source
(Device::ram_runs_as_dma_buf, Imported::Runs), held by the command buffer until it completed and
freed then. The chunk is neither imported nor asked for, so copies pin their own pages while they
run and never a chunk's untouched pages, which udmabuf allocates for good. Without the source, a
source that fails or answers a dma-buf of another length, the margin of the allocation limit, a
run that is the whole chunk or passes one dma-buf, the copy takes the chunk as before.

A list's VkBuffer holds each run from where the runs before it end: RamChunk keeps the runs and
their offsets (RamChunk::offset_of, RamChunk::bytes), and the copy maps each piece through it;
regions take their host bytes from the pieces, not the import's span. alone_ranges takes one
chunk's sorted ranges (chunk_ranges with no cap) and joins them as before, so every other plan
(ANV, NVIDIA, lavapipe, MoltenVK, RADV without the source) copies as before.

Counted: WorkCounts::host_ram_run_list_imports (new), live in run_imports_live. Tests: copy.rs
units for page_runs and run_lists; host_ram_dma_buf's tile tests over a RAM with a udmabuf list
source (lists of at most 1,024 runs, no chunk, nothing asked, no untouched page resident) and,
without it, the chunk; elsewhere the list source never asked. The bench takes the list source and
prints first and repeated copies, sorted runs and lists per copy, over surface-shaped and
scattered tiles. api_signatures blessed (three added: DmaBufRunsSource, with_dma_buf_of_runs,
the counter; nothing removed); docs/REFUSALS.md regenerated (a DmaBuf site).

Verified: cargo fmt and the signature and refusal scripts only; the 780M runs follow.
(cherry picked from commit f2e5c143dd314835fd58cd6f8430c5c7c620e52a)
2026-11-08 08:18:42 -08:00
Anees Iqbal bdeed7eaa6 HOWTO, signatures: copies over a chunk not imported, staged gathers and their counts
docs/HOWTO.md's host RAM copy paragraph said a copy over a chunk not
imported waits for its import; it now says what each takes: ranges
alone (at most 16, not on MoltenVK or ANV), a staged gather through the
CPU on devices whose thread imports ahead, and the wait otherwise, with
the counts that show each.

api_signatures.tsv blessed for the six new WorkCounts fields
(signatures.py --bless: six records added, none moved).

(cherry picked from commit 9332df0676eea0a5336ee95ffc25deb2b5d0b05f)
2026-11-08 07:54:42 -08:00
Anees Iqbal 748465a50e Host RAM copies of runs each at a byte of the buffer: one call for a laid-out surface
BlitCommandEncoder::copy_runs_from_host_ram(ram, runs, destination) and
copy_runs_to_host_ram(source, ram, runs) take (buffer byte, host run)
pairs, so a device cache that keeps a surface's layout (row r at
base + r * pitch, the padding between rows the guest's and untouched)
copies every row in one call instead of a call a row (the Iris measured
2054 calls at 3.9 ms GPU and 8.1 ms CPU against 0.83 ms and 1.5 ms for one
call of the same runs, m3-max-8523).

The call now holds runs at their buffer bytes (Run); copy_from_host_ram
and copy_to_host_ram lay theirs one after another from their offset
(one_after_another), so their behaviour and refusals are as before. Runs
join where they touch in the RAM and in the buffer (merged). pieces()
places each piece at its buffer byte; the record path takes the span
from the lowest run's first byte to the highest's last for the bindings,
windows and hazard tracking, and the kernel's entries already carry their
buffer word, so only the table's filling changes. Runs that all end on a
word and lie at words of the buffer's memory take the dispatches; others,
and copies that write a destination byte twice (a scatter's host bytes, a
gather's buffer bytes), take regions, in rounds where a byte is named
twice so the later run's bytes stay. For the runs calls, a run past the
buffer is RangeOutOfBounds (the first such run's), and a run at a buffer
byte off a word takes regions instead of being refused.

Tests: a laid-out surface (rows at a pitch over scattered pages, two side
by side, one in each chunk) both ways in one call with sentinels in the
buffer's padding and the whole RAM compared, 4-byte rows by a dispatch per
chunk, 2-byte rows and rows at a buffer byte off a word by regions; a
gather naming one buffer byte twice keeps the later run's bytes; the
runs calls' refusals; unit tests for merging pairs, in_words off a buffer
word and pieces at their buffer bytes. The bench's laid-out one-call form
now uses copy_runs_to_host_ram from the laid-out cache.

Docs: both calls' API docs, the module docs, Problem::HostRam, HOWTO
section 6 and the runtime README; signatures re-blessed (REFUSALS.md
regenerated, unchanged).

(cherry picked from commit 8292ae5075d07cbcd6eada94cf8dc99060792722)
2026-11-08 07:12:13 -08:00
Anees Iqbal 1c33448daa dma-buf lane: a view of single pages takes the route its device answers; ANV's dma-buf limits documented
What: the reversed-view test now asserts each measured driver's route for a no-copy Shared
buffer over 64 and list_limit + 1 single pages of a memfd in reverse, mapped from the file and
through udmabufs (VM_PFNMAP), placed outside the guest's range, with a dma-buf source:
- RADV: through dma-bufs, one chunk, or two in a sparse buffer;
- ANV: by pointer from the file; through udmabufs, one dma-buf where one udmabuf holds the view,
  else refused (Unsupported, HostMemory) after one request for a single dma-buf of the whole
  view;
- lavapipe: by pointer.
No route is a copy. It prints the mappings the view and the import took.

with_dma_buf's docs and HOWTO now say what ANV does. It imports a dma-buf for a plain buffer but
reports none for a sparse one, so its source is asked for one chunk of the whole length, which one
udmabuf must hold. It refuses the pointer of a mapping of dma-bufs.

Why: a consumer's probe found ANV refusing a view of list_limit + 1 pages mapped through
udmabufs. The runtime's route there was not a copy, nor a skipped source:
- the pointer import of the udmabuf mapping was refused: vkGetMemoryHostPointerPropertiesEXT
  answered memoryTypeBits 0x7f, then vkAllocateMemory with VkImportMemoryHostPointerInfoEXT
  returned VK_ERROR_INVALID_EXTERNAL_HANDLE on memory types 2 and 1;
- the source was then asked;
- vkGetPhysicalDeviceExternalBufferProperties for DMA_BUF reports import for flags 0 but not for
  SPARSE_BINDING, so the request's granule was the whole 4,198,400 bytes, and one udmabuf of 1,025
  items is past list_limit 1024.
No buffer of Vulkan binds more than one imported memory without sparse binding, so the runtime has
no documented path for such a view on ANV.

Verified: diagnostics on a scratch branch (never merged), on the Iris Xe (ms01, job m3-max-8433,
Linux 7.3.1, i915), the 780M (job m3-max-8454) and lavapipe (gem10, job m3-max-8477). The runs of
this test follow.

(cherry picked from commit 32ba8392a0aa8d16b4fceb9b6ed052e5d618b1a0)
2026-11-08 06:36:45 -08:00
Anees Iqbal ded385b661 YCbCr textures: announce the device's conversion at the first conversion; the lanes read in-place samples as Metal's
On the Radeon 780M, which converts the 4:2:0 formats itself and reads their planes in place, the
ycbcr lanes failed 9 of 48 at this branch (um870 m3-max-8383) and 17 of 48 at development's tip
(gem10 m3-max-8421), the same 9 among them. Two causes:

- A texture whose conversion is the device's announced ycbcr-filter-not-exact as it was made,
  though a texture whose planes every function reads in place never converts and so never reads
  the device's conversion (a_ycbcr_texture_sampled_and_gathered_by_one_function_reads_its_planes_in_place,
  a_ycbcr_sample_through_an_unmeasured_filter_is_announced). Converts::new now announces it at
  the texture's first conversion. WorkCounts::ycbcr_device_conversions still counts the texture
  as it is made, so a lane can tell before a read that the texture's image holds the device's
  conversion. The lanes' notice predicates now take a conversion that ran,
  WorkCounts::ycbcr_device_samples (device_samples), in place of the textures made.
- The lanes held the samples of a texture whose planes are read in place to its image's texels,
  the device's conversion on such a device, where a function reading the planes converts the codes
  itself: Metal's conversion and filter under the lane's exact_answers (YCbCrInPlacePolicy::Exact),
  as ycbcr.rs states. Texels::sampled takes Metal's steps of the codes (modelled) for a texture read
  in place and the image's texels elsewhere, in a_linear_sample_of_a_ycbcr_texture_is_metals,
  a_linear_sample_is_metals_through_each_sampler_and_result and its fragment twin,
  a_ycbcr_slot_takes_the_devices_filter_in_the_pipeline_its_creation_made and
  ycbcr_textures_read_the_texels_metal_converts; a_draw_samples_the_planes_as_written_before_it
  holds a draw read in place to Metal's conversion of the uniform codes.

four_two_two_and_four_four_four_codes_read_what_metal_reads also held a code twin over a surface
whose chroma plane it does not fit in to Metal's codes where the device reconstructs them itself:
it now takes the device's codes there, as the test's other surfaces do.

Docs: the ycbcr.rs and ycbcr_device.rs module docs, Degradation::YCbCrFilterNotExact and its
docs/API.md catalogue entry say the notice comes at the first conversion.

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

(cherry picked from commit 5f83699d296386c3b0b357f2baa63cfefc086096)
2026-11-08 06:29:47 -08:00
Anees Iqbal b30da69b50 Host RAM copies of runs of words take the pages copy's dispatches, not regions
The pages copy's table entries become three words: the run's first word in
the scattered binding, its first word in the consecutive one (from the
shape's first_word) and its words, at most a page's 1024. Each invocation
copies its strided words below the run's count. Whole pages are entries of
1024 words, one a page as before, so their tables' entries, dispatches and
windows are unchanged.

In the runtime, a copy whose runs all end on a word (they already start on
one, and the buffer's bytes too) takes the dispatches: plan() cuts each
piece into runs of at most a page from its start and where a window of the
buffer ends. Only runs that end off a word (rows of 1- or 2-byte texels),
or a scatter whose runs write a byte twice (share_a_byte, so the later
run's bytes stay as with regions), keep vkCmdCopyBuffer regions.

The Iris measured regions at about 1.6 us of GPU and 1 us of CPU each
(m3-max-8389: 8853 regions of a 31.5 MB surface, 14.0 ms GPU, against 0.99
ms for the page kernel over the same pages).

Tests: the kernel's interpreter test of word runs (a word, 128, 129, a run
across a page, a page less a word) with no word around them changed; the
plan's cuts at a page and at a window's end; a device test of rows of 2044
bytes at a 2048 pitch from 16 bytes into a page, a run ending a word before
a page's end, three pages and more from inside a page, one across the
chunks' end and a word, with sentinels over every touched page, a dispatch
per chunk and no region both ways, and a twice-named scatter of word runs
by regions, the later run kept. The regions refusal case now ends off a
word. The bench measures rows of 4-byte texels (dispatches), of 2-byte
texels (regions) and 2046 bytes at a 2048 pitch.

Docs: the kernel's module and entry docs, the copy module, both calls' API
docs, HOWTO and the runtime README; signatures re-blessed (entry() takes
the run's words and returns 12 bytes; ENTRY_WORDS).

(cherry picked from commit 562fc5fc526cce2b31db280c4bbffb29314f8ac4)
2026-11-08 06:20:15 -08:00
Anees Iqbal 6ba9ac779f BufferDescriptor::aligned_byte: lay a buffer's byte on a multiple of 256 bytes of its memory
A consumer that lands decoded frames in a buffer of the runtime's own memory makes plane textures
at CoreVideo's offsets: the first plane 32 bytes into the surface, the second 32 bytes past a
multiple of 256 after the first's rows. A linear image aliasing the buffer binds at the buffer's
memory offset plus the texture's, which must meet the device's linear-image alignment (256 on
RADV, 128 on NVIDIA, 64 on lavapipe), and the runtime starts each buffer on a multiple of 256, so
those planes are shadows there (the 780M probe, um870 m3-max-8351: Shared and Private buffers,
in place at 0 and 256, shadows at 32, 64 and 128).

BufferDescriptor::aligned_byte (with_aligned_byte), a runtime extension for the runtime's own
memory, names the byte to lay on a multiple of 256 (LINEAR_IMAGE_ALIGNMENT). placed_new_buffer
then makes the VkBuffer that byte's shortfall longer, binds it where its placement starts, and
starts the buffer's bytes that many bytes into both (BufferParts offset and base, the mechanism
host imports use), so the byte lands on the multiple and textures there alias the memory. Such a
buffer is never parked nor taken from the parked, and lies in no fresh pages. Its length and
gpuAddress (the runtime's address space's) are unchanged; a Shared one's contents start the
byte's remainder short of a multiple of 256, which the field's docs name against Metal's
page-aligned contents. Refused with NoCopy contents (Problem::AlignedByteNoCopy).

tests::aligned_byte: over Shared and Private buffers laying byte 0x20, the 8-bit and 10-bit
frames' planes (R8/RG8 at rows 3840, R16/RG16 at rows 7680; the second plane at 0x20 + 0x7E9000
or 0xFD2000), sampled, written and rendered into, alias wherever the same texture at offset 0 of
a plain buffer does, and are shadows at 0x20 of a plain buffer wherever the device's linear
alignment is past 32; a blit of each sampled plane reads the bytes at its offset; length,
gpuAddress and contents as above; the refusal over NoCopy. Docs: the field, HOWTO, API.md's
shadowed-texture entry, the runtime README; api_signatures blessed and REFUSALS.md regenerated.

New public items: BufferDescriptor::aligned_byte, BufferDescriptor::with_aligned_byte,
Problem::AlignedByteNoCopy.

Verified: cargo fmt; the 780M, lavapipe and Iris runs follow.
(cherry picked from commit bef28766eee658ef30dfcc5d0492a1493171b34d)
2026-11-08 06:06:13 -08:00
Anees Iqbal fe5f08a4b1 Host RAM copies take runs at word starts and any end, copied by regions
reims's laid-out device cache downloads hand copy_to_host_ram each texel
row's bytes (encode_out): runs that start on the device's linear texture
alignment, always a 4-byte word, and end at any byte, short of the row's
padding, which the guest's CPU owns. merged() refused every such run
(Problem::HostRam) and the consumer fell back to a view of the surface's
pages: on ANV one mapping per 4 KiB page, 278 of 294 device caches in
boot 8267.

Now a run starts on a 4-byte word and ends at any byte past it. Copies
whose runs are all whole 4 KiB pages keep the pages copy's one dispatch
per chunk, unchanged. Any other copy records each run's bytes in a chunk
as a region of vkCmdCopyBuffer between the import that holds them (whole
pages, imported as before) and the buffer: byte offsets and sizes, so no
other byte of the runs' pages is read or written. The regions of one
import are one command, at most 1024 each (MOST_REGIONS). A scatter whose
runs name a byte twice takes a round of commands per overlap, so no byte
is written by two regions of one command (VUID-vkCmdCopyBuffer-pRegions-12482),
the later run's bytes left; a buffer over host pages the runs overlap is
refused (VUID-vkCmdCopyBuffer-pRegions-00117). Counted in the new
WorkCounts::host_ram_copy_regions.

Tests: copy.rs's unit tests (word starts, any ends, rows that touch merge,
whole_pages, rounds); host_ram_copy_device's
runs_inside_pages_move_their_bytes_alone_and_leave_the_rest_of_their_pages
(2046-byte rows at a 2048 pitch from 16 bytes into a page, a run ending 2
bytes before a page's end, one across the first chunk's end, one of 3
bytes; pattern sentinels around them; gather into Shared and Private,
scatter back; 10 regions, no dispatch; twice-named bytes; the overlapping
buffer refused); the whole-page test now also asserts no regions; the
refusal test's cases off a word. host_ram_copy_bench gains the laid-out
download: a call a row, one call, and the view with a blit a row.

Docs: copy.rs module and both calls' API docs, Problem::HostRam,
docs/HOWTO.md, the runtime README; docs/REFUSALS.md regenerated and the
API signatures re-blessed (the new WorkCounts field).

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

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

(cherry picked from commit 4c1beda492dcc4af16923df09724b7fbf0e7387a)
2026-11-08 05:22:32 -08:00
Anees Iqbal 535f50063f Pooled bound over tracked Private buffers alone: CPU-visible caches lie in place at any size
The owner's 2026-11-07 ruling: over CPU-visible memory the GPU works in
place wherever the device's check passed, however much slower; a shadow
there is a correctness fallback, never a speed choice. The 48 KiB pooled
bound (LinearCost) chooses between two speeds where both forms give the
same answer, which holds only over bytes only the runtime's commands
write. So it now applies to tracked textures over Private buffers alone
(Texels::only_commands_write), for every access; over a Shared or Managed
buffer, and for an untracked texture, a texture that samples, renders or
is written takes the DRM_FORMAT_MOD_LINEAR image at its pitch at any size
wherever its check passed. This widens the previous commit's sample-only
exception. reims's histogram (boot 8203) shows no rendered cache past
48 KiB, so the render and write side changes nothing measured today.

The bound's doc comment, LinearCost's (internal and public) and
docs/API.md and docs/HOWTO.md now say so.

Test: a_texture_past_the_pooled_bound_is_a_shadow_of_its_linear_cost_over_private_memory_alone
replaces the rendered bound test and the previous commit's sampled one:
164x82 at 704-byte rows, past the bound, rendering and sample-only, over a
tracked Private buffer Shadow(LinearCost) and no pitched image where the
device makes such images, over a Shared buffer never LinearCost and the
pitched image where the pooled check of its access passed.

(cherry picked from commit cd89debcd731885e8045dc998252a08edc3dc60f)
2026-11-08 05:20:54 -08:00
Anees Iqbal f8caa83975 Pooled bound: a texture that only samples bytes the CPU writes lies in place at any size
The 48 KiB bound weighs a DRM_FORMAT_MOD_LINEAR image at Metal's pitch
against a shadow that renders into its own optimal image, or samples it
copied in once. A texture that only samples a Shared or Managed buffer's
bytes (or an untracked texture that only samples) has no such shadow: its
shadow is copied in whole at every command buffer that samples it, as the
CPU may have written the bytes. The guest's large device caches are
WebKit's tiles, about 5 MiB each, CPU-painted and only sampled; past the
bound each was a shadow re-copied in every command buffer.

Measured on the Iris Xe (ANV, Mesa 26.2.6; job m3-max-8243,
runtime_lane::pooled_draw_costs::pooled_sample_costs), a frame that
samples four such textures whole after the CPU wrote a texel of each,
GPU microseconds as shadows at the padded pitch against linear images at
the tight one: over Shared buffers 1308x512 (2.7 MB) 327.8/215.9,
1324x940 (5.0 MB) 802.2/380.1, 3648x2038 (30 MB) 5789.3/2601.6; over
Private buffers, whose shadows stand copied in once, 237.7/216.2,
404.4/409.4, 2028.1/2433.2. So the bound keeps covering textures that
render or are written, and those that only sample bytes only the
runtime's commands write (Texels::only_commands_write, the predicate a
shadow's standing uses).

Test: a_sampled_texture_past_the_pooled_bound_lies_in_place_over_bytes_the_cpu_writes
(164x82 at 704-byte rows, past the bound, sampled: over a Shared buffer a
pitched image where the pooled reads check passed and never
Shadow(LinearCost); over a Private buffer Shadow(LinearCost) where the
device makes such images).

(cherry picked from commit d99c9c507b00e7b1537257a7a2fddd18d9563e2f)
2026-11-08 05:20:54 -08:00
Anees Iqbal 48caeeb155 DegradeNotice::command_buffer: the command buffer whose work announced a notice
A consumer that makes some notices fatal (reims-vgpu's ReleasedCommandState,
PrivateResourceOption, HostDeallocatorDelayed) could not tell which command
buffer a notice was about: a ReleasedCommandState announced at a host step on
the scheduler's steps thread ended its whole VM. Now every notice carries the
ID of the command buffer whose work the runtime was doing on the announcing
thread, so the consumer can fail that one command buffer.

What changed:
- CommandBuffer::object_id: an ObjectId, minted at the command buffer's
  making from the process-wide count buffers, textures and heaps use.
- DegradeNotice::command_buffer: Option<ObjectId>, read at the notice's making
  from a thread-local scope (degradation::NoticesFor), as `call` reads the
  call being lowered. The scope is set where the runtime holds the command
  buffer and does its work: the compute and blit encoders' logged funnels and
  their other recording calls and ends, the render lowering's at-call funnel,
  its unit calls, its batches' lowering (on the lowering thread or a drain)
  and its end, the resource state encoder's calls, encoder openings, the
  commit (at the call or queued behind a render end), a batch's submission and
  the storage-form settle that rides on it, host steps, a rebind's encoding
  again, and GPU-time reads. Nested scopes name the innermost.
- None, explicitly, for a recovery of the device (device-recovered), for
  grouped-completion (several command buffers' batches), and inside the
  program's code the runtime calls (exit_guard::program, indirect command
  checks, executed-commands handlers).
- A bind's memoized notices, announced again at each later bind under
  announce_each, are named as that bind's: its command buffer and the call
  being lowered (the call was the first bind's before; same mechanism).
- ObjectId docs, docs/API.md section 9, docs/RUNTIME-PORTING.md; API
  signatures re-blessed (two records: the field and the method).

Tests (runtime crate, device tests):
- notice_command_buffers: an ICB execution recorded at a host step announces
  released-command-state on the steps thread naming the executing command
  buffer; its commit's host-replayed-indirect-commands, on the program's
  thread, names it too; private-resource-option of an ICB made between the
  encoder's calls names none.
- deferred_calls: the call-naming test also checks the command buffer under
  both lowering policies; a new test waits for the lowering thread to announce
  unsized-points after end_encoding and checks the thread, call and command
  buffer, and that a device notice between the encoder's calls names none.
- vertex_conversion_notices: a memoized bind notice (device-nan-encoding)
  announced at a second command buffer's draw names that command buffer and
  its own call index, with bound_notices_made proving the memo was reused.

(cherry picked from commit b4c2ba83ea726229f129a405ce6f432b0bdb0127)
2026-11-08 04:45:15 -08:00
Anees Iqbal df2d326289 A device's teardown leaves the device to the process's end at its next step once the exit began
runtime_lane::exits::exits_right_after_learning_of_completion_are_clean failed on the RTX 5080
in lane 10 of development's round at 9bd38c7994: handler_learns_exit's exit took 2.08 s, against
the lane's EXIT_LIMIT of 1.5 s. In that case the program drops its device while a command buffer
is in flight, then exits once the command buffer's completed handler has run. The device's last
reference goes on the handler thread, so its teardown (DeviceShared::drop, one section of the
exit guard) runs while the program's exit begins, and the exit's hook waits for that section.

Each step of that teardown was timed in a scratch build (b5080 entry holds-exit-2, beside another
process's lane on the GPU). vkDestroyDevice, through the validation layer into NVIDIA's driver,
took 0.3 to 2.6 s; every other step took under 0.25 s in all. 86 of the 120 exits ran past the
hook's 2 s bound and ended at once. In each stack taken 1.2 s after the child's last line, the
teardown's thread was in vkDestroyDevice. The same tail showed with 47174c4775 (the queue-switch
check's round hold) reverted: entry holds-exit-1, 30 exits a tree, the two trees' exits in the
same two modes (about 25 ms, and 150 to 250 ms with a tail to 0.6 and 0.95 s).

The teardown now reads the guard at three points: before its wait for idle, before its pipeline
caches and memory go, and before vkDestroyDevice. Once the exit has closed the guard, the device,
its objects and its memory are left to the process's end, as where the exit began before the
teardown, so the exit waits for no more than the teardown's step in progress. A teardown that no
exit races is unchanged. exit_guard's module docs ("Once closed", BOUND), the teardown's comments
and docs/API.md's process-exit difference say so.

Verified, RTX 5080 Laptop GPU, b5080 entry holds-exit-3 (a shared batch). Runtime_lane::
framebuffer_fetch looped beside on the GPU. handler_learns_exit's child ran as the lane runs it,
alternating two builds 60 times each: development dc064aec27 with the step timings, and the same
with this change. Each exit was measured as the lane measures it, less the exiting thread's wait
for a CPU:

                              before (dc064aec27)   this change
    teardown on the handler   43 of 60              41 of 60
    left at wait-for-idle     -                     41 of 41
    hook's wait (handler)     0.17 to 1.03 s        1 to 7.5 ms
    exit, median              478 ms                206 ms
    exit, 90th percentile     932 ms                411 ms
    exit, longest             1130 ms               590 ms
    exits of 500 ms or more   29                    1
    exits of 1 s or more      2                     0

- With this change, an exit whose teardown ran on the handler still takes 0.17 to 0.59 s past the
  hook. That time is in the exit handlers registered before the hook's last registration (the
  driver's and the layer's), with the device left to them. Before, that remainder was 24 to
  138 ms.
- exit_guard's unit tests passed 46 of 46 (homelab-gem10-1, m3-max-8041).
Not run before this commit: the exits lane whole (development's round runs it), and the change
beside the heavier GPU load of holds-exit-2 (queued: holds-exit-4).

(cherry picked from commit 4ee7b0934a7e2db25b2262cf9c03d84313336be3)
2026-11-08 03:41:48 -08:00
Anees Iqbal f5da0934bf exit_guard: past half its bound, the hook names where the sections it waits for began
An exit that waited for the runtime's work said nothing about what it waited for until its bound
ran out, and then only that the driver still ran it (the at-once notice). An exits-lane exit
that took 2.08 s on the RTX 5080 (runtime_lane::exits, handler_learns_exit, development
9bd38c7994) left no sign of the call it waited for.

Each thread's outermost section now keeps its caller's place while it lasts (Guard::places, a
slot of 64 each, Location::caller through the #[track_caller] doors: enter, Guard::enter,
Guard::enter_making, driver_making, and so release::object's caller). Once its wait has passed
half its bound, Guard::close says on standard error, once: "metal2vulkan: the exit has waited N ms
for M section(s) of the runtime's Vulkan work, begun at: file:line, ...". A section that begins
while every slot is taken goes unnamed. exit_guard's module docs and docs/API.md's process-exit
difference say so.

Tests:
- tests::exit_guard::the_sections_in_progress_name_where_they_began: an outer section's place
  is named, a nested section's is not, another thread's section is named with its own place,
  and an ended section is gone.
- a_busy_exit_past_the_bound_ends_at_once_with_its_status now reads the naming line before the
  notice for a section in progress, and no such line for a CPU device's work.

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

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

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

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

(cherry picked from commit 990d744ec71269663e292c7f2f3e4148d166bacb)
2026-11-08 03:29:51 -08:00
Anees Iqbal 6717cac4ea Pooled class: a bound in bytes past which a texture over pooled memory stays a shadow (TextureShadowReason::LinearCost)
Measured on the Iris Xe (probe 7933): a small cache's shadow costs a fixed 3.5-4.3 us a
command buffer that writes it, which a linear image at Metal's pitch saves, while caches of
1.4 MB and more render and sample 8-18% slower as linear images than as shadows with their
copies. Over Private memory both forms give the same answer (no CPU reads the bytes, the check
judges the first move), so this chooses between two speeds and takes no FAST-PATHS row or
switch. in_place::POOLED_PITCHED_BYTES bounds a texture's rows to their pitch, the same on every
device; past it the cause is ShadowCause::LinearCost, which the placement query answers as the
new public TextureShadowReason::LinearCost { bytes } through the shared route. docs/API.md (the
padding-unobserved reason) and HOWTO say why.

The bound's value here (256 KiB) is provisional: the size sweep on the Iris and the 780M places
it at the measured crossover in a following commit.

Verified: cargo fmt; api signatures re-blessed (one variant added); REFUSALS.md regenerates
unchanged; builds follow.

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit 1978c9008cf2ee9a7d90033e940a93ba24680fbe)
2026-11-08 01:41:31 -08:00
Anees Iqbal 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 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 11a1901a23 In place: the shadow notice names in-place images; the lane counts image-to-image copies
Follows the commit before, whose "WIP" line this commit's verification replaces: an in-place
image of a texture that does not render takes the usages its descriptor lacks where the device's
check passed for what they reach (the storage usage where the writes check passed, the one that
lets free padding change; the attachment usage where the renders check passed; the sampled usage
always), the first set the device makes the image with, most usages first, each at the texels'
pitch in their memory or not made. A texture that renders keeps the route's `storable`
(`texture/route.rs`), the strict writes check, as before; renders stay strict.

- The `undeclared-usage-shadow` notice's declaration and docs/API.md's entry name the in-place
  case: a shadow or stand-in where the device's check failed for what the usage lets reach the
  pages, none where it passed.
- `fresh_pages_take`'s docs point at the route's `storable`.
- The lane counts a shadow's copies from an image too (`shadow_texels_copied_in_images`), which
  is how the usage shadow of an image in place copies, and prints the count on either path.
- The module docs split the declared usage, the lacking usages and a render target's usages
  into their own entries.

Verified: pending (clippy, rustdoc, the runtime's unit tests, lavapipe and Iris lanes run next).
(cherry picked from commit 11d16a1b92cfdca3c409ff2f0501a67f0c1b607c)
2026-11-08 01:11:44 -08:00
Anees Iqbal 7205978cfa Make a tiled texture of more than one level over a buffer's bytes
The x86 macOS guests' WindowServer asks for a texture over a buffer with several
mipmap levels through Metal's private newTiledTextureWithDescriptor:offset:
bytesPerRow: (BGRA8Unorm 54x54 of 6 levels, 64x60 of 7, ShaderRead, over a new
16384-byte Shared buffer at 256 bytes a row). The runtime had no such entry, so
the guest's bundle answered nil and the x86 featureProfile could not be turned on.

Buffer::new_tiled_texture makes what new_texture makes, and a 2D texture of more
levels (BufferTextureCall::Tiled lets linear_plan take them; a texture buffer of
more levels stays MipmapLevelCount, and its offset keeps the validated 16-byte
rule as the linear SPI's does). No Vulkan image lays level 0 over the buffer's
rows and the other levels elsewhere, so the shared route sends it to a shadow
over any buffer (Route::Levels, answered TextureShadowReason::Mipmapped): one
image of every level, made zero in a Shared or Managed texture, whose existing
shadow copies move level 0's texels alone (their range was already level 0), so
the bytes reach level 0 before the GPU reads it and level 0's writes reach the
bytes by the end of the encoder. Announced as shadowed-texture, naming the
levels; counted in shadowed_textures and shadows_zeroed.

The paths that assumed every texture over a buffer has one level:
- blits: such a texture is an image to a blit, as a heap shadow is
  (Texture::blit_texels; BlitCommandEncoder::see notes it), so every level is a
  blit source and destination, generate_mipmaps included;
- get_bytes and replace_region reach level 0 in the bytes and the other levels
  in the image;
- a reinterpreting view shadow and a usage shadow, whose truth would be the
  bytes alone, are refused for it.

Buffer::tiled_texture_placement answers the placement for the new call. Docs:
the item's rustdoc (Metal's selector and what differs), docs/API.md, the
degrade catalogue, RUNTIME-PORTING, the runtime README; api_signatures blessed
(three additions, no breakage), REFUSALS regenerated (MipmapLevelCount's text).

Verified: api-signatures, refusal-surface and metal-coverage checks locally; the
builds, lint and device runs are the potluck jobs that follow.

(cherry picked from commit b040d815059b99a20426234239aa756b282b25b9)
2026-11-08 00:39:19 -08:00
Anees Iqbal e038e8b5fa Tell a loss refusal apart by lost_refusal's own answer, and regenerate the refusal surface
Device::lost_under named RuntimeGap::MadeBeforeRecovery in a match, which
the refusal surface script counts as a refusal site of the gap (a third
one, lost_under, which refuses nothing). It now compares the answer with
DeviceLost and with lost_refusal's own answer for the generation, which is
MadeBeforeRecovery wherever the line recovers past it, as the check already
requires: the same calls go to the serving generation.

docs/REFUSALS.md regenerated: the gap keeps its two sites; five refusal
sites read their _now function's name now that the public forwarders run
through Device::at_serving (the refusals are unchanged).

(cherry picked from commit 0eea4c413fdcddf56a39f7f12b89c8ca23f9ff01)
2026-11-08 00:14:43 -08:00
Anees Iqbal ab8651ae38 Run a device call again on the serving generation where its own was lost under it
tests::device_recovery::each_recovery_announces_its_own_wait failed on the M3
in 10 of 30 runs at 2fed3c2453 (m3-max-7120): a waiter thread's
`device.new_buffer(..)` returned NotImplemented(MadeBeforeRecovery) while
another thread recovered the device. A public call of a root handle took the
serving generation (Device::current -> Line::current), the recovery marked it
lost, and the call's own check of the loss (new_buffer_placed's is_lost) then
refused it through lost_refusal, whose line had gone past the generation. The
call came from the device the program holds, which Metal keeps across a
recovery: it must not be refused because the generation it took was lost
while it ran (rule 2).

The device's public calls now run through Device::at_serving: a run refused
for its generation's loss (DeviceLost, or MadeBeforeRecovery as lost_refusal
answers it) where the line went past that generation runs again on the one
serving next. A run refused so kept nothing, so the call runs whole again.
Each run is on a later generation than the one before, after its recovery,
which Line::current waits for, announced past RECOVERY_NOTICE as before; a
line that cannot recover still answers the loss, and a thread command
buffers' completion depends on, whose calls reach the lost generation, is
answered as before (no retry). A call refused for an object of an earlier
generation while its own generation serves is answered as before.

The calls that consume arguments a refused run could not hand to a second
one (host memory and its deallocator or keep-alive, a range token, a buffer
descriptor's contents) run through Device::at_serving_taking: they go to the
generation once it is not lost, else to the next, and from there a loss of
it follows the call: the thread's RunsOn scope makes Device::is_lost answer
false for that generation to the call's own checks, so the call completes on
it as one the loss came after, its object made before the recovery. The two
texture calls with a range token make the texture through at_serving and keep
the token on it after (their _now forms, used by nothing else, are gone). The
calls that wrap the consumer's own Vulkan objects (new_texture_with_vk_image,
_plane, new_buffer_with_vk_buffer) are unchanged: those objects belong to the
VkDevice the caller made them on.

Tests: device_recovery gains a call whose first run meets a recovery and runs
again on the next generation, and a taking call that completes on the
generation lost after it took its arguments. Docs: the runtime README's lost
device section, API.md's device-recovered notice, line.rs's module docs.

(cherry picked from commit 3af6741dcf79b99a608ea0a464b98734dac52ba5)
2026-11-08 00:14:43 -08:00
Anees Iqbal d60e8b5b60 Answer a texture's placement through the image in place's making up to its bind
On the Radeon 780M (RADV) a guest surface whose pitch is no multiple of 256
bytes (3664 px BGRA8 at 14656 bytes a row) is refused Refusal::Pitch where the
image in place is made: the driver lays its linear image's rows out at another
pitch, and refuses the DRM_FORMAT_MOD_LINEAR image at that one. The query
stopped at the route and answered InPlace, so the consumer sent such a surface
in place and got a shadow copied in for every command buffer, the case the
query exists to prevent.

Now the image in place's making is two steps, shared: Device::unplaced makes
and checks the image of a plan before any memory is bound (over pages imported
by their pointer, in_place_unbound's linear or DRM_FORMAT_MOD_LINEAR image and
its requirements against the bytes' place and memory type; over dma-buf pages,
dma_buf_image_unbound's image checked against the pages, before the caller's
source is asked), and Device::place binds it. in_place_image runs the rows
check, then the wider plans and the declared plan through both steps as
before. The query's placement_over_buffer, where the route is the image in
place, calls Device::in_place_image_made: the same rows check and the same
unbound step for the declared plan first and then the wider plans, releasing
each image unbound, answering Shadow(Refused(kind)) with the declared plan's
refusal where none is made. Its cost: one or two VkImages where the declared
plan is made in place, a pair more per wider plan where it is refused; nothing
bound or submitted. What only the bind shows stays unknown: over dma-buf pages
the caller's source and the driver's import of its dma-buf.

The new device test a_pitch_the_device_lays_no_image_at_answers_its_shadow
asks and makes BGRA8Unorm textures at pitches past their rows (61 texels at
256..1024 bytes, 3664 texels at 14656, 14672 and 14848, a render target), each
answer equal to what the making counted, and at least one Shadow(Refused(Pitch)).

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

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

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

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

Verified: pending.
(cherry picked from commit 200f2a9e2b26eeaff45c1cc5ec71decf42d8437e)
2026-11-07 23:57:05 -08:00
Anees Iqbal 95a5f1ad37 Point HOWTO's integrators at the texture placement query
docs/HOWTO.md's passage on textures over host pages told a program to start
the in-place check early with Device::settle_in_place_checks; it now also says
that a zero timeout later answers whether the verdicts are known, and that a
program routing each surface to its pages or to a copy of its own asks
Buffer::texture_placement (or texture_placement_with_iosurface_plane), whose
answer is the making's own decision. Docs only.

(cherry picked from commit 17bbae52a0330a75a5d1cd522407f2888dc7bcff)
2026-11-07 23:40:30 -08:00
Anees Iqbal 1aeff532b6 Answer where a texture over a buffer's bytes lies before it is made
A consumer that routes each surface either to textures over its pages in place
or to a cache of its own had to parse the doc-hidden in_place_check_report()
strings and re-derive row ends to learn the runtime's verdict. Now it asks:

- Buffer::texture_placement(descriptor, offset, bytes_per_row) and
  Buffer::texture_placement_with_iosurface_plane(descriptor, plane) answer a
  TexturePlacement: InPlace, Pending (a shadow made before its verdict, which
  moves in place where it passes), Shadow(TextureShadowReason) (policy, store
  width, check failed or unchecked with its InPlaceAccess and InPlaceRowEnds,
  Refused(InPlaceRefusal), texels past the length, a device copy),
  NotHostPages, or OtherShape.
- The answer is the making's own decision: the route a texture over a buffer
  takes (past its length, no host pages, a device copy, bytes detached or
  copied, and the in-place decision against the verdicts) moves out of
  storage_over_buffer into Device::route_over_buffer (texture/route.rs), which
  the making and the query both call. make_texture_over takes a goal, make or
  ask, so the query runs every check the making runs before it makes anything
  and refuses the same arguments with the same errors; the IOSurface client
  direction refusal is one function both use.
- Device::settle_in_place_checks is public, documented: it starts the check,
  says when the verdicts are known (a zero timeout waits for nothing), and how
  a recovery's new VkDevice reads them again or checks anew.

Tests: tests/texture_placement.rs maps every route and shadow cause to its
answer; tests/texture_placement_device.rs (m2v_gpu, m2v_cpu_icd) asks and
makes over host pages: pending then known after the settle, the pending
texture moving to the answer at the next quiet commit, a store width, a render
target, an IOSurface plane, a long buffer, texels past the length, no host
pages, a texture buffer, detached bytes, the Shadow policy and a forced failed
check, comparing each answer with the counts the making moved, and the
errors of refused arguments.

docs/API.md and the runtime README describe the query; api_signatures
re-blessed; docs/REFUSALS.md regenerated.

(cherry picked from commit bef6ce09f56d8a7c1ad5ee7ef934a06a39b58c7a)
2026-11-07 23:35:06 -08:00
Anees Iqbal 973245f2c6 Make a rebound draw's slot rebinds and push overlaps allocate nothing in steady state
runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds
read 21.16 allocations a draw on the M3 in a debug build, past its bound of
20 (round 7e9acd5e73). Cut 4 (2fed3c2453) added allocations to the draw path:

- BindingPlan::rebind_draw_slots_with checked the rebinds it was given
  against fresh ones (slot_rebinds) at every draw in builds with debug
  assertions: a new SlotRebinds, its lists and each changed buffer slot's two
  field lists, at each draw rebound.
- The runtime made a draw's slot rebinds anew at each miss of its cache
  (SettledHere::rebinds: a new settle, or a draw rebound that changed other
  slots): the slots' copy and the rebinds' lists, in release builds too.
- Bound kept each push write's later overlaps in a list of its own
  (push_later), one more list a record allocates at its first push.

Now:
- SlotRebinds holds flat lists of Copy items: a changed buffer slot's push
  fields are ranges of one list of fields (words) rather than two lists of
  its own. BindingPlan::slot_rebinds_into makes rebinds in place of what a
  SlotRebinds held, its lists keeping their room, so making them again for
  no more slots and fields allocates nothing; slot_rebinds makes them in a
  new one. SlotRebinds is Default (made of nothing) and names its slots
  (SlotRebinds::slots). The builder walks the template's changed push fields
  through one iterator (changed_fields) for the validity check, each
  buffer slot's residual and guest-address fields, and the loose ones, in
  the order the lists held before.
- rebind_draw_slots_with's debug check makes the rebinds again in a
  thread-local scratch whose lists keep their room: it allocates nothing
  past its first.
- SettledHere keeps the rebinds in a SlotRebinds it makes them in place in,
  and a new settle takes the replaced one's (SettledHere::took_place_of), so
  a cache miss allocates nothing where the lists had room.
- Bound keeps the overlaps beside each push write's shape in the one list.

Public: BindingPlan::slot_rebinds_into, SlotRebinds::slots and its Default
(signatures blessed; API.md says so). engine_graphics_binder checks
slot_rebinds_into over rebinds of other slots against slot_rebinds.

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

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

Doc only.

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

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

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit f815203f074e1b2f922cd2a2d337ba31ea51e02f)
2026-11-07 22:13:59 -08:00
Anees Iqbal 5aa31f836c Rebind a draw's slots by rebinds the plan works out once for them
A rebound draw that moved buffer offsets spent about 470 instructions
a draw (lavapipe, draws.10k shape) in rebind_slots, and 13% of the
M3's time, writing one 4-byte push word: each draw walked the
template's stages, fields, buffers and vertex buffers again to find
what the changed slots decide, though that depends on the plan and
the slots alone.

BindingPlan::slot_rebinds now works that out once for a list of slots
(a public, opaque SlotRebinds: each changed buffer slot's place among
the descriptor ranges and its push fields, the loose fields, the
vertex buffer places; None where rebind_draw_slots_into answers
Ok(false) whatever the state), and rebind_draw_slots_with rebinds by
it, looking at the state and the commands alone and writing each word
as a fixed-size store. rebind_draw_slots_into is the two in turn, so
there is one implementation; builds with debug assertions check that
the rebinds given are the plan's own for their slots.

The runtime keeps the rebinds with the settled draw (SettledHere),
made at the first draw rebound that changes a list of slots and kept
while the next draws change the same slots; a new settle drops them.

The rebind test now also rebinds each case by rebinds made once per
plan and slot list and holds them to the whole rebind's answer and
commands. docs/API.md describes the two calls; the surface table,
the signature table and docs/REFUSALS.md (a renamed site) follow.

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

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

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

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

(cherry picked from commit ea33a4ce5c909723a5c425a7e1dd8ce0fc4a8d5f)
2026-11-07 21:41:11 -08:00
Anees Iqbal ee5d3cfab9 Regenerate the conformance coverage for lavapipe's linear texture alignment rows
d62b50b90e added 16 known-gaps rows for device-linear-texture-alignments (lavapipe's own
answer) without regenerating docs/CONFORMANCE-COVERAGE.md: ledger rows 3295 -> 3311 and the
case's rows listed. scripts/conformance-coverage/coverage.py, nothing else changed.
2026-11-07 21:10:16 -08:00
Anees Iqbal 0529a98e4c Announce each recovery's own wait, slow failing and failed making
After a device's first recovery, a later recovery's step notices were
never shown: a call's wait for the recovery past 10 seconds, its command
buffers taking past 10 seconds to fail, and its new VkDevice's failure
all went through degrade_once(DeviceRecovered), whose record carries
across generations, and the first recovery's own notice set that record.
So a slow second recovery announced nothing, and a second recovery whose
VkDevice could not be made left the device answering as lost with no
notice (rule 2: a degradation is announced).

Each recovery's notices are now its own (Device::degrade_recovery_step,
whatever the kind's record says), still bounded: the wait is announced
once per recovery by the first call to wait past the bound (a flag in
the line's Lost state, so N waiting calls give one notice, not N), the
slow failing once per recovery by the call that claimed it, the failed
making once (the line fails). degrade_recovered no longer sets the
kind's record, which nothing reads for this kind now.

Tests (tests::device_recovery, device builds): with the bound set to
zero through a per-device test hook, each_recovery_announces_its_own_wait
runs a first recovery, then recoveries with three threads calling the
device, and requires a later recovery to announce one wait (never two);
a_later_recovery_announces_its_failure fails the second recovery's
making through a hook and requires its notice to reach the sink.

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit 0cff30259ed6a7cba9bfcabb02643650204c1e79)
2026-11-07 19:55:50 -08:00
Anees Iqbal b8f7b5a7f9 Answer minimumLinearTextureAlignmentForPixelFormat: from the device's images, per format
The query answered 16 for every format on every device, Metal's answer on an Apple GPU. On RADV a
texture at 16 never goes in place over host pages: its linear images lay rows at multiples of 256
and align their memory to 256, and DRM explicit layouts take only multiples of 256. A guest that
lays its buffers out by the answer then gets shadows where 256 would have given images in place.

The answer is now the device's, worked out lazily at a format's first query. The runtime makes
the images a 2D ShaderRead texture over host pages takes in place (in_place_unbound, the product's
own maker: the driver's linear image made for host allocations at the texture's pitch, else the
DRM_FORMAT_MOD_LINEAR one). It tries each power of two P from 16 to 4096, at widths of 1 to 1920
texels and 3 rows. The answer is the first P at which every width's image lies at
roundup(width * texel, P) and its memory alignment divides P. Each image is released and never
bound.

- The first answer is kept for the device's life.
- Each answer is recorded per driver, runtime and format in the shader cache's content directory.
- A device that imports no host pages, a format no P brings in place, and a failed probe all
  answer Metal's 16.
- New counts: WorkCounts::linear_alignments_probed and linear_alignments_recalled.

Nothing new is refused. LINEAR_ALIGNMENT (16) stays the acceptance rule, and a texture under the
answer is made as before: an image in place where the device takes its layout, else the
announced shadow.

The query moves from DeviceProperties to Device
(Device::minimum_linear_texture_alignment_for_pixel_format), since it needs the device's images.
DeviceProperties::minimum_linear_texture_alignment_for_pixel_format is removed.

The private properties change as follows:
- deviceLinearTextureAlignmentBytes and linearTextureAlignmentBytes are the largest per-format
  answer.
- The iosurface pair stays 16.

Supporting changes:
- texture/in_place_image.rs's in_place_unbound becomes pub(super).
- buffer_texture.rs's texel_bytes becomes pub(super).
- The unit tests now hold Metal's rule (capabilities::linear_alignment_rule).

Tests:
- A record test.
- runtime_lane::linear_alignments:
  - Every format's answer is printed.
  - A texture at the answer over host pages is in place wherever the check passed for reads.
  - A 64-byte-row texture is made, as a shadow, where the answer is larger.
  - A second device of the same driver reads the record and probes nothing.

Regenerated: api_signatures, docs/REFUSALS.md, docs/METAL-COVERAGE.md (coverage.tsv mapping).
Updated: RUNTIME-PORTING.md and the conformance device-queries docs.

Verified: python generators only, so far. The builds, unit tests and the lanes on the M3, RADV,
lavapipe and NVIDIA run next, and their results go with the tip.

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

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

Not yet built.

(cherry picked from commit b0cf11a49e44b8530b84e664d231c928421ddf93)
2026-11-07 19:14:46 -08:00
Anees Iqbal a508b327de Zero-initialized images: an enables test, API.md's runtime-own extensions, the signature table
Enables::enable_zero_initialize_device_memory gets the test each runtime-own enable has
(tests/enables.rs: the structure, of the registry's type 1000620000, is chained only once
enabled, its member TRUE, the extension's name after host image copy's). docs/API.md's paragraph
of what the runtime enables for itself outside the vocabulary names VK_EXT_zero_initialize_device_memory
and when. api_signatures.tsv gains WorkCounts::images_started_zeroed (scripts/api-signatures, --bless).

Not yet built; the next gem10 build runs it.

(cherry picked from commit 2ec9061a61c7262e7a05b4e42f0e1122518439cf)
2026-11-07 19:14:46 -08:00