Commit Graph
260 Commits
Author SHA1 Message Date
Anees Iqbal fa19bdd391 Check every half bit pattern through a kernel's moves on every profile
The steps this packet landed as, in order:
- Read a half by the device's widening on MoltenVK where no use reads a NaN's bits
- Set the runtime version at the merged tree
- Bless the golden output hashes at the merged tree
- Bless the authored compile census at the merged tree

Content: the tree of `development` at f9408d00e6, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal bd4499fcd3 Count a typed threadgroup half array's volatile accesses as one each, and keep the arena's covered
Content: the tree of `development` at fc574f50aa, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 07d517d728 Leave the assumed-unmeasured flag out of a profile's capability members
Content: the tree of `development` at e4d849cdd8, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 644e055652 Keep a GPU pool's blocks while in use, and release a command buffer's own objects after its handlers
The steps this packet landed as, in order:
- Count the most GPU pool blocks leased at once
- Share one GPU pool block per queue among its command buffers
- Keep an arena's fitted list on the pools a completing command buffer takes out

Content: the tree of `development` at 0a94bc93a0, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal c1e9b6b2b9 Name a line pipeline's record as its triangle sibling's, so its making converts nothing again
The steps this packet landed as, in order:
- Read no data back from a making the driver found in its record, which MoltenVK rewrote each time
- Hash with sha2 0.11, which runs SHA-256 on ARMv8's SHA2 instructions

Content: the tree of `development` at 457e874745, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 62370dc95a Fetch a BGRA8 or RGBA8 shadow's texels through its own view in cut merges
Content: the tree of `development` at ed95238f3d, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 7f28814948 Destroy a block's buffer of addresses with no vkQueueSubmit under way, and make no buffer in the memory log
Content: the tree of `development` at ff17d7c868, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 8e6905f816 Merge four words an invocation in the shadow merge kernel
Content: the tree of `development` at 1ef6536d6c, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal b238e202a4 Report the encoding thread's CPU time per many_draws frame in host_ab
The steps this packet landed as, in order:
- Measure a frame shaped as the guest's window drag in host_ab
- Keep up to 256 spare descriptor pools, a window server's frames' worth

Content: the tree of `development` at c4853d8383, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 4d9b17a359 Run a batch's first work in its work's VkSubmitInfo, not one of its own
The steps this packet landed as, in order:
- Count render encoders' render pass instances by where they began, and their splits by cause
- Set the runtime version and pin the runtime sources at the merged tree
- Bless the golden output hashes at the merged tree
- Bless the authored compile census at the merged tree
- Regenerate the refusal surface at the merged tree

Content: the tree of `development` at effa414f26, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 3926ac1204 host_ab: a compositing workload of the consumer's frame shape; count the VkSubmitInfos submitted
Content: the tree of `development` at 89ca6673eb, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal ddd339e2a3 Count released objects by kind and shadow keeps by planner, for the residency churn
The steps this packet landed as, in order:
- Count no-copy imports a live import already holds
- Recycle a texture's image and memory for the next texture of the same making
- Add a control build that turns the image recycler off (--cfg m2v_no_recycle)
- Count image, buffer and memory releases by the place that released them
- Recycle the runtime's buffers and their memory for the next buffer of the same size

Content: the tree of `development` at db877e7a50, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 7ef86a35d8 Hold a kernel's static half threadgroup arrays as typed Workgroup objects
The steps this packet landed as, in order:
- Pin the runtime sources after the typed threadgroup step's doc edit
- Take the device's sin and cos as Metal's fast ones in a fast-math module on MoltenVK
- Write the typed threadgroup region test's module as a plain string
- Convert a plain class's half texel by the device's conversion on MoltenVK
- host_ab: compare each gpu kernel's output between the sides
- Share an imageblock slice write out to the whole threadgroup where one invocation writes it
- Copy a half slice's cell bits straight to a half-bits slot

Content: the tree of `development` at b0e2bd6190, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal d01ed34d37 Add DeviceOptions::assume_unmeasured_identity: run a measured device as an unmeasured GPU
The steps this packet landed as, in order:
- Pin the runtime sources at the switch on the development base
- Blend fast-math colors into BGR10_XR_sRGB and RGB10A8_2P_XR10_sRGB as the linear forms do
- Name a placement heap texture the heap does not make at an offset inside it

Content: the tree of `development` at 3386fdcac8, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal f9ebf83b15 Measure a frame of many small draws in host_ab, shaped as m2vbench's draws mode
Content: the tree of `development` at afac0fda19, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 782f13aa8d pipeline_records: a compute state's dispatch leaves a record per making, its creation's too
Content: the tree of `development` at 0f64c799aa, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal b253a0ad98 Convert a two-plane YCbCr texture only where its planes changed since the last conversion
Content: the tree of `development` at b3c5e804ad, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 4d90c98090 Keep the runtime's own kernels' spare descriptor pools apart from command buffers'
Content: the tree of `development` at e1d60ab9d4, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal 0a7b64f41d Bind the last set 0 again, and settle a dispatch once, where nothing it reads changed
The steps this packet landed as, in order:
- Ask a heap texture's image requirements once, and take owned kernels' sets from spare pools
- Find a replayed draw's pipeline where its state's last draws found it

Content: the tree of `development` at 6f29d4516f, unchanged.
2026-10-26 13:19:03 +02:00
Anees Iqbal fab21259b7 Make a compute state's first dispatch pipeline at its creation, and one form per key on MoltenVK
Content: the tree of `development` at 52fe66739d, unchanged.
2026-10-26 13:19:02 +02:00
Anees Iqbal c356f8d13d Check a host step's commands from the records it read, without reading them again
Content: the tree of `development` at 412587dab0, unchanged.
2026-10-26 13:19:02 +02:00
Anees Iqbal f6442761df Let an indirect command buffer's execution check the commands its host step records
Content: the tree of `development` at 480957f307, unchanged.
2026-10-26 13:19:02 +02:00
Anees Iqbal 3a02b6330a host_ab: feature kernels, a host-clock latency split, and per-variant encode runs
Content: the tree of `development` at 61b5179154, unchanged.
2026-10-26 13:19:02 +02:00
Anees Iqbal 9810aff5e0 Add a host A/B benchmark: the same Metal workloads natively and through the runtime
Content: the tree of `development` at 6d4bcda22f, unchanged.
2026-10-26 13:19:02 +02:00
Anees Iqbal a2c440b8bc Drop the ban on behavior keyed to an earlier session from AGENTS.md
The owner lifts it: a device may keep what it checked or learned about
itself in an earlier session (its driver's answers and defects, checked
on the device). The bans on keying behavior to an app, a shader hash or
a corpus census stay. Doc-only; cargo fmt --all run.
2026-10-19 02:43:05 +03:00
Anees Iqbal 62cad6be54 Regenerate the tables and set the versions at the landed tree
The generated and blessed files, and the three version constants, as of the tree this series ends
on. They come last so that no packet commit before this one claims a version or a table, and so
the final tree is exactly the tree verified at the tip.

- docs/REFUSALS.md regenerated.
- crates/metal2vulkan/tests/golden_hashes.tsv and the air_input printouts as blessed (the table
  tests 25 of 25 on the M3 Max host, with xcrun metal-as for the typed-pointer fixtures).
- crates/metal2vulkan-validation/corpus/authored-compile.tsv as blessed: 2256 authored cases on 21
  profiles, 47376 cells, 46245 compiled and 1131 refused, 0 failed, 0 differences, 0 regressions.
- crates/metal2vulkan-validation/runtime-sources.sha256 recomputed.
- SEMANTICS_VERSION 1798, RUNTIME_VERSION 1496, ARTIFACT_FORMAT_VERSION 431.

Verified at this tree: the full suites on the RTX 5080 Laptop, RTX 3090, RX 7900 XTX, Radeon 780M,
Iris Xe and the M3 Max through MoltenVK, the CPU suites (product, validation, lavapipe's CPU ICD),
fmt, clippy in every configuration, rustdoc, the API reference and refusal-surface checks,
packaging and doctests; the failures those runs found were fixed in this series and their lanes
run again green.
2026-10-19 00:16:01 +03:00
Anees Iqbal 58cea0eaa7 Time the scheduler's take-up apart from the driver's submit, and allow the storm tail the host's delivery
New WorkCounts::batch_submit_nanos times each vkQueueSubmit, and the take-up tests bound only the
scheduler's own time: the long take-ups on the RTX 5080 were inside the driver's call. The queue
storm's p99 may exceed the reference's by its margin plus twice the reference's own completion
delivery, for the runtime's two extra host hand-offs per burst.
Verified: the 5080 under load, 22 of 22 (the old bound would have failed 11); the storm on the M3
quiet and under eight default-QoS spinners.

Folds in:
- Time the scheduler's take-up of checked commits apart from the driver's vkQueueSubmit
- Allow the queue storm's tail the host's delivery of a completion for the runtime's two extra hand-
  offs
2026-10-19 00:16:01 +03:00
Anees Iqbal 24d5b9a432 Give each translator test its own allocation count and scratch directory
Under cargo test, whose tests run as threads of one process, three footprint tests counted every
thread's allocations and tests sharing a process-id-named scratch directory deleted each other's.
The counting allocator now counts the measuring thread alone, and one Scratch helper gives each test
a directory of its own, removed on drop, at the 42 sites that named theirs by process id. Test-only.
Verified: two full cargo test runs with no scratch failures, and the touched tests under nextest.

Folds in:
- Count the translator tests' allocations on the measuring thread alone, so cargo test's threads
  leave them alone
- Give each of the translator's tests a scratch directory of its own, removed on drop
2026-10-19 00:16:00 +03:00
Anees Iqbal 33e89bd482 Fit mesh, compute and tile pipelines to ANV's compiler word bound
On ANV a pipeline whose largest stage module passes 400,000 words under the exact forms is
retranslated with those forms dropped until it fits; render pipelines already were, and now mesh,
compute and tile pipelines are too, announced as exact-forms-over-compiler-limit with the kind of
pipeline state named. New Device::fit_mesh_variant, fit_compute_pipeline and fit_tile_pipeline for
pipelines linked from stages compiled ahead. The known gap is gone from docs/FAST-PATHS.md.
Verified: the fit tests for every kind, 188 translator and runtime tests and the device notice tests
on ANV, and 7 of 7 on RADV.

Folds in:
- Fit mesh, compute and tile pipelines to ANV's compiler word bound
2026-10-19 00:16:00 +03:00
Anees Iqbal 0a34e8c743 Read a per-sample fragment function's pixel reads where Vulkan evaluates them, noted, as Metal accepts them
A fragment function that runs per sample (programmable blending reads its attachment) and also reads
[[position]] z or w, [[point_coord]], [[barycentric_coord]] or a centroid varying was refused at
link; Metal accepts it and reads each as the pixel's in every sample's run (M3 Max at 4x, measured).
These reads now read where Vulkan evaluates them for the sample, with
PrecisionNote::MultisamplePosition and its bound (the value's change over half the pixel's diagonal,
or across the covered area for a centroid varying). Chromium's Skia Graphite on Dawn (Claude
Desktop) made such pipelines. The new test shader is its own fixture, engine/multisample_fetch;
engine/multisample is unchanged.
Verified: the guest's pipelines compile on six profiles and Claude Desktop draws in the macOS guest
on the RTX 5080 with no fatal line; the multisample, point_coord and link tests fail without the
change and pass with it.

Folds in:
- Read a per-sample fragment function's pixel reads where Vulkan evaluates them, noted, as Metal
  accepts them
- Move the programmable-blending fixture entry out of engine/multisample into a fixture of its own
2026-10-19 00:16:00 +03:00
Anees Iqbal 84ba0af335 Record a lavapipe dispatch of a variant that bakes samplers in its own command buffer
lavapipe samples a binding with a baked immutable sampler as Repeat when the dispatch follows a copy
in the same VkCommandBuffer. New RuntimeDriverDefect::ImmutableSamplersLostAfterCopies, on every
lavapipe release: there an encoder's dispatch of a variant that bakes samplers records in a command
buffer of its own; WorkCounts::baked_sampler_dispatches_apart counts them.
Verified: the YCbCr constexpr test on lavapipe 26.0.8, 3 of 3 (3 of 3 failing without the fix), and
on 26.2.4; the related lanes 40 of 40 on each.

Folds in:
- Record a lavapipe dispatch of a variant that bakes samplers in its own command buffer
2026-10-19 00:16:00 +03:00
Anees Iqbal e320a1f475 Drop design-record, work-package and evidence codes from comments, and retire vk12-bare from the corpus
Comments, fixture notes and docs lose their design-record numbers, work-package codes and evidence
codes; lines that earlier commits of this series added carry their cleaned text there, so this
commit holds the cleanup of lines that predate the series, the retired vk12-bare profile's corpus
rows (a rationale and two observation rows), and docs/FAST-PATHS.md's measurements stated as they
stand. Thirteen hash-keyed files keep their citations, because their bytes are case or record
identities: eight case-keyed .ll fixtures and five parity sources.
Verified: the CPU suites (4997 of 4997 and 1328 of 1328), clippy, rustdoc and doctests.

Folds in:
- Drop evidence codes, design-record numbers and work-package codes from comments and fixture notes
- Drop the retired vk12-bare profile from the corpus
- Say the fast-path ledger's measurements as they stand, without commits, rounds or host incidents
- Keep the case-keyed .ll fixtures byte for byte
- Keep the parity lanes' fingerprinted sources byte for byte
2026-10-19 00:16:00 +03:00
Anees Iqbal affd8a5eb7 Split an interlocked pass at the fetch on every GPU, and delete the whole-pass reroute
The UHD 770's cost fact said an interlocked pass ran faster kept whole; measured again, splitting at
the fetch wins on every measured GPU (UHD 770, Iris Xe, Radeon 780M, RTX 3090, RTX 5080 Laptop) on
the window server's passes, so the UHD 770 carries InterlockedPassSplitNoSlower like the rest. With
no device keeping a pass whole, the whole-pass reroute is deleted:
DriverFact::InterlockedPassWholeFaster, RenderCommandEncoder::reroute()'s whole branch and
interlocked_colors(). The extended-range half shadow's draw keeping stays.
Verified: the framebuffer_fetch, extended_range and multisample lanes on all seven GPUs, 271 of 271
each.

Folds in:
- Run an interlocked pass split on the UHD 770 as on every GPU measured, by the corrected cost fact
- Delete the whole-pass reroute, which no device reaches since the UHD 770's fact was corrected
2026-10-19 00:16:00 +03:00
Anees Iqbal a95b37d56d Read a calibration pair again while its least deviation stays above 20 us, four readings at most
A GPU-time calibration re-reads the CPU/GPU timestamp pair while the best reading's deviation stays
above 20 us, up to four readings, so a preempted vkGetCalibratedTimestamps under load no longer
skews it.
Verified: the gpu_times lane on the RX 7900 XTX and lavapipe, 11 of 11; the four-reading case by its
unit test.

Folds in:
- Read a calibration pair again while its least deviation stays above 20 us, four readings at most
2026-10-19 00:16:00 +03:00
Anees Iqbal 6898b52edf Hold freed memory for the program's own with_vk_queue submissions, and tear the device down on its own thread
On drivers that park freed memory (MoltenVK among them), memory freed while the program's own
with_vk_queue submissions may still use it now waits for them, by a mark each use signals. The watch
of those marks and the release of freed memory hold only the device parts they use, never the
device, and teardown closes the parking first and waits for the handler threads: the program's last
drop tears the device down on its own thread before it returns, as Metal's last release does
(vkDestroyDevice needs external synchronization and every child object destroyed first).
freed_memory.rs is listed among the modules that may keep the device's functions, with that reason.
Verified: the freed-memory and teardown tests on ANV, lavapipe and the M3 through MoltenVK (14 of 14
each), the two teardown tests fail without the fix, and the presenting test that crashed in the
batch passed 20 of 20 on the M3.

Folds in:
- Hold MoltenVK's freed memory for the program's own with_vk_queue submissions, by a mark each use
  signals
- Hold nothing of the device in the watch of the program's marks and the releases of freed memory
- List freed_memory.rs among the modules that keep the device's functions
2026-10-19 00:16:00 +03:00
Anees Iqbal 8b5d74d9aa Round exact fetched blends to half by the controlled conversion, and code 8-bit values in float
The exact in-shader fetched blends round to half by the controlled conversion and decode and write
8-bit codes in float, which keeps Metal's stored bytes while dropping the integer paths.

Folds in:
- Round the exact fetched blends to half by the controlled conversion, and decode and write 8-bit
  codes in float

Verified by each folded change's own checks; the tree this series ends on is the one verified
at the tip on six GPUs, the CPU suites and lint (see the tables commit).
2026-10-19 00:16:00 +03:00
Anees Iqbal 982e699ecd Start a heap shadow's image as its memory lies, without the zeros its copy in overwrites
A heap shadow's image starts in the layout its memory already lies in, without first clearing zeros
that its copy in overwrites anyway: one GPU clear less per heap shadow.

Folds in:
- Start a heap shadow's image as its memory lies, without zeros its copy in overwrites

Verified by each folded change's own checks; the tree this series ends on is the one verified
at the tip on six GPUs, the CPU suites and lint (see the tables commit).
2026-10-19 00:16:00 +03:00
Anees Iqbal 7bc5866f45 Draw a multisampled 32-bit float depth copy, announced, where the driver's fragment depth is unmeasured
On a driver whose fragment depth is unmeasured, a multisampled Depth32Float copy is drawn and
announced rather than refused.

Folds in:
- Draw a multisampled 32-bit float depth copy, announced, on a driver whose fragment depth is
  unmeasured

Verified by each folded change's own checks; the tree this series ends on is the one verified
at the tip on six GPUs, the CPU suites and lint (see the tables commit).
2026-10-19 00:16:00 +03:00
Anees Iqbal 5783db2459 Keep a fetched merge's texels in an image copy of its shadow, the kept images held per queue
A fetched merge keeps its texels in an image copy of its shadow where the copy in takes no keep, and
kept images are held per queue and taken by any later keep of the same shape once its encoder ended,
so merges stop making a new image each time.

Folds in:
- Keep a fetched merge's texels in an image copy of its shadow where the copy in takes no keep
- Keep merges' kept images per queue, taken by any later keep of the shape once its encoder ended

Verified by each folded change's own checks; the tree this series ends on is the one verified
at the tip on six GPUs, the CPU suites and lint (see the tables commit).
2026-10-19 00:16:00 +03:00
Anees Iqbal e841dd6b4a Read the Radeon 780M of Hawk Point as the measured Phoenix 780M, with its own device profile
The Radeon 780M of Hawk Point (PCI device 0x1900) takes the driver facts measured on the Phoenix
780M (0x15bf), the same GPU, and gets its own committed device profile.

Folds in:
- Read the Radeon 780M of Hawk Point (0x1900) as the measured Phoenix 780M (0x15bf)

Verified by each folded change's own checks; the tree this series ends on is the one verified
at the tip on six GPUs, the CPU suites and lint (see the tables commit).
2026-10-19 00:16:00 +03:00
Anees Iqbal b660f64e17 Copy equal rows between buffers as one dispatch on ANV and the RTX 5080 Laptop, and split long copy regions
A copy of rows between two buffers whose rows lie apart is one vkCmdCopyBuffer with a region per
row, and ANV records each region as a blit operation of its own. In a guest frame's profile on
the Iris Xe one such copy a frame took about 15.7 of the recorder thread's 19 ms. ANV's recording
time for a single region also grows with the region's size at some sizes: one two-plane YCbCr
texture's planes copied into its staging buffer cost about 15 ms of the recorder's time a frame.

Row copies:
- Every copy of rows between buffers goes through one place, row_copies.rs (RowCopies): a blit
  between a buffer and a texture over a buffer or between two textures over buffers (through its
  overlap scratch too), a buffer-texture copy's rows through its staging buffer, and every
  shadow's copy back out of its staging buffer, wherever it records: a render pass's steps
  between instances and before tile dispatches, a rotated texture's store, and a heap's
  two-plane and tiled textures' copies back.
- RowCopies makes the copy one dispatch of the new translator kernel bind::rows_copy_module
  (RowsCopyModule) where the device is measured to run it faster (new
  DriverFact::RowCopiesDispatchFaster), the copy has 2 or more regions of the same size in whole
  4-byte words, 4-byte aligned, evenly spaced with destination rows at least a row apart, and it
  fits the device's storage buffer range and workgroup counts. Invocation (x, y) stores word x
  of source row y at word x of destination row y and writes nothing else, so the bytes are the
  copy's. Every other copy stays regions. The kernel's set 0 is pushed through the device's
  checked push command where VK_KHR_push_descriptor exists, else allocated from a pool the
  command buffer keeps; the callers name the dispatch's accesses so the tracker orders it.
- The fact holds on ANV (Mesa 26.2.4, keyed on the driver, so it covers the measured Iris Xe and
  UHD 770 identities) and on NVIDIA 615.71.09 on the RTX 5080 Laptop GPU. RADV is not listed: its
  GPU time rose 3 to 5% at 1080 rows.

Long copy regions: every vkCmdCopyBuffer the runtime records goes through Vk::cmd_copy_buffer,
which records each region over 16 KiB whose size is no multiple of 4 KiB as two regions of the
same command, its bytes up to the last whole multiple of 4 KiB and the rest. The same bytes are
copied by the same command, so the split is exact on every device and is not keyed to a driver;
five helpers that recorded copies through a bare ash::Device now take the device's functions.

Counters: WorkCounts::row_copies, row_copy_regions, row_copy_regions_most, row_copies_dispatched,
copy_regions_split, and copy_sites, which names the places in the runtime that recorded buffer
and image copies with their calls and regions (the device's checked functions record them
through #[track_caller] methods). The runtime re-exports CopySite. Docs: docs/HOWTO.md's copies
section, row_copies.rs, device/functions.rs, WorkCounts.

Verified, as the commits state:
- runtime_lane::row_copies::row_copies_cost (release, one blit a frame of 1920 BGRA8Unorm rows
  into rows 8192 bytes apart): 1080 rows on the Iris Xe CPU 3.1-3.3 -> 0.28-0.40 ms and GPU
  5.3-7.8 -> 1.13 ms; on the UHD 770 CPU 0.77-0.83 -> 0.04-0.11 ms and GPU 3.3-5.3 -> 0.59-0.91
  ms; on the RTX 5080 Laptop GPU 2.03-2.05 -> 0.42-0.43 ms.
- rotated_textures::rotated_surface_frame_costs (1920x1080 BGRA8Unorm, release, UHD 770): rotation
  1 clear+draw 4.41/4.43 ms against 7.24-8.24 ms, rotation 2 3.59-3.88 against 5.11-5.73 ms.
- span_copy_cost on the UHD 770: one region of 8,294,411 bytes recorded in 0.018-0.020 ms against
  28.4-35.1 ms, its GPU time 0.64-0.66 against 5.97-5.99 ms; the YCbCr frame 2.89-2.98 against
  6.80 ms of GPU. On RADV and NVIDIA the split recorded in the same CPU time and ran within about
  10 us of GPU time where one region was already quick, and faster where it was not (8,294,411
  bytes on the RTX 3090: 1520 against 6051-6061 us).
- Copy lanes with every byte checked under the validation layer (rows between buffers, a shadow's
  staged rows going back as one dispatch, blits of textures over buffers, textures over bytes
  past their VkBuffer) pass as dispatches on the UHD 770 and the RTX 5080 Laptop GPU and as
  regions on lavapipe; the rotated, tile-shadow, two-plane heap and heap-layout lanes pass on the
  UHD 770 with each rotated store's rows going back as a dispatched copy of rows.
  long_copies_of_any_size_copy_metals_bytes (prime sizes and offsets) passes on the UHD 770, the
  RX 7900 XTX, the 780M and the RTX 3090, and the YCbCr, blit, pitched-surface, no-copy,
  first-use, fill and frame-cost lanes pass on the UHD 770.
- tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions (the push goes through
  the checked functions), bind::rows_copy, the driver_facts tests, owned_divisions, api_surface,
  and the runtime unit tests named row_copies, work_counts, functions, copy, shadow, first_move
  and ycbcr; clippy in every configuration and Rustdoc.
2026-10-19 00:16:00 +03:00
Anees Iqbal d77bd86377 Compute half + - * and fma in 16 bits under the 16-bit float controls
On a device whose half roundings take the 16-bit float controls (RoundingModeRTE, DenormPreserve
and SignedZeroInfNanPreserve for 16 bits with shaderFloat16: ANV and RADV among the committed
profiles), a half + - * is now the device's 16-bit OpFAdd, OpFSub or Fma(a, b, -0.0), kept apart,
between exact conversions (ops::f16_binary, the form the measured MoltenVK fact already takes).
Where shaderFmaFloat16 is enabled too, a half fused multiply-add is OpFmaKHR on 16 bits (new
fma::Route::F16Khr), under either policy. Elsewhere the f32 operation and its rounding pair, the
round-to-odd routine and native device maths' Fma stay as they were.

Exact: Vulkan's precision table lists OpFAdd, OpFSub and OpFMul for half precision, and OpFmaKHR,
as correctly rounded, to nearest even under RoundingModeRTE, with denormals kept under
DenormPreserve and zero signs under SignedZeroInfNanPreserve, the modes the entry declares where it
computes in 16 bits (narrow::computes_in_16_bits). That is Metal's half arithmetic and Metal's
half fma, which the round-to-odd routine emulated. A NaN's bits are the device's, as the
controlled rounding's already are; Metal's NaN is selected around the instruction where the
profile asks for it. The half fma under native device maths no longer records NativeFma there.

Why: the device's compiler spent most of a large half fragment function's making on the f32 ->
f16 -> f32 rounding pairs, most of which follow a + - * or a fused multiply-add. On ANV a
consumer's largest fragment library made in about 4 s, and about 2.2 s without its rounding pairs.

New: VkFeature::ShaderFmaFloat16 (the Khronos table, enables, the ash and runtime feature chains,
derivation, the codec), OpFmaKHR's feature by its operands' width, the builder's OpFmaKHR on 16-bit
floats, and the owned fixture engine/hfb_filter_bank (a 32-case switch of runtime-sampler tap
loops and half arithmetic chains) with its engine inventory rows. The validation engine's enable
list enables shaderFmaFloat16 from VkPhysicalDeviceShaderFmaFeaturesKHR beside shaderFmaFloat32,
and the opened-chains pin records it for the profiles that list it. Docs: docs/FAST-PATHS.md's half
rounding row, and the NativeFma notice in artifact.rs and docs/API.md.

Verified, as the commits state:
- On the UHD 770 (ANV, Mesa 26.2.4) the fixture's fragment library made in 1.74-1.89 s against
  4.64-5.26 s before (3 alternating rounds, no driver caches), SIMD8 instructions 25,902 ->
  18,736, translation 0.17 s release; driver_deviations::half_arithmetic_answers_as_metal passes
  there.
- On the UHD 770 in the release m2v_gpu build, the groups that failed before the engine enabled
  the feature pass: candidate engine runs, platform enables and device, engine_render,
  engine_compute, engine_textures, acceptance_pipelines, the runtime lanes kernel_textures,
  sparse_textures, renders, argument_buffers and runtime_probe, and the half and fma driver
  deviations.
- Debug translator tests: engine_arith, lower::arith, the fma, derivation, device, ash_interop,
  cache and fast_paths tests, and the engine inventory's llvm_as parts; engine_native_half
  (counting the 16-bit operations and their exact conversions) and engine_spirv_cross_forms (no
  NativeFma where the half fma route is F16Khr), with fused and engine_arith, 213 passed.
- clippy of metal2vulkan.
2026-10-19 00:16:00 +03:00
Anees Iqbal b6addb96c0 Read storage without a format by its format's bit under VK_KHR_format_feature_flags2 or Vulkan 1.3
Vulkan enables the SPIR-V capabilities StorageImageReadWithoutFormat and
StorageImageWriteWithoutFormat by shaderStorageImage{Read,Write}WithoutFormat, by Vulkan 1.3, or
by VK_KHR_format_feature_flags2; under the last two each format's own
STORAGE_{READ,WRITE}_WITHOUT_FORMAT bit (VkFormatProperties3) says whether it may be accessed so.
Intel's ANV and SwiftShader lack shaderStorageImageReadWithoutFormat, and the translator took the
feature as the only route, so a storage read the shader cannot declare with a SPIR-V format was
refused there even where the format's own bit grants it. Metal accepts such reads: an A8Unorm
storage texture read, and a fetch of an A8Unorm color attachment through the pixel interlock.

Now:
- VkExtension::KhrFormatFeatureFlags2 joins the Khronos name table, the cache codec, the
  runtime's and the validation platform's extension tables and the enable facts (core in 1.3, no
  feature member). The runtime enables it below Vulkan 1.3 where the device lists it.
- A module's Requirements list the two capabilities without their feature
  (device::requirements::WITHOUT_FORMAT_CAPABILITIES), and DeviceProfile::check and
  DeviceDescription::required_enables resolve them on the device: the feature where the device has
  it, else nothing at Vulkan 1.3, else the extension. A device with none is refused naming the
  feature, as before.
- metal::format: a typed declaration stays preferred wherever SPIR-V names the format; the
  declarations SPIR-V cannot name (the storage choice, the fetch's storage form, the depth and
  stencil fallbacks, the slot's formatless refusal, the ulong form) go by the features or by the
  format's own bit.
- A heap stays on the features: a per-pipeline check of each member's bit is not built, and
  docs/FAST-PATHS.md's known gap says what the formats' bits leave refused on ANV.

Effect on the committed profiles, read at the runtime's Vulkan 1.2 with and without the
extension over every PixelFormat: on intel-irisxe-rplp-anv and intel-uhd770-rpls-anv an A8Unorm
storage texture read and read-write, and an A8Unorm color attachment fetch read and written,
single and multisampled, now compile (an A8_UNORM view declared without a format), and an A8Unorm
texture buffer takes the A8_UNORM view in place of R8_UNORM holding alpha in red (both Metal's
texels). On intel-irisxe-anv and swiftshader nothing lifts. Every other changed cell on the four
profiles (1280) keeps its refusal and now names the format's missing bit in place of the feature.
The engine fixture tables do not change on any profile. The validation platform's Vulkan 1.2
device contexts enable the extension where a profile lists it, and the opened-chains pin records
it (32 contexts on 16 profiles, one more extension each).

Verified, as the commits state: the unit tests device::tests::enables (the feature, the version or
the extension), metal::format (access by the format's bits with the extension),
lower::fragment::fetch (an A8Unorm attachment fetched by its own bit, the fetch tests at Vulkan 1.2
with and without the extension), spirv::requirements and spirv::serialize, and the
framebuffer-fetch compile test all pass; public_fixtures_engine parts 1-8 unchanged; the
per-profile census above, run as a temporary test; candidate::platform::enables::tests 21 of 21;
clippy. New lane runtime_lane::alpha_in_red::a8_storage_reads_without_the_feature_go_by_the_format_s_bit
(a device made without shaderStorageImageReadWithoutFormat, as ANV is, reads its own A8_UNORM by
the format's bit under the extension: Metal's (0, 0, 0, 0.6) and 178).
2026-10-19 00:16:00 +03:00
Anees Iqbal 9d2a757be3 Record more passes inline: memoryless DontCare colors, splits across the interlock, wide clears
The consumer's guest recorded only about 3 of its frame's roughly 32 render passes inline; every
other pass recorded its draws into a secondary command buffer that the recorder begins, replays
and ends and the pass's primary executes. On the Iris Xe a split instance costs 61 to 87 us of
encoding CPU in a secondary against 5 to 9 us inline. This packet counts why a pass is not
inline and removes the three reasons the guest's passes hit.

Counted:
- opens_inline returns the check that ruled a pass out (Result<(), NotInline>), its checks in
  the same order, and WorkCounts gains one count per reason: passes_not_inline_encoders,
  _layouts, _actions, _buffer_textures, _attachments, _draws, _memoryless, _storage, _stand_ins
  and _memoryless_writes. NotInline::Actions carries the first action ruled out
  (work_counts::ActionsRefused), counted in passes_not_inline_actions_dont_care_load,
  _unequal_reach, _nan_clear, _resolve and _store, which sum to passes_not_inline_actions.
- WorkCounts::tile_dispatches_recorded counts the tile dispatches render encoders record.

Recorded inline where they were not:
- A memoryless color loaded and stored DontCare (a 2D level and layer of a format that takes
  transfer writes) no longer rules the open out. The inline instance renders the transient image
  in place, clears it to zero (Metal's measured answer for a DontCare memoryless color in a pass
  that draws) and stores it DontCare. No inline instance writes a memoryless color: a first draw
  that writes one keeps the instance in a secondary, and a later one splits the pass before it
  (WorkCounts::inline_memoryless_write_splits). A backing that arrives after the inline instance
  is cleared, never copied into, so no instance reads what an earlier pass left in the queue's
  kept backing.
- An instance after a split also records inline where its shape is the first instance's except
  for the colors its draws leave out of the subpass for the pixel interlock, and the only
  stand-ins arriving with it are memoryless colors' backings loaded Clear. Each such shape takes
  its own render pass and framebuffer (inline_splits::Later), a left-out color's slot holding the
  device's placeholder, and arriving backings are cleared to the first instance's clear before
  the instance they arrive with. The copies before a kept instance are planned only where a
  shadowed texture was used, and kept draws reuse room the device keeps (at most 8 rooms of 64
  draws), so the move adds no allocation a frame.
- A pass whose Clear loads reach past the render area (Metal clears whole 32-pixel tiles)
  records its first instance inline over that reach, where every stored color is cleared to the
  same reach, none is loaded where the reach passes the render area, and each memoryless color is
  at least as large; its load operation's clear reaches what Metal's does, its draws' scissors
  stay inside the render area, and the pass plans no reach clears. Otherwise it records as
  before, counted as ActionsRefused::UnequalReach.

New owned fixture mli_memoryless_step (fragments mli_tag_step and mli_count_seed) with its engine
inventory rows. clear_reach.rs's docs say the inline instance's own clear past the render area
is unmeasured on MoltenVK.

Verified, as the commits state:
- Lane tests: inline_reasons (each reason and each action, a memoryless color beside a stored
  one, a later write that splits once, colors cleared past half their side, an unequal reach);
  framebuffer_fetch (memoryless tags loaded DontCare over two passes in turn: each pass records
  inline and splits once into an instance that also records inline, and the second pass would
  read 13c where it reads 11c if a backing kept the first pass's tag); clear_reach (colors whose
  clears reach alike record inline over their reach, each texture holding Metal's answer);
  tile_dispatches.
- On lavapipe the touched lanes pass (140 passed in the last run, with frame_costs' allocation
  and command-buffer checks), and the runtime's unit tests pass (1058). On the RX 7900 XTX (RADV)
  the touched lanes pass (134) with no VUID message; on the UHD 770 (ANV) they pass except four
  tests that need Metal observations the host's copy lacked, which pass on RADV.
- Composite bench (40 passes, 120 draws a frame): split instances recorded inline 0 to 38,
  secondaries executed 40-42 to 2-4, allocations 3774 to 3468 a frame on ANV and 3396 to 3244 on
  RADV. Part-area bench on RADV: passes recorded inline 20 to 95 a frame, secondary executions
  80 to 5, encoding CPU 1.91 to 1.69 ms, through completion 2.29 to 1.97 ms.
- The engine fixture inventory (LLVM 21); clippy in the plain, m2v_gpu and m2v_cpu_icd cfgs and
  Rustdoc.
2026-10-19 00:16:00 +03:00
Anees Iqbal e47fa7a846 Bench the encoding thread on the guest's frame shapes, over host pages and in composite passes
The validation lane frame_costs gains three ignored release runs, run by name, so the runtime's
encoding-thread cost can be compared on the shapes the consumer's guest submits:

- frame_costs_guest_passes times the plain device on the guest's frame shapes, with passes
  loading their layer in the guest's mix (15 clear, 4 load, 1 don't-care in 20): one image's 100
  one-draw passes, as 100 command buffers of one pass and as one command buffer of 100 passes,
  and another image's frame of 41 command buffers (9 with no pass, 32 with one pass, 277 draws,
  most of them in five big passes).
- frame_costs_host_pages times the window server's frame and that image's frame with the index
  and rectangle buffers as no-copy buffers over one host mapping, plus a third no-copy buffer over
  the whole mapping, so each draw's uses take the uses of the keys their bytes share, as the
  guest's buffers over its RAM do.
- frame_costs_guest_composite draws 40 command buffers of one pass shaped like the guest's
  composite passes: a BGRA8Unorm layer loaded and stored, a memoryless RGBA16Float scratch
  loaded and stored DontCare, one plain blended draw and two draws that fetch the layer, so a
  device that fetches through the pixel interlock splits each pass at the first fetch, as the
  guest's do. A second run swaps the scratch for a private texture cleared and stored. A new
  FRAME-COST line counts, a frame, the passes whose first instance recorded inline, those that
  did not by every reason, the split instances recorded inline, the instances ended unrun, and
  the replays' render pass begins and secondary executions.

The frame loop now walks a layout (command buffers, then passes, then draws), and the per-pass,
per-command-buffer and per-draw figures divide by that layout's counts; the window server's run
keeps its draws and its numbers. Validation only: no runtime change.

Verified, as the commits state: clippy of the validation crate, plain, m2v_gpu and m2v_cpu_icd.
On the RX 7900 XTX (RADV, release): the plain guest shapes 2.86 ms a frame and 38.0k user-space
instructions a draw, over host pages 3.83 ms and 41.9k, the other image over host pages 1.89 ms
and 40.8k; the composite with the memoryless scratch 0 passes inline, 80 render pass begins and
80 secondary executions, encoding thread 2.46 ms a frame, and with the scratch kept 38 inline,
80 begins, 42 executions, 2.14 ms (two rounds that agreed). On lavapipe the composite run passes
with 0 and 38 passes inline.
2026-10-19 00:16:00 +03:00
Anees Iqbal e357ba7f4f Record nothing for a render pass that changes no texel, as Metal keeps every texel of it
Once a frame the consumer's guest encodes two 1080p passes over its framebuffer's host pages that
draw nothing: one loaded DontCare and stored Store with no command, and one loaded Load and
stored Store with state calls only. Metal keeps every texel in such a pass: the M3 Max changed 0
of 8294400 bytes of a shared and an IOSurface 1920x1080 BGRA8Unorm texture under DontCare/Store,
Load/Store, Load/DontCare and DontCare/DontCare, in 1 and 3 passes. The runtime already gave
Metal's answer, but still recorded a render pass instance that loaded and stored every attachment
over the render area.

end_pass now returns before any recording where render/untouched.rs's changes_nothing holds:
- no draw call (an execution of render commands and a tile dispatch count as one) and no
  visibility result buffer;
- one render pass instance that nothing recorded into;
- every attachment but the hidden depth loaded Load or DontCare and stored Store or DontCare,
  with no resolve;
- no depth/stencil state with depth writes set in the pass (Metal stores such a depth's words
  without their signs even with no draw, which the runtime strips after the pass), and no depth
  whose Clear held a NaN (whose word the runtime writes before the pass).
Such a pass records no render pass instance, no shadow or stand-in copy and no tracker use of its
attachments; a secondary begun as it opened ends unrun and its pool goes back to the device's
spares. The encoder still holds its attachments until the command buffer completes, and its core
ends as before (fences, residency, uses), so ordering against later work stands. A Clear load, a
resolve, separate depth and stencil textures loaded DontCare, and the first group of a pass of
several color groups still record as before.

New WorkCounts field untouched_passes_skipped. render/untouched.rs, clear_reach.rs and the
counter's docs state the rule.

Why: on the Iris Xe such a pass cost 25 us of GPU time loaded Load/Store, and 42 us loaded
DontCare or over a padded surface (1920x1080 BGRA8, the GPU clock held at 300 MHz); skipped, the
Load/Store passes cost 12.1 us, the encoder's own empty command buffer.

Verified, as the commits state:
- runtime_lane::clear_reach::a_pass_that_changes_no_texel_records_nothing: DontCare/Store,
  Load/Store and Load/DontCare with no draw call, and a Load color beside a DontCare/Store depth
  that keeps 0.75, are skipped with their texels kept; a Clear load, a draw call of no vertex and
  a visibility result buffer are not. Without the change the counter stays 0 and the first four
  cases fail. All 7 clear_reach tests passed on the RTX 5080.
- The two depth conditions come from a first form's failures on the RX 7900 XTX
  (depth_denormals' NaN-clear and signless-store tests read the bytes the skip left). Five
  kept_buffer_bytes cases that failed there now assert the skip exactly for their no-draw passes
  and check their bytes as before.
- clippy plain, m2v_gpu and m2v_cpu_icd.
2026-10-19 00:16:00 +03:00
Anees Iqbal aa2be705d5 Let a new texture register while a batch is replayed or submitted, waiting for no submission
A batch's submission takes the new resources' first work (FirstMoves::take), which holds the
device's place in the submissions' order until its vkQueueSubmit returns, and every registration
of a new resource (a texture's, buffer's, fill's, bytes' or texels' first move, as a Shared or
Private texture is made) waited for that order, so that no texture's heap set elements were
written between a batch's take and its submission. Two things made a texture's making wait long
inside that span: the batch's deferred command buffers were replayed after the take, and
MoltenVK encodes a command buffer's Metal commands inside vkQueueSubmit on the calling thread (5
to 32 ms for 4096 to 65536 fills on the M3 Max). In the consumer's guest on the Iris Xe with
deferred recording, the guest's task thread blocked 1311 ms over 110 such waits (about 17 ms a
frame). Metal's makes wait for no submission.

Now:
- A batch's deferred command buffers replay before the take (crate::recorder::resolve on each,
  waiting for a replay in progress), with no lock a registration takes; their handles stay as
  encoded until the vkQueueSubmit, which finds them replayed. Only the barrier command buffers
  the submission records after the take replay inside the order. What replays, and the commands,
  are unchanged.
- On a device whose heap sets take writes while a command buffer that binds them is pending
  (descriptorBindingUpdateUnusedWhilePending: every committed profile but the Vulkan 1.2
  floor's), a batch holds the texture slots' writes over that span instead
  (FirstMoves::take_holding, heap_sets::hold): elements asked meanwhile are written in order as
  the hold ends, before the batch's place in the order goes, and a registration takes no place.
  A device without the feature keeps its registrations ordered (FirstMoves::ordered).
- New WorkCounts fields: heap_slot_writes_deferred (the writes a hold deferred) and
  registrations_waited (registrations that found a submission holding the order and waited for
  it, counted only where registrations are ordered).
- Docs: texture/first_move.rs's order, heap_sets.rs, and the lane's module docs.

Verified, as the commits state:
- runtime_lane::first_use::a_new_texture_waits_for_no_submission_s_replay times a Private
  texture's making (a Shared one moves on the host where VK_EXT_host_image_copy exists and never
  waited) and now asserts the making added no wait for a place, printing its time. On the 780M
  and RX 7900 XTX (RADV) it took 0.04 to 0.19 ms while the command buffer was scheduled 58 to 64
  ms after its commit; with the replay moved back after the take it took 56 to 60 ms.
- On the M3 Max through MoltenVK (60 makings after commits of 4096 to 65536 fills): before the
  slot-write hold 20 makings waited for the order, up to 13.0 ms; with it none waited, the
  slowest taking 0.158 ms.
- The FirstMoves unit tests, among them a registration that waits for no submission where batches
  hold the slots and one that waits where registrations are ordered, and the count's tests:
  first_move, heap_sets and exit_guard tests, 62 passed.
- runtime_lane::first_use's 11 tests on the UHD 770 and lavapipe. Beside 128 busy threads and as
  8 parallel copies, on lavapipe and the UHD 770, every run passed with 0 waits for a place
  (183 makings, the longest 0.55 ms on lavapipe and 0.23 ms on ANV); the earlier time-ratio
  failures were the host's load and the validation layer's lock, not a wait of the runtime's.
- clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd; Rustdoc -D warnings.
2026-10-19 00:16:00 +03:00
Anees Iqbal 1ef457d88b Refuse an unordered framebuffer fetch and drop interlocked draws' barrier where the driver orders them
Three changes to framebuffer fetch and the pixel interlock.

1. An unordered framebuffer fetch is refused; FramebufferFetchPolicy is deleted. Metal orders a
   fragment function's read of its color attachment after every earlier fragment of the pixel,
   within a draw and across draws. Where a device offers neither ordered form
   (rasterization-order attachment access, or the pixel interlock's storage form where the
   pipeline's state lets it be exact), the opt-in FramebufferFetchPolicy::AcceptUnordered
   compiled the read as an unordered input attachment with a precision note. An unordered read
   can return the attachment before an earlier overlapping fragment's write: a different value
   in memory, not a rounding, which the owner's rule allows neither as a default nor as a
   switch. No exact form exists on such a device, so the fetch is refused there, as the default
   already did. The runtime never ran the unordered form, so no runtime behaviour changes.
   - Removed: DevicePolicy::framebuffer_fetch, the enum FramebufferFetchPolicy and its
     re-export (and its api_surface row), ProfileFields::framebuffer_fetch,
     PrecisionNote::UnorderedFramebufferFetch, and the runtime's note kind of that name, whose
     code metal2vulkan-degrade-unordered-framebuffer-fetch is retired; the runtime's
     framebuffer_fetch::ordered check; validation's --accept-unordered-fetch on corpus-vulkan,
     corpus-moltenvk and corpus-pipeline, and the device worker's framebuffer_fetch field.
   - lower::fragment::color refuses a read no ordered form serves (Unsupported{FramebufferFetch},
     naming both forms); lower::fragment::fetch refuses a blocked storage form with its blocker.
   - The profile's fields change, so every profile fingerprint does.

2. No barrier between interlocked draws' colors on a driver measured to order them. Between two
   draws of a render pass instance where the later one reaches a color in the fetch's
   interlocked storage form (or an extended-range color's half shadow) that the earlier one
   wrote, the runtime recorded a fragment-to-fragment storage barrier on every device. Vulkan
   orders such draws by the interlock alone (ordered interlock modes follow rasterization
   order, which follows primitive order through a subpass, and the interlocked storage image is
   decorated Coherent). A new answer fact, DriverFact::InterlockOrdersDraws, measured on ANV on
   the Iris Xe of Raptor Lake-P, drops that barrier there for these colors alone. The fragment
   imageblock's storage and the depth stand-in keep their barrier everywhere, as does every
   unmeasured driver. RADV on the Radeon 780M still needs the barrier: without it one blend
   table case leaves 19 of 495 band results wrong over 5 runs. New lanes:
   runtime_lane::interlocked_draw_order (every device, with its owned fixture ido_draw_order) and
   the ignored release bench runtime_lane::tile_path_costs (a window server's composite on
   Metal's tile path, fixture tgp_composite), with their engine inventory rows. A FAST-PATHS
   bullet records the barrier and the fact.

3. A left-out interlock color's framebuffer slot holds a placeholder image. A color attachment
   the draws read and write as a storage image in the interlock is left out of their subpass,
   but its framebuffer slot held a view of the very image the draws write, which the validation
   layer reads as VUID-vkCmdDraw-None-06537 for a draw recorded inline. The slot now holds a view
   of a placeholder that nothing reads or writes (DONT_CARE load and store, GENERAL layouts): the
   device keeps one for each format and sample count, plus one for each further color of that
   shape in the same framebuffer, grown to cover a larger framebuffer and freed once no
   framebuffer holds it; none is made per frame. A color whose draws use sample planes, and the
   planes' anchor, keep their own image's view. New WorkCounts fields
   storage_placeholders_made and storage_placeholder_attachments.

Verified, as the commits state:
- The translator's fetch tests (pipeline::compile ordering, engine_fragment, engine_moved_writers,
  device profile fingerprints and serde, fast_paths) keep the refusals; the raster-order-group
  read on a device with neither ordered form expects the fetch's own refusal naming both forms.
  Validation checks every public fetch case is refused on lunarg-desktop-baseline-2023 and
  vk12-floor, and that the command-line flag is gone.
- Iris Xe (ANV) with the fact in place: interlocked_draw_order 3 runs with every texel right,
  extended_range_blend_table 17 passed (0 of 495 bands wrong), framebuffer_fetch 49 passed. A
  1080p pass of 27 interlocked draws took about 1.08 million GPU cycles with the fact against
  1.46 million with the barrier forced (about 9 to 20 us a draw).
- The placeholder lane test (two RGBA32Uint colors over four passes and sizes): placeholders and
  slots (2, 2), (2, 4), (4, 6), (4, 8) through the interlock on the RX 7900 XTX (RADV) and the
  UHD 770 (ANV), none through input attachments, no validation message. On lavapipe 122 lane
  tests and 47 runtime render unit tests passed; on the RX 7900 XTX 94 lane tests passed.
- The engine inventory and llvm_as parts pass for the new fixtures; clippy in every
  configuration and Rustdoc -D warnings.
2026-10-19 00:16:00 +03:00
Anees Iqbal 6f3730abf7 Keep a queue's memoryless color backings across its passes and command buffers, one per shape
A pass that renders a memoryless color attachment into an image of its own (a framebuffer fetch
through the pixel interlock reads it, or the pass splits) made a fresh backing image for each
pass, held by its command buffer and freed when that completed. On a device without lazily
allocated memory (ANV), a 1920x1080 RGBA16Float attachment fetched by about ten passes a frame
made and freed a 16.8 MB image each pass, and the runtime's memory log on an Iris Xe showed a 64
MiB image block made and freed up to three times a second, each a fresh allocation the kernel
zeroes.

Now each command queue keeps those backings (attachment_stand_in::pooled_backing), keyed by the
attachment's pixel format, render format, samples, layers and extent. A pass takes a kept one
that backs no other attachment of the pass, else makes one and keeps it. The pool keeps at most
32 backings and at most 256 MiB beyond the one just made, the one taken least recently going
first, and goes with the queue; each command buffer still holds the backings it rendered into
until it completes. The count bound covers a compositor's frames on the consumer's macOS guest,
which render 11 to 14 extents of one memoryless RGBA16Float attachment a frame (about 40 MB
together): a bound of 8 evicted each backing before its next take. A memoryless depth or stencil
backing is still the pass's own.

Exact: Metal refuses a Load and a Store of a memoryless attachment, and a pass gives every texel a
draw can read a value before its draws (its Clear, or the zero its DontCare load clears to), so
no pass reads what another left in a backing. The passes of one queue that take a backing are
ordered by their uses of it.

New WorkCounts field pooled_backings_made. The memoryless-backed notice's cost text and its
docs/API.md catalogue entry say a color's backing is kept by its command queue.

Verified, as the commits state: clippy -D warnings for the runtime and validation crates, plain,
--cfg m2v_gpu and --cfg m2v_cpu_icd. The lane cases
framebuffer_fetch::a_queue_keeps_one_memoryless_backing_for_its_passes (three command buffers of
two passes over fresh memoryless attachments, the second loaded DontCare and read as zero: one
backing where the device announces memoryless-backed, none elsewhere) and
a_queue_keeps_a_memoryless_backing_for_each_shape_it_renders (12 sizes twice in turn, every texel
checked: 12 backings, where a bound of 8 makes 24) were added for the device batches.
2026-10-19 00:16:00 +03:00
Anees Iqbal e35bf78bd5 Shadow every padded texture over a buffer and every texture over host pages, keeping CPU writes
A texture over a buffer could be an image bound to the buffer's bytes: a padded texture that only
read (PaddedReadsPolicy::Alias, the default), and any 2D texture over a no-copy buffer's host
pages (a linear image, a DRM_FORMAT_MOD_LINEAR image at Metal's row pitch, or on MoltenVK a Metal
texture over the import's MTLBuffer). An image bound to imported memory starts UNDEFINED, and a
layout transition "may perform read and write accesses on all memory bound to the image
subresource range", so such an image kept Metal's bytes across its first move only through a
host keep (read the bytes, submit the move alone, wait, write back what changed), which undid a
CPU write made inside that window. Metal keeps every CPU write to bytes a command buffer does not
write: on the M3 Max, a kernel reading half a padded no-copy texture while the CPU rewrote the
bytes between its rows and its other rows kept every CPU byte in 10 of 10 rounds. Changing bytes
in memory is not a precision note, so under the owner's rules it may be neither a default nor a
switch; exact is the default, and cost chooses only among exact forms.

Now a padded texture over a buffer, and every 2D texture (or array) over a no-copy buffer's host
pages, imported by pointer or as dma-bufs, is a shadow on every device, whatever its usage: an
optimal image of the runtime's memory, copied in from the bytes before a use and merged back
after a write. Texture::vk_image answers None for such a texture.

Removed:
- DevicePolicy::padded_reads and the enum PaddedReadsPolicy (Alias, Shadow); its FAST-PATHS row,
  its tests::fast_paths choice and its api_surface row.
- The images over host pages: the linear image for host allocations, the DRM_FORMAT_MOD_LINEAR
  image over host allocations with its refusal memo, the modifier image over a buffer texture's
  own dma-buf, the Metal texture over the import's MTLBuffer on MoltenVK (VK_EXT_metal_objects is
  no longer enabled for it), and the one image shared by textures of one plan over one import.
- The first move's host keep, and its notice unrestored-first-move-bytes (Degradation
  UnrestoredFirstMoveBytes), retired.
- WorkCounts fields first_move_keeps, first_move_kept_bytes, first_move_restored_bytes,
  pitched_host_images, pitched_host_image_refusals, pitched_host_image_refusals_recalled,
  shared_alias_images and shared_alias_moves_waited.

Kept: the buffer's dma-buf import as the last resort where the pointer is refused, on any device;
the images of heap textures over host pages, including over dma-bufs (a heap resource's contents
are undefined until written, in Metal too); a linear image over a buffer of the runtime's own
memory (PREINITIALIZED), whose first move FAST-PATHS records as a one-line known gap.
ShadowedTexture (shadowed-texture) now also covers read-only padded textures.

Also: a staged shadow's copy back merges rows that lie one after another into one region (a
packed 1080p surface takes one region, not 1080), and two new counters size what a shadow kept
across a command buffer's passes could save: WorkCounts::shadow_attachment_passes and
shadow_attachment_textures.

Docs: docs/FAST-PATHS.md (the shadow bullet with its costs, the known gaps), docs/API.md
(section 1's texture paragraph, the shadowed-texture and dont-care-stand-in entries, the retired
code), docs/HOWTO.md section 6, the runtime README, linear_attachment.rs's module doc.

Cost, as measured: on the Iris Xe a frame sampling four BGRA8Unorm tiles over no-copy pages took
3.2-5.3 ms as shadows against 3.0-6.1 ms as images (textures made once) and 3.4-7.1 against
4.6-8.6 ms (made each frame). On the UHD 770 (ANV, release, alternated), one Load/Store pass into
the guest's 1080p surface took 1.89-1.97 ms as a shadow against 2.56-3.09 ms as the linear alias,
whose draws ran slowly in host memory; 12 passes 20.9-21.1 ms against 27.4-27.8 ms, at about 40 us
more CPU a pass.

Verified, as the commits state:
- runtime_lane::first_use_writes (new: another thread writes bytes of a texture over host pages
  that its first use does not read, from 2 ms before to 2 ms after the commit; every write stays)
  passes on the RTX 3090, the Radeon 780M and the UHD 770.
- runtime_lane::pitched_surfaces asserts a shadow for every surface (counted, vk_image None),
  including the CPU write beside a padded texture during its first use and the new counters;
  no_copy_textures asserts a shadow and no modifier queries; the keep, pitch-refusal and
  shared-image tests go with what they tested.
- The lanes restated for the shadows pass whole: dma_buf_imports 13, resource_ids 38,
  rotated_textures 7 and linear_attachments 20 on the RX 7900 XTX and the 780M (RADV), the UHD
  770 (ANV, with row_copies 2) and the RTX 3090.
- linear_attachments renders over a Shared buffer of the runtime's memory, so the linear
  attachment paths stay covered, each test asserting the way its passes took; 21 pass on the RTX
  3090, the 780M, the RX 7900 XTX and the UHD 770.
- Runtime and validation nextest without a device, 2306 passed; the translator's fast_paths,
  api_surface, published_crates, refusal and driver_facts tests, 34 passed; clippy in every
  configuration and Rustdoc -D warnings.
2026-10-19 00:16:00 +03:00