Commit Graph
5218 Commits
Author SHA1 Message Date
Anees Iqbal ce6bc460cf A lost generation's live buffers' table goes at its rest: the lost VkDevice no longer lives on
What: at a lost generation's rest (`DeviceShared::keep_nothing`), its table of the live buffers
and the table's spare go (`LiveBuffers::close`), before its recycler closes, so their buffers
park there and go with it. The table's lifetime rule says so (`live_buffers.rs`: its module docs
and `Inner::current`, `Inner::spare`), and `keep_nothing` lists it among the device-level objects
of work.

Why: the table's upload buffer (and the spare), buffers of the runtime's own on the generation,
hold it "only while a listed buffer lives, which holds it too". A recovery breaks that rule: it
carries the listed buffers on, and they stop holding the lost generation, but no command buffer
runs there again to make the next change that would drop the table. So once any command buffer
had made the table (an indirect command buffer's execution, which resolves its records'
addresses through it), the lost `DeviceShared` kept two strong holds (the upload buffer's handle
and its pages') for the life of the process, its `VkDevice` and driver memory with it, after the
program let go of everything. Development had it before this change (a diagnostic on lavapipe:
"1 tables made", live VkDevices 2 before and after the program's release of everything; the
generation came to rest).

Test: `device_recovery_live_table::a_lost_generation_s_live_buffers_table_goes_at_its_rest`.
An indirect execution makes the table (`WorkCounts::live_tables_uploaded` rises: the path ran),
the buffer and its state go, the three buffers live past a marked loss (not a parked
generation); the live VkDevices fall to 1 while they live, and stay 1 once they go. Its helpers
(the indirect state, buffer, command and execution) serve the every-kind test next.

Verified, at the change on a0b85d89d4 (with the carry after it): on lavapipe (msi, nextest, one process a
test) this test and the 41 other recovery, indirect-command-buffer and released-program tests
pass; its negative control (`close` made a no-op) fails it at the live count with the buffers
alive (after the test's 60 s wait), and the every-kind test at its end. On the GPUs, one
process a test: the Radeon 780M (RADV) and the Iris Xe (ANV) pass it with the 41 others; the RTX 3090
passes it, and fails one other, the exportable test, as development does there (its DmaBuf
re-export's inode). Clippy of the runtime, validation and conformance (all targets and
features, --cfg m2v_gpu and m2v_gpu_hazards): no message.
2026-11-13 00:37:07 -08:00
Anees Iqbal 9906832ceb Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-13 00:23:01 -08:00
Anees Iqbal b6131002df A compute pipeline's making names itself and dumps its module before the driver's call
With METAL2VULKAN_LOG_PIPELINES on, a compute VkPipeline's making now logs a line as it starts,
before vkCreateComputePipelines: the kernel, its SPIR-V hash and words and its specialization.
With METAL2VULKAN_DUMP_PIPELINES set, its module is written then, not after. A making that never
returns (a driver compile that runs for tens of minutes) is the start line without its made
line, and its module is on disk, where before neither the line nor the module appeared until the
driver returned. Default-off diagnostics; no product path changes.

The made line no longer writes the module (the start did). The compute log test checks that the
start line, with the same module hash, comes before the made line.
2026-11-13 00:21:49 -08:00
Anees Iqbal e47cfad71f Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-13 00:19:23 -08:00
Anees Iqbal 7bcc61b408 SEMANTICS_VERSION 2081, RUNTIME_VERSION 2205: a large kernel's whole grids run on its partial-threadgroups variant
A kernel whose base module holds COUNTED_WORDS (65,536) SPIR-V words or more now runs its whole
grids, uniform dispatchThreads and dispatchThreadgroups, on its partial-threadgroups variant with
every thread live, where its ragged grids of the same form run on that variant. A large kernel
then needs one VkPipeline per threadgroup size for all three kinds of dispatch, and its creation
no longer makes the predicted plain region no dispatch would take. Where the variant is refused,
the dispatch takes the plain pipeline. Smaller kernels are unchanged. The answers are the same
(words equal the split's and Metal's), so this is not a speed-for-accuracy choice and takes no
switch; the measured GPU cost of the variant on uniform grids (0.997-1.020 of the plain form, XTX
24567) is stated at compute::partial_direct and in docs/API.md.

The binder lays a whole grid on a partial plan out as the same regions without the NONUNIFORM
flag, and a dispatchThreadgroups's regions with MultiRegion 1 (SEMANTICS). The runtime picks the
variant (ComputePipelineState::whole_on_partial) and counts it in
WorkCounts::whole_dispatches_on_partial_variants (RUNTIME). Two public translator accessors,
CompiledFunction::observes_threadgroup_partition and observes_partition_through_simdgroups_alone,
expose facts the compile already decides.

Verified by the change's own runs: lints green in every configuration (24640, 24641); translator
tests 5/5 (24667), whole Threads and Threadgroups grids on the partial plan equal to the split's
and Metal's words with one specialization per threadgroup size on 5 profiles; lavapipe 3/3
(24642), a large kernel making 1 VkPipeline over 2 whole dispatchThreads, 1 dispatchThreadgroups
and 1 ragged grid (counter 3) and a small kernel the 2 it made before (counter 0). The XTX run
(24690) is pending.
2026-11-13 00:18:39 -08:00
Anees Iqbal 03c587b9ee A large kernel's whole grids run on its partial-threadgroups variant
A kernel that observes its threadgroup partition runs its ragged dispatchThreads grids on its
partial-threadgroups variant, one VkPipeline of the call's threadgroup size (MultiRegion 1),
while its whole grids took the plain pipeline (MultiRegion 0): two driver compiles of the same
module. On a guest's run on an RX 7900 XTX the plain one, for a kernel of 2,415,531 words, was
26.9 s of a 39.8 s warm pass.

Now a kernel whose base module holds compile_memory::COUNTED_WORDS (65,536) SPIR-V words or more
runs every direct dispatch of a threadgroup size on that variant, every thread live, where its
ragged grids of the same form run there (it observes its partition, and for a one-row grid in
one-row threadgroups otherwise than through its simdgroups alone, whose such grids run flat).
Where the variant is refused it falls back to the plain pipeline as before. Smaller kernels keep
the plain pipeline. Both forms give the same answers, so there is no switch and no FAST-PATHS
row.

- Binder: on a partial-threadgroups plan, a whole Threads grid takes the same L-sized regions
  per group-count chunk, unflagged (no NONUNIFORM), and a Threadgroups dispatch's regions have
  MultiRegion 1, so one specialization of a threadgroup size runs all of them.
- Translator API: CompiledFunction::observes_threadgroup_partition and
  observes_partition_through_simdgroups_alone state the two partition facts the compile already
  decides, so the runtime can decide at creation which form a kernel's ragged grids take.
- Runtime: compute::partial_direct takes whole grids and dispatchThreadgroups of such a kernel
  (ComputePipelineState::whole_on_partial). WorkCounts::whole_dispatches_on_partial_variants
  counts each such dispatch. A creation's predicted region is not made for such a kernel's
  predicted dispatch, which would run on the variant, not the base.
- GPU cost, measured once on the XTX (RADV) with the probe on steelbrain/uniform-partial-probe:
  1,048,576 threads in 64, partial/plain 0.997 to 1.020 over four straight-line kernels, words
  equal. Stated at partial_direct and in docs/API.md's dispatch-regions paragraph.

Tests: engine_partial_threadgroups's whole_grids_run_on_the_partial_plan_with_every_thread_live
(whole Threads and Threadgroups dispatches on the partial plan give the split's and Metal's
words, and every grid of a threadgroup size takes one specialization, on the CPU interpreter);
the runtime's a_large_kernel_s_whole_grids_run_on_its_partial_variant (a large kernel makes one
VkPipeline over whole grids of both forms and a ragged one, counting 3 whole dispatches, with the
plain pipeline's words; a small kernel makes the plain pipeline's and the variant's, counting 0).
heap_trimmed makes its two large makings at two threadgroup sizes, since its whole and ragged
grids now share one.
2026-11-13 00:18:06 -08:00
Anees Iqbal 11b6ad08e9 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-13 00:10:30 -08:00
Anees Iqbal 92743c316c RUNTIME_VERSION 2204: the draw merge passes hold their counts in u32 words
The GPU form of a merged render execution (bind/replay/merged.rs) now computes its counts as two
u32 words, low first, with the corners as an OpUMulExtended product and the sums carried by hand;
the only u64 values it computes are addresses. On an RTX 3090 a guest's merged first draw came
out at 2^33 above its true total and hung the GPU. The runtime's merge kernels' SPIR-V changes,
and so do the counts a merged draw reads on such a device. That changes runtime behaviour.

Verified by the change's own runs: the_merge_passes_compute_no_u64_but_addresses fails with
merged.rs from before the fix and passes with it (24675); clippy and rustdoc clean (24675); 50
bind::replay tests pass on um790, the interpreter merge tests among them (24638). Not yet
verified on the device that hung: that is reims's RTX 3090 rerun.
2026-11-13 00:09:48 -08:00
Anees Iqbal 49faf7c8a0 The merge passes hold counts of corners in u32 words
A guest's render executions merged on an RTX 3090 (NVIDIA 620.70.06) drew their first merged
draw over 4 chunks of 2^31 - 2 vertices, seconds of vertex work, and the GPU hung (Xid 109).
The encoder trail's GPU-form readback showed both executions' totals at exactly 2^33 above the
sum of their commands' corners (321039 and 2184 corners, with second draws of 321047 and 2192
vertices), and a total no sum of whole triangles makes. The arguments, ranges, status words and
second draws were otherwise right. So the u64 count itself came out wrong in the passes, as the
u64 division did before on an RTX 5080 laptop GPU (615.71.09).

The passes now hold every count as its two u32 words, low first, as the prefix and the block
sums already lay out a u64. A command's corners are the OpUMulExtended product of its whole
vertices and its instances. A sum adds the low words and carries into the high ones. The last
pass takes the total's words directly to the u32 division it already ran. A u64 the passes
compute is an address alone. The layout is unchanged, so the vertex variant reads the prefix as
before.

Tests:
- the_merge_passes_compute_no_u64_but_addresses (replacing the division-only check): a u64 in
  either pass is built only by OpIAdd, OpIMul, OpUConvert of a u32, a constant or a push
  constant load, and used only to build another or as a pointer. Before the change it fails, on
  the u64 compare, select, shift, conversion, load and store.
- The interpreter's merge tests (saturation and the VERTICES fault among them) hold the same
  answers.
- The trail's GPU-form test gains an indexed case of the guest's shape: 8162 commands, the first
  86 through a range read from a buffer, 90 blocks of 91. Its first merged draw must hold no
  instance.

Verified:
- On the 2080 and the 3090 (620.70.06), the indexed case's synthetic shape ran right before the
  change too (total 22446 corners, no block sum with a high word; the 3090 run skipped the draw).
  Its scratch sat below 4 GiB of device address there, so neither device reproduced the guest's
  high word, and the hanging device's proof is the guest rerun.
2026-11-13 00:09:20 -08:00
Anees Iqbal 61a2ce6563 An indexed merged execution through a range read from a buffer draws no whole chunk below one
The trail's GPU-form test gains an indexed case of the compositor's shape: 8162 commands, the
first 86 of them run through a range a buffer holds, merged over 90 blocks; its first merged draw
must hold no instance.
2026-11-13 00:09:20 -08:00
Anees Iqbal 1c4019cead Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-13 00:08:25 -08:00
Anees Iqbal c589882480 RUNTIME_VERSION 2203: a surface depth texture's usage shadow copies the plane's own aspect
A usage shadow of a depth or stencil texture made over a surface's plane, or of a view of one,
now copies only the aspect the plane holds, one aspect per region as Vulkan copies
(VUID-VkBufferImageCopy-aspectMask-00212, which the validation layer reported). The other aspect,
which no copy writes, starts at zero, as the texture's own shadow does. The X32_Stencil8 view's
shadow also took its aspect from the view's format (stencil), so it copied the plane's depth bytes
into the stencil. It now takes the unit of the texture made over the plane
(Texture::surface_plane_unit). Which bytes a shadow holds changes runtime behaviour.

Verified by the change's own runs on lavapipe (24672): one usage shadow, the depths are the
plane's, the stencil reads 0, and the validation layer reports nothing. With usage_shadow.rs
reverted, every second texel's depth is wrong and the test fails. A test-only hook
(sampled_costs_forced) makes if_free answer "not free" to force the shadow. clippy --cfg m2v_gpu
passes (24673); runtime suite 2454/2455, the one failure an intermittent guest-RAM test that also
fails without the change (24657).
2026-11-13 00:07:36 -08:00
Anees Iqbal fcc0a73ed8 A surface depth texture's view takes its usage shadow's aspect from the plane
What: a usage shadow of a view of a depth or stencil texture over a surface's plane copies the
aspect the plane holds, the unit of the texture made over the plane
(`Texture::surface_plane_unit`), not the unit of the view's own format.

Why: an `X32_Stencil8` view of a `Depth32Float_Stencil8` texture over a plane took the
stencil as its unit, so its usage shadow copied the plane's depth bytes into the stencil
(lavapipe, m3-max-24657: the view's stencil reads were not 0). The plane holds the depth.

Verified: pending the lavapipe run of
tests::surface_depth_usage_shadow at this commit.
2026-11-13 00:07:01 -08:00
Anees Iqbal 7e7f26aadc Name the usage-shadow test's depths apart from its read helper
What: the depths the kernel read are `seen`, not `read`, which shadowed the
helper the stencil read then called.

Why: the test did not compile (E0618).

Verified: the jobs that follow.
2026-11-13 00:07:01 -08:00
Anees Iqbal 3aad189eaf A surface depth texture's usage shadow copies the plane's aspect alone
What: texture/usage_shadow.rs's shadow of a texture's bytes copies only the
aspect a surface's plane holds (copy_plan::surface_depth_unit) for a depth or
stencil texture over a plane, and starts the image ZeroUnpatterned so its
other aspect reads 0, as the texture's own shadow does
(Device::storage_over_buffer). Every other usage shadow is as before.

Why: it copied DEPTH|STENCIL in one region from the bytes, against
VUID-VkBufferImageCopy-aspectMask-00212, and the plane holds no stencil.

Verified: tests::surface_depth_usage_shadow on lavapipe (job in the report).
2026-11-13 00:07:01 -08:00
Anees Iqbal 8d24c78348 Test a surface depth texture's usage shadow under the validation layer
What: tests::surface_depth_usage_shadow makes a Private Depth32Float_Stencil8
texture over a surface plane without ShaderRead, on a device where a test
hook (DeviceShared::sampled_costs_forced, read by Device::if_free) makes
SAMPLED cost every image that lacks it, so the texture's shadow lacks it and a
kernel's depth read binds a usage shadow of the bytes. It asserts one usage
shadow was made, the depths read are the plane's, the X32_Stencil8 view reads
0, and the validation layer reports nothing.

Why: that usage shadow copies both aspects from the bytes in one region,
which VUID-VkBufferImageCopy-aspectMask-00212 forbids (one aspect a region),
and the plane holds the depth alone.

Verified: fails without the next commit's fix on lavapipe (job in the
report).
2026-11-13 00:07:01 -08:00
Anees Iqbal e5876e36b1 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 23:58:40 -08:00
Anees Iqbal 228ab0ca29 RUNTIME_VERSION 2202: a Managed buffer's named range is copied in by the GPU as the submission runs
By default (ManagedCopyInPolicy::AtSubmission), a Managed buffer's didModifyRange range is now
copied by the GPU from the import or the runtime's own mirror into the device copy as the
submission runs. There is no CPU copy and no staging. The old commit-time snapshot stays as
ManagedCopyInPolicy::AtCommit, selected by DevicePolicy::exact_answers(): the Macs disagree (the
5300M doesn't read a write made after the commit, the UHD 630 does), so the default takes the
cheaper answer (owner rule 11-07), with its bound in FAST-PATHS. Staging that remains (uncovered
pages, copied imports, AtCommit) is host-cached system memory, never BAR, sized so the recycler
reuses it. That changes runtime behaviour.

Verified by the change's own runs (managed_copy_in_bench, 32 MiB commits): RTX 3090 eGPU commit
190 ms -> 0.04 ms, completion 194 -> 17.5 ms, 0.17 -> 1.9 GB/s (24627); RX 7900 XTX commit 6.0 ->
0.03 ms (24636); unified memory copies nothing (lavapipe, 24602). managed_copy_device 28/28 and
device_copies 8/8 on both GPUs in both settings; clippy and rustdoc green (24603, 24577, 24578).
2026-11-12 23:58:01 -08:00
Anees Iqbal a0e7b75ad6 The copy-in ledger row states the measured cost of AtCommit
What: docs/FAST-PATHS.md's managed_copy_in row gives the copy-in bench's
medians on the RTX 3090 (eGPU) and the RX 7900 XTX: the commit call and the
wall time to completion of 32 MiB commits under both values.

Why: a ledger row states the cost of its accurate form.

Verified: jobs 24627 (3090) and 24636 (XTX), two rounds each, both values.
2026-11-12 23:57:16 -08:00
Anees Iqbal a6bf288f2c Match the managed copy-in policy by equality in the tests
What: the named-rounds tests' readable() and the lane test's step-4 answers
test ManagedCopyInPolicy by equality instead of matching its variants.

Why: the enum is non_exhaustive, so a match outside its crate needs a
wildcard; the tests did not compile (E0004).

Verified: the jobs that follow.
2026-11-12 23:57:16 -08:00
Anees Iqbal 9f3dc79994 A Managed buffer's named range is copied in by the GPU as the submission runs, by default
What: DevicePolicy gains managed_copy_in (ManagedCopyInPolicy, a runtime
choice no profile carries). Under the default, AtSubmission, a commit that
takes a did_modify_range's range has the GPU copy it from the host copy (the
import of the caller's pages, or the runtime's own host-cached memory) into the
device copy as the submission runs (Buffer::upload), with no CPU copy and no
staging. Pages no import maps are still staged by the CPU at the commit. Under
AtCommit, which exact_answers() selects, the commit copies the range on the
CPU as the host copy holds it then (the RV2145 snapshot, Buffer::upload_now,
now upload_at_commit). Staging buffers of both directions are now Shared in
the default CPU cache mode, host-cached system memory, never the device-local
(BAR) memory a write-combined buffer prefers without unified memory, and of
power-of-two lengths (64 KiB at least), so a like-sized later copy takes a
buffer the recycler parked rather than new memory.

The ledger gets its row (the bound: a CPU write after the commit, before the
GPU runs the command buffer, may be read), and managed.rs, managed_copy.rs,
API.md's accepted difference, the runtime README, FAST-PATHS' costs bullet and
the conformance crate's Policy::Exact say so. tests::fast_paths names the
choice and checks it keys no profile and that exact_answers() takes AtCommit.
The named-rounds race tests take the policy: by default each round reads, in
each byte, its own byte or one the CPU wrote to its buffer after its commit
(0xee, a later round's), never an earlier round's; under AtCommit only its
own; three AtCommit tests join the three default ones. The lane test's step 4
reads either oracle's answer by default and the 5300M's under AtCommit
(exact_answers_take_a_did_modify_range_at_the_commit).

Why: a compute benchmark's commits spent most of their time in this copy on a
discrete GPU (a CPU memcpy into write-combined staging in BAR across an eGPU
link, fresh 32 MiB chunks each time). The oracles differ on the bytes after
the commit (5300M A,B,B,A,B; UHD 630 A,B,B,B,B), so the cheaper answer is the
default and the snapshot stays behind the switch (AGENTS.md rule 1).

Verified: jobs in the report (lint both cfgs, the translator's fast_paths, the
runtime suite on lavapipe, managed_copy_device and the lane test on the RTX
3090 and the RX 7900 XTX, and the copy-in bench there before and after).
2026-11-12 23:57:16 -08:00
Anees Iqbal a2f5af1c5c The copy-in bench takes the exact answers from its options' policy
What: managed_copy_in_bench sets options.policy.exact_answers(), a method of
the policy value, in place of a call of it without one.

Why: the bench did not compile.

Verified: built in the following change's jobs.
2026-11-12 23:57:16 -08:00
Anees Iqbal 57019cf01a The managed copy-in bench, and a check that unified memory copies nothing in
What: tests::managed_copy_device gains managed_copy_in_bench (ignored, run in
release): did_modify_range of 256 KiB, 4 MiB and 32 MiB, written by the CPU
before each of 40 commits of a command buffer that reads the range's last
bytes, over the runtime's own Managed buffer and one over the caller's pages
through their import, on the default device and on one of
DevicePolicy::exact_answers(). It prints (MANAGED-COPY-IN) the median and
largest commit call, the median wall time to completion, the range over it in
GB/s, and the bytes copied in and the buffers parked, taken again and evicted.
And a_did_modify_range_on_unified_memory_copies_nothing: on a device with
unified memory both kinds of Managed buffer copy and stage nothing at a
did_modify_range, and the next command buffer reads the CPU's write.

Why: the copy-in at commit is most of a measured compute workload's gap on a
discrete GPU; the bench measures it before and after its change at the same
code, and the check holds the no-copy answer on unified memory.

Verified: built and run in the jobs of the following change (it has no
behaviour of its own).
2026-11-12 23:57:16 -08:00
Anees Iqbal a0b85d89d4 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 23:42:15 -08:00
Anees Iqbal 68bfb94cc1 RUNTIME_VERSION 2201: the runtime's attachment images start at zero where DontCare stays DONT_CARE
On a device where an unstored DontCare load stays the driver's DONT_CARE (no UnstoredClearNoSlower
under the Driver policy), the runtime's own attachment images (depth/stencil scratch, stand-ins,
backings, fetch scratches, colour twins) now start zeroed, so such a load never reads a released
texture's texels. Devices that clear those loads pay nothing. That changes runtime behaviour.

Verified by the change's own runs: on lavapipe the new test fails without the fix and passes with
it, runtime suite 2454/2454 (24582); Iris 25/25 (24584); clippy and rustdoc 24552 and 24553. The
class's other routes were read and none can be read by a program.
2026-11-12 23:41:36 -08:00
Anees Iqbal 7b77851a95 Runtime attachment images start at zero where an unstored DontCare load stays DONT_CARE
What: Device::new_planned_texture, which makes the runtime's own images (the
scratch image of separate depth and stencil textures, stand-ins, backings,
colour twins), starts an image with color or depth/stencil attachment usage
that a clear writes at zero (Start::ZeroUnpatterned) on a device whose
unstored DontCare loads stay the driver's DONT_CARE
(clear_reach::UnstoredLoads::DontCare: UnstoredDontCarePolicy::Driver on a
driver without DriverFact::UnstoredClearNoSlower). Elsewhere it starts as its
memory lies, as before. FAST-PATHS' unstored DontCare row and API.md say so.

Why: such a load reads what the image holds (a depth or stencil test, a
blend, a fetch). A Private runtime image started as its memory lay, and a
recycled one may hold a released texture's texels, of another process of a
consumer whose processes share the device. Devices that clear such loads read
nothing of it, so they pay no clear.

Verified: tests::unwritten_parts on lavapipe and Iris Xe (jobs in the
report).
2026-11-12 23:41:01 -08:00
Anees Iqbal 8aa703617d Test that separate depth and stencil textures' scratch image reads no released texture's stencil
What: tests::unwritten_parts gains a leg: a pass of a Private Depth32Float
texture and a Private Stencil8 one (which renders through a scratch image of
the combined format) clears the stencil to 0xA5 and stores it; its textures
and scratch are released, and a pass of two new textures takes the three
parked images, loads its stencil DontCare, stores nothing and draws where the
stencil is 0xA5. It must draw nothing.

Why: the scratch image (Device::new_planned_texture) starts as its memory
lies, and on a driver that leaves an unstored DontCare load to DONT_CARE
(lavapipe) the stencil test reads a recycled image's texels, which may be a
released texture's of another process.

Verified: fails without the fix on lavapipe (next commit's job).
2026-11-12 23:41:00 -08:00
Anees Iqbal d645212f96 SEMANTICS_VERSION 2080: half division and sqrt at 16 bits
Under the 16-bit float controls, a half division is now the device's 16-bit OpFDiv, its divisor
scaled into Vulkan's 16-bit range first (bound 2.5 half ulp), and a half sqrt is the 16-bit Sqrt.
That's the device's native form (owner rule 1); the NativeDivision and NativeTranscendentals notes
state the 16-bit bounds. An undefined f32 that is not an exact half now stays f32. The translated
SPIR-V changes; the golden tables are re-blessed on development.

Verified by the change's own runs: hnq on the Iris profile goes from 68 to 8 OpFConvert, spirv-val
passes (24518, 24528); clippy, half engine tests 85/85 and rustdoc green (24551).
2026-11-12 23:21:26 -08:00
Anees Iqbal ae413fd7e9 Half sqrt at 16 bits: its bound belongs to NativeTranscendentals, which it records
On a device whose float functions are not Metal's, a half sqrt is the
device's instruction for Metal's function and records
NativeTranscendentals (function_notes), not DeviceArithmetic. The 16-bit
Sqrt's bound moves to that note's doc and its catalogue entry; the
division test asserts NativeDivision and NativeTranscendentals, as the
Iris Xe profile records (job 24519: [NativeTranscendentals,
NativeDivision, NativeNanEncoding]).
2026-11-12 23:20:51 -08:00
Anees Iqbal 502650252b Half hold: an undefined value's f32 stays undefined, not its twin's widening
A use of an undefined f32 value that is no exact half (a float2 built by
inserting coordinates into an undefined vector) read the widening of its
16-bit twin: hnq's fragment shader had six OpFConvert of an OpUndef.
The f32 undefined value is kept for those uses instead; the twin is the
16-bit undefined value as before.

Test: engine_half_hold's division kernel builds a float vector on an
undefined one and asserts an f32 OpUndef stays and no undefined value is
widened (Iris Xe, RADV).
2026-11-12 23:20:51 -08:00
Anees Iqbal ab56a1c88e Half division and square root at 16 bits under the 16-bit float controls
Rule 1: where the module computes half in 16 bits under the 16-bit float
controls (QuantizeForm::Controlled), the device's native form of a half
division and square root is its 16-bit OpFDiv and Sqrt, so those are the
only form there; elsewhere the float instruction rounded to half stays.

- divide::native: a half quotient under the controls narrows its operands
  (exact, they are halves), scales a divisor past 2^14 by 2^-2 and a
  denormal one by 2^10 into Vulkan's range for the 16-bit OpFDiv
  ([2^-14, 2^14], 2.5 half ulp), divides at 16 bits and widens. The
  scaling is exact but where the quotient rounds to zero or overflows
  anyway.
- math::float_fn: a half sqrt under the controls is the 16-bit Sqrt
  between exact conversions (Vulkan: inherited from 1 / InverseSqrt).
- narrow::computes_in_16_bits counts 16-bit FDiv and Sqrt, so the entry
  declares the controls (denormals kept, IEEE zeros, infinities, NaNs).
- ops: float_ty and f16_splat, shared with f16_binary.
- NativeDivision and DeviceArithmetic state the 16-bit bounds; docs/API.md,
  docs/FAST-PATHS.md, the narrow and half_hold module docs follow.
- Test: engine_half_hold's half_division_and_sqrt_are_16_bit_under_the_
  float_controls (Iris Xe and RADV: 16-bit FDiv x2 and Sqrt, none at 32,
  no exact narrowing, the exact answers on the interpreter, L3, the notes;
  lavapipe: the float forms, the same answers).

Verification: in the following potluck runs (FConvert count on hnq,
the half engine tests, spirv-val, clippy, the suite).
2026-11-12 23:20:51 -08:00
Anees Iqbal bf59ee08f4 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 23:17:53 -08:00
Anees Iqbal 62dfb5cec3 String literals whose line continuations were lost join their lines again
A run of spaces inside a string literal, where a line once ended in `\`, printed the next line's
indentation into the text. Swept every .rs file's string literals (non-raw) once for a run of
four or more spaces between two non-space characters, and for literals whose line ends without a
continuation; the latter were all intended multi-line text (LLVM IR, SQL, data tables, usage).

Restored (each run became ` \` and the next line's indentation, 28 runs):
- product messages: render_state.rs (SampleDepthClamp's text), degradation.rs
  (YCbCrFilterNotExact's text), two_planes.rs (a blit's why-not), device/create.rs (the dropped
  instance layers' line);
- tests and suites: render_sibling_work.rs, shadow_standing_device.rs, image_standing.rs (2),
  conformance texture_views.rs (2) and rate_map_sweeps.rs (3), validation plan_resources.rs and
  parallel_encodes.rs (2);
- conformance times.rs: a wrapped line after an explicit `\n`, its two-space indent kept;
- engine_refused_families.rs: one space in an LLVM IR line's `ptr addrspace(1)`.

The degradation texts change in whitespace alone; docs/API.md's catalogue names the kinds, not
these texts, and still matches. Left as written: aligned columns and indentation after `\n`
(kernel_textures.rs, renders.rs, argument_buffers.rs, degradation_catalogue.rs, the
conformance stability, verdict and cost reports, the tab table of dma_buf_leak_probe.rs, usage
texts). cargo fmt.
2026-11-12 23:16:47 -08:00
Anees Iqbal c1835b7e0b Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 23:11:04 -08:00
Anees Iqbal 8dda227927 RUNTIME_VERSION 2200: a new buffer's zeros are one fill on every device
A new buffer's first-move zeros are now one vkCmdFillBuffer on unified-memory devices too,
instead of copies from the device's zero buffer, one region per 4 MiB. Nothing structural needed
the copy there any more. That changes runtime behaviour.

Verified by the change's own runs, zeroing 17,899,520 bytes (GPU timestamps, median of 20): 780M
fill 0.532 ms against copies 0.748 ms; Iris fill 0.517 against 0.527 ms (24390). The first-use lane
passes on the Iris (24379) and 780M (24380), "its zeros 1 fills"; clippy 24359.
2026-11-12 23:10:26 -08:00
Anees Iqbal c72bbdb125 A new buffer's zeros are one fill on every device, unified memory too
What: `FirstFill::zeros` set a new buffer's word-aligned zeros with one
`vkCmdFillBuffer` only on a device without unified memory; a device that
shares the host's memory copied the device's zeros instead. It now fills on
every device (copies stay for a range whose ends are not multiples of 4).
The first-use lane's `a_new_private_buffer_reads_zero_through_its_first_fill`
asserts exactly one fill (`WorkCounts::new_buffer_zero_fills`) on every
device; it asserted none on unified memory. The docs of `zeros`,
`first_move.rs`, `word_fill.rs` and `new_buffer_zero_fills` say so.

Why: the copy read the zeros as well as it wrote the range, which costs on
unified memory too. Measured on one blit zeroing 17,899,520 bytes, GPU time
by timestamps, median of 20 (a diagnostic branch, not committed):
- Radeon 780M (RADV, Mesa 26.2.6): fill 0.532 ms, copies 0.748 ms; the
  command buffer's wall time 1.556 vs 1.900 ms.
- Iris Xe (ANV, Mesa 26.2.6): fill 0.517 ms, copies 0.527 ms; wall time
  0.948 vs 1.070 ms.
The discrete numbers already in the doc (RX 7900 XTX) are unchanged.

Verified (at the same change on bfcd63c5e2): the first-use lane on the Iris
Xe and the 780M (11 passed each, "its zeros 1 fills" on both); clippy over
the workspace, all targets and features, green. Not FAST-PATHS material: no
accuracy is traded.
2026-11-12 23:09:52 -08:00
Anees Iqbal 2eb43d2483 The warm pass's unread-record warning joins its continued lines; the posted import free's deallocator timing documented
warm/pass.rs: say_unread's format string had lost its line continuations, so the warning printed
runs of spaces ("it is          not warmed"); each line now ends in `\`, as written.

free_thread.rs (What is posted) and host_memory.rs (The deallocator): where a completed command
buffer's release lets go of a no-copy import last and its deallocator waits for the free, the
free and the deallocator run on the free thread, possibly after the command buffer's waiters
returned (about 16 ms at most on an RTX 2080, m3-max-24385): Metal ties the deallocator to the
buffer's deallocation, not to a wait for the command buffer.

Docs and a message text only; cargo fmt.
2026-11-12 23:09:36 -08:00
Anees Iqbal 5a51abe484 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 23:07:56 -08:00
Anees Iqbal 7e82dd697a RUNTIME_VERSION 2199: runtime images whose parts no copy writes start at zero
Three runtime-made images could start holding a released texture's texels in a part no copy
writes, where a program could read them: a surface depth's storage shadow's other aspect (read
through an X32Stencil8 view), the later levels of a tiled texture over a Private buffer in a
format generate_mipmaps refuses, and a surface depth pass image's stencil under an unstored
DontCare load. All three now start zeroed. That changes runtime behaviour.

Verified by the change's own runs: on lavapipe both new tests fail without the fix and pass with
it, runtime suite 2447/2447 (24470); Iris 24/24 with it and the tiled test failing without it
(24525); clippy and rustdoc 24473 and 24474.
2026-11-12 23:07:16 -08:00
Anees Iqbal a6b9980002 Count a shadow started at zero by its start, not the removed flag
What: storage_over_buffer counts WorkCounts::shadows_zeroed where its
image started otherwise than as its memory lies (start.is_some()), the
flag the previous commit replaced.

Why: the previous commit left one use of the removed `apart`, which
clippy (jobs 24443, 24444) reported as E0425.

Verified: rebuilt in the jobs that follow.
2026-11-12 23:06:41 -08:00
Anees Iqbal b8257d9c10 Runtime images whose parts no copy writes start at zero, never as their memory lies
What:
- Device::storage_over_buffer: a surface depth or stencil texture's
  shadow whose copies leave an aspect out starts ZeroUnpatterned in every
  storage mode (Metal reads 0 there); a tiled texture of more than one
  level starts Start::Zero, as a new texture of its storage mode does.
  Before, both went through new_image, which starts a Private image held.
- surface_depth.rs pass_image (the twin and an X32_Stencil8 view's
  private image) starts ZeroUnpatterned: no copy writes its stencil.
- Docs: storage_over_buffer's comment, surface_depth.rs module docs and
  FAST-PATHS.md's tiled later levels gap say what they now read.

Why: a Private image's memory may hold a released texture's texels, of
another process sharing the device (a recycled image). A kernel reads the
shadow's stencil through an X32_Stencil8 view, blits and samples read a
tiled texture's kept later levels, and a pass's DontCare stencil load the
driver leaves reads the twin's.

Verified: tests/unwritten_parts.rs (previous commit) fails without this
and passes with it; runs follow.
2026-11-12 23:06:41 -08:00
Anees Iqbal 576cf81f4f Test that runtime images whose parts no copy writes never read a released texture's texels
What: tests/unwritten_parts.rs, two device tests over recycled images.
- A Private Depth32Float_Stencil8 texture over a surface plane: two such
  textures pass with their stencil cleared to 0xA5 and are released, and
  two more take the four parked images (their shadows and pass twins). A
  kernel's read of each X32_Stencil8 view must read 0, and a DontCare,
  unstored pass that draws where the stencil is 0xA5 must draw nothing.
- A Private RGBX8Unorm tiled texture of two levels over a Private buffer,
  whose second level the take leaves (LaterLevels::Kept): its second
  level written by a blit, released, and another made over another
  buffer takes the image; its second level must read what a new
  texture's does.

Why: the shadow's other aspect, a tiled texture's kept later levels and
the surface depth twin start as their memory lies for Private storage,
while no copy writes them: a program can read another process's texels
there. The fix follows.

Verified: written to fail without the fix (lavapipe run follows).
2026-11-12 23:06:41 -08:00
Anees Iqbal 9437ea2517 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 23:05:00 -08:00
Anees Iqbal ab8bd0c700 RUNTIME_VERSION 2198: a completed command buffer's last host-import frees go to the free thread
The host-pointer imports a completed command buffer frees last are now posted to the device's
paced free thread instead of being freed back to back on the completion handler thread, where a
burst held the scheduler's submits (on NVIDIA up to 29 ms a free, bursts of 173). The import's
deallocator and keep-alive still run after its vkFreeMemory, a full queue or teardown frees in
place, and a program's own release still frees in the release. That changes runtime behaviour.

Verified by the change's own runs: lint 24371. 2080 A/B in one process (24385): pings beside a
round of 64 MiB x4 frees 0.168 / 3.21 ms (median / p99) posted against 2.264 / 6.44 ms in place;
512 KiB x32 0.143 / 0.65 against 0.193 / 1.04 ms. A deallocator may now run up to about 16 ms
after wait_until_completed returns.
2026-11-12 23:04:21 -08:00
Anees Iqbal 52fb9edac3 The completion leg measures the frees posted and in place in one process, alternating
A loaded host made a before-and-after pair of 2080 runs incomparable (the first bench's own 64 MiB
frees took 2.1 ms in one and 44 ms in the other). The leg's rounds now alternate between the
release's posting and the in-place free it replaced (free_thread::FREES_IN_PLACE, a device-test
stand-in, never a product switch), so both forms meet the same host, and print per form.

Verified: in the 2080 job that ran it.
2026-11-12 23:03:45 -08:00
Anees Iqbal 41b5430f6a A completed command buffer's release posts the host imports it frees last to the free thread
On NVIDIA each vkFreeMemory holds the device's other vkQueueSubmits while it runs, and a
completed command buffer that let go of no-copy buffers' imports last freed them on the thread
that runs the next completed handlers, back to back and unpaced. Now, inside a completed command
buffer's release (free_thread::AtCompletion), an import whose free a deallocator or a keep-alive
waits for is posted to the device's free thread, which paces it as it paces a block's free; the
deallocator and keep-alive run there after the free, possibly after the command buffer's waiters
returned. The queue stays bounded at 64: a post that finds it full, the teardown begun or no
thread frees in place. An import nothing waits for is freed in place, before the waiters return,
as the caller may unmap its pages once they did. A program's own release still frees in the
release. No switch, nothing by vendor.

The paths: HostImport::drop (a pin's last hold at completion), and rebind's Retained, a command
buffer's hold of a releasable import's objects (Imported::let_go_at_completion). The posted
objects hold the device through holder handles (device/holds.rs), so the program's last drop on a
program thread waits for them, and the thread frees them unpaced once the holds stopped. Where the
program's last drop ran on a runtime thread, a posted import can hold the device's last share:
the teardown then runs on the free thread, which frees what is still queued in place of waiting
for itself and ends unjoined.

Counted: WorkCounts::host_import_frees_posted; memory_frees_paced counts their pacing.
docs/FAST-PATHS.md's known gap on NVIDIA's frees is updated, and the Deallocator doc names the
free thread.

Verified: tests::completion_import_frees (posted with a deallocator, in place with none, and the
teardown on the free thread), the runtime suite and lavapipe device tests in the check job, and
the 2080 bench before and after.
2026-11-12 23:03:45 -08:00
Anees Iqbal f27fe52e9d The import free hold bench's completion leg: imports a completed command buffer frees
A leg beside the free-hold bench's own: the same pinger, beside rounds of 32 no-copy buffers of
512 KiB and of four of 64 MiB whose command buffer's completion lets go of their pages last (each
copied from once, then released while the command buffer is in flight), each deallocator noting
when it ran. Printed per size: the frees' runs, how long after the wait the last deallocator ran,
and the pings beside a round against the quiet ones, with the free thread's counts. The bench's
device, pinger and device name are shared helpers now.

Verified: built in the 2080 job that ran it (the numbers go with the change that follows).
2026-11-12 23:03:45 -08:00
Anees Iqbal 126a6fe5b6 The GPU form's text: its two continued lines joined as written, and the note's hold on its scratch documented 2026-11-12 23:03:45 -08:00
Anees Iqbal a86b8aadfa The GPU form's arguments read as arrays of four words 2026-11-12 23:03:45 -08:00
Anees Iqbal 177ef10860 The GPU-form trail test executes commands a blit's copy wrote, which take the GPU form 2026-11-12 23:03:45 -08:00