Commit Graph
583 Commits
Author SHA1 Message Date
Anees Iqbal fc79fdd4e9 Announce every NVIDIA RTX 5080 Laptop clear and plain fill off a whole code: its clears take either nearest code
runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear (vkCmdClearColorImage of 762
colours into each of 70 formats) on the RTX 5080 Laptop GPU at 0b556ddfd6: 352 fills stored 382
normalized channels a code from Metal's, each one of the two codes nearest the scaled value,
unannounced where the value was not near a midpoint. Vulkan allows it ("returns one of the two
unsigned binary integer values with exactly b bits which are closest to the floating-point value
r. Implementations should round to nearest"). The 8- and 16-bit unorm and snorm channels went
toward zero (R16Unorm's 0.001, 65.535 codes, stored 65; R8Snorm's -0.5 stored -63), packed and
10-bit channels and an sRGB format's alpha at times to the code above the nearest. An under-note.

What:
- DriverFact::ColorClearTakesEitherCode, on the RTX 5080 Laptop GPU (NVIDIA), with its
  measurement in its doc.
- clear_value::rounds_apart takes the fact: on such a driver a normalized channel's clear is in
  question wherever its scaled value is off a whole code, not only near a midpoint; the clear and
  the plain colour fill (blit_fill, fill_value, render_pass) announce device-color-conversion then.
- docs/API.md's catalogue entry for the clear conversion names the fact.
- Tests: driver_facts' table test; a fill_value unit test of the rule on the measured cases with
  and without the fact; api_signatures for the new variant.

Verified: in the lane proof runs on the 5080 and the M3 (counts in the series' last commit). The
M3's and lavapipe's facts are unchanged, so their notices are.

(cherry picked from commit f2da9346bb51ed034f0d5f8bf076c8d55c57f277)
2026-11-05 05:10:38 -08:00
Anees Iqbal f1def3dffe Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
Re-applies 384734851d (reverted in the stack by 5dbf6f3be3) on top of the previous commit, which
merges a heap half read's class arms as the texel's half bits.

What: narrow::round_texel rounds through round_measured, so in QuantizeForm::Converted the
conversion pair's narrowing is recorded as measured. On a profile that takes
DriverDeviation::MetalHalfConversion (MoltenVK on the Apple M3 Max's macOS 27 identity) a texel's
half rounding records no PrecisionNote::NativeHalfConversion, and the module requires
VkProperty::MetalHalfConversion instead: a texel the module decodes itself
(extended_range::decode), a merge of texels (a heap read's phi of its fetched texel and its decode
routine's) and an image instruction's. The note stays for roundings by narrow::round: half
operations and functions computed in float, filter sums, packs and the rest. Other profiles never
read the measured set, so they are unchanged by construction, and round_measured emits the same
pair, so the SPIR-V is unchanged. SEMANTICS_VERSION 1967: recorded notes change on moltenvk-m3.

Why: reims-vgpu's strict Mac tests die on native-half-conversion at a kernel that reads an
argument buffer's texture as half (their ycbcr_probe.metal read_held, over BGRA8Unorm). Every heap
half read carries the decode routine of the seven extended-range/padded/bfloat forms, and its
merge, so it recorded the note whatever the texture. MetalHalfConversion measured the device's
conversion as Metal's half(float) for loaded and computed floats; where Metal's half texel is not
the nearest even half of the texel's value, the access's own note states it: HalfTexelConversion
(outright for a heap element, by the bound class at a slot) or DevicePackConversion (a decoded
texel). The stack 28 gate's cross-class lane failure that reverted it came from the heap read's
merge of widened halves, not from a rounding: an integer texel's bits read as half go through no
rounding, and the previous commit merges them as integers, so they keep their bits without a note.

Kept from 384734851d: the core tests heap_half_texels_round_by_the_measured_conversion and
decoded_half_texels_round_by_the_measured_conversion, the M3 lane
heap_extended_reads::heap_half_reads_of_every_code_round_their_float (half_conversions::half_of
made pub(super) for it), and the docs: the PrecisionNote, DriverDeviation and VkProperty rustdoc,
API.md's native-half-conversion exemption, the driver-facts record (which now also says the
argument buffer's cross-class half read rounds nothing and names its lane), narrow's docs.
runtime-sources.sha256 moves for the doc edits in driver_facts.rs and requirements.rs, which change
no behaviour of a run.

Verified: pending in this commit; the next jobs run the core and M3 lane checks on it.
(cherry picked from commit 1757bd7866aa87c4e38ab83f0b4c4d83e68c75bb)
2026-11-05 04:28:29 -08:00
Anees Iqbal 5dbf6f3be3 Revert counting a texel's half rounding as measured on MetalHalfConversion profiles
This reverts the stack's pick of 384734851d ("Count a texel's half rounding as the measured
conversion on MetalHalfConversion profiles"); SEMANTICS_VERSION goes to 1965, since the recorded
notes change back.

The stack 28 gate's M3 lane run failed
runtime_lane::cross_class_reads::argument_buffer_cross_class_reads_are_the_native_words: an
argument buffer's half read of an integer texture (R8Sint, RGBA8Sint, RG16Sint, RGBA16Sint,
RGBA32Sint, RGBA16Uint, RGBA32Uint; 66 of 2170 lanes) answers the device's quiet NaN 0x7e00 where
the slot's read of the same texel keeps its bits (0xfff5 and the like). The heap read rounds its
texel through float, and that rounding's narrowing no longer recorded NativeHalfConversion on
moltenvk-m3, so the stage carried no note that leaves a half NaN's bits to the device (the notes
were SetPastLayoutSupport, DeviceNanEncoding and HalfTexelConversion). The commit's measurement
covered the extended-range forms' codes, not an integer texel's bits read as half. Until a fix
keeps those bits or notes them, the note stays as it was before the change.

The doc conflict in driver_facts.rs (a later pick's measurement paragraph for the reverted rule)
takes the text from before the change.

Verified: not yet; the gate reruns the core suite and the M3 lanes on this tree.
2026-11-05 02:46:28 -08:00
Anees Iqbal 4f32162f99 Regenerate the conformance coverage document for stack 28's cases and recordings
The coverage document is generated from the suite's sources and recordings; the stack's picks
each regenerated it on their own base, so it is derived again here once over all of them.
Verified: python3 -I scripts/conformance-coverage/coverage.py --check reports it as derived.
2026-11-05 02:09:58 -08:00
Anees Iqbal 95859dac16 Regenerate the conformance coverage document for the composited row
python3 scripts/conformance-coverage/coverage.py over the tree with
pass-start-barrier-private-composited's recording: one more recording, case and Metal-run answer,
and the Metal items the row reaches counted once more.

(cherry picked from commit 0147b3a386081175dfaffa7c72513efac6def034)
2026-11-05 02:08:34 -08:00
Anees Iqbal bc1d0ab837 Say in render-pass-split's trigger that a read of the clear alone takes a cleared copy instead
The declaration in degradation.rs and docs/API.md's catalogue entry both said a draw that reads a
color attachment's texture after a memory barrier splits the pass. A read of the clear alone
before any draw of the pass now reads its copy cleared to the clear in the pass's one instance
where the copy can be (WorkCounts::attachment_read_clears), so both name that exception.

Docs only; unverified beyond cargo fmt.

(cherry picked from commit 1bcf89e89571bc7f65694c10ea34bdde6c3af6b0)
2026-11-05 02:08:33 -08:00
Anees Iqbal de64560175 Name the pass-start read's cleared copy in the API guide's accepted difference
docs/API.md: a draw that reads the clear after a render-target barrier before
any draw of its pass reads its copy cleared to the clear in the pass's first
instance where the copy can be so (WorkCounts::attachment_read_clears), else an
instance after one of the clear alone.

Unverified: documentation of 4259b7f41c, whose runs are pending.
(cherry picked from commit cc9312dcc9a97d5c663efbfea3f0f25374581249)
2026-11-05 02:08:33 -08:00
Anees Iqbal d3f2bf185a HostRam: test a run-bound buffer against copies of its pages; copies' take wording
On gate/stack27b the HostRam copies (copy_from_host_ram,
copy_to_host_ram) and the run imports compose: a copy reads and writes
a chunk's pages through the chunk's import, and an object over a chunk
not imported yet is bound in an import of its own run, two imports of
the same pages ordered only by their host bytes (host_aliases.rs).

New device test
a_run_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes:
four pages over a chunk not imported are bound in their run's import,
and then, both ways:
- a fill through the buffer before a gather of its second page;
- a scatter into that page before a copy out of the buffer.
Each way runs in one blit encoder (a barrier recorded between them),
in two encoders of one command buffer, and across two queues in commit
order (the writer behind 2 GiB of private fills). The six copies import
nothing, and the run's import stays live. On a device with
RuntimeDriverDefect::AliasedImportBlitsUnordered (MoltenVK) the test
asserts the fallback: no run import, the buffer imports the chunk and
lies in the copies' import.

Docs: copy.rs's module docs and HOWTO said a copy takes a chunk "as an
object does", importing it or waiting for its import; objects no longer
wait, so both now say that a copy makes no run import of its own and
waits. host_ram.rs and HOWTO add the copies to what a run-bound
object's uses order against, and the test module's docs add the
composition.

Verification is pending in this commit: M3 and RTX 5080 device runs.

(cherry picked from commit be6d43fbf2c0a5921a2468038740ef3604a2da9f)
2026-11-05 02:08:32 -08:00
Anees Iqbal c074aa490e Document the HostRam window's direction, the runs' imports and their fallback
docs/HOWTO.md's "One run inside one chunk" bullet now says what the
branch's runtime does: the window opens in the takes' direction, up or
down the RAM; an object over a chunk not imported yet is bound in an
import of its own run (run_bound_buffers_made, run_imports_live) and
never waits for the chunk's fault-in; the price is up to one more
allocation and pin per such object; and where the object falls back to
the chunk's import (thread stopped, chunk failed or given back,
allocations within the margin, a whole-chunk run, or
RuntimeDriverDefect::AliasedImportBlitsUnordered on MoltenVK).

It adds the measured result from tests/host_ram_window_bench.rs on the
RTX 5080 laptop (NVIDIA 615.71.09), at 2b2419c67c: 256 2 MiB heaps
upward, downward and scattered had no making of 5 ms or more (slowest
1.4, 1.5, 3.7 ms), against 2, 8 and 15 makings importing a chunk
(slowest 8.2 to 8.7 ms) without the change; 128, about 76 and 20 heaps
were bound in their own runs' imports.

Docs only; verified by reading the text against host_ram.rs's
for_object and after_take.

(cherry picked from commit 25572e5af997da7009960fa31bf94c5d478e2370)
2026-11-05 02:08:32 -08:00
Anees Iqbal 749daae1d9 Say a texture's image of any storage mode may overflow past device-local memory
Every texture's image is placed in Private memory (image_plan.rs), so a
Shared or Managed texture's image overflows as a Private one does; the
notice's declaration, the catalogue entry, the runtime README and the
lane's site note now say so.

Verified: nothing (docs and comments only).
(cherry picked from commit ec5b5a70fdea000eb9a7d5ab84e5aaad02fffed4)
2026-11-05 02:08:31 -08:00
Anees Iqbal 8ccb2934c9 Place resources past a full device-local heap in system memory
Placement refused a resource once device-local memory was full: memory.rs
gives the Private class only DEVICE_LOCAL types, every texture's image is
Private, and a Managed buffer's own bytes on a device without unified memory
are Private, so place() returned OutOfMemory(Device). On the RTX 5080, 96 of
5090 1-MiB Managed GPU copies were refused at about 5 GB held, where Metal
on a 4 GiB Radeon Pro 5300M made, used and read back 12 GiB of Managed
buffers, six 1 GiB Private buffers and a 17 GB Private heap.

- memory.rs: overflow_candidates, the types a Private or Memoryless
  resource overflows into where none of its own has room (allowed,
  allocatable, neither device-local nor lazily allocated; those the host
  does not map first). place() tries them after the class's own types;
  such a placement is marked (Placement::overflowed) and counted
  (Memory::overflows, WorkCounts::device_memory_overflows). Metal's own
  refusals (max_buffer_length, texture limits) stay where they are.
- Driver paging first: VK_EXT_pageable_device_local_memory with
  VK_EXT_memory_priority, enabled where the device lists both and has
  pageableDeviceLocalMemory (enables.rs, create.rs); the spec lets such a
  driver page memory out rather than fail an allocation. Every allocation
  keeps the default priority.
- Degradation::DeviceMemoryOverflow (performance), announced once for a
  program's buffer or heap (degrade_system_memory, which now names the
  storage mode) and texture (Texture::overflowed) that overflowed.
- Tests: tests::memory::device_local_classes_overflow_into_system_memory,
  tests::device::pageable_device_local_memory_is_enabled_where_the_device_has_it,
  and the device test tests::device_memory_overflow (a GPU hazard, under
  m2v_gpu_hazards on a GPU, in the shape of 7b57d9a87a; check-cfg added),
  which fills device-local memory where it can overflow and makes, uses
  and reads back Private buffers, a Private heap with a buffer and a
  texture, Private textures and Managed buffers past it. The lane names
  the kind's site as the runtime's test (degrade_notices OVERFLOWED).
- Docs: API.md (runtime-own extensions, catalogue entry), runtime README
  memory model.

Verified: nothing yet (cargo fmt only); builds and runs follow as potluck
jobs.

(cherry picked from commit 586f2d0b5c6708016d9a255c0934f9727569125c)
2026-11-05 02:08:30 -08:00
Anees Iqbal 504d01b759 Present the Mac class the consumer declares, by default its GPU's, as the fresh-texture key
The fresh-texture key (DeviceProperties::lossless_compression) was
has_unified_memory. That is wrong for every integrated GPU that is not
Apple's. The consumer's oracle shows an Intel UHD 630 Mac reports unified
memory and reads zero or a released texture's texels from a new Private
texture, as the AMD 5300M does, and never Apple's pattern. The owner's
choice (option B): the consumer declares the Mac class the device presents,
and the default follows the GPU family.

What:
- MacClass { AppleSilicon, IntelOrAmd } (public, capabilities.rs), with
  MacClass::of_vendor: an Apple GPU (vendorID 0x106b, MoltenVK on Apple
  silicon) is AppleSilicon, every other GPU IntelOrAmd.
- DeviceOptions::mac_class and RawDevice::mac_class (Option, None by default:
  the GPU's class) feed presents_lossless_compression, still the one place
  the key is decided. lossless_compression is class == AppleSilicon. The
  options' equality and Debug list the field.
- A new Private texture under IntelOrAmd on a GPU that is not Apple's holds
  what its memory held, as before (private_textures_unfilled). On an Apple
  GPU, whose own image of such a texture is compressed and reads Apple's
  pattern, it is filled with zeros as it is made, which is what such a Mac
  reads where its memory held nothing. Counted by the new
  WorkCounts::private_textures_zero_filled. The pattern path now runs only
  where the device presents compression.
- AppleSilicon keeps the runtime's pattern and zeros on any GPU. The device's
  own contents are not Metal's pattern on the M3: in the negative control
  (m3-max-88) leaving Private textures unfilled failed 16 of the 28 lanes.
  No PrecisionNote: the fill is capability (the declared Mac's contract),
  not arithmetic. An Apple-class pattern that no clear or copy writes
  exactly still announces fresh-pattern-zeroed.
- Defaults change only where unified memory and GPU family disagree: Intel
  and AMD integrated GPUs and lavapipe now present no compression (their new
  Private textures are unfilled). The M3 (Apple) and the discrete GPUs
  answer as before.
- Docs: docs/API.md (the accepted difference and the fresh-pattern-zeroed
  entry), the runtime README, the degradation declaration, the work-count
  docs. api_signatures blessed. REFUSALS.md regenerated with no change. No
  FAST-PATHS row: no speed-for-accuracy choice.

Tests:
- tests::capabilities::lossless_compression_is_the_presented_mac_class
  (no device): every vendor kind (Apple, Intel, AMD integrated and
  discrete, NVIDIA, Mesa CPU) under no declaration and both declarations.
- tests::mac_class (device, both settings):
  the_default_class_is_the_gpu_s and
  a_declared_class_other_than_the_gpu_s_is_presented. Each reads a new
  Private RGBA8Unorm target and checks the counters: AppleSilicon reads
  Metal's magenta pattern; IntelOrAmd on an Apple GPU reads zero
  (zero_filled +1); IntelOrAmd elsewhere is unfilled (+1).

Verified: cargo fmt --all. Build, clippy and tests run as potluck jobs
after this commit (results in the next commit or report).

(cherry picked from commit f3d6f24ca447fbcadc8df56e63e598cbc92e09b7)
2026-11-05 02:08:30 -08:00
Anees Iqbal 9fe1b0175f Key the compressed shape's clear route in the extended-range and bfloat clear checks
A clear takes Metal's straight route only where nan_clear::keeps_nan_sign holds (render.rs),
which the fresh-texture key now makes false on a device that presents a Mac keeping no texture
compressed: there a 16 x 16 plain target is not compressed, so it clears through half, as
Metal's uncompressed targets do (expected, not measured on such a Mac). Three checks still
expected the straight route there and failed on the RTX 5080 Laptop at fd34a10316:

- conformance xr-clear-routes-{bgra10xr,bgra10xr-srgb,bgr10xr,bgr10xr-srgb}: divergent at
  case/plain-16/texels/0..3 alone (15 sites), unlisted, in the replay of job m3-max-120; the
  baseline replay at 0b556ddfd6 (job m3-max-141) held none of them (its other 908 unlisted gap
  sites are the same in both runs). ClearRoutes now declares
  replay::without_compression("plain-16").
- validation runtime_lane::extended_range_targets::clears_take_metal_s_route (15 clears
  differ, all the 16 x 16 draws-false shape) and runtime_lane::bfloat_targets::
  bfloat_clears_take_metal_s_route (11, all that shape), suite job m3-max-124: each now expects
  ClearRoute::Straight for that shape only where DeviceProperties::lossless_compression holds,
  else ThroughHalf.

docs/API.md's accepted difference says the clear route too, and keeps_nan_sign's doc says it
decides the route.

Verified on the M3 Max, no device: nextest metal2vulkan-conformance 1011/1011; cargo clippy -D
warnings on validation and conformance with --cfg m2v_gpu (all targets, all features);
docs/CONFORMANCE-COVERAGE.md re-derives unchanged. UNVERIFIED: none of the three has run with
this commit on the 5080 or the M3.

(cherry picked from commit 1c042263e5fee942b79fbd30042c2dc9f222b61b)
2026-11-05 02:08:30 -08:00
Anees Iqbal 64bea51c0c Put the fresh-texture key behind one presented fact, and give every lane and case its arm
The key that decides whether the Mac a device presents keeps textures losslessly compressed is
now one public fact, DeviceProperties::lossless_compression, decided in one private function,
capabilities.rs presents_lossless_compression. Today it is has_unified_memory, as the approved
proposal said; the owner's open question (unified memory, a consumer-declared Mac class, or a
family split) changes that one function. Everything that differs because Apple silicon
compresses reads only that field: Device::metal_compresses_textures() (a new Private texture's
fill, compressed_blit::compressed(), nan_clear::keeps_nan_sign), the validation lanes
(fresh_contents::unfilled, patterns_of) and the conformance venue (Venue::lossless_compression;
the Metal side answers supportsFamily(MTLGPUFamily::Apple1)).

This finishes what the parked commit before it listed as open:

- docs/API.md: a new accepted-differences group, "The Mac a device presents", whose entry
  (slug a-device-that-presents-a-mac-without-texture-compression-answers-as-that-mac) gives
  reims's measured AMD 5300M and Intel UHD 630 rows for fresh Private contents and marks the
  blit encodings, fills and NaN clear sign as expected, and states the Intel-iGPU limit. The
  fresh-pattern-zeroed catalogue entry and its rustdoc say the key; so does the runtime README's
  "New resources" bullet.
- Conformance: Justification::WithoutUnifiedMemory became WithoutCompression (and
  Unjustified::VenueCompresses, Offered::lossless_compression, replay::without_compression /
  WITHOUT_COMPRESSION). The fresh family's Private rows declare it at their fresh site; the
  compressed-blits-* rows of the BGRA10_XR formats (the only ones whose canonical encoding the
  runtime writes) declare it at the seven sites a blit reaches through the compressed texture.
  The fresh test now asserts the new shape (renamed
  a_row_loosens_the_notices_site_and_a_private_texture_s_fresh_site); the compressed-blits test
  asserts the venue declarations site by site.
- Lane arms on an unfilled device: fresh_costs (the counter moves by count x runs per Private
  shape; no readback), fresh_writes (patterns_of in both controls and the scratch test; the
  forced single-sample note only where the device fills), parallel_encodes (no expected
  pattern), depth_denormals (no draw/store check of unwritten texels, no sign, no zeroed note),
  compressed_blits (the notes and the Canonical rewrite only where the device compresses).
  degrade_notices needs none (FRESH_PATTERNS is only its catalogue list); the tile-store lanes
  (rotated_textures, snorm_tile_store, padded_loads, extended_range_blends) read draw notes,
  which are not keyed.
- api_signatures.tsv blessed for DeviceProperties.lossless_compression and
  WorkCounts.private_textures_unfilled. docs/CONFORMANCE-COVERAGE.md regenerated (the Metal leg
  now calls supportsFamily:, and WithoutCompression is a justification it names).

No RUNTIME_VERSION or runtime-sources pin change here: left to the orchestrator.

Verified on the M3 Max, no device: cargo clippy -D warnings over the runtime, validation and
conformance (all targets, all features) plain and with --cfg m2v_gpu; nextest
metal2vulkan-conformance 1011/1011, metal2vulkan-runtime 1234/1234 (2 skipped),
metal2vulkan api_signatures + api_surface 15/15; the refusal-surface and metal-coverage checks
pass. UNVERIFIED: no device run yet (the lanes, the nan_signs test and the conformance replays,
on the M3 and the 5080), and no negative control yet.

(cherry picked from commit fd34a1031602645e87e4cb192d1044790f79a88f)
2026-11-05 02:08:29 -08:00
Anees Iqbal 61e6e1f9ac Announce device-pack-conversion where a heap set holds a texture by its raw texels
A heap holds a texture of a form ExtendedRange::HEAP_READ names
(BGR10_XR, BGRA10_XR, R10Unorm_X6, RG10Unorm_X12 and the bfloat
formats) by its raw texels alone, its raw view in the unsigned integer
class. A function's float read, sample or gather of it through an
argument buffer decodes the raw texels itself, by the device's
arithmetic, within the bounds PrecisionNote::DevicePackConversion
states. That is the same conversion a slot's read records statically,
but nothing announced it for a heap read: the stage cannot know which
textures an argument buffer names, and recording the note on every heap
float read would announce it for argument buffers that never hold such
a texture.

Scope it through the run-time mechanism a decoded twin already uses.
heap_sets now notes, per set, the textures whose raw view a set's
unsigned integer array holds (SetEntry.raws, detected in texture_info
by the class and bind::heap_raw_form). It announces
Degradation::DevicePackConversion, naming the texture ("BGRA10XR
texture at resource ID n"), at the first command that binds a set
holding one, and once (degrade_once) as one is placed in a set a
pending command buffer may read through. This matches TwinRead's
twin_read and twin_placed. A command whose sets hold no such texture
announces nothing. A command that binds a set holding one announces it
whether or not its function reads that texture, because the runtime
does not see which textures an argument buffer names. The twin
bookkeeping shares the new noted and pending_read helpers.

The runtime's DevicePackConversion doc, docs/API.md's
device-pack-conversion entry and heap_sets' module docs say so.

New lane test
runtime_lane::heap_extended_reads::a_heap_set_holding_a_raw_texture_announces_its_decode.
It dispatches a heap float-read kernel with only an RGBA8Unorm texture
live (no device-pack-conversion announced), then with a BGRA10XR
texture made (the notice names that texture's resource ID). It prints
the stage's own notes beside the notices.

No RUNTIME_VERSION bump (not asked for on this branch).

Verification: the branch's next CPU job (clippy, runtime suites) and
GPU job (the heap_extended_reads lane on MoltenVK on the M3).

(cherry picked from commit f5c2127ebee39d3fcf221e1930e287d26c7f9e68)
2026-11-05 02:08:28 -08:00
Anees Iqbal 75228b052b Record no device-nan-encoding for a color output that only ever returns NaN-free constants
A fragment function's color output to a half-float attachment recorded
PrecisionNote::DeviceNanEncoding wherever the device's conversion stores
a NaN otherwise than Metal, even when every value the function returns
there is a constant with no NaN lane, which stores no NaN. Texture
writes already skip the note for such a constant texel
(texture::holds_no_nan); color outputs now apply the same structural
rule. stage_io::returns_no_nan follows each `ret` of the function to the
output's member (through insertvalue chains and aggregate constants),
and color_write::plan, called from the output-variable path and from
the storage-form path, leaves the note out when every return holds such
a constant. Any computed, undef, argument or partly unknown member
keeps the note.

Per-site audit of the device-nan-encoding notes on MoltenVK on the M3
(the reims strict Mac tests), with the translator CLI over each site's
stages:
- (a) undefined tests x3 (xr_constant_fragment and the other
  constant-colour fragments): their outputs are NaN-free constants, so
  the note was wrong there. Fixed here.
- (c) encode_render x2 (sweep_fragment, sweep_half_fragment): computed
  outputs that sweep through NaN values. The device stores its own NaN
  encoding, so the note stays.
- (c) rgbx x3 (rgbx_write_half, store_half, read_write_half, and the
  NaN clears and half NaN writes): deliberate NaN texel writes. The
  note stays.
- (c) slice_write_repro x1 (slice_write, slice_write_l0): computed
  texel writes. The note stays.

New public fixture ncw_constant_colors (our own MSL, compiled by
scripts/regen-air-fixtures). It covers a half and a float constant
colour, a constant NaN colour, a computed colour, and a two-member
struct whose member 0 is a constant and member 1 computed. The new test
engine_link::constant_colors_without_a_nan_record_no_nan_encoding
checks, on the lavapipe and moltenvk-m3 profiles, that the note is
recorded exactly for the NaN constant, the computed colour and the
pair's computed member, and that each stage links and validates.

docs/API.md's device-nan-encoding entry states the rule. SEMANTICS_VERSION
goes to 1963 because the recorded notes change. The golden tables
need the new fixture's rows, re-blessed on development.

Verification: the new test and the touched suites run in the branch's
next CPU job.

(cherry picked from commit 2d436ebc2963f1aac1854b850ff1808e654c61f3)
2026-11-05 02:08:28 -08:00
Anees Iqbal 6eb2a66d6e Gather a two-plane YCbCr texture's planes in place
A function that samples a YCBCR8_420_2P or YCBCR10_420_2P texture and also
gathers it (a probe asking each lane for a sample or a gather of red or
blue) lost the in-place form for the whole slot: `in_place_sample` built no
gather, so the gather set `in_place.blocked`, the slot bound the converted
image, and on MoltenVK its linear samples went through Metal's sampler of
RGBA16F-like texels: `ycbcr-filter-not-exact` (Half/FloatSampleFilter), and
through a pixel sampler `pixel-sampler-scaling`. Those notes killed three
of a consumer's strict Mac tests.

What: the in-place form now builds a 2D gather of a component without
comparison, constant offset or none, through a constexpr sampler (either
filter: a gather follows none) or a runtime one. The gather is the
extended-range emulation's `gathered` over `Decode::InPlace` taps: the four
taps of the linear footprint, each the texel Metal reads there (the border
texel past a border axis), in Vulkan's order, a runtime sampler's word
mapped as a 4:2:0 texture addresses. A gathered slot stays off the device's
own Y'CbCr conversion (`device: false`):
VUID-RuntimeSpirv-OpTypeSampledImage-12206 admits only samples through it.
No Quad routine for a gather. SEMANTICS_VERSION 1962 (facts and modules of
gathered slots change).

Tests (engine_ycbcr_in_place): every gather of each component of random
8- and 10-bit planes under three conversions, constexpr and runtime
samplers, float and half, on the lavapipe and moltenvk-m3 profiles, equals
Metal's model taps on the interpreter; a gather states the in-place fact
with `device: false`; a function that samples and gathers through one
runtime sampler notes FloatSampleFilter/HalfSampleFilter on its image
compile and states the fact, and its in-place compile builds both forms and
notes neither those nor PixelSamplerScaling. Device evidence against
Metal's rows follows with the fixture and conformance cases.

Docs: API.md and FAST-PATHS (in-place reads and the planes-image row),
RuntimeFact::YCbCrInPlace, InPlaceReads, the runtime README.
(cherry picked from commit b95b95a355f9a8ff4c1bfacbf329a728c4896db9)
2026-11-05 02:08:27 -08:00
Anees Iqbal 2e2c1ec056 Leave fneg, fabs, floor and ceil unnoted where the M3's Metal keeps their denormals
MoltenVK on the Apple M3 Max runs a SPIR-V `OpFNegate`, `FAbs`, `Floor` and
`Ceil` through Metal's own compiler, which keeps a denormal operand of
negation and absolute value and reads it as the zero of its sign in floor
and ceil, as plain Metal does. The translator noted `DeviceDenormals` on
every such operation, so a strict consumer died on a kernel that negates a
float though the answer is Metal's.

What: a new APPLE9-only `DriverDeviation::MetalUnaryDenormals` (and its
`VkProperty`) on the moltenvk-m3 profile. A function whose float negation,
fabs, floor or ceil the deviation covers records no `DeviceDenormals` for
them and requires the property instead; fabs keeps its Metal-own exemption
on every other profile, and trunc, round, rint, fract, sign and the rest
stay noted (the lane does not check them). `ARTIFACT_FORMAT_VERSION` 486
(the property's tag), `SEMANTICS_VERSION` 1961 (notes and requirements
change).

Evidence: the committed MoltenVK M3 observations of the four denormal
cases (nan_denormals, nan_denormals_fast, dfl, dfl_fast) hash equal to
Metal's on the same M3. The float_denormals gate lane now checks probe rows
-a, 0-a, -(a*b), fabs(a), floor and ceil where the deviation is taken, and
asserts the module requires the property exactly then; the
arith unit test covers each op under each fast and unary setting. Device
runs follow on the GPU job for this stack.

Docs: FAST-PATHS row on device denormals, API.md degrade catalogue,
driver_facts' measurement paragraph, api_signatures.tsv; refusal surface
and signatures checks pass.

(cherry picked from commit f3f65903a395b46b3a8001c4259bb1e4bb7bc203)
2026-11-05 02:08:27 -08:00
Anees Iqbal a139f39c89 Note a texel centre's denormal only under an address mode that parts texel -1 from texel 0
What: a nearest pixel-coordinate sample at its texel's centre, floor(x) + 0.5, records
DeviceDenormals for that floor: Metal's sampler reads a negative subnormal x as texel -1, where a
floor that flushes it (MoltenVK's) makes texel 0. Clamp to edge, mirror clamp to edge and mirrored
repeat read texel -1 as texel 0, so the note now holds only where the s or t mode is repeat, clamp
to zero or clamp to the border:
- a constexpr sampler decides it from its (mapped) s and t modes at compile (centre_parts);
- a runtime sampler slot's clauses add, per axis, a test of the bound sampler's word that the
  axis's mode is none of the three. The word is read through a new note-only key,
  SpecKey::BoundSamplerWord(slot): no constant declares it and no pipeline's key carries it, so
  the mode adds no VkPipeline variant (the alternative, the ADDRESS bits in SamplerState's fields,
  would split every runtime pixel sampler slot's pipelines by mode on every device). The plan
  records its value beside the pushed specialized values (slots::record_noted, given by
  BindingPlan::specialized_value), SpecClause::tests_bound_values counts it, and the runtime's
  degrade_bound_values announces such a clause at each draw or dispatch, as it does for a pushed
  format class. The runtime's notice reads "under the formats and samplers it binds".
- NoteOn::BoundSampler is the lowering's name for the key.

Why: reims-vgpu's strict Mac tests died on device-denormals from a nearest clamp-to-edge pixel
sampler, under which the device's texel is Metal's.

Tests: tests::engine_sample_coordinates::a_texel_centre_notes_denormals_only_where_its_mode_
parts_texel_minus_one (constexpr array samples per mode on every committed profile; the runtime
slot's clauses evaluated over every s/t mode pair, and never under a normalized state);
cache::tests::the_version_485_member_round_trips;
runtime_lane::pixel_samplers::a_texel_centre_s_denormals_wait_for_a_mode_that_parts_texel_minus_one
(device: nothing at making, nor under clamp to edge and mirror clamp to edge, once under clamp to
zero). Conformance: four cases pixel-samplers-subnormal-{edge,zero,border,mirror}, the RGBA8Unorm
texture through a nearest filter at sixteen coordinates of subnormals, zeros and -2^-126 on each
axis, recorded on Metal in a following commit.

Versions: ARTIFACT_FORMAT_VERSION 485 (the SpecKey variant), SEMANTICS_VERSION 1960 (the clauses).
api_signatures gains the variant. Docs: API.md and FAST-PATHS.md (device-denormals), the
DeviceDenormals, SpecKey, SpecClause and plan rustdoc.

(cherry picked from commit 624008697abfab1dbb3039a926902373b84e1268)
2026-11-05 02:08:27 -08:00
Anees Iqbal 6e63f015b5 Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
What: narrow::round_texel rounds through round_measured, so in QuantizeForm::Converted the
conversion pair's narrowing is recorded as measured. On a profile that takes
DriverDeviation::MetalHalfConversion (MoltenVK on the Apple M3 Max's macOS 27 identity) a texel's
half rounding no longer records PrecisionNote::NativeHalfConversion. That covers a texel the module
decodes itself (extended_range::decode) and a merge of texels (a heap read's phi of its fetched
texel and its decode routine's), as well as an image instruction's. The module requires
VkProperty::MetalHalfConversion instead. The note stays for roundings by narrow::round: half
operations and functions computed in float, filter sums, packs and the rest. Other profiles never
read the measured set, so they are unchanged by construction. The SPIR-V is unchanged too:
round_measured emits the same pair.

Why: reims-vgpu's strict Mac tests die on native-half-conversion at a kernel that reads an
argument buffer's texture as half (their ycbcr_probe.metal read_held). Every heap half read
carries the decode routine of the seven extended-range/padded/bfloat forms, and its merge, so it
recorded the note even for a BGRA8Unorm texture. The note states that the device's conversion may
differ from Metal's half(float), and MetalHalfConversion measured that conversion as Metal's
half(float) for loaded and computed floats. Where Metal's half texel is not the nearest even half
of the texel's value, the access's own note states it: HalfTexelConversion (outright for a heap
element, by the bound class at a slot) or DevicePackConversion (a decoded texel).

Verified:
- New core tests heap_half_texels_round_by_the_measured_conversion (heap half read, nearest sample
  and gather on moltenvk-m3: no note and the property with the deviation, the note without it,
  HalfTexelConversion kept; a linear sample's filter sum keeps the note on both) and
  decoded_half_texels_round_by_the_measured_conversion (a slot's half read of each extended-range
  form: the same, DevicePackConversion kept). Both fail with round_texel's old rounding and pass
  with the change; half_conversions_are_metals_where_measured still passes.
- Notes of every public fixture subject on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before
  and after (a temporary dump over the golden-hash subjects, 2,915 per profile): 7 change, all on
  moltenvk-m3, each losing NativeHalfConversion alone and keeping HalfTexelConversion
  (a8r_buffer_read_half, hlf_half_buffer, selected_member_texture and
  kernel_texture_variant_leftovers, the .ll and .air.ll forms).
- reims's ycbcr_probe read_held on moltenvk-m3 through the CLI: [DeviceNanEncoding,
  HalfTexelConversion, NativeHalfConversion] before.
- Pending: the M3 lane heap_half_reads_of_every_code_round_their_float (new) and the lanes that
  read the note (alpha_in_red now requires a8r_buffer_read_half to be Metal's there).

Docs: the PrecisionNote, DriverDeviation and VkProperty rustdoc, API.md's native-half-conversion
exemption, the driver-facts record, narrow's docs.

(cherry picked from commit 384734851de7b2f1a3106355a6c941080f097be4)
2026-11-05 02:08:27 -08:00
Anees Iqbal 493178c82e Keep a draw's heap part while what it is made of holds
A replayed page's host step costs about 400 ns per replayed draw per
resident texture (reims: 14 s a frame). Each draw works its heap part
out again for every texture its encoder made resident, though the
residency did not change and the command rebinds only a buffer:
- the handle tables, at every heap member (bind::heap::member_id,
  table_bytes);
- where the heap writes go (heap_elements, member_id again);
- each heap entry's view check (bound_view, view_reading,
  binding_view, Image::view);
- for every member, a neutral image descriptor in each heap image
  array whose class it does not fit (neutral_view, border_texel,
  BicubicTexels::with_border). heap_sets::bind then dropped every one
  of those.

Now:
- The translator splits the heap part from the rest of a draw's
  commands:
  - BindingPlan::instantiate_draw_apart_into writes every command but
    the heap tables;
  - heap_tables_into writes the heap tables alone (handle tables,
    sampler tables, function-table directories);
  - heap_slots names the texture slots they read besides the used
    resources.
  instantiate_draw_into is unchanged. A consumer breaks nowhere: all
  three are additions. docs/API.md says when the tables may be kept.
- The runtime keeps each draw's heap part in its encoder's LiveBind
  (render/heap_part.rs): the heap tables, where the heap writes go
  (Arc<HeapElements>), and the writes past the heap's entries
  (binding::PastHeap). The first draw that checks every entry's view
  lists those writes, and meets no notice the device announces at each
  occurrence (EachWatch) while it does.
- What a part is made of:
  - the plan, by address;
  - the variant's heap capacity;
  - the residency's generation;
  - the argument samplers: the count of sampler-ID slot changes they
    were listed at, else compared state by state;
  - the function tables, compared;
  - what the plan's heap slots bind, compared;
  - the heap placement and the token order.
- Parts are kept for the last 8 plans, so pipeline states drawn in
  turn and the plans a draw's primitive type picks each keep their
  own. They go as the encoder ends.
- Builds with debug assertions check every kept part against one
  worked out whole, and every listing of writes past the heap against
  one listed again.
- bind_into writes no heap image element at all, whatever the plan
  reads: the device's heap set holds each one. One predicate,
  heap_sets::holds_element, now says this for bind_into and
  heap_sets::bind.
- WorkCounts::draw_heap_parts_made counts the parts worked out. The
  replayed-frames lanes print it, and the resident uses' walk counters.

Builds with debug assertions check a kept listing against the writes
listed again in place, allocating nothing.

Measured, release, the replayed textured page
(runtime_lane::replayed_textured, 3 frames, interleaved with the
commit before over two rounds):
- Apple M3 Max, MoltenVK 1.4.2:
  - host_step_ms 10363-10491 a frame before, 1489-1621 after;
  - test time 31.7-32.5 s before, 5.1-5.3 s after;
  - pixels e3306dc52a1c9e86 in both;
  - peak RSS 306-317 MiB in both.
- RTX 5080 Laptop (b5080 entry resident-x-heap-part-004402, kind t):
  - host_step_ms 8800-8931 before, 1309-1359 after;
  - pixels 8e977e2bb4582473 in both.
- After, in both: draw_heap_parts_made 2 a frame (the point draws'
  plan and the other draws'). resident_uses_made stays 10,009,006 a
  frame; the next commit addresses it.

The 5080 binaries came from build-only commits. Their release code
equals this tree's but for the Deferred Send and Sync below this
commit and the lane's extra counter print.

Verified:
- On the M3 (potluck), clippy, plain and --cfg m2v_gpu, all targets,
  of the translator, the runtime and the validation crate; Rustdoc
  -D warnings; scripts/api-docs.
- The translator's heap, binder, instantiate and api tests, 143 of
  143. Among them, graphics tests check that instantiate_draw_apart_into
  plus heap_tables_into equals instantiate_draw_into wherever the
  latter succeeds.
- The runtime's suite, debug, --cfg m2v_gpu, hazard filter: 1626 of
  1627. The one failure, exit_guard's
  only_the_listed_modules_keep_the_device_s_functions, fails on the
  base too: a547d0ce33's command_buffer Parts shares a name with the
  device's Parts.
- The validation lanes over residency, draws and notices, debug,
  --cfg m2v_gpu, hazard filter: 246 of 247. The one failure is
  runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_
  within_their_bounds: 21.50 allocations a draw on the M3 against
  DRAW_ALLOCATIONS_DEBUG, 20. Whether that comes from this change or
  from its base is not yet measured. The release bound
  (DRAW_ALLOCATIONS) was not run.
- Negative control: with the kept part never kept, the new test fails
  at draw 1 (heap_parts 1, expected 0).

(cherry picked from commit 12f8301c62ffbbc149c04792007895649b8fe9ed)
2026-11-05 02:08:26 -08:00
Anees Iqbal 8fcff2117f Put a host step's copy of a chunk's records off where they changed at two steps in a row
On the 5080, a page whose GPU-written records change at every frame (replayed_frames at K=0,
5000 records, CHANGE_EACH) paid about 0.9 ms more a host step than the baseline: base 19.15 ms,
the tip 20.05, means of 3 interleaved runs of 22 warm frames each (b5080 entry icb-p-010218).
The same tip with the host step's keeping cut off (no comparison, no copy) ran 19.31. perf of
the steps thread put the difference in memmove: each step copied every chunk's records, 11 MB,
into the copy the next step compares with, 575 KB a chunk, past the caches (h 501 Mcycles of
memmove against 416 with no keeping). The comparison itself is a few hundred microseconds less
than that and the single read (ff4610cd46) already left one read a record.

A host step that records inline now copies a chunk's records only where it needs them
(kept_commands::StepCopy, held in each chunk's state beside the bytes it last read):

- where the records hold the bytes the last step read, it records from those bytes and copies
  nothing (ReadFrom::Held);
- where they changed since, it copies them again, as before;
- where they changed at the step before too, it reads them in place, record by record, as an
  execution that keeps nothing does (ReadFrom::InPlace, RecordSource::Storage), and copies them
  at one step in eight only (COPY_EVERY), each chunk at a step of its own among the eight, until
  a comparison finds them as the step before read them. A CPU write to the chunk, or a recording
  of it kept or forgotten, starts it over.

So records that change at each step are copied for an eighth of their chunks a step, and a chunk
whose records stop changing is copied again within eight steps and compared at the next. What a
step keeps is unchanged: a chunk is kept only where its records compared equal, byte for byte.
WorkCounts::host_step_chunk_copies_put_off counts the chunks read in place.

Tests: kept_commands::tests::records_that_change_at_each_step_are_copied_at_one_step_in_eight_a_chunk
(the schedule: chunk 0 copied at steps 0, 1, 10, 18, 26, chunk 7 at 0, 1, 3, 11, 19, 27, one
chunk in eight a step from step 3, a held comparison and a write start it over). The kept-steps
lane's changing case asserts each chunk's copy put off from the records' second change on, each
record still read once (indirect_record_bytes_copied), the pixels a fresh page's, and that once
the records hold again a step within ten records apart and keeps every chunk, the next running
them kept. replayed_frames' split prints host_step_chunk_copies_put_off and
indirect_record_bytes_copied.

Verified: nothing yet; the M3 clippy, units and lanes, the negative control (always copy) and the
5080 timings follow.

(cherry picked from commit cd7b2a7e74f2a6aeef4e8080689bb4bab50c0a2f)
2026-11-05 02:08:25 -08:00
Anees Iqbal 3ab5303945 Have a host step that records inline read its records once, into the copy it keeps
A step whose records change at each frame copied every chunk's records for the next step's
comparison (written_bytes_into) and then read each record again to decode it (record_now):
11 MB copied twice a frame on a page of 5000 commands. On the 5080, three interleaved runs at
K=0 with records changing every frame stepped 19.6 ms on average against 19.0 ms at
04115e977f, with libc's copy at 13.4% of the steps thread's cycles against 11.2%.

steady now hands such a step StepReads, what it reads its records into, chunk by chunk:
the bytes the last step read where it has them, else a fresh copy, and a chunk whose kept
recording's records hold reads those. The inline recording decodes its records from those
copies (IndirectCommandBuffer::written_records_in), and keeps them for the next comparison
once it recorded. keeping answers Keeps: kept, or inline with or without reads.

WorkCounts::indirect_record_bytes_copied counts the bytes copied out of a buffer's record
storage. The kept_steps lane's changing frames now expect each record copied once (DRAWS x
COMMAND_BYTES); copying them again besides fails it.

Not built or run yet.

(cherry picked from commit ff4610cd4660b94835af7841e24114d6ee89fae2)
2026-11-05 02:08:25 -08:00
Anees Iqbal 347b9870c4 Keep a host step's chunks only where two steps read the records alike, and copy the residency once an execution
A host step that compared a kept chunk's records and found them changed recorded every chunk
apart again, each into a secondary of its own, to keep: on the replayed-frames page at 5000
resident pairs on the M3 that cost 23.3 ms a step where the records changed at each frame,
against 18.3 ms recorded inline (one binary, keeping switched off by a temporary patch). Phase
timers put the difference in a copy of the residency per chunk and its drop (2.9 ms over 20
chunks), a fresh 11 MB copy of the records (about 1.1 ms more read), resolutions and contexts.

Two changes:

- RenderExecution::steady decides before recording. A step keeps chunks only where the records
  hold, chunk by chunk, the bytes a kept recording was made from or else those the last step
  read, compared whole. Else the execution records inline, as before keeping, and each chunk's
  records are copied into the bytes the last step read (IndirectCommandBuffer::
  written_bytes_into, no new pages after the first), for the next step's comparison; a recording
  whose records changed is forgotten and counted recorded again. So records that change at each
  step cost the step one copy of them beside today's inline recording, and a step records apart
  and keeps only what two steps read alike. The chunk store keeps those bytes per chunk
  (KeptChunks::look_up_step, read); a chunk recorded apart keeps them as its recording's bytes,
  copying nothing again.
- The chunks an execution records apart carry the encoder's residency from one to the next with
  the bind state (replay_encoder takes it owned), so an execution copies the command buffer's
  residency once, as one recorded inline does.

The kept-steps lane now counts chunks recorded apart to keep (WorkCounts::kept_contexts_made):
the first frame records inline, the second apart, the third runs kept; a records change records
inline, then apart, then kept; another input's change records apart at once; and records that
change at each step record inline each frame, keeping nothing, each frame drawing what a fresh
page draws.

Verified: clippy, plain and under --cfg m2v_gpu, on this Mac. The lanes and the page's timings
on the M3 follow.

(cherry picked from commit b9b1c0aab9728e57e517cb6f0abdfc1df44e9b03)
2026-11-05 02:08:23 -08:00
Anees Iqbal 5b451a6508 Hold a commit's refused recording of a write-resident ICB's records for the host step
A commit that recorded an execution from the CPU's records and found a record it refuses failed
there, though a route met after the commit may still write those records before the work runs:
another queue's command buffer that the work waits for through a shared event, encoded and
committed after this commit. Metal runs what that route wrote (the new probe
crates/metal2vulkan-conformance/probes/icb_cross_queue_writes.m, M3 Max, macOS 27.0.1, validation
off: `written` completes both command buffers with the kernel's green triangle; `unwritten`
completes too, drawing the CPU's mismatched-format command as garbage). Dying there where Metal
runs breaks the owner's rule 2.

Now, where the commit's recording of a render pass's executions, or of a compute execution, is
refused and the command buffer made one of the executed buffers resident for writing
(Residency::writable_indirect_command_buffers), the segment is held for its host step
(Prepared::held sets Segment::host), prepared as a step's: settled variants and made-ahead
pipelines, its footprint bound. The step waits for the work before it, records from the records
as they stand then, and fails the command buffer at that batch's submission only where they are
still refused. A refusal of another buffer's records, and every valid recording, keep the
commit-time path. Counted: WorkCounts::commit_refusals_held (api_signatures row).

The lane test write_routes::a_refused_command_another_queue_writes_again_runs_what_it_wrote runs
the probe's `written` shape: both command buffers complete, the centre is green, and the counter
moved once. docs/API.md states the held refusal.

Verified: clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and
validation crates; api_signatures/api_surface 15/15. The lane test is not run on a device yet.

(cherry picked from commit 83a1365119f1563ce45f97941a335ea119bc9efc)
2026-11-05 02:08:23 -08:00
Anees Iqbal 042ec0a481 Keep a host step's recordings of GPU-written render commands, compared with the records
A host step of a render execution whose records the GPU may write recorded every command at
every step: about 12 to 17 ms for the replayed-frames page's 5000 indexed draws on the M3, every
frame, though the page's records are the same bytes each frame. The step now keeps its chunks as
commit keeps the CPU's (render/executions/kept.rs, kept_commands.rs): from a chunk's second step
on it records the chunk apart into a context of its own and keeps it with a copy of the bytes of
its records; a later step runs the kept recording where the records hold those bytes now,
compared whole, and its key is equal, and records it again otherwise. No write forgets such a
chunk: the comparison decides.

The key is everything the recording reads beside the records: the RenderKey commit's chunks use
(inherited pipeline state, pass shape and layout, encoder state, scissors, amplification,
attachments among the resident resources, the resident set compared whole once a list), plus the
inherited tables' buffers by key with offsets and attribute strides (new: commit's chunks need
tables that bind nothing), plus KeptChunk::runs_again's checks (each address named resolves as it
did, no no-copy buffer moved, nothing detached, everything held alive). The step keeps only where
the commands inherit the pipeline state and the inherited tables bind buffers alone; a record
barrier makes its chunk not plain instead of ruling the execution out. Its chunks draw in the
large-buffer form, as the step's other draws do. The step's round trip stays: the records are
known only once the work before them completed.

Counters: WorkCounts::host_step_chunks_kept, host_step_chunks_recorded_again,
host_step_records_compared and host_step_compare_nanos (api_signatures rows added). The
replayed_frames lane prints them and a hash of the target's pixels per frame (a blit copies the
target out); the new kept_steps lane changes one input at a time (the records the GPU wrote, the
inherited buffer and its offset, the inherited state, the scissor, the resident set, the buffer
an index address names at the same address, the inherited no-copy buffer's pages) and checks a
re-record, the pixels of a page that kept nothing, and keeping again after. FAST-PATHS' entry on
kept recordings states the host step's.

Verified: cargo check and clippy -D warnings, all features, plain and --cfg m2v_gpu, for the
runtime and validation crates; api_signatures/api_surface 15/15; fast_paths 19/19; the runtime's
kept and indirect-command unit tests 32/32. The device tests (kept_steps, replayed_frames,
the ICB lane modules) are not run yet.

(cherry picked from commit 9b3d13a6d22fba484cce4923fd87ad503f7bc060)
2026-11-05 02:08:23 -08:00
Anees Iqbal cc4c44bd7e Make the GPU hazard tests opt-in under --cfg m2v_gpu_hazards
Owner's rule (11-05): tests that fault a real GPU, hold one for long, or
allocate toward its limits never run in sweeps, lanes, stress loops or
gates; they run only when that feature is tested, on request. On the M3
Max a GPU fault's recovery fails other processes' command buffers in
flight (.config/nextest.toml has the measurement). #[ignore] is not
enough, since lanes run --run-ignored all, so the gate is a cfg: on a
real GPU a hazard compiles only under --cfg m2v_gpu --cfg
m2v_gpu_hazards. Under --cfg m2v_cpu_icd it compiles and runs as
before, so lavapipe CI keeps them.

Gated (each doc comment now says which hazard it is):
- runtime_lane::host_memory::a_gpu_fault_fails_its_command_buffer_and_the_queue_runs_on
  and ::a_lost_device_s_command_buffers_let_go_of_their_pools_after_the_driver_s_completion:
  GPU writes into read-only host pages, real page faults (2 and 3).
- host_memory::a_no_copy_buffer_s_pages_are_imported_when_it_is_made:
  no-copy buffers of 1 to 16 GiB.
- vertex_strides::vertex_fetches_past_4_gib_of_a_buffer_are_refused and
  stage_in_strides::stage_in_fetches_past_4_gib_of_a_buffer_are_refused
  (and their `Large` helper): 4 GiB + 4 KiB buffers.
- heaps::the_largest_heap_lies_in_one_allocation: a heap of the device's
  largest allocation, up to 4 GiB.
- cross_queue_shadows: the three tests whose spin holds one command
  buffer for 1.5 s.
- framebuffer_fetch::storage_forms::a_steady_stream_takes_the_storage_form_at_its_first_lone_commit:
  a single-dispatch spin of up to 1 s that only its cap ends on Apple GPUs.
- detach::table_3_a_detach_waits_for_running_work_then_refuses: single
  dispatches calibrated to 500 ms (up to 2 s loaded), the cap alone ending
  them on the M3 Max, where Metal ended some 0.5 s dispatches as hung.
- runtime tests::detach_lost: one dispatch of 2^25 loads (about 4.5 s on
  the M3 Max) whose word the GPU does not see raised.

Made safe instead of gated:
- mesh_draws::object_grids_run_as_metal_runs_them: on a GPU without the
  hazards cfg, grids past 2^20 object threadgroups are skipped (printed),
  as a CPU ICD already skips them; the 70k to 262k grids and the
  past-the-watchdog discards still run. The 4.6M grid took 12 s in one
  command buffer on the RTX 5080 Laptop GPU.
- detach::a_resident_buffer_no_command_reaches_fails_its_submission_once_detached
  takes the spin kernel without calibrating a cap (`spin_kernel`): its
  word is raised, so the cap never mattered, and the calibration's
  unraised runs are bounded only at 16 x 50 ms.
- cross_queue_shadows::an_encoder_after_a_signal_reads_what_another_queue_wrote_after_it
  no longer calibrates a spin it never ran.

The cfg is declared for unexpected_cfgs in the runtime, validation and
conformance manifests. docs/VALIDATION.md says what a hazard is and how
to run one; CONTRIBUTING.md and .config/nextest.toml mention the cfg.
The device lane is unaffected: its builds set RUSTFLAGS to --cfg
m2v_gpu alone. No product code changed (no RUNTIME_VERSION bump; the
runtime-sources pin skips test modules).

Verified on this Mac (no test run on any GPU): cargo fmt --all; cargo
clippy --workspace --all-targets --all-features -D warnings clean plain,
under --cfg m2v_gpu, --cfg m2v_gpu --cfg m2v_gpu_hazards and --cfg
m2v_cpu_icd. cargo nextest list -p metal2vulkan-runtime -p
metal2vulkan-validation --all-features --run-ignored all: under --cfg
m2v_gpu 5022 tests, under --cfg m2v_gpu --cfg m2v_gpu_hazards 5034, and
the difference is exactly the 12 gated tests; all 12 are listed under
--cfg m2v_cpu_icd (5000 tests).

(cherry picked from commit 7b57d9a87a3dd8275a2ece547fc0bd9b9cb6808c)
2026-11-05 00:43:51 -08:00
Anees Iqbal a0bebe78f1 runtime: copy runs of a guest RAM to and from a buffer on the GPU, from the chunk imports
`BlitCommandEncoder::copy_from_host_ram(ram, runs, destination, destination_offset)` gathers runs
of a `HostRam` the device uses into consecutive bytes of a buffer, and
`copy_to_host_ram(source, source_offset, ram, runs)` scatters them back (a runtime extension:
Metal has none). A surface that is a scatter of guest pages is copied straight from the RAM's
64 MiB chunk imports, with no view mapped per surface (one mmap per run) and no import made per
surface.

How: adjacent ascending runs merge, descending neighbours stay apart; runs are cut at chunk ends;
the 4 KiB pages become a table in the command buffer's upload arena, and each chunk the runs touch
takes one dispatch of the new `bind::pages_copy_module` (more only past the storage-buffer range
or the workgroup count). A chunk not imported yet is imported, or its pending import waited for,
as an object over it does.

Ordering: each chunk a copy uses gets a resource key placed over the chunk's host bytes in the
host-alias placements, the way no-copy buffers and heaps are placed, so the copy's chunk uses
(joined to at most 16 ranges per chunk) order against other copies and against every no-copy
object over the RAM's own addresses, in one encoder and across encoders; the buffer side is
tracked like any blit. A scatter's writes reach the RAM's dirty log as the GPU's in place, so a
copied backing over those pages takes them in at its next commit. Objects made over another
mapping of the pages (a view resolved through `with_runs`) are not ordered against the copies.

Refused with `Problem::HostRam`: an empty run, one off 4 KiB, one outside the RAM, a RAM the
device does not use, buffer bytes off a 4-byte word; no host import is `Unsupported`; bytes past
the buffer are `RangeOutOfBounds`. Replayed at rebinds (`BlitCall::HostRamCopy`). New counters
`host_ram_copies`, `host_ram_copy_bytes`, `host_ram_copy_dispatches`. README, HOWTO, the
API signature rows and docs/REFUSALS.md updated.

Verified:
- On this M3 Max (MoltenVK), --cfg m2v_gpu under nextest: the five new device tests
  (`tests::host_ram_copy_device`: round trips byte for byte over ascending, descending, adjacent,
  repeated and chunk-crossing runs into Shared and Private buffers; CPU writes before the commit
  gathered and a scatter's bytes in the pages after completion; the two hazard cases in one
  encoder and across encoders; a copied backing over the pages taking a scatter at the next
  commit; the refusals) and the ten `tests::host_ram_device` tests: 15 passed.
- Negative controls, each a saved build: merging descending neighbours fails
  `adjacent_ascending_runs_merge_and_descending_ones_stay_apart` and
  `a_gather_and_a_scatter_move_every_runs_bytes_in_order` ("the gathered bytes"); not placing the
  chunk keys over the host bytes fails
  `copies_are_ordered_against_a_no_copy_buffer_over_the_same_pages` ("a later reader sees the
  scatter"). The first control found the test pattern repeating every 1 KiB, so a page swap
  went unseen; the pattern now differs per page.
- The `host_ram::copy` unit tests (merge, refusals, chunk cuts, the plan, the joined uses) and
  `consumer_auto_traits`; clippy --workspace --all-targets --all-features -D warnings, plain and
  --cfg m2v_gpu; rustdoc -D warnings; `signatures.py --check` after the bless; the refusal
  surface `--check`.
- The ignored release bench `tests::host_ram_copy_bench` on the M3, a 3840x2054 BGRA8 surface
  (31,549,440 bytes, 31,551,488 in whole pages) scattered over 1 GiB of shared RAM: 7703 4 KiB
  runs (5490 descending neighbours, 7279 runs after the merge) take 16 dispatches, 0.35 ms of CPU in the call, 0.59 ms of GPU and 0.64 ms from commit to completion
  for a gather (scatter 0.37 / 0.58 / 0.64). The view path at the host's 16 KiB page (1926 runs:
  a view mapped run by run, a buffer `with_runs`, a buffer-to-buffer copy, the release) takes
  1.58 ms to map, 2.36 ms to make the buffer, 0.99 ms commit to completion and 0.78 ms to
  release; the gather of the same 1926 runs takes 0.14 ms CPU and 0.60 ms commit to completion.
Ported onto gate/stack27, where the device's thread imports a window of chunks ahead of the
objects (paced, with the memory lock released, short of maxMemoryAllocationCount and giving back
what no object took). The conflict was `RamOnDevice`'s fields alone: the copies' `ChunkKeys` sit
beside the window and its wake, and the old cursor is gone. The copy still takes each chunk
through `RamOnDevice::chunk(.., By::Object)`, the objects' own path, which now moves the window
past it, wakes the thread and clears the chunk's untaken mark; there is no second import path. The
copy module docs and HOWTO say so. The ignored release bench waited for every chunk imported
ahead, which the window never does; its warm-up copy now imports the chunks the runs touch.

The verification above was on the old base; this tree's is in the commit that follows.

(cherry picked from commit 923718777c198bef526dd07f701fc71a71e07b00)
(cherry picked from commit fa00224f7b29ab0359c8305a47da9c9273fc5d37)
2026-11-05 00:43:50 -08:00
Anees Iqbal 03d4e53238 Record the copy beside another storage mode's import as a GPU-to-GPU gap
What: copied.rs's GPU-to-GPU note and docs/FAST-PATHS.md's known gap now
also name a copy beside a live import of the same bytes for the other
storage mode (a Managed buffer's import, then a Shared buffer over the
same bytes whose import the gate refused): two memories that agree only
through the pages, as overlapping copies do.

Why: a buffer lies in a live import of its own memory class, else in a
live copy of either class; a copy made while only the other class's import
lives is a second memory. Lying in the other class's import instead was
left out: it would change which memory type the buffer's import takes.

Verified: docs only (cargo fmt).
(cherry picked from commit 9f473f8f10f82e59864fd5abb74615b65c3b2e14)
2026-11-04 22:15:56 -08:00
Anees Iqbal 215a9f7583 Time the pass-start barrier family on the M3 Max, and count it in the conformance coverage
What: `conformance times --runs 8 --write` over the 13 pass-start-barrier cases keeps both
legs' figures in their recordings, and docs/CONFORMANCE-COVERAGE.md is regenerated
(scripts/conformance-coverage/coverage.py): 1141 recordings in 153 case modules, and
`MTLBarrierScopeRenderTargets` now compared.

Why: `times::every_case_carries_its_timing` holds every case to a timing record, and the
coverage doc is derived from the recordings and the suite's sources.

How verified: potluck job m3-max-37 on the Apple M3 Max, debug build, exit 0: 13 cases carry
their timing; 4 within 10x, 9 unmeasured because our leg announces render-pass-split (and the
display row two more), so its work is not Metal's. The host's load was 188 while Metal's leg
ran, so the margin is reported, not judged. coverage.py --check passes.

(cherry picked from commit 8ce6ed8262789fb7887794bb7073eb63dbed249e)
2026-11-04 21:54:22 -08:00
Anees Iqbal cee5c7eeb3 Name a draw's read behind a barrier as the cause in the render-pass-split notice
What: a split made so a draw reads a color attachment's texture after a memory barrier
(`Split::AttachedRead`, the pass-start barrier's split among them) is now counted for the
split's degrade notice (`SplitCauses::attached_reads`), whose reason says so: "draws that read
a color attachment's texture after a memory barrier read what its load actions and the draws
before the barrier stored, in a Vulkan render pass instance after theirs, ending N of them".
The `RenderPassSplit` declaration and docs/API.md's catalogue entry list the cause.

Why: such a split counted neither as a barrier split (`self.barrier` is false for a
render-target barrier before any draw, and for one between draws, which records in the
instance) nor as any other cause, so the notice fell to its last reason, "its draws keep
different attachments out of their subpass", which describes no part of this pass. The
conformance replays of the pass-start barrier family showed the split announced on every
barrier row (Apple M3 Max, lavapipe).

How verified: builds (conformance binary, debug). The lane assertion added to
`a_draw_after_a_barrier_at_the_pass_start_reads_the_clear` (the split's reason, and a notice
exactly where a pass split) is NOT yet run; the runtime-sources pin is not re-hashed (the
coordinator's).

(cherry picked from commit 30b797c61b27d4dbe34386c36a27837bb3ed8ead)
2026-11-04 21:54:21 -08:00
Anees Iqbal 34bafa410d Record the pass-start barrier family on the M3 Max (unverified on our side)
WORK IN PROGRESS, parked: recorded on Metal, not yet replayed on the runtime.

pass_start_reads.rs adds 13 conformance cases (pass-start-barrier-*), each a pass that clears a
BGRA8Unorm target and draws a read of it (owned fixture psb_reads):
- 32x32 private and over-a-buffer targets, each with: the barrier then a read at own pixels; the
  barrier then a pixel-coordinate sample; the read and the sample with no barrier; a solid draw,
  the barrier, then the read.
- display-masked-read: a 1728x1216 private target holding an earlier DontCare pass's leftovers
  (61x55, 45x45), cleared, the barrier, a read at own pixels through a 453x100 scissor beside an
  A8Unorm mask over a buffer at texture 3.
- new-texture-chain: two new 896x576 private textures, each cleared, the barrier, a read at own
  pixels through 841x521 (the second beside the first at texture 3), then a target over a buffer,
  loaded, the barrier, and a read of the second over it.
- new-texture-tile: a new 448x576 texture cleared, the barrier, a read over all of it.
Texels are recorded as runs of equal texels (fresh_contents::texel_runs, now pub(super)). Rows
with a barrier accept, beside the M3 Max's recorded answer, the Mac2 answer the case states, by
docs/API.md's accepted difference a-barrier-over-the-render-targets-orders-what-it-names-as-a-
mac2-gpu-s-does (the sentence naming these cases is added to it here). tests.rs bills the 13
cases' cost records to the next whole-set run (AFTER_THE_LAST_RUN).

Verified:
- conformance record on the M3 Max (macOS 27, 3 runs, one outcome each): every row's read
  draws the texels from before its pass, the barrier or not; Metal's validated leg stops the
  barrier ("scope (0x4) cannot contain MTLBarrierScopeRenderTargets on this device; afterStages
  (0x2) can not contain ... MTLRenderStageFragment on this device").
- cases::pass_start_reads unit tests pass (plain target), including
  metal_reads_the_texels_from_before_the_pass_on_the_small_rows against these recordings.
- clippy -p metal2vulkan-conformance --all-targets --all-features -D warnings.

Unverified / owed:
- conformance replay of these cases on the runtime (M3 MoltenVK, 5080, lavapipe): whether each
  barrier row matches the stated Mac2 answer exactly, and which notices each venue announces
  (shared-in-system-memory is declared; shadowed-texture or dont-care-stand-in may be needed).
- times::every_case_carries_its_timing fails until `conformance times --write` runs over these
  13 cases on the M3.
- docs/CONFORMANCE-COVERAGE.md not regenerated.
- new-texture-chain's recording is 1.46 MB of pretty-printed JSON (three 896x576 sites of 1042
  runs each); consider dropping the first texture's site.

(cherry picked from commit 724afbf80b78c14a8824dfb96203df3813fba9aa)
2026-11-04 21:54:20 -08:00
Anees Iqbal 60d3c512a6 Announce copied-host-pages for a buffer that lies in a live copy
What: a no-copy buffer or rebind that lies in the live copy of the same
bytes (`Device::degrade_copied_shared`) announces `copied-host-pages`, its
detail saying it lies in that copy and whether the copy drops the GPU's
writes. docs/API.md says so.

Why: such a buffer makes no copy of its own, but the GPU uses a copy for
it all the same (`Buffer::host_backing` answers `Copied`); before the join
each one was a copy and was announced. A consumer that asks for the kind at
each occurrence (`DeviceOptions::announce_each`) hears it per buffer as
before.

Verified: cargo check of the runtime (all features); the lane runs follow
on the M3.

(cherry picked from commit a4a75f118381a9f049157b1da063ba2fa4c9bff5)
2026-11-04 21:54:20 -08:00
Anees Iqbal 6c4b409fb0 Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an
admitted import failed) now joins its memory and is placed as an import is
(`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later
no-copy buffer over exactly the same first byte and length, of either
storage mode, finds it (`HostAliases::import`: an import of its class,
else the live copy), lies in it through `Device::buffer_in_import`, is
named to it (`copied_as`) and joins its key, with the gate not asked. A
rebind onto such bytes lies in the copy too where its textures were
planned at the copy's offset (its first byte) and no image in place rides
on it; an import keeps the old `!moved` rule. A heap's own copy is placed
but joins nothing; a buffer whose writes are dropped keeps its read-only
view. New counter `WorkCounts::copied_host_buffers_shared`.

Why: two copies of one memory agreed only through the pages (merge back
at the writer's completion, copy in at the reader's commit). reims-vgpu
measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface,
each over its own refused no-copy buffer: a blit write then a blit read in
one command buffer, and a reader committed first on a second queue waiting
on the writer's event, both read all 16384 bytes stale, where Metal and
the runtime in place read the write. The consumer also made a full copy of
the surface per texture per present.

The remaining GPU-to-GPU gap, between a copy and another copy or import of
overlapping but different bytes, is recorded in copied.rs, docs/API.md,
docs/HOWTO.md and docs/FAST-PATHS.md's known gaps.

Verified: cargo check of the runtime with tests; the lane in the next
commit, run on the M3 (see its message).

(cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa)
2026-11-04 21:54:19 -08:00
Anees Iqbal 3797c098eb Order a pass's clear before a draw that reads it after a barrier at the pass's start
A pass that clears a color and begins with a memory barrier over the render targets (after the
fragment stage, before it) and then samples that color's texture in a draw read the texels from
before the pass. Mac2 GPUs read the clear there (an Intel UHD 630 after the barrier, an AMD
Radeon Pro 5300M with or without it). The draw reads the texture's copy, taken ahead of the pass's
load actions (render/shadows.rs), and a barrier split the pass only where a draw of the current
instance came before it, so a barrier at the pass's start split nothing.

Such a barrier now orders the pass's load actions (`loads_ordered`): the scope form with the render
targets, or the resource form over an attachment's texture, after the fragment stage and before a
stage at or before it, recorded before any draw of the pass. A draw after it that samples the
texture of a color the pass clears (`Texture::cleared_in`) takes the existing after-barrier path:
it records into an instance after the pass's first, which runs the clear and draws nothing
(`next_instance` keeps the first instead of replacing it), so the copy before it holds the clear;
or, where the device has them, it reads through snapshots inside the first instance. The split is
counted as the after-barrier read's (`attachment_read_splits`, `instance_splits_attached_read`)
and reloads stand-ins over a buffer's bytes as one after a barrier does. A pass with such a
barrier but no such draw records as without it.

docs/API.md section 10 gets the accepted difference this ordering is: Apple GPUs do not support
the render-target scope, and the M3 Max reads the texels from before the pass after it.

The owned fixture psb_reads (regen-air-fixtures) holds the functions the lane and the coming
conformance cases draw with: a read and a pixel-coordinate sample of texture 0 at the fragment's
own pixel, channels reordered so a read is told from a skipped draw, and two-texture reads.

Verified on the M3 Max (MoltenVK, debug, --cfg m2v_gpu), runtime_lane::attachment_reads:
- a_draw_after_a_barrier_at_the_pass_start_reads_the_clear: both targets (own image, over a
  buffer), psb_read and psb_sample, the scope alone, with the textures and the resource form:
  the clear inside the scissor, one split each (attachment_read_splits 1, instance splits 1,
  2 instances begun), own-pixel copies of 308 texels (the 20x12 scissor and a pixel round).
- a_draw_after_a_clear_with_no_barrier_reads_the_texels_from_before_the_pass: no split.
- a_barrier_at_the_pass_start_costs_nothing_without_a_read_of_a_cleared_color: a loaded target
  read after the barrier, and a cleared one with a draw reading another texture: no split, as
  many instances begun and copies taken as with no barrier.
Negative control: the same tests on the tree without the runtime change fail at pixel (4, 4),
reading [0, 64, 0, 255] (the texel from before the pass, reordered) where the clear's
[120, 200, 40, 255] is due.

(cherry picked from commit 923095effcd188a93ee5134ecc4dad3fab21b3fe)
2026-11-04 18:50:30 -08:00
Anees Iqbal 1a541744e1 Destroy an event's semaphore where its release goes again, and record NVIDIA's event costs
What: an event's release destroys its timeline semaphore on the releasing thread again, as at
4bbafa667d (event.rs is that commit's again); the device's free thread frees blocks alone. The
semaphore posting goes with its counter (WorkCounts::semaphore_destroys_posted; the API table
blessed: the field removed), its runtime test and its lane rows. docs/FAST-PATHS.md's known gaps
record what making and releasing an event costs on NVIDIA, and why the release is not posted.

Why: NVIDIA's driver runs a vkCreateSemaphore behind a vkDestroySemaphore another thread runs,
so a posted destroy moves its cost onto the program's next event and adds to it. Measured on the
RTX 5080 Laptop GPU with the bench's event modes (each row 1000 events unless said; before and
after interleaved within each hold; CPU package 83-103 C), p50 unless said:

  burst, 1000 made then released     inline: make 143-262 us, release 495-579 us
                                       (0.47-0.57 s a 1000 released)
                                     posted, bound 4096: release 0.2-0.5 us, but the makes
                                       while the destroys drained 1048-1676 us (1.10-1.66 s
                                       a 1000)
                                     posted, bound 64: release 0.5-1.2 us, p99 1.5-2.2 ms,
                                       0.51-0.66 s a 1000; makes unchanged
  steady, make one and release the   inline 203-238 us a pair; posted (64) 390-507 us
  one before, back to back
  steady, 2 ms apart (500)           inline 488-490 us a pair (event), 663-677 us (shared);
                                     posted 260-263 us and 417-421 us
  the driver's own cost              grows with the semaphores live: 98-119 us a make and a
                                     release with one or two live, against the burst's
                                       143-262 and 495-579 us with 1000 live

On the M3 Max (MoltenVK 1.4.2) a pair costs 2.6-2.8 us inline and 5.3-5.9 us posted back to
back, about 45 us either way 2 ms apart; Metal's own newEvent and newSharedEvent take 0.8-1.9
us there. The consumer's guests made no event in a boot of theirs, and their host makes a few a
second, so no shape of use has the posted destroy ahead, and the burst at a program's close,
which posting was for, gains nothing: the device's teardown drains what was posted.

Verified on the M3 Max (debug, --cfg m2v_gpu, under maclock and memcap): 90 runtime tests
(posted_frees, freed_memory, teardown_threads, memory, allocations, event, cpu_copy_layouts)
and 27 lane tests (posted_frees, shared_event, events, pool_churn, staging_batches) pass;
api_signatures and api_surface pass; clippy (plain and --cfg m2v_gpu, workspace, all targets,
all features) and the release check of the runtime's tests are clean. The inline rows above
are the RTX 5080's at 4bbafa667d's event path, which this restores.

(cherry picked from commit 1659544703425cd461106fba2cff7cfe73a02a8a)
2026-11-04 18:50:29 -08:00
Anees Iqbal b2df1add01 Bind a storage view of a whole buffer from its space's start, so draws that move only an offset keep their set 0
What: `bind::instantiate::planned_range` gives a descriptor-form slot read
through a storage view of its `Whole` window the range from the start of
the bound buffer's space to its padded end, whatever the bind offset, and
the bind offset as its `SlotBindOffset` residual. `bind_buffers` (every
draw's and dispatch's instantiation) and `rebind_slots`
(`rebind_draw_slots_into`) take it. Every other slot keeps
`descriptor_range`'s range: uniform views (whose `RangeAtBindOffset`
specialization reads a range from the bind offset), bounded windows, and a
storage view whose range from 0 would pass the view's
`maxStorageBufferRange` (`PlannedBuffer::max_range`) or 2^32 bytes (a
32-bit residual and offset), or whose bind offset lies at or past the
padded end. The tessellation factor and index bindings keep it too.

Why: `EncoderCore::set_zero_of` was 14.3% (draws.10k) and 8.8% (WS-like)
of the encoding thread's samples: every draw allocated, wrote and bound a
set 0 of its own. A `device T *` slot's range started at the bind offset
aligned down, so each new offset wrote another descriptor and neither
`LastSetZero` nor `SetCache` could match.

Vulkan: the descriptor's offset is the space's start (256-aligned, as a
bind at offset 0 has it today) and its range ends where today's ends (the
padded end), so offset + range, and a dynamic binding's effective offset +
range (VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979), are what they
were. dynamic_writes moves that same start into the dynamic offset for
every bind offset. The range is explicit, never VK_WHOLE_SIZE (06715 does
not apply). Hazard ranges are untouched: they come from the plan's use
ranges from the bind offset (`binding::bytes_use`).

Behaviour: a Metal offset m from the bind offset reads byte residual + m of
the range, the same byte as before for every access inside the window. An
access that reaches back before the bind offset (a negative index, the
32-bit offset wrapping) and lands in the buffer's space now reads and
writes the buffer's bytes there, as Metal's does; before, it lay outside
the descriptor range unless it stayed within the alignment's residue. On
a device with robustBufferAccess (or under in-shader containment against
the view's size) accesses are bounded by the larger range [space start,
padded end) instead of [bind offset aligned down, padded end): such an
access before the bind offset is in range and reaches the buffer's bytes
where it was a robust out-of-bounds access (a zero, a value from within
the buffer, or a dropped write). Accesses past the end are bounded as
before.

SEMANTICS_VERSION 1957 -> 1958: instantiated descriptor ranges and
residuals change. golden_hashes_match_the_table passed unchanged here (it
hashes compiled modules, which this does not change); the re-bless on
development decides.

Tests: planned_range's unit tests (the range from 0 and the residual at
every 4-byte offset for base alignments 16, 64 and 256, and a 2^32-byte
buffer at its last word; each fallback equal to descriptor_range's
answer). A device test, set_zero_at_offsets: 9 draws of colored_vertex
moving only two device buffers' offsets reuse 8 sets and bind 1, and draw
what 9 draws of buffers of their own draw (0 reused, 9 bound).
dynamic_multi_variable's moved-offset dispatches now reuse their
predecessor's set (7 of 8) and still answer Metal's values from each
dispatch's own offset. docs/API.md states the range.

Verified: the translator suite, 3324 of 3324 (plain). On the M3 Max
(MoltenVK 1.4.2), debug, --cfg m2v_gpu, under maclock and memcap: 96 of 96
runtime tests (fix 1's set plus set_zero_at_offsets,
dynamic_multi_variable, uniform_bind_offsets, binding_view, range,
rebind_descriptor_slip, rebind_behind_a_wait, depth_ranges, attributes),
and 220 of 220 validation lanes under the validation layer (fix 1's set
plus stage_in_regions, stage_in_strides, padded_loads, escaped_slots,
absent_reads, chosen_pointers, dispatch_*, read_through_views,
guarded_effects, index_fetches, first_vertex, vertex_strides, host_bytes,
pointer_uploads, commands_recorded, runtime_lane::tests, among them
renders::public_render_cases_match_metal and
tests::stage_in_region_cases_match_metal). Negative control:
planned_range forced to fall back fails set_zero_at_offsets ((0, 9)
against (8, 1)) and both dynamic_multi_variable moved-offset tests
((0, 0) against (7, 0)). clippy plain and with --cfg m2v_gpu clean.

Per draw on the encoding thread, release with thin LTO, 3 interleaved
rounds against the parent build, medians:
  draws.10k  11201.7 ->  9212.4 instructions (-17.8%), 616-661 -> 485-495 ns
  WS-like    23121.1 -> 21752.5 instructions (-5.9%)
One round's counts: draws.10k 0 -> 29880 sets reused, 30000 -> 120
vkCmdBindDescriptorSets, 6 -> 60000 vkCmdPushConstants (the residuals;
both stages' writes are pushed where either changes); WS-like 0 -> 3744
sets found in the command buffer's cache, binds unchanged at 4000.

(cherry picked from commit b875660ecbad7dd6f9dfa9f976ef1c2b32bded1e)
(cherry picked from commit b09293e9c22d80e4ae4c505b00ba0e07e6a8165c)
2026-11-04 18:50:27 -08:00
Anees Iqbal cc6b083fc2 Let what every write route of a command buffer may write reach every buffer it made resident for writing
What: what an indirect command buffer's records may hold (WrittenCommands, command_writes) took a
writer's writes only from the encoder that made the buffer resident for writing (Writers: the
state set then, each set after, and that encoder's executions). The routes that mark the buffer
(write_routes.rs) were already the command buffer's. Routes now keeps what all of its routes may
write (states set in any encoder, before the residency or after it, and what executed buffers'
records may name) and adds it to every buffer made resident for writing, at the call that brings
either; an encoder opens with what the ended ones met. For two encoders open together (a parallel
render encoder's) the commit adds what each did not see of the other, and the followers that
sets off are marked outside the command buffer's lock, as the commit's marks are. Writers is
gone: Routes holds a superset of what it held.

Why: Metal runs what a kernel wrote with the buffer resident for writing in any encoder of the
command buffer, before the kernel's or after it (the probe icb_routed_writes.m, M3 Max, macOS
27.0.1). The marks matched that; the summary did not, and an execution of a buffer that inherits
the encoder's state decides on the summary whether the GPU alone runs it, as draws of the one
primitive type it allows. With the residency in another encoder than the kernel's, the GPU alone
ran the kernel's point as a draw of the CPU's triangles, which drew nothing (the previous commit's
lane). The bug is older than the write routes: the summary was per encoder before them too.

What it moves: an execution of a buffer whose command buffer sets, in another encoder than the
one that made the buffer resident, a state that may write what the GPU-alone forms rule out: a
render execution takes the host step where that state may write more than draws of one primitive
type, buffers, resets and cleared barriers; a compute execution in a concurrent encoder orders its
commands where it may set a barrier, and a checked one calls its check where the records may name
a state that may encode. The lanes that made a buffer writable with a state set in an encoder of
its own (indirect_host_steps::encoding_state_set: icb_replay_encode's, which may set pipelines,
dispatch, set threadgroup lengths and barriers) showed it: with it, 6 of the 480 tests of the 40
modules changed (render_merged_executions' GPU forms into a shadowed target took the host step,
6 executions; five dispatch_executions tests saw barriers, check calls and a host step), all
others as before, resident_draws among them (its writer and residency share an encoder: no host
step on its write path, its chunks kept). Those lanes are about the GPU-written path, not about
what the state writes, so the lever now sets icb_reset_encode's state (resets alone, which no
GPU-alone form rules out).

Docs: written_commands.rs and write_routes.rs module docs, IndirectCommandBuffer::command_writes,
render/executions/gpu.rs, the runtime README and docs/API.md section 10.

How verified (debug, --cfg m2v_gpu, M3 Max under MoltenVK): runtime_lane::write_routes passes
(it failed before this commit: After and Before drew no point); the 39 ICB lane modules and
write_routes, 480 tests, pass with the reset lever; the runtime's
tests::write_routes_device::a_route_reaches_every_buffer_its_command_buffer_made_writable (new:
a later encoder's state, one set before the residency, and a parallel encoder's at the commit)
and tests::written_commands pass; clippy -D warnings with --cfg m2v_gpu is clean.

(cherry picked from commit 7d13a4dee21162a972b40fd9868e3e2f9112a677)
(cherry picked from commit 13b9646e48b767defdd189bf156a2a9130b3b857)
2026-11-04 18:50:27 -08:00
Anees Iqbal e924d293c5 Compare against Metal what an execution runs of commands a kernel wrote, by where the command buffer made the buffer resident for writing
What: a new owned fixture, icb_routed_writes, whose kernels write command 0 of an indirect command
buffer: a render command with its state taken from the argument buffer (irw_encode_draw), a
render command of a buffer that inherits the encoder's state, a point at the target's centre
beside the CPU's triangle in command 1 (irw_encode_point), and a compute command with its state
from the argument buffer (irw_encode_dispatch). A Metal probe
(crates/metal2vulkan-conformance/probes/icb_routed_writes.m) and a lane
(runtime_lane::write_routes) run the same four shapes: the buffer made resident for writing in
the kernel's encoder, only in an encoder after it, only in one before it, and nowhere; a later
encoder of the same command buffer executes the buffer.

Why: the marks of a buffer the GPU may write are the command buffer's, while what its records may
hold was gathered per encoder. The lane asks whether an execution runs what the GPU wrote, with the
right state and pixels, wherever the command buffer paired the residency with the writer.

Metal's answers (the probe, M3 Max, macOS 27.0.1, validation off, verified): in the kernel's
encoder, after it and before it, all three kinds ran the kernel's command (green, green, words
0x100 to 0x103). Nowhere: the render command and the point did not run (the CPU's records: red),
the compute command did. docs/API.md records that last difference: no encoder of the command
buffer made the buffer resident for writing, which Metal's contract asks of a function's write,
and the runtime runs the CPU's records there (APART in the lane).

How verified: the lane, debug with --cfg m2v_gpu on the M3 Max under MoltenVK, fails at this
commit, which is the bug the next commit fixes: [(Same, [true, true, true]), (After, [true, false,
true]), (Before, [true, false, true]), (Nowhere, [false, false, false])] against Metal's (with the
compute command apart), the inherited state's executions taking 2, 0, 0 and 0 host steps: with the
residency in another encoder than the kernel's, the GPU alone ran the kernel's point as a draw of
the CPU's triangles, which drew nothing. The render command and the compute command ran right in
every shape.

(cherry picked from commit 25134688d13d1abedab5e3ee5e1ff4c9db442a90)
(cherry picked from commit ba7f047a7987a63a9e1f6fd78ae7093f27326e55)
2026-11-04 18:50:27 -08:00
Anees Iqbal f35128eb43 Mark an indirect command buffer at the call that completes a write route, and let the routes go at the commit
The write routes marked a buffer at its command buffer's commit. An execution's segment is cut
into a part of its own, which waits for the work before it, as it is encoded
(`Segment::host`, from `gpu_written` then), so an execution encoded after the writer in the same
command buffer, in its encoder or a later one, was recorded with the writer's part and ran the
CPU's records: indirect_host_steps' commands_a_kernel_writes_run_after_it and 19 other lanes
drew nothing.

The routes now mark at the call that completes the pair: a write use where a state that may
encode, or an execution whose records may name one, was met in the command buffer; such a state
set, or such an execution encoded, where a write use was. An encoder opens with what its command
buffer's ended encoders met (`Routes::carried`), so a later encoder's execution is encoded as one
the GPU may write, as it was when a write use marked the buffer at its call. The commit still
decides again from what the records name then, and still leaves the followers.

The command buffer's routes held each buffer made resident for writing or executed until the
command buffer itself dropped, past its completion: a released buffer's range and resource ID
stayed taken (indirect_command_buffers' buffer_identifiers_follow_metal_s_encoders,
resource_ids' an_indirect_command_buffer_s_id_is_held_as_metal_holds_it). The commit now clears
them once it decided; what it leaves unmarked is held until completion, as before.

Docs: the gpu_written contract, write_routes.rs, docs/API.md and the runtime README say when.

Verified with the lane commit after this one (debug, --cfg m2v_gpu, this M3 Max on MoltenVK):
the 39 lane modules that execute indirect command buffers, 479 tests, all pass, where B alone
failed 35; the runtime's written_commands, degradation, degradation_catalogue and
degradation_sites unit tests pass; fmt; clippy -D warnings of the runtime and validation crates,
all targets and features, under --cfg m2v_gpu.

(cherry picked from commit e8e85c6936ecc731fa557440033ac9d3e40953e2)
(cherry picked from commit 106af168144e7a76fcc5366e39fec10a3693611c)
(cherry picked from commit 38605155f851abdf697c818c5387c1980af6a0bd)
2026-11-04 18:50:27 -08:00
Anees Iqbal 66c9163ce3 Mark an indirect command buffer written by the GPU only where a route that may write its records meets it
A write residency of an indirect command buffer (useResource:usage: with MTLResourceUsageWrite)
marked it written by the GPU at the call, whatever the encoder's functions could do. Every
execution of it then waited for the work before it and was recorded by a host step, and kept no
chunk. A page whose kernel only counts, with the buffer made resident for writing, paid the host
step every frame (51 to 61% of the write frame in the kept-steps measurement), though no function
of it can reach a record: a function writes records only through an indirect-command operation.

The mark now comes from the routes that can write records (write_routes.rs), decided by
structure alone:
- the commit of a command buffer that made the buffer resident for writing in any of its compute
  or render encoders (residency is the command buffer's) and also set, in any of them, before or
  after, a pipeline state whose functions' indirect_command_writes is not empty (the translator's
  answer from their AIR: the indirect-command operations their bodies may call, every one where a
  body makes a call the translator cannot see into), or executed commands whose records may name
  such a state;
- after a commit that found neither, the first CPU or GPU write that leaves such a state in the
  records of a buffer it executed (the executed buffers hold the commit's unmarked buffers weakly
  until then, released as the command buffer completes; the marks run once the setter let its
  locks go);
- a blit's copy into the buffer or reset of a range in it, at the call, as before.
A heap holds no indirect command buffer and residency sets are refused, so neither is a route.
The mark is for good, as before. It keeps the route that met the buffer first, which the
host-replay notice names: for a state, its functions' names and the kinds of indirect-command
operation they may call; else the route. WorkCounts::indirect_write_residencies_unmarked counts
each commit's write-resident buffers it left unmarked.

The resident_draws fixture gains rd_encode, a kernel that may reset a command and resets none,
regenerated with scripts/regen-air-fixtures; the lane's `encode` path uses it, off the measured
paths.

Docs: the gpu_written contract, the runtime README, docs/API.md (the catalogue's
HostReplayedIndirectCommands trigger and cost, and the contract), the module docs that named the
old rule. api_signatures.tsv blessed (one field).

Verified (debug, --cfg m2v_gpu, this M3 Max on MoltenVK): the resident_draws lane's three tests
pass: a kernel that cannot encode (rd_touch) leaves the buffer unmarked, with no host step in any
of three frames, its two chunks run from the kept recording in the third, one unmarked residency
counted a commit, and the read path's pixels; a kernel that may encode (rd_encode) marks it at the
first commit, a host step every frame, no chunk kept, the same pixels, and the notice names
rd_encode and its reset; every path draws the encoder's pixels. Negative control (neg.py: every
state counted as calling no operation, and no executed buffer's records as naming one): the
encoding test fails (no host step in frame 0), the other passes. The runtime's written_commands
(a new test of the followers), degradation, degradation_catalogue and degradation_sites unit tests
pass. fmt; clippy -D warnings of the runtime and validation crates, all targets and features,
under --cfg m2v_gpu.

(cherry picked from commit 6e1b62a03039dd81a2005afa26a3001de2064110)
(cherry picked from commit 13dac865f4096559a5b97841d893e1da02e160ec)
(cherry picked from commit 862a72c76e82b657ef158ee1c7cbf789240ea745)
2026-11-04 18:50:27 -08:00
Anees Iqbal 968ccc4af0 host_ram: import a window of chunks ahead of the objects, not the whole RAM
What:
- The thread Device::use_host_ram starts now keeps a window of chunks past the one an object
  last took imported (host_ram.rs, Window): one chunk after a take outside the window (and the
  RAM's first chunk before any take), AHEAD_CHUNKS = 4 once a take lands inside it. It never
  imports past the window, never goes back to the RAM's start, and so faults in at most 4
  chunks (256 MiB) that no object took for one take, and at most 1 for a take that starts no
  run. While its window is imported it waits (Wake: a mutex and a condition variable), woken
  when an object takes another chunk or the use ends, holding the device and the RAM only
  weakly, as between chunks before.
- Unchanged: the pacing (SCHED_BATCH, yields, MADV_POPULATE_WRITE in 2 MiB steps), imports with
  the memory lock released, the stop a quarter short of maxMemoryAllocationCount and the
  give-back of untaken chunks.
- Docs: host_ram.rs, Device::use_host_ram, WorkCounts::host_ram_chunks_imported(_ahead),
  docs/HOWTO.md ("One run inside one chunk"), with the numbers below and the burst caveat.

Why: reims-vgpu's time to first present on the RTX 5080 laptop went from 11-12 s to 13.9-86.1 s
with the whole-RAM ahead import, worst at low MemFree, the normal state of a Linux desktop
whose page cache fills memory. Reproduced without a VM (release probe, public API: 16 GiB of
fresh memfd RAM under MADV_HUGEPAGE through use_host_ram, an mmap+munmap sampler, CPU-bound and
bandwidth-bound workers, a toucher faulting its own THP memory, vmstat and PSI):
- The whole-RAM import took 40.4 s at 35.4 GB free with only 21 free 2 MiB blocks, and 57.4 s
  at 17.1 GB free: pgmigrate 4.1-9.1 M pages, PSI memory "full" 6.6-9.6 s, another thread's
  mmap up to 0.96-1.19 s, another thread's 2 MiB faults up to 0.8 s at p99 0.48 s, a CPU-bound
  worker up to 51% slower at p50 and a bandwidth-bound one up to 128%.
- 99% of it is the fault-in of fresh huge pages (direct compaction and reclaim, holding the
  process's memory map lock): per chunk p50 39-123 ms, worst 1.46 s. The import itself (pin and
  vkAllocateMemory) of a resident chunk took 1.7-3.2 ms at p50 (0.56 s for 248 chunks).
- So the thread now faults in only what the objects are about to reach.

Measured on the same laptop (NVIDIA 615.71.09, Linux 7.2), release, one run each, MemFree
1.7-3.0 GB with 82-88 GB of page cache. Pattern: 40 2 MiB heaps at use_host_ram, then 8 bursts
of 128 consecutive heaps (4 chunks) 1 s apart, 2.08 GiB in all, with a toucher writing 1024
2 MiB pages spread over the same RAM (the guest's own faults):
                       ahead  own imports  making max (after the first 40)  PSI full
  adaptive (this)        36        2              26.9 ms                     0.97 s
  fixed 4                36        2              6.6 / 171 ms (2 runs)       0.48 / 0.97 s
  fixed 1                 9       26              372 / 614 ms (2 runs)       2.1 / 2.9 s
  none (no thread)        0       34              544 ms                      1.14 s
  whole RAM (cut at 40 s) 138      2              194 ms                      14.6 s
The 2 own imports are heaps 0 and 32, made as use_host_ram starts. 16 heaps over scattered
chunks, 300 ms apart: chunks faulted ahead adaptive 16, fixed 1 16, fixed 4 38, fixed 16 46;
making p50 adaptive 99 ms, fixed 1 51-60 ms, fixed 4 61-135 ms, fixed 16 160 ms, none 28 ms
(states vary run to run). A window of 8 or 16 bought nothing more for consecutive heaps and
cost more (16: PSI full 1.5 s, guest-fault p99 134 ms). A burst that runs more than 4 chunks
past the last take waits at each chunk past the window, one fault-in each (45-70 ms at p50 in
that state, at worst 0.34 s).

No DevicePolicy switch: this trades speed for speed, and no measurement favoured the whole-RAM
form.

Tests:
- host_ram::tests::a_take_inside_the_window_opens_it_and_one_outside_gives_one_chunk (the rule)
  and ::the_devices_thread_imports_the_window_past_the_last_take_and_no_more (the order: the
  start's one chunk, the window past a take, a held chunk passed, nothing past the window or the
  RAM's end, nothing back after a jump).
- tests::host_ram_device::the_window_ahead_moves_with_the_objects_and_imports_no_more: fresh
  THP RAM of 16 chunks; the first chunk alone before any take; a full window once a heap takes
  it; a run of heaps over the window imports nothing on its own thread; one chunk past a jump;
  a full window again once the run goes on; nothing past the RAM's end; the skipped chunk never
  imported. 14 chunks ahead, 1 by an object, over 259 heap makings, on both devices.
- chunks_are_imported_ahead_so_no_making_waits_for_one and
  the_ahead_thread_leaves_the_allocation_limit_to_the_objects now open the window with a heap
  over the first chunk; the limit test gives back the 3 chunks no object took.

Negative controls (a temporary build with one defect switched on at a time, M3, release,
--cfg m2v_gpu); each test failed as follows:
- whole-RAM order (next_ahead wrapping as before): the order unit test ("none past the start's
  one chunk", Some(1)); the window device test ("the device's thread went on past the window",
  16 chunks).
- a fixed window of 4 for every take: the rule unit test (Window { from: 10, chunks: 4 } after a
  jump); the window device test (13 chunks ahead after the jump).
- the window one slot off: the window device test ("no chunk past it", 6 live).
- no wake when an object takes another chunk: the window device test ("a full window past the
  take", 1).
- no thread: chunks_are_imported_ahead_so_no_making_waits_for_one ("the device's thread
  imported the RAM's first chunk", 0).
- no give-back: the_ahead_thread_leaves_the_allocation_limit_to_the_objects ("the untaken
  chunks went back", 0).
- with no switch, the same binary passes the window device test.

Verified:
- RTX 5080 laptop, release, --cfg m2v_gpu: the host_ram and allocations tests, 30 passed,
  0 failed.
- M3 Max (MoltenVK 1.4.2, macOS 27.0.1), release, --cfg m2v_gpu, under maclock: 28 passed,
  0 failed (the two dma-buf tests are Linux-only).
- cargo clippy --workspace --all-targets --all-features -D warnings, plain and with
  --cfg m2v_gpu; cargo doc -p metal2vulkan-runtime with -D warnings.

(cherry picked from commit 6d72e50ebb7d52e195fea5062bfed989af2877d4)
2026-11-03 17:44:41 -08:00
Anees Iqbal de2b62a868 Check a plain event's waiting command buffer at once, its wait on the VkQueue
What: `landing_waits`, the waits a checked head's submission checks wait to land, now skips
every wait that `EventShared::wait` answers. A plain event's wait for a signal submitted or
reserved before the batch therefore holds no check. The check runs as soon as the batch is
otherwise ready (on the scheduler's thread, or via `claim_check` on a committing thread in
commit_and_submit), and the batch goes with its wait on the VkQueue, as an unchecked batch's
does. A shared event's wait still holds the check until its value is reached, because
`EventTimeline::wait` answers none for it while the host may set the value. So does a plain
event's wait for a signal behind a merge.

Why: reims's 5080 decode path saw no gain from a plain Event, because their platform checks
every command buffer and the checked head was held until the signal landed. The conformance
case event-wait-behind-a-running-signal (previous commit) measured Metal on the M3 Max (macOS
27.0.1): a command buffer whose MTLEvent wait only a still-running signal meets is Scheduled at
once, so it is submitted and checked at once. One whose MTLSharedEvent wait such a signal meets
stays Committed until the signal lands. The old rule was Metal's for the shared event only.

Docs: checks.rs "When." states the split and cites the case. The runtime README
(set_submission_check, commit_and_submit) and RUNTIME-PORTING (the same two rows) say the same.
docs/API.md states no such rule, so it is unchanged.

Lane tests (runtime_lane::submission_checks):
- an_event_wait_a_gpu_signal_in_flight_meets_is_checked_at_once (new). In one try the waiter
  reads Scheduled while the signaller's companion event still reads 0, and the companion read 0
  inside its check. In every try `heads_awaiting_check_signals` does not move, the check runs
  once, and the fill runs. This holds both for a waiter committed before the signaller and for
  one committed with commit_and_submit while the signal is in flight.
- a_submission_detached_while_a_gpu_signal_is_in_flight_fails now covers the SharedEvent alone,
  and asserts that `heads_awaiting_check_signals` counts the held head.

Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, through maclock and memcap 12288:
124 passed. That covers the runtime's event, interop, reserved-queue, semaphore, check and
scheduler tests, and the lanes runtime_lane::submission_checks, events, event_round_trips,
command_queues and failed_commits. Caught with 8 and 4 fills of 64 MiB (plain), and 8 and 4
(shared).

Negative control: `landing_waits` without the skip (the old hold). The new test failed with "at
commit false: a head awaited its checks' signals", left 2, right 0. The shared test still
passed. Restored and touched.

(cherry picked from commit 3751927c29cee4a1dcbeb9786120245119a328a1)
2026-11-03 16:16:40 -08:00
Anees Iqbal 9e698176bc Record what Metal does with a wait whose signal is already running
What: a conformance case, event-wait-behind-a-running-signal, in the event_orders family, with
two rows, one for MTLEvent and one for MTLSharedEvent. Queue A's command buffer runs 192 fills
of 256 MiB into a private buffer, then signals a companion shared event at 1, then the event
under test at 1. Queue B's command buffer waits for the event at 1, then fills 256 shared bytes.
A is committed, then B. RUNNING_WINDOW (20 ms) later the case reads B's status and handlers,
the shared event's value, A's status, and last the companion. A companion still at 0 proves the
signal had not landed by any of those reads, since one command buffer's signals land in order.
A run whose companion reads 1 records only that fact, so it differs from an answer rather than
passing as one. B's Scheduled status is the proxy for "submitted, and so checked"; the case's
docs say so.

Why: reims's platform sets a submission check on every command buffer, and the runtime holds a
checked head until each value it waits for has landed. checks.rs justified that with "Metal
submits the submission, and checks it, once the signal happened", which nothing had measured.
event-cross-queue-wait reads a waiter only while its signaller is not yet committed, and
event-held-command-buffer only while only the host can raise the event.

Metal's answer, recorded on the M3 Max (macOS 27.0.1): 5 of 5 runs identical, and the
validated leg ran.
- MTLEvent: B reads Scheduled with its scheduled handler run while A still reads Scheduled and
  the companion reads 0. Metal submits it at once, with the wait on the GPU.
- MTLSharedEvent: B reads Committed with no handler run, signaledValue 0, A Scheduled. Metal
  holds it until the signal lands.

The fills measured 156 to 163 ms of GPU time on the M3 Max (a throwaway Metal probe,
GPUEndTime less GPUStartTime, three runs), so the read falls about eight windows before the
signal.

Our side replays divergent on the M3 (MoltenVK) on the plain row: B still reads Committed at
20 ms. A's vkQueueSubmit takes 10 to 27 ms there, in MoltenVK's encoding of our fills by
transfers. A later commit reduces that.

(cherry picked from commit 2efae5489b87b0c37603d1c5e7b51a5222a49414)
2026-11-03 16:16:40 -08:00
Anees Iqbal 289af45922 Give the shadow runs' RTX 5080 Laptop times again, measured with the in-place first pass
The previous commit removed the RTX 5080 Laptop numbers from docs/FAST-PATHS.md because they
described the earlier form of the runs. They are measured again here, with the in-place first
pass and the second keep.

Verified on msi-laptop (RTX 5080 Laptop GPU, NVIDIA 615.71.09), under an exclusive GPU hold with
no VM running. Release builds of the 700-pass probe were made at 36c3063e16 (tip) and at
2bc0f1eac6 (fix), and run interleaved, three processes each. The times are commit to completion
of the second to fourth command buffers of each process:

- passes back to back: fix 6.5-9.1 ms, tip 6.3-9.0 ms;
- with an empty 1x1 encoder between every two passes: fix 9.3-12.2 ms, tip 9.1-12.7 ms.

The fix took 5 shadow copies and kept 2,097,152 texels in every run; the tip took 3 and kept
1,048,576. The figures for the build without runs (40.6-43.0 ms and 44.5-47.1 ms) are the ones
the row already gave.

(cherry picked from commit fa2b1b354d818fd4a373fb5af7ba1c5dd44ce21c)
(cherry picked from commit 8674db962402c9c425765fe0c8430f1383edd6ff)
2026-11-03 15:58:55 -08:00
Anees Iqbal 4bfeb66cd9 Merge a shadowed texture's pass in place until a second pass goes on from it
A shadowed texture's pass that opened a run left its merge to its batch's submission
(`Deferred::RunMerge`). That splits its encoder's commands into a continuation VkCommandBuffer and
records a segment of batch work at the submission. A pass that no later pass goes on from paid for
this and saved nothing. The conformance cases rotated-planes-load-0-64x16 and -32x32, one such pass
each, measured alone on the M3 Max: command_buffers_begun 3 -> 6, command_buffers_submitted 2 -> 5,
submit_infos 1 -> 2, end_command_buffer 3 -> 6, encoder_command_buffers_begun 2 -> 3, batch work
1 -> 2, and one batch barrier and one continuation that the recordings do not have. Reverting the
shadow runs alone restored the recorded counts; reverting the twin-shadow fix changed nothing.

Now the pass that would open a run merges in place as its encoder ends, as a pass alone does, and
only marks where a run may start (`PassRuns::placed`). The pass after it opens the run
(`Joined::Placed`): its image is carried, with no copy in, and it keeps the texture again.

The second keep is required. A run's merge compares its keep with the image its last pass left,
byte by byte, and a byte equal in both keeps the buffer's byte. A first attempt went on over the
in-place pass's keep instead. Bytes that the later passes changed and changed back then kept the
in-place merge's value, and the byte comparisons failed:
- tests::shadow_runs::runs_over_host_pages: 1,176 bytes;
- tests::merge_scratch's passes over host pages;
- the validation lane's many_passes_over_host_pages tests.
So a run of k >= 2 passes costs two keeps, two merges and k - 1 continuations, and a lone pass
costs nothing extra.

Verified on the M3 Max (MoltenVK 1.4.2, --cfg m2v_gpu):
- `conformance cost --runs 8 --alone --show` for both rotated-planes cases: every count that rose
  equals the recording again. The four counts that differ alone from the whole-set measurement
  (command_buffers_deferred, cmd_push_constants, device_memory_allocated,
  queues_sharing_a_vk_queue) also differ with the shadow runs reverted.
- New test tests::shadow_runs::a_pass_alone_merges_in_place. A pass alone: 0 continuations,
  3 shadow copies. Three passes: 2 continuations, 5 copies. The bytes equal a private texture's.
  Negative controls:
  - with the in-place path disabled, it fails at (1, 1, 3);
  - with the pass after a marker opening the run without a keep (`Joined::Opens`), it fails at
    (3, 0, 7).
- tests::shadow_runs and tests::merge_scratch, 10 of 10, with updated counts:
  - runs_over_host_pages: 32 copies, 14,680,064 texels kept;
  - the scissored passes keep at [0, 1, 2];
  - the rebind encodes 4 passes again.
- The runtime's shadow, merge, linear, rebind, re-encode and replay tests: 155 of 155.
- The validation lane's shadow, padded, linear, rotated and surface tests: 145 of 145.
- The 700-pass probe now takes 5 shadow copies and keeps 2,097,152 texels (3 and 1,048,576
  before). Release builds of this tree and of its parent, interleaved, three processes each, the
  second to fourth command buffers: commit to completion was 32.7-35.6 ms against the parent's
  31.6-36.1 ms, and with an empty encoder between every two passes, 61.5-67.2 ms against
  60.4-67.0 ms.

docs/FAST-PATHS.md gives the new counts and the M3 times. The RTX 5080 Laptop numbers are removed:
they described the previous form, and that host was running VMs, so they were not measured again.

(cherry picked from commit 2bc0f1eac676dcc86dadfbd37a81313977515d45)
(cherry picked from commit 55c7f307a92c67125d31b08c33b3f91c7d14a67b)
2026-11-03 15:58:54 -08:00
Anees Iqbal 241ee2c0d1 Keep and merge a run of passes over one shadowed texture once, not once a pass
What: a render pass whose color is a shadowed texture merged back (its truth a buffer's bytes
another writer may write, such as a no-copy buffer's host pages or a Shared buffer's), loaded and
stored, now joins a run of passes (pass_runs.rs) where it may. The run's first pass copies in (or
takes the carried image) and keeps, as before. Each later pass goes on over the image the pass
before it left (ShadowSync::go_on) and keeps nothing. Each pass leaves its merge to its batch's
submission (Deferred::RunMerge, RunWork::Shadow), and the run's next pass takes it over, so the
merge recorded is the last pass's, compared against the first keep. The run holds the keep's
scratch or kept image (RunHeld::Shadow, its MergeLease) until it ends or the command buffer
commits.

Why: consecutive render passes over one merged-back shadowed texture each copied in, kept and
merged the whole texture. 700 one-rectangle passes over a 1024x1024 BGRA8Unorm texture over host
pages took 1,401 shadow copies and 700 merges.

The rule, structural, with no names: a run ends wherever something other than its own passes
could observe or change the bytes, as in the linear runs' list:
- any encoder between its passes that is not a render encoder;
- a render encoder that names the bytes' buffer or its host range, reaches memory it does not
  name, fences, resolves, writes visibility results, records later or renders over a rate map;
- a render encoder with an attachment over those bytes, or whose draws or attachments take a
  shadowed texture over them (the run's own texture bound to a draw included);
- a signal, a wait or a host step (a new batch), and the command buffer's end;
- for a shadow, the encoder no longer carrying the image (the carry dropped).
A shadowed color joins only when it is loaded and stored, has no stand-in and no planes, belongs
to a pass of one render pass instance that is not inline and not inside a predicated laying, is
laid out as one image's texels at level 0 and slice 0, and merges back.

Encoded again: unlike a linear attachment's run, a shadowed texture's run may hold passes over
host pages, which a rebind before the first submission encodes again. Such a pass leaves its run
(RunMerge::leave). The merge it took over records after all (given back), and the pass copies in,
keeps and merges for itself. Where a later pass took its merge over, it keeps the run's scratch
again after its own merge (RunMerge::keep_after), so that later pass's run merges what the passes
after it change. Run segments now record again (Segment::records_again) and splice. An encoder
encoded again takes no pooled scratch or kept image (ShadowMerge::new's `lent`). A run's merge is
resolved at its calls (Deferred::resolved_at_its_calls), so it holds no host pages past commit;
before this, a rebind of such a run was refused with Rebind(EncodedUses).

Two more changes. A run's keep that a later pass writes outside merges and keeps every texel next,
and a run's pass that needs texels the copy-in did not hold copies every texel in. A merge in whole
blocks stays in blocks where the keep holds the pass's area (stores_blocks), under the same
read-to-store window that shadow.rs's Stored attachments already state.

Counted with the existing counters: shadow_copies, shadow_texels_kept and
shadow_merge_dispatches_planned fall from one per pass to one per run. docs/FAST-PATHS.md records
the run and its costs.

Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under maclock and memcap:
- tests::shadow_runs (new, all pass):
  - runs_over_host_pages_keep_and_merge_once: 1024x1024 BGRA8Unorm over host pages, rows of 15360
    bytes, with blits, foreign render encoders, reads, CPU byte writes, a signal and an aliasing
    view between runs. Mid-sequence and final reads match a private texture byte for byte, and
    the padding is untouched. Joined: 22 copies, 9 merges. Apart: 112 copies, 54 merges.
  - rebound_passes_leave_their_runs: 3 encoders encoded again, 0 refused, bytes equal.
  - scissored_runs_keep_again_once_and_merge_in_blocks: keeps at passes [0, 1], all in blocks.
- Runtime suites (shadow, merge_scratch, linear_runs): 69 of 69 passed.
- Validation runtime_lane (shadow, padded, linear): 91 of 91 passed.
- Negative controls, each a sabotaged build, source restored and touched after; each fails:
  - go_on off: every pass keeps;
  - follows across encoders: keeps [D0, D8, D9, D10, A11, D12];
  - leave off: 961,469 bytes differ;
  - stores_blocks reverted: every scissored pass keeps.
- Release probe, 700 passes in one command buffer, base a543f6428d against this commit: shadow
  copies 3 against 1,401, texels kept 1,048,576 against 734,003,200, merges planned 1 against 700.
  Commit to completion, runs 1-3: 31.6-35.3 ms against 69.3-99.9 ms. With a 1x1 render encoder
  between every two: 61.6-65.0 ms against 107.4-118.6 ms.
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09), the same probe, runs 1-3: 6.6-10.0 ms against
40.6-43.0 ms, and 9.7-12.3 ms against 44.5-47.1 ms. The same 11 shadow, merge and linear device
tests passed there.
clippy --all-targets --all-features -D warnings passed plain and with --cfg m2v_gpu, and cargo fmt
was run.

(cherry picked from commit bf783428131f46c7289518a50b8505e809ecc8e5)
(cherry picked from commit 99949a4cd08cd042e448484e0b1d2f5da1898db5)
2026-11-03 15:58:53 -08:00
Anees Iqbal 385a2ed40f Record host steps on up to eight threads, so one queue's long step holds back no other queue's
What: scheduler/steps.rs had one thread per device record every host step of every queue, in
hand-over order. It now hands each step to a free thread of a pool, or starts one for it below
THREADS (8); past the cap a step waits for the first thread free, in hand-over order. The first
thread stays until the scheduler stops, as the one thread did; each later one ends after 2 s with
no step. All start at the user-interactive class, each step is still a section of the exit guard,
and where the host cannot start the first thread the scheduler's thread records the step itself,
as before.

Why: the consumer (one device for every guest process) saw WindowServer's present wait 13.6 s in
the host after the page's context had closed. A page's render-bundle ICB execution was recording
a seconds-long host step, and any command buffer whose draw or dispatch has a pipeline still
being made takes a host step too (deferred.rs: RenderPass with making(), Pending), which queued
behind the page's on the one thread. A dead context's step keeps recording, as its command buffer
holds what it uses.

Order is still the scheduler's: only a line's head is handed over, marked stepping until its step
ends, so a logical queue's steps are recorded one at a time in its order, and a head that waits
for an event value, or is behind an earlier commit's conflicting batch (order.rs), is not gated
or handed over (gate_heads takes `behind`).

Audit of what assumed one step at a time device-wide:
- kept chunks (kept_commands.rs): no host step uses them (render executions keep only when
  !step, compute executions only when states.is_none());
- upload and descriptor arenas: per command buffer (State::uploads, State::descriptors); their
  spares are the device's, under a lock; the command pool is per command buffer, recorded under
  its `reencoding` turn, which host_step takes;
- pipeline making: the pool, the budget's turns and the making maps already serve concurrent
  encoders; the in_host_step()-gated branches (Urgency::HostStep, keep_room skipped, kept
  variants not taken back, takes_multi_variable_dynamic, make_at_creation skipped, sampler-set
  count) read a thread-local, so they hold per thread; kept.rs StepNumbers is thread-local and
  per command buffer, whose steps stay sequential, `made` handed on through end_step and the
  scheduler's locks;
- residency: a command buffer's own value, its address index made per residency;
- the scheduler's wake and hand-over: record() marks the inbox under its lock and wakes, as a
  committing thread does; begin_step/end_step are the command buffer's atomics; post pushes
  under the steps' lock;
- the exit guard: sections are counted per thread and in atomics, HOST_STEPS is thread-local,
  called() is atomic; many sections at once were already normal;
- interior mutability used by the steps thread alone: none besides the steps' own state (every
  shared object is Sync and shared with committing threads already);
- notices: every-occurrence notices announced inside steps (each_in_order) of two queues may now
  interleave; Metal orders nothing between such queues.

Docs: the scheduler's "Host steps" section, left.rs, WorkCounts' host-step counters, kept.rs,
RecordsRead::HostStep and FAST-PATHS.md's pipeline-wait row say steps' threads. The
host-replayed-indirect-commands notice already says only resources the execution may reach hold
later batches back, so it is unchanged.

Verified on the M3 Max (MoltenVK, --cfg m2v_gpu, maclock+memcap), with the next commit's lane
test runtime_lane::steps_apart::another_queue_goes_on_while_a_host_step_records: before, queue
B's own stepped command buffer did not complete within 10 s while queue A's step was held (A's
objects kept, and released); after, 18.6 / 18.9 ms in debug. Its ordered checks (a step after
an event A signals, and a pass into A's target) begin only after A's step ends, before and after.
Negative control: THREADS = 1 fails the test again (Stepped, kept and released); restored and
touched. Release, A a real 5000-draw step (2.7 to 5.0 s), B's stepped kind went from 3580 ms
(released: 3359) to p50 1.49 / max 15.6 ms (released: 1.65 / 40.4); idle 1.32 ms p50.
Runtime tests::(scheduler|inbox|host_step|waiter_submits|commit_and_submit|completion_order|
unsubmitted|pipeline_wait_order|blit_order): 50 passed. Lane cases (indirect, kept,
*executions, *host_steps, submi*, steps_apart, resident_draws, event_round_trips,
command_queues): 272 passed. clippy --workspace --all-targets --all-features -D warnings, plain
and with --cfg m2v_gpu: clean.

(cherry picked from commit e15fd6752fe4f714b73dab0ee72d15fce686f3d7)
(cherry picked from commit 229f407b2abe2de5b85bf3d98b2080d0a0667e9d)
2026-11-03 13:34:03 -08:00
Anees Iqbal f6692d84e5 Keep an ICB execution's chunks where its check can see nothing among its commands
Before, any execution given a check (execute_commands_in_buffer_checked) recorded every command at
every commit and kept no chunk, even when the check's needs ruled out everything the buffer's
records may hold. In that case commit never calls the check: RenderExecution::check_sees and
Execute::check_sees answer from the needs and IndirectCommandBuffer::command_writes. A consumer
that hands every execution of own-state commands a check for draws of points, and draws
triangles, never had its unchanged commands run from kept recordings.

Now RenderExecution::keeping declines where `self.check_sees_now()` holds, and Execute::keeping
where `self.check_sees()` holds. The decision is the structural one commit makes for the check,
the check's needs against what the records may hold. When a later write makes the records hold
something the check looks for, it forgets the chunks it reaches. At the next execution
check_sees is true, so keeping declines and the execution records inline, calling the check with
every command.

Docs: the "Which executions" lists in render/executions/kept.rs and indirect_execute/kept.rs, and
docs/FAST-PATHS.md's kept-recordings row.

Tests (runtime_lane::kept_commands), counting records read, chunks and commands kept and
contexts made (WorkCounts::indirect_chunks_kept and kept_contexts_made show the kept path ran),
and the commands the check was called with:
- a_checked_execution_keeps_where_its_check_sees_nothing (render). With needs for states that
  may encode indirect commands, which the inherited state can't, the check sees nothing:
  [N, 0, 0, 0], then [N, 0, 0, 3], then [0, 3, N, 0], and the check is called 0 times. With
  needs for draws of points, which the records hold, the check sees: [N, 0, 0, 0] three times,
  and the check is called with all 3N commands.
- a_checked_compute_execution_keeps_where_its_check_sees_nothing: a compute execution checked for
  every kind. Its records hold no draw and no state that may encode, so it keeps as above, and
  the check is called 0 times. No fixture kernel encodes indirect commands, so compute has no
  "check sees" leg.

Verified on the M3 Max, debug (--cfg m2v_gpu), on lane 7583fe5d99 with the first-execution ruling
cherry-picked beneath it:
- nextest -j 8 over every runtime_lane module that executes an indirect command buffer: 39
  modules, 473 tests, all pass.
- Negative control: keep only with no check at all (the condition before). Both new tests fail
  at "the second records three chunks to keep" ([600, 0, 0, 0] where [600, 0, 0, 3] is expected).
- Negative control: keep whatever the check (render). The render test fails at "a check that sees
  keeps nothing" ([0, 3, 600, 0] where [600, 0, 0, 0] is expected).
- fmt --check, clippy -D warnings (runtime and validation, all targets and features, m2v_gpu),
  metal2vulkan tests::fast_paths 19/19.

Needs a RUNTIME_VERSION bump. No SEMANTICS_VERSION: no translated module changes.

(cherry picked from commit d75cb04ac8ed9d4616b10aa13d26af869a32d405)
(cherry picked from commit efafed587dd062f7d87bd9c9868ccb035e9ddc26)
2026-11-03 13:34:03 -08:00
Anees Iqbal 24dc3f20bb Keep an ICB range's chunks from their second execution, and forget a written chunk in one store
A range's first execution no longer pays for keeping. Before, every execution of CPU-encoded
commands recorded each 256-command chunk apart, in a KeptContext of its own (a command pool, a
descriptor arena and uploads), so it could run that recording again later, even when no later
execution came. Now a chunk is recorded to keep only from its second execution with no write
reaching it since. The first execution since a write records inline, as before 922caf3199, and
keeps nothing. A consumer that re-encodes every command each frame now pays nothing for keeping.

- kept_commands.rs: KeptChunks notes which chunks an execution that may keep its commands ran
  since a write last reached them. look_up answers each chunk of a range as Kept::Recording (a
  kept recording), Kept::Again (run before, nothing kept) or Kept::First, and notes each as run.
  IndirectCommandBuffer::kept_chunks answers None, so the execution records inline, when every
  chunk is First. When some chunks are kept and others are not, a First chunk records apart from
  its command buffer's own pool and arenas, with no KeptContext, and is not kept. An Again chunk
  records apart in a KeptContext and is kept.
- KeptChunks is dense: one ChunkState per chunk (kept recording, stepped, seen) up to the
  furthest chunk looked up, plus a flag for whether any chunk holds a state. KeptChunks::wrote
  costs one store per chunk the written range covers, whatever the number of kept chunks, and
  returns at once while no chunk holds a state. Before, it ran BTreeMap/BTreeSet::retain over
  every kept and stepped chunk on each setter call.
- WorkCounts::kept_contexts_made counts the KeptContexts made (api_signatures.tsv).
- Docs: kept_commands.rs, render/executions/kept.rs, indirect_execute/kept.rs and
  docs/FAST-PATHS.md (the kept-recordings row).
- examples/icb_setters.rs --kept now executes three times before each repetition: the first
  keeps nothing, the second records every chunk to keep, and the third runs all of them from
  those recordings.

Tests:
- runtime_lane::kept_commands asserts kept_contexts_made beside the records read and the chunks
  and commands kept.
  - A once-executed range makes no context: [N, 0, 0, 0].
  - Its second execution keeps every chunk: [N, 0, 0, 3].
  - Its third runs them: [0, 3, N, 0].
  - After a write, the written chunk records inline again and the next execution keeps it.
- kept_commands::tests::a_write_costs_the_chunks_it_covers asserts the count of chunk states
  wrote() looks at.

Verified on the M3 Max:
- Debug device lanes (--cfg m2v_gpu, nextest), with the live compute flags fix from stack22
  applied locally (not part of this commit): every runtime_lane module that executes an indirect
  command buffer (39 modules, 471 tests) pass.
- Negative control for the ruling (each chunk keeps from its first execution), debug:
  3 of the 5 kept_commands tests fail, a first execution making 3 contexts where 0 are expected
  and a written chunk making 2.
- Negative control for wrote() (it walks every chunk state): a_write_costs_the_chunks_it_covers
  fails, looking at 1000 states where 1 is expected.
- Unit tests: kept_commands::tests 2/2 and metal2vulkan tests::fast_paths 19/19.
- cargo fmt --check and clippy -D warnings (runtime and validation, all targets and features,
  --cfg m2v_gpu) are clean.
- icb_setters compute --kept (release, instructions per command, median of 30, two runs each):

  | | before (2c542021bf) | after |
  |---|---|---|
  | compute command, nothing kept | 2528.7 / 2529.1 | 2428.1 / 2427.7 |
  | compute command, 64 chunks kept | 5947.8 / 5945.5 | 2586.5 / 2583.9 |
  | set_kernel_buffer, 64 chunks kept | 1129.6 / 1129.6 | 456.9 / 456.3 |

  With three executions, the third runs all 64 chunks from kept recordings (the
  bench prints [64]), at 2583.9 and 456.3 instructions.
- conformance cost --alone indirect-render-commands-inherited-state reads arena_pools_made 1,
  argument_objects_retained 2 and argument_tables_retained 1, the recorded bounds. With a first
  execution's KeptContext these read 3, 6 and 3 (the cost run that held its record back).
- execution_costs (release) on a loaded host: wall times are dominated by host load. An earlier
  pair of runs read the first execution as slower (render n=1024 all re-encoded commit 2.88 to
  6.55 ms), but the parent then read 6.55 ms itself under the same load. Time Profiler, test
  thread CPU, same case and count, this change on 2b55ab415e against its parent:
  - render n=1024 one re-encoded, 300 executions: 611 to 610 ms;
  - compute n=1024 all re-encoded, 80 executions: 336 to 333 ms;
  - render n=1024 all re-encoded, 120 executions: 782 to 859 ms. This is the inline path's
    whole-range read: RenderExecution::commands collects the range into a second
    Vec<Option<Command>> (memmove 0 to 25 ms in RenderExecution::record), and render_records
    reallocates as it grows. The same profile has IndirectCommandBuffer::edit, whose code is
    the same in both builds, up 31 to 40 ms, so part of the difference is load.
  A later run of this commit's tree read render n=1024 all re-encoded at 2.37 ms commit, one re-encoded
  at 0.61 ms, and compute n=1024 all re-encoded at 3.49 ms.

Needs a RUNTIME_VERSION bump. No SEMANTICS_VERSION: no translated module changes.

(cherry picked from commit a54756c6a4f7fbe9ae82d732e8de46a19f4f86e5)
(cherry picked from commit 71e798c081648ea3818abbffc7538a3061456c75)
2026-11-03 13:34:02 -08:00