Commit Graph
4120 Commits
Author SHA1 Message Date
Anees Iqbal 4f3bc2e7a3 One page, one import: compile fixes (a Pages placement accessor, raw handle bits in Debug, an unshadowed test heap)
The first build of ed11f23e9a failed: bind_in_import read Pages' private
memory field, InImport's Debug printed handle flags ash gives no Debug for,
and a test's heap binding shadowed its heap helper. Found by potluck job
m3-max-18250 (lavapipe build on ms01).
2026-11-11 19:01:50 -08:00
Anees Iqbal cfd7bc829e One page, one import: a buffer over a live import's pages lies inside it, else a copy
VK_EXT_external_memory_host leaves a host allocation imported twice into one device
undefined (issue 6: "Some platforms do not allow locking the same physical pages for device
access multiple times, so attempting to do it may result in undefined behavior"). The runtime
imported the same pages twice in several ways: a heap's own import was never noted in
HostAliases, so a no-copy buffer over exactly a heap's bytes, or over part of them, imported
them again (the consumer's guest heaps over 2 MiB page-block views, and the block's view as a
buffer); a buffer over part of a live buffer's bytes imported its own (counted,
object_churn.imports_inside_live: 34 in one 3090 walk); and a heap over a live buffer's bytes
imported its own.

Now:
- a heap's own import is noted (HostAliases::hold), joining no key;
- a buffer or heap over exactly a live import's bytes lies in that import (a heap keeps its
  heap identity);
- a buffer whose window a live import holds all of is bound inside that import's memory at
  its offset, with a VkBuffer of its own and no import (Device::bind_in_import,
  Placement::in_import, which holds the import; the import is exposed, so never released
  while idle); counted object_churn.buffers_bound_in_import;
- a buffer or heap whose window a live import holds some of and not all, and a heap a live
  import holds more than, is a copy (CopiedBecause::OverImport, copied_over_live_imports,
  announced copied-host-pages);
- rebinds take the same rule;
- imports_inside_live now counts only imports made where a live one held some of the pages
  all the same (two buffers made at once).

Tests: host_aliases unit test a_page_a_live_import_holds_is_never_imported_again; device
tests one_import (heap first, buffer first). Not yet run: this commit is for the build.
2026-11-11 19:01:50 -08:00
Anees Iqbal 269d7066c4 FAST-PATHS: what is built around a cold making's driver time, and the compute kernels' case
The known gap on the cold making of a 200,000-word compositing module ended "Nothing is built
around it", which was not true. It now names what is:

- the driver records across boots (`shader_cache/driver.rs`), named by the driver's identity, so a
  driver update, another device or a removed content directory makes every making cold again, and
  no machine's records serve another's;
- pipeline records and `Device::warm`, which remake a previous process's creations on a thread of
  their own below every other making, and what they do not cover today (a compute state that
  states no required threadgroup size predicts nothing, so its dispatches' pipelines are made at
  their first dispatch);
- `PipelineWaitPolicy::Bounded` at creation and at commit, and dispatches that hand their making
  to the pool;
- the consumer's creation of guest states on a compile thread off the guest's command path.

It adds the compute case: a convolution kernel's 12 variants at a macOS 12.7.6 login, one SIMD8
program each of 6,222 to 8,925 instructions with 70 to 221 spills, and the host-load
sensitivity that made the same login's makings 2 to 13 times slower than alone.

Measured on the Iris Xe (Mesa 26.2.6), the dumped modules made by a scratch harness with
the logged specialization, one module of its own per making, the driver's disk cache off:
- the 23,108-word variant alone 0.27 to 0.34 s (jobs 18284, 18292); 11 at once 0.31 to 0.53 s
  each, 0.50 to 0.53 s for all (18293); device robustness on or off alike (18292);
- the 138,047-word fragment module alone 2.03 to 2.42 s, two at once 2.42 to 2.53 s each, four
  at once 2.69 to 3.33 s each (18284);
- under 20 and 30 busy threads on the 20-CPU host, that fragment making 6.27 and 7.94 s, and 11
  kernel makings at once under 20 busy threads 0.78 to 1.44 s each (18293);
- the program counts from INTEL_DEBUG=cs (18226).
The login's own numbers (4.87 s; 1.5 to 4.2 s, 10 or 11 at once; the guest's 1 to 197 command
buffers a second during the making) are the consumer's cold-login log at the 12.7.6 capture; the
3.1 ms warm making is the consumer's warm boot.

Docs only.
2026-11-11 18:36:17 -08:00
Anees Iqbal 61bb2acf30 RUNTIME_VERSION 2072, SEMANTICS_VERSION 2039: a call only quad helpers reach through a select is fenced on Apple GPUs
On the M3 through MoltenVK, a 27.0.1 guest's widget glass drew white strips or a comb in 8x4
blocks at its vertical edges, in every saved screen. The widget's gradient draw writes colour 0 in
the storage form and ends in an OpSelect whose one value operand is a NoContraction add, picked
where coverage is below a bound. SPIRV-Cross inlines that single-use operand into the ?: arm, so
the [[clang::optnone]] add runs only in lanes past the gradient's vertical edges: the quad
helpers. That is Apple's recorded store-drop shape (DriverWorkaround::DiscardDropsSimdgroupStores):
a call only helpers make, then a storage write, and the simdgroups at the edge lose the draw's
writes. spirv::helper_branches looked only at branches, so the select was neither guarded nor
fenced, and no note was recorded.

Now the helper guard treats a non-branch path to a call as a branch: a scalar OpSelect value
operand, a scalar OpLogicalAnd/OpLogicalOr right side, or a reader inside a non-uniform
selection arm, reached through single readers. Such a call gets the fence the branch form gets
(an identity OpGroupNonUniformShuffle after it, which SPIRV-Cross writes inside the arm). Where
the fragment stage can't shuffle, the pipeline records PrecisionNote::HelperBranchDropsSimdgroupStores.
The guard runs only on a profile with DriverWorkaround::DiscardDropsSimdgroupStores (MoltenVK on an
Apple GPU), so no other device's module changes. It is exact and takes no switch. Docs: API.md's
degrade-notice catalogue and artifact.rs name the new case.

Tests: fixture rch_helper_select (our own MSL: a NoContraction sum picked where coverage != 1,
with no branch), lane runtime_lane::helper_select, unit tests on modules built in the test (an
arm-read call fenced; loop-read and uniform-arm calls not).

Verified (potluck jobs, on the branch):
- M3 MoltenVK 1.4.2 (m3-max-18169), helper_select: without the fix rch_select_arm and
  rch_select_and lost 174 covered pixels' writes each, in whole groups, fences 0, no note; with
  it fences 1, 0 lost, 0 extra, no note. The two controls (the pick an implicit-LOD sample reads
  after it; the pick on a constant-buffer flag) unchanged at fences 0, 0 lost. helper_tangle and
  discard_fetch_groups unchanged.
- GPU time on the M3, worst case (every fragment of a 1024x1024 pass takes the arm): 32 draws
  2.874 -> 3.125 ms, least of 5 command buffers (+0.25 ms per 33.5M fragments).
- Golden tables on the M3 (18216): exactly 4 rows move, rch_select_arm and rch_select_and in
  both spellings, in the moltenvk-m3 cell alone; no other fixture's cell on any profile.
- clippy plain, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings (18210).
Expected, not yet run: the consumer's 27.0.1 boots at the fix against its base.
2026-11-11 18:22:48 -08:00
Anees Iqbal 9efdb88630 Bless rch_helper_select's expectation rows and golden printout
On the M3 at 86884548c8 (m3-max-18216): bless_engine_inventory took 0 moved cells and 10 new rows, all rch_helper_select's; bless_engine_goldens wrote tests/air_input/rch_helper_select.txt under the pinned LLVM 21.
2026-11-11 18:16:57 -08:00
Anees Iqbal e97d5da60c Docs: HelperBranchDropsSimdgroupStores also covers a call in no branch that SPIRV-Cross writes in one
The catalogue entry and the variant's rustdoc name the new case: a ?: arm, the right side of a && or ||, or a selection's arm, where the call's value is read once (spirv::helper_branches).
2026-11-11 18:13:09 -08:00
Anees Iqbal 86884548c8 Test: a call read once in a helper arm is fenced where SPIRV-Cross writes it, not where a loop reads it
tests::engine_helper_picks builds fragment modules that sample at LOD 0, add 1 to the red with NoContraction in the entry block and store the sum once: in the arm of a selection on the coordinate (fenced on moltenvk-m3), in a loop body, or in the arm of a selection on a specialization constant (neither fenced); intel-arl-anv fences nothing. SPIRV-Cross writes the first call inside the arm and keeps the loop's at its definition (checked with Homebrew's spirv-cross on synthetic modules).
2026-11-11 18:11:14 -08:00
Anees Iqbal dd2723f57a Lane helper_select and unit test: a pick only quad helpers make, with no branch
The fixture rch_helper_select's companions (scripts/regen-air-fixtures,
m3-max-18157): every pick is an AIR select, which the translator writes as an
OpSelect and SPIRV-Cross as a ?: whose arm calls spvFAdd.

runtime_lane::helper_select draws the 32x16 triangle of guarded_effects with
each function and checks every covered pixel's write against Metal's answer:
no write may be lost where the fragment records no
HelperBranchDropsSimdgroupStores, on a device with the defect the ?: arm and the
&& right side are fenced (or noted without a fragment shuffle), and the pick a
sample reads after it and the pick on a constant block's flag are left alone.
a_fenced_pick_s_gpu_time prints the GPU time of 32 draws of a 1024x1024 pass
whose every fragment picks the sum, and checks every texel.

tests::engine_fragment::a_helper_call_a_select_picks_is_fenced holds the same
forms on moltenvk-m3, on it without the fragment SHUFFLE (the note instead),
and on intel-arl-anv (nothing), each module through L3.

Verified so far: nothing; the M3 runs before and after the fix follow.
2026-11-11 18:11:13 -08:00
Anees Iqbal 4e803f6641 Fixture rch_helper_select: rch_select_sampled picks one coordinate, so the compiler writes a select 2026-11-11 18:11:13 -08:00
Anees Iqbal 790c0a1dc9 Fixture rch_helper_select: pick sums of values every invocation has, so the compiler writes selects, not branches
With a buffer load in the picked arm, the compiler kept a branch (the load is not speculated), which the branch analysis already covers. Summing components of the sampled colour lets it speculate the addition into a select.
2026-11-11 18:11:13 -08:00
Anees Iqbal fbc5374a07 Fixture rch_helper_select: picks a sum only quad helpers make, with no branch
Fragment functions, without fast math so every float operation is
NoContraction (SPIRV-Cross's optnone spvFAdd), that read a coverage texture,
sample at LOD 0 and pick, where the coverage is not 1, a value an addition
makes: as a component (rch_select_arm), on the right of a && after the
coverage test (rch_select_and), as a coordinate an implicit-LOD sample then
reads (rch_select_sampled), and on a constant block's flag
(rch_select_uniform). Each writes a texture after it. The compiler writes each
pick as a select, and SPIRV-Cross writes that as a ?: whose arm holds the call.

The .ll and .air.ll companions follow from scripts/regen-air-fixtures.
2026-11-11 18:11:13 -08:00
Anees Iqbal d7a2d20011 helper_branches: a call SPIRV-Cross writes in a ?: arm, a && or || right side, or a selection's arm counts as a helper-path call
SPIRV-Cross moves an expression read once into what reads it. An optnone call
(a NoContraction FAdd/FSub/FMul, QuantizeToF16, MulExtended, Reflect) outside
every selection and loop, whose value reaches through single readers a value
operand of an OpSelect on a scalar condition, the second operand of a scalar
OpLogicalAnd/OpLogicalOr, or an instruction inside a selection's arm, is
written in that arm: `cov < t ? spvFAdd(a, b) : c`. Where the condition is
not draw-uniform, only the quad helpers past a primitive's edges may take it,
and on MoltenVK on an Apple GPU (DriverWorkaround::DiscardDropsSimdgroupStores)
Apple's compiler then loses the simdgroup's texture writes after it. The
analysis looked only at branches, so such a call was neither fenced nor noted.

Facts::conditional follows the chain (a value read more than once, a phi or
terminator operand, an instruction without a result, or a reader inside a loop
the call is outside ends it: SPIRV-Cross keeps that value where it is defined,
checked with Homebrew's spirv-cross on synthetic modules). Such a call is
counted as one inside a construct: fenced by the identity shuffle where the
fragment stage shuffles, else PrecisionNote::HelperBranchDropsSimdgroupStores.
The per-instruction write test of the open blocks is now linear in the block.

SEMANTICS_VERSION 2039: modules with such a call get fences on profiles with
the workaround.

Verified so far: nothing; the lane and unit tests follow.
2026-11-11 18:11:13 -08:00
Anees Iqbal a3ff35c1a0 Re-bless the authored compile census at d0f800ddd0
Its product fingerprint follows the runtime-sources pin at d0f800ddd0 (dv-m3).
2026-11-11 18:09:52 -08:00
Anees Iqbal e8558ff364 Re-bless the golden tables at d0f800ddd0
What moved since 892e4b230b's bless. Blessed on the M3 (dv-m3).
2026-11-11 18:09:52 -08:00
Anees Iqbal bb113bd5eb Tests: the texture-over-dma-buf residency test waits for the in-place checks as their own tests do
host_residency::a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable waited for the
device's in-place checks within SETTLE (20 s), the bound for an import's release. On ms01's Iris
Xe in the round at d0f800ddd0 (m3-max-18134) the checks took longer and the test failed with "the
in-place checks never answered" at 27 s, while the in-place check's own tests in the same run
passed at 47-56 s. It now waits CHECKS (120 s), the bound in_place_check.rs and copied_device.rs
use. Test-only.
2026-11-11 18:00:28 -08:00
Anees Iqbal b0f40ec5e2 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-11 17:58:32 -08:00
Anees Iqbal 5175cca5b4 Pipeline creation log: a compute line names its kernel's descriptor, and the dump writes compute modules
A compute pipeline's line in METAL2VULKAN_LOG_PIPELINES named the kernel's function, its SPIR-V
hash and length, its specialization constants and notes, but not what the kernel was made from:
a cold boot's slow compute creations could not be made again off the device, because the
function's Metal constant values were nowhere in the log, and METAL2VULKAN_DUMP_PIPELINES wrote
render modules only.

The compute line now ends with `; descriptor: ` and the same naming a render state's first line
gives each function (its name, the SHA-256 of its bitcode, the constant values by index and by
name with their types and bytes), from one helper both share (`render::logged_function`). With
the dump directory set, the line's module is written there as `<hash>.spv` (`dump_modules`, the
render dump's writer, now over any modules), and a failed write is named in the line as a render
line names it. Nothing is kept or measured while the variables are unset: the descriptor's text
is made only where the log is on (`compute_kernel`).

The creation log's module doc also names the record words the split prints since the record
naming change (`record's cache shared`, `found in cache`, `compiled`).

Test: `opencl_data::the_pipeline_creation_log_names_a_compute_pipeline_and_its_notes` now runs
its child with the dump directory set, and asserts the line's descriptor (the kernel's name,
`air`, `constants {`), no dump failure, and a SPIR-V module (its magic) at the hash the line
names. It and the creation_log unit tests, and lint, run on this commit as jobs after it is made
(the report names them); a failure is fixed forward.
2026-11-11 17:57:53 -08:00
Anees Iqbal a58070d630 Docs: a cold making of the 200,000-word compositing fragment module is the driver's own cost
Records, as a known gap, what is left of the Iris Xe's cold login
creations after the records stopped naming attachment formats: the one
compile of the compositing fragment module (203,016 words, macOS
26.7.2) that every state over another format then finds in its record.

Measured with a scratch harness making the module's fragment shader
library cold, the driver's disk cache off:
- ANV, Iris Xe, Mesa 26.2.6: 3.3 to 3.7 s at load ~16 (m3-max-17871);
  its program is 29,101 SIMD8 instructions, 34 spills, 10,585 non-SSA
  registers.
- RADV, Radeon 780M: 1.3 to 3.0 s (m3-max-17958, -18098).
- RTX 3090, 620.70.06: 4.5 to 7.4 s (m3-max-17957, -18097).

Why no translator change: spirv-opt -O (186,314 words) and -O with
frozen specialization constants (180,402) leave ANV's NIR within 0.2%
(27,347 to 27,393 instructions) and its program within 9 instructions,
and their creations are no faster than the original's within the
run's noise (m3-max-18022, -18034, -18127). Holding half values in 16
bits across moves, phis and selects (a scratch pass on the -O module)
makes it 29,719 instructions with 103 spills. So the words the
translator emits do not drive ANV's time; the shader's own work does
(NIR: 4,163 fmul, 2,868 fadd, 1,689 ffma, 1,835 csel, ~290 samples,
30 loops).

VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT: ANV builds the same
program in the same time and the 3090 the same time; RADV takes 0.9
to 1.0 s (m3-max-18098), at a draw cost not measured. Nothing is
built around it. Doc only.
2026-11-11 17:57:53 -08:00
Anees Iqbal 55e664e122 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-11 17:55:35 -08:00
Anees Iqbal 8db2f6f5c8 RUNTIME_VERSION 2071: the runtime's own runs of memory frees step aside for the device's submissions
On NVIDIA (620.70.06) each vkFreeMemory holds the device's other submissions while it runs, and
not only for imports: plain host-visible frees hold too. RV 2067 paced the device checks' own
allocations and frees; the runtime's other threads still freed in bursts.

Now step_aside gains a paced-thread mark and pace(): a runtime thread that frees memory in a run
waits before each free until as long as its frees before it took has passed since the last one
ended (the checks' OwnCall rule; the checks' step now counts from the calls' end too). Paced: the
free thread before each block (fresh-pages imports included); the residency thread's idle
releases (its sweep holds imports weakly while it waits, so a program's release meanwhile still
frees its import inside that release); a guest RAM's give-back of untaken chunks and its listed
thread's idle chunk and list releases. Never paced while a caller waits for the frees: an
allocation at the limit (free-thread waiters, Allocations::give_back_awaited), the device's
teardown, a guest RAM use's end. A program's own release of a no-copy buffer still frees its
import in the release, unpaced (Metal's contract). Handler threads are not paced (a wait there
would delay the completed handlers behind it). WorkCounts gains memory_frees_paced and
memory_frees_paced_nanos. FAST-PATHS known gap: NVIDIA's vkFreeMemory holds other submissions.

Tests: tests::import_free_hold_bench (ignored bench: five kinds freed in turn and paced, beside a
fill every 250 us); a posted-frees burst runs paced; the at-limit test asserts no free is paced
while the allocation waits; step_aside units.

Verified (potluck jobs, on the branch):
- RTX 3090 (18052, quiet host, two runs), fill p50 beside frees in turn -> paced: 512 KiB pointer
  imports 0.46-0.50 -> 0.29-0.32 ms; 512 KiB dma-buf imports 0.47-0.54 -> 0.23-0.25 ms; 64 MiB
  pointer imports 2.6-2.9 -> 0.10-0.13 ms; 512 KiB plain 1.2-1.6 -> 0.17-0.22 ms; 64 MiB plain
  70-79 -> 0.15-0.19 ms (baseline 0.13-0.14 ms). Paced runs take 1.2-2.2 times as long. posted_frees
  5/5 (each in its own process), burst 2 of 2 frees paced, step_aside 7/7.
- RTX 2080 (18054): the same results.
- lavapipe touched suites 130/130 (18094); clippy all features, --cfg m2v_gpu, --cfg m2v_cpu_icd
  and rustdoc -D warnings (18103, 18094).
2026-11-11 17:54:36 -08:00
Anees Iqbal b7d06c3820 Docs: a check's step waits until its own calls' length has passed since they ended 2026-11-11 17:54:27 -08:00
Anees Iqbal d729b77438 FAST-PATHS: on NVIDIA each vkFreeMemory holds the device's other submissions, measured
The known gap the frees' pacing answers in part: tests::import_free_hold_bench on an RTX 3090
(NVIDIA 620.70.06, quiet host, two runs) put a fill's commit to completion at 0.13-0.14 ms beside
no free, 0.46-0.54 ms beside runs of 512 KiB pointer or dma-buf imports freed one after another
(each free 0.26-0.39 ms), 2.6-2.9 ms beside 64 MiB imports (2.2-2.4 ms each), 1.2-1.6 ms beside
512 KiB plain host-visible allocations (1.1-1.2 ms) and 70-79 ms beside 64 MiB ones (28-30 ms);
paced, 0.10-0.32 ms beside every kind. An RTX 2080 on a loaded host showed pacing lower the median
beside every kind too. What stays open: a program's own release of a no-copy buffer frees its
import there (Metal's contract), unpaced, as does a completed command buffer's handler that frees
the imports its blits held last; one free still holds a submission that meets it.
2026-11-11 17:54:27 -08:00
Anees Iqbal f225901063 import_free_hold_bench: four plain host-visible allocations of 64 MiB beside the fresh pages' imports 2026-11-11 17:54:27 -08:00
Anees Iqbal 2bc93939b1 import_free_hold_bench: dma-bufs imported as a no-copy buffer's are, for a buffer made for them 2026-11-11 17:54:27 -08:00
Anees Iqbal 17264bcfbe import_free_hold_bench: two expressions in the forms clippy asks for 2026-11-11 17:54:27 -08:00
Anees Iqbal 92b5394ed4 step_aside tests: an owed wait is at least half the call, whatever the host's scheduling between them 2026-11-11 17:54:27 -08:00
Anees Iqbal 2106a7f65f Tests: the import free hold bench, and the posted frees run paced
tests::import_free_hold_bench measures what a vkFreeMemory of an import of host pages holds of
another thread's submissions: a pinger commits a one-word fill every 250 us while the bench's
thread makes and frees, through the runtime's doors, 32 pointer imports of 512 KiB, four of 64
MiB, 32 dma-buf imports of 512 KiB (udmabuf) and 32 plain host-visible allocations, each kind's
frees in turn and paced (step_aside::pace), printing the frees, the runs and the pings beside
them. tests::posted_frees gains a burst of posted frees that runs paced, and the allocation at the
limit now checks that the frees it waits for are not paced. api_signatures re-blessed for the two
new WorkCounts fields.
2026-11-11 17:54:27 -08:00
Anees Iqbal c9b96ccdb0 Pace the runtime's own runs of memory frees after the frees before them
NVIDIA's driver holds every other thread's vkQueueSubmit while it frees memory, a host-pointer
import's for 0.5 to 0.9 ms on an RTX 3090. The submission checks already pay their own
allocations and frees back before their next step (step_aside::OwnCall); this applies the same
owed time to the device's own threads that free in runs: the free thread before each block, the
residency thread before each idle import it releases, and a guest RAM's threads before each chunk
or list they give back or release. Each waits until as long as its frees before took has passed
since the last ended (now also the checks' rule), never while a caller waits for those frees (an
allocation at the limit, the device's teardown, a guest RAM use's end). The residency sweep holds
its imports weakly while it waits, so a program's release meanwhile frees its import in that
release, as before. Counted: WorkCounts::memory_frees_paced, memory_frees_paced_nanos.

Not yet built: the bench that measures the hold and the paced frees follows.
2026-11-11 17:54:27 -08:00
Anees Iqbal 5beb5ee031 Tests: the submission checks' recall test counts copies besides priming's
tests::submit_check_device::the_checks_answer_once_and_a_second_device_recalls_them held the
device that ran the checks to the cmd_copy_buffer count of the one that recalled them, which
held while every device was primed. Since 6ce451f452 a device made again on what stays loaded is
not, so the first (primed: priming's one copy within its buffer) counted 1 and the second 0
(lavapipe, gem10, m3-max-18039 and 18111, 3 of 3). Each count now leaves out the copies the
device's priming recorded, where ExitRegistrations::primings shows it was primed.
2026-11-11 17:45:41 -08:00
Anees Iqbal d0f800ddd0 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-11 17:15:40 -08:00
Anees Iqbal 100ea7b465 RUNTIME_VERSION 2070: a texture in place over a no-copy buffer's dma-buf no longer pins the buffer's import
RADV lists every imported memory in every kernel submission, 0.43-0.44 us each on the 780M and
the XTX (raw probe: 512 dma-buf imports of 1 MiB cost 229-234 us per submission against 7-8 us
with none; 64 pointer imports of 1 MiB 191-200 us). A texture in place over a no-copy buffer's
dma-buf import kept the buffer's import live for good, so each such surface listed two dma-bufs
per submission, though its DRM_FORMAT_MOD_LINEAR image has its own dedicated import.

Now HostPages::dma_buf reads the pages the way a blit does (blit_pages: imported again if
released, still releasable), and the in-place watch and dma_buf_unplaced take the offset from
Buffer::offset_in_host_pages() instead of a pinning memory() read; heap images take the same
path. Sampling and rendering go through the image's own import. A blit that names such a
texture runs on the buffer's bytes and imports the buffer again, as any blit does. The image's
own import stays listed for its life (RADV requires a dedicated allocation for it). The
per-import cost and the remaining limits (second buffers and bindings keep imports for good;
separate submit calls list every import again; no documented switch takes an import off the
list) are a FAST-PATHS known gap.

Tests: lane runtime_lane::submit_per_surface (128 surfaces of 64 KiB, each a no-copy buffer and
an in-place texture, measured after a 4 s idle); device test
host_residency::a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable.

Verified (potluck jobs, on the branch):
- 780M PHOENIX, Mesa 26.2.6: before (17864) 256 dma-bufs listed per submission, 119 us in the
  ioctl, 128 buffer imports kept for a texture; after (17939, three runs) 128 listed, 58-67 us,
  0 kept. In use: 256 listed, 115-129 us.
- XTX NAVI31: before (17927, load ~20) 256 listed, 160 us; after (17999, three runs) 128 listed,
  59-70 us; in use 256 listed, 108-109 us.
- The device test passed on the XTX (17999) and the 780M (18002): "1 chunks released under a
  texture in place, rendered into, imported again by its blit and released again".
- lavapipe 164/164 (18007; the device test skips: lavapipe imports the pointer).
- clippy default, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings (17978, at the last
  code commit; later commits are docs).
In the consumer's 780M walk the saving is bounded: at most about 43 of 160 kept imports are kept
by a texture alone (about 18 us per submission, for surfaces idle past their window).
2026-11-11 17:14:40 -08:00
Anees Iqbal 515367b8f2 FAST-PATHS: the XTX's submission times beside surfaces over dma-bufs
submit_per_surface on the RX 7900 XTX, three runs at the tip: 128 surfaces list
256 dma-bufs (108 to 109 us in the ioctl) while in use and 128 after their idle
window (59 to 70 us). Text only.
2026-11-11 17:14:21 -08:00
Anees Iqbal e2c31d54e4 FAST-PATHS: what RADV lists in each submission, and what a texture in place over a dma-buf keeps
The idle-release bullet says a texture in place over a no-copy buffer leaves
the buffer's import to the release (its blit reads the buffer as any blit), with
the 780M lane's counts (submit_per_surface, three runs: 128 surfaces list 256
dma-bufs while in use, 128 after the idle window). A known-gap entry records the
per-entry cost the raw probe measured on the 780M and the XTX (0.43 to 0.44 us
per dma-buf import per kernel submission), what Vulkan offers that does not
change it (memory priority, no device address, no pageable extension listed),
that separate submission calls list every import again, and that each in-place
texture's own image import stays listed for its life (RADV requires a dedicated
allocation of such an image).
2026-11-11 17:14:21 -08:00
Anees Iqbal e70c878fed Test: a texture in place over a dma-buf renders through its own import; its blit reads the buffer
On the 780M the test's claim that the texture's blit imports nothing failed:
a blit that names a texture over a buffer runs on the buffer's bytes
(blit_texture.rs, the module's note), so it imports the released buffer again,
as any blit does, and leaves it releasable. The test now clears the texture in
a render pass while the buffer's import is released (written through the
image's own import, residency unchanged, the pages read back), then checks the
texture's blit imports the buffer again and that it is released again.
2026-11-11 17:14:21 -08:00
Anees Iqbal f2d9378edb Lane: submit_per_surface counts each phase's textures and releases, not the device's totals
dma_buf_textures_in_place and host_imports_released are running totals, so the
64-surface phase printed 96 textures in place (32 + 64). The lane now reads both
at the phase's start and prints the difference. Report-only lane; built and run
on the 780M with the next runtime change.
2026-11-11 17:14:20 -08:00
Anees Iqbal 2abe74f6f1 Docs: say what an in-place dma-buf texture lists now, without the history
The host_residency module doc and HOWTO section 6 told what a guest surface
listed before the in-place texture stopped pinning its buffer's import; docs
say what is true now. Text only.
2026-11-11 17:14:20 -08:00
Anees Iqbal a4a6497772 Heap textures over dma-buf pages read the heap's pages as the in-place ones do
HostPages::dma_buf now answers a Result (the pages read as a blit reads
them, imported again where released); the heap's dma-buf image maker
(texture/heap.rs) is its other caller and takes the change. A heap's import
is kept for good whatever reads it, so nothing of its residency changes.

Found by the lint job m3-max-17783 (E0271 at texture/heap.rs).
2026-11-11 17:14:20 -08:00
Anees Iqbal 9b2ef7c237 A texture in place over a dma-buf import leaves the buffer's import releasable
RADV lists every imported VkDeviceMemory in every kernel submission, about
0.43 us each on the Radeon 780M and the RX 7900 XTX (a from-scratch Vulkan
probe, Mesa 26.2.6, Linux 7.3.3: 64, 256 and 512 dma-bufs held cost 31.5,
111 and 229 us an empty vkQueueSubmit against 7.2 with none). A consumer's
guest surface is a no-copy buffer over its pages and a texture in place over
the buffer: on RADV the texture is a DRM_FORMAT_MOD_LINEAR image in a
dedicated import of a dma-buf of its own pages, and making it read the
buffer's import apart (ReadApart::Texture), which kept the buffer's import
for good. So each surface listed two imports in every kernel submission for
its whole life.

The image asks the buffer's source for its own pages and binds none of the
buffer's memory, so its making now reads the buffer's dma-buf pages as a
blit does (HostImport::blit_pages: imported again where released, left
releasable), and the in-place watch a rebind reads takes the texels' offset
from the buffer's place in its host pages (Buffer::offset_in_host_pages),
not from their import. The buffer's import is then released after its idle
window like any blit-only one; the texture's image keeps its own import.
Pointer-imported pages, shadows and texel views still read the import apart:
they bind or read the buffer's memory.

Test: tests/host_residency.rs
a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable: the buffer
under an in-place texture is released (its chunks leave
dma_buf_memories_live, the image's import stays), the texture reads the
CPU's writes made meanwhile without importing anything, and the buffer's
next blit imports it again. Without the change the release never comes.
Docs: host_residency.rs, HostMemory::with_dma_buf, HOWTO.md.
2026-11-11 17:14:20 -08:00
Anees Iqbal eedd63e340 Lane: what each kernel submission costs beside surfaces over dma-buf pages
runtime_lane::submit_per_surface holds 0, 32, 64 and 128 surfaces, each a
no-copy buffer over a run of memfd pages imported as dma-bufs and a texture
in place over it (HostPageTexturePolicy::InPlace), reads each texture once,
then times 300 single-fill command buffers at once and again after the
surfaces sat idle past the device's first idle window. It prints the
textures in place over a dma-buf, the dma-buf memories live of buffers and
of images, the buffer imports released while idle and those a texture keeps,
and, under the kernel-submission counter, the dma-bufs each kernel
submission lists. A measurement, ignored by default, Linux only.

Why: RADV lists every imported VkDeviceMemory in every kernel submission,
about 0.43 us each on the Radeon 780M and the RX 7900 XTX (a from-scratch
Vulkan probe, Mesa 26.2.6, Linux 7.3.3), and a consumer's guest surface may
list two: its buffer's import and its in-place image's dedicated import.

Not run yet: built and run by potluck jobs on the 780M and the XTX.
2026-11-11 17:14:20 -08:00
Anees Iqbal d7b399c09c 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-11 17:10:36 -08:00
Anees Iqbal 975a78ce6b RUNTIME_VERSION 2069: a device made again on what stays loaded skips the exit guard's priming
A device is primed only when it will register the exit hook: the process's first device, the
first after a shared-object load, or a device of a new identity. A device made again on what stays
loaded registers nothing, and its calls are not the first ones (an earlier device's priming made
each), so it now skips priming. To answer that before priming, the device's functions and guard
identity are made earlier in the making. If a device registers without having been primed
(something changed between the check and the registration), the calls primed before are
forgotten, so each section's first call registers the hook again. ExitRegistrations (hidden)
gains a primings count.

Why: on the RTX 3090 (620.70.06) priming spends 112-144 ms in one call,
vkCreateIndirectCommandsLayoutEXT (m3-max-17899), and over 8 makings every device after the first
was made with no load (loads 67, at_devices 1; 17904): each re-made device paid priming for
nothing.

Tests: exit_guard::whether_a_device_registers_is_answered_before_its_priming,
exit_guard::a_device_registered_unprimed_forgets_the_primed_calls (fork test), primed_devices
(device cfgs); the two priming fork tests take the new signatures.

Verified (potluck jobs, on the branch at d36c330b67):
- lavapipe (m3-max-17994): clippy --cfg m2v_cpu_icd all targets and features clean; exit_guard
  and primed_devices 59/59 ("4 of 4 devices made again with no load; primings 1, at_devices 1").
- default cfg (17995): clippy clean; exit_guard 58/58.
- RTX 3090 release A/B, 2 runs x 8 makings: the runtime's own share of a re-made device (making
  minus vkCreateDevice) median 226 ms (140-459, busy node; 18001) -> 13.9 ms (13.2-15.6; 18000);
  making median 831 -> 561 ms; primings per re-made device 3 -> 0. The first device in a process
  still primes (own share about 293-336 ms with instance setup).
Not measured: the 5080 A/B; a lane whose validation layer reloads per instance still primes.
2026-11-11 17:09:35 -08:00
Anees Iqbal eea814d11a Devices: name the exit guard's identity apart from the properties' identity
The properties read after priming bind `identity` again (a DeviceIdentity), which the
registration took instead of the guard's Vec<u64> (E0308 at 6ce451f452, m3-max-17990).
2026-11-11 17:09:19 -08:00
Anees Iqbal 45182b7aeb Devices: prime only a device that registers the exit hook
What. A device's making asks the exit guard, before priming it, whether it will register the
hook (`exit_guard::before_priming`, now given the device's identity, answers
`Devices::admits`: the process's first device, the first after a load of a shared object, or
one of an identity new since). Only such a device is primed. A device made again on what stays
loaded, after a device of its identity registered, registers nothing and is no longer primed:
its calls are not the first, an earlier device's priming made each. The device's functions and
identity are made before the priming for the question; nothing else moves. A device that
registers unprimed after all (a load or another device between the question and its
registration) forgets the calls primed before, so each section's first call registers the hook
again. `ExitRegistrations` (hidden, for the lanes) counts the primings.

Why. Bug 487/676: on NVIDIA a device's making spent 120-160 ms of its own beside
vkCreateDevice, nearly all in priming's vkCreateIndirectCommandsLayoutEXT (112-144 ms on the
RTX 3090, NVIDIA 620.70.06, scratch timers on steelbrain/triage2-scratch 2edaaa5afa; m3-max-17899).
On that GPU every device after the first was made on what stayed loaded (the loads count stayed
at 67 over 8 makings and at_devices at 1, e6e5c1a34b, m3-max-17904), so each re-made device
paid priming for nothing. Priming exists only so that a device's registration of the hook comes
after the statics its calls make.

Tests: tests::exit_guard::whether_a_device_registers_is_answered_before_its_priming (the
answer agrees with the registration and notes nothing),
a_device_registered_unprimed_forgets_the_primed_calls (fork: 42), the two priming fork tests on
the new signatures, and tests::primed_devices (device cfgs): the first device primes, each made
again with no load neither primes nor registers.
2026-11-11 17:09:19 -08:00
Anees Iqbal 7a22646091 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-11 17:04:38 -08:00
Anees Iqbal 402cb93322 RUNTIME_VERSION 2068: a driver cache record names its pass without the attachments' colour formats
On the Iris Xe (ANV 26.2.6) a cold guest login made three pipelines that differ only in their
colour attachments' formats, and each compiled its own fragment shader for 4.2-4.4 s inside
vkCreateGraphicsPipelines: the shader parts' driver cache records were named by the full pass,
formats included, so no creation found another's compile.

Now the two shader parts' VkPipelineCache records name the pass with PassShape::without_formats
(attachment presence, samples, fetch inputs, unread inputs, storage attachments, view mask and
locations kept). The library objects keep their full names: they link against VkRenderPasses
that must be compatible, so only the driver's cache record is shared. A format the translation
reads still names its own record through the stage's module words. Record-naming version 2 -> 3
(shader_cache/driver.rs). With METAL2VULKAN_LOG_PIPELINES on, each library's split says whether
its record loaded, missed or shared an earlier making's cache, and whether the driver found it
there. Docs: docs/API.md, env_vars.rs.

Tests: unit test record_pass_formats; device test
driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records (RGBA8Unorm, then
BGRA8Unorm, then RGBA16Float: each later creation takes the first's caches and makes one fragment
shader library; RGBA16Float under NearestEven rounding, which the translation reads, keeps its
own record); creation_log text test.

Verified (potluck jobs, on the branch at 538c7e8eb4):
- Iris Xe ANV 26.2.6 (m3-max-17968): 2 of 2 makings took an earlier making's cache, 1 fragment
  shader library made, 2 driver hits and 0 misses, for BGRA8 and RGBA16F. lavapipe (17953): 2 of
  2 shared, 1 library each. M3 MoltenVK 1.4.2 (17956): 1 of 1 shared, 1 hit each.
- The 26.7.2 module, cold, Mesa cache off, harness (17871) on the Iris: own cache per format 3.65,
  3.53, 3.26 s; one shared cache 3.46 s, then 0.0 and 0.0 ms (APPLICATION_PIPELINE_CACHE_HIT).
- fmt, clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc -D warnings (17965).
Expected, not yet run: the device test on the 3090 and the 780M, and the consumer's cold boots.
2026-11-11 17:03:37 -08:00
Anees Iqbal f1c100d87c Tests: the rounding creation's pre-rasterization library is the earlier creation's own
creations_over_colour_formats_take_the_first_s_records expected the
RGBA16Float creation under NearestEven rounding to hand one making the
first's cache where the device links (its pre-rasterization part). That
creation makes no pre-rasterization library at all: the RGBA16Float
creation before it made that library against the same pass, under the
same library name, and the runtime reuses it. Its one making is the
fragment shader library of the rounding module, under a record of its
own, so no making takes an earlier making's cache on any device.

Verified on lavapipe before this fix (job m3-max-17929, um870): the
first two creations printed 2 of 2 makings handed the first's cache and
1 fragment shader library made each; the third printed 0 makings shared
and 1 miss, which the old expectation (1) failed. The test now expects
0, one fragment shader library made where the device links, and one
answer per making from a reporting driver.
2026-11-11 17:03:24 -08:00
Anees Iqbal 26e6fa6fc0 Tests: the format-sharing test's doc names the module's size in round words
The test's doc gave the measured module's exact word count; round it.
Also, to correct the previous commit's body: the third creation there is
an RGBA16Float pass under NearestEven rounding, a format the translation
reads (the fragment function rounds the half channel itself), so its
fragment part keeps a record of its own and only its pre-rasterization
part, where the device links, takes the first's. Doc only.
2026-11-11 17:03:23 -08:00
Anees Iqbal 5a1e043784 A driver cache record names its pass without the attachments' formats
A render making's record of the driver's data, and the libraries of its
pre-rasterization and fragment shader parts, were named by the pass
shape whole, formats included. A program that makes one state against
passes that differ only in a colour attachment's format (RGBA8Unorm,
RGBA16Float, BGRA8Unorm) so got one VkPipelineCache per format, and the
driver compiled the same fragment module once in each: on the Iris Xe
(ANV, Mesa 26.2.6) 3.3 to 3.7 s per compile for one large module, three
times over at a cold start.

No stage's conversion reads an attachment's format through the pass: a
format the translation reads is in the stage's own words and constants,
which name the part's record too. So a part's record now names the pass
by PassShape::without_formats (which attachments it has, its samples,
fetch inputs, unread inputs, storage attachments, view mask and
locations), and the depth bias is left out of it as before. The library
names the runtime keys its own library objects by keep the formats (the
libraries are made against VkRenderPasses, which must be compatible);
only the driver cache record is shared. A driver that does key a stage
by format keys that entry apart in the one cache: a compile, never a
wrong pipeline.

The record-naming version (shader_cache/driver.rs VERSION) goes to 3.
METAL2VULKAN_LOG_PIPELINES now says, per library, whether its record
was loaded, missed or its cache shared with an earlier making, and
whether the driver found it in that cache or compiled it (from
VK_EXT_pipeline_creation_feedback).

Measured before the change (a harness making the module's fragment
library against three passes on the Iris Xe, MESA_SHADER_CACHE_DISABLE):
a cache per format, 3.5 s, 3.7 s, 3.3 s; one shared cache, 3.5 s then
0.0 ms and 0.0 ms, the second and third APPLICATION_PIPELINE_CACHE_HIT.

Tests: record_pass_formats (a pass's record name drops formats, keeps
presence, samples, fetch inputs and view mask);
driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records
(two makings over BGRA8Unorm and RGBA16Float share the first's record,
caches_shared grows by the makings, one fragment library compiled,
while a constant that changes the module keeps its own record);
creation_log's text test.
2026-11-11 17:03:23 -08:00
Anees Iqbal 1aa0a93702 Re-bless the authored compile census at 892e4b230b
Its product fingerprint follows the runtime-sources pin at 892e4b230b (dv-m3).
2026-11-11 16:45:51 -08:00
Anees Iqbal db66fb2672 Re-bless the golden tables at 892e4b230b
What moved since ebc5a68a67's bless. Blessed on the M3 (dv-m3).
2026-11-11 16:45:51 -08:00