Commit Graph
141 Commits
Author SHA1 Message Date
Anees Iqbal c944d63548 matrix: a leg whose suite never reported fails
A job that printed a leg's device lines and was then killed before the leg's M2V-SUITE line ran
nothing of that leg, yet the leg was judged on its other suites: on 248d41074f the 3090 and the
UHD 630 read PASS on their harness suites alone while their rt jobs (m3-max-40768, 40800) had
been killed for RAM. Such a leg now fails with the job and its exit.

Verified: the script parses; the next matrix run on development's tip exercises it.
2026-11-17 06:45:22 -08:00
Anees Iqbal 248cee5cbf matrix: a job killed over its RAM runs once more, sized from that kill
Jobs are sized from their last measured runs: 1.3x the peak, at least 2 GiB. On 248d41074f
the held workspaces sat at a commit the tip does not descend from, so the GPU legs got fresh
ones, and the rt jobs on ms01 (m3-max-40768) and the Windows host (m3-max-40800) went over
their 2 GiB in their first two seconds (potluck why: over memory, 2 GiB and 2.1 GiB of 2) and
lost their legs. Such a job now runs once more with the room its kill gives it (1.5x), and the
leg is judged on that run.

Verified: the script parses; exercised by the next matrix --legs rerun on 248d41074f.
2026-11-17 06:35:58 -08:00
Anees Iqbal 248d41074f matrix: a run of some legs is timed against the note's other GPUs; untested suites show their exit
The cross-GPU time rule took its median from the run's own GPU legs, so `run --legs` of one GPU
had fewer than three and never judged time. The median now takes every GPU leg of the sha's
note, with each leg's base, and only the legs of this run are judged.

The harness suite counts no tests, so its verdict read "harness 0/0"; a suite that ran no test
now shows its exit code.

Verified: unittest of scripts/matrix passes; `show 73e0af4b66` prints the new form.
2026-11-17 06:19:58 -08:00
Anees Iqbal c8321149f7 matrix: a job kind's default minutes stay its timeout floor
The timeout was 1.5x the longest of the kind's last three runs, at least 5 minutes. A held
workspace makes most builds incremental (the msi build of 793a1f7980 took 1.8 minutes), so the
next build was given 5 minutes, which a full rebuild after a translator change would overrun and
waste the run. The kind's default (build 30, Windows build 60, lavapipe 60, GPU 15, timing 20
minutes) is now the floor; measured runs only raise it.

Verified: the script parses; unittest of scripts/matrix passes. The sizing itself runs on the
next matrix run.
2026-11-17 06:19:58 -08:00
Anees Iqbal 6a5e230514 matrix: the harness's timed workloads per GPU in an exclusive job; time records in microseconds 2026-11-17 06:19:58 -08:00
Anees Iqbal bb30a0b040 matrix: a GPU job prunes carry mirrors left by jobs that never ran 2026-11-17 06:19:58 -08:00
Anees Iqbal 391cc679e7 matrix: a chain's own failure fails its legs; no stats for a job that never started 2026-11-17 06:19:57 -08:00
Anees Iqbal aaa6350ee6 matrix: record the driver version; read dispatch errors from the reply 2026-11-17 06:19:57 -08:00
Anees Iqbal b4b22c7b2c matrix: the per-commit matrix runner and the user-space instruction counter (WIP) 2026-11-17 06:19:57 -08:00
Anees Iqbal 374e29a988 metal2vulkan-rt: the floor's shader features, queue family, timestamps and memory types
The floor now also requires what the translator's shaders and the runtime's
core need of every device:

- shaderInt16, shaderInt8, storageBuffer16BitAccess (Vulkan 1.1 features,
  now read and enabled through Features::vulkan11), storageBuffer8BitAccess,
  scalarBlockLayout, vulkanMemoryModel and vulkanMemoryModelDeviceScope. The
  translator emits 8- and 16-bit access only in storage and physical storage
  buffers in practice (uniform views are u32 or uvec4, push fields are 32- or
  64-bit), so the uniform and push-constant 8/16-bit features stay out; it
  does use device scope.
- timestampComputeAndGraphics, and timestampValidBits of at least 36 on the
  first queue family with graphics and compute, which Capabilities names
  (queue_family). A device with no such family is Missing::QueueFamily.
- a host-visible, host-coherent, host-cached memory type (Shared storage)
  and a device-local, host-visible, host-coherent one (the parameter ring),
  each usable by a buffer of BUFFER_USAGE: every Vulkan 1.3 buffer usage plus
  device addresses. Vulkan answers buffer memory types only for a created
  device, so check() finds a type with each set of flags and carries the
  memory properties, and memory_types(device, &capabilities) chooses the
  first usable type of each with vkGetDeviceBufferMemoryRequirements.
  Missing::MemoryType names the flags.

Each shortfall is named in BelowFloor, with a unit case; the README's Floor
section states every item and tests::floor holds it to the code. The device
test now also creates each device with the floor's features and extensions
and chooses its memory types on it.

CI's lavapipe step (ci.yml and scripts/linux-gate-ci) runs the rt crate's
device tests too. refusal_surface.py reads metal2vulkan-rt and writes the
floor's Missing as section 10 of docs/REFUSALS.md; signatures.py pins
metal2vulkan-rt's public surface in api_signatures.tsv.

Verified: see the lane report (compile job, device legs on every lab GPU,
lavapipe and the Windows UHD 630).
2026-11-17 05:33:25 -08:00
Anees Iqbal bcd50aba9f C3 venues: the Iris venue allows the RPL-P alone, which its translation key names
Iris venue: allow the RPL-P alone; the RPL-S derives another translation key

Since SEMANTICS 2128 DriverWorkaround::PushReadsLengthenThreadPayload is keyed on the Iris Xe of
RPL-P (8086:a7a0) alone, where it was measured. The UHD Graphics 770 of RPL-S, which the
intel-irisxe-rplp-anv venue also allowed, has a capture that differs from the RPL-P's only in
maxMemoryAllocationSize, but its derived profile does not take the workaround, so its translation
key differs. Venues::check_profiles refuses that, and every test that loads the committed venue
list failed, among them candidate::engine::guards::tests::no_venue_runs_a_guarded_target_under_
robustness_1_alone, the c3 venue tests and the two-device profile test.

The RPL-S leaves the venue: translation tells the two apart, and no cluster host has an RPL-S to
record a venue of its own. Its capture stays committed (other tests read it as a device profile).

- c3-venues.json: the Iris venue's devices are the RPL-P alone.
- c3::tests: the venue allows the RPL-P alone; pushing the RPL-S with its own capture is refused
  as a device that derives another key and needs a venue of its own; the RPL-P's capture under
  the RPL-S's identity is refused as another device's.
- candidate::platform::profiles::tests::the_intel_venue_allows_the_rplp_alone_and_stops_the_rpls
  (was one_intel_venue_allows_both_devices_and_stops_any_other): the captures still differ only
  in maxMemoryAllocationSize, the workaround is the RPL-P's and not the RPL-S's, the keys differ,
  and the venue runs the RPL-P and stops the RPL-S on its name, device ID and driver build.
- c3/venues.rs docs and the regen script's comment say so.

Verified: cargo fmt; built and tested in the next potluck job.

Iris venue tests: the RPL-S also stops on its key and allocation size; six venue devices

The venue no longer allows the RPL-S (51c031e187), so its check against the
RPL-P's venue reports, past its four identity differences, its own
translation key and its host's maxMemoryAllocationSize; and the venues allow
six devices, not seven. Both tests now say so.

Verified: cargo fmt; clippy and the c3/candidate tests run as a potluck job.

Iris venue tests: the venues that present the requirements documents no longer list the RPL-S

The RPL-S is no venue device since 51c031e187, so the presented-on lists of
lunarg-desktop-baseline-2023 and roadmap-2022 drop it.

Verified: cargo fmt; clippy and the c3/candidate tests run as a potluck job.

Fix for development's red since SEMANTICS 2128 (d3b1dbdbe0): DriverWorkaround::PushReadsLengthenThreadPayload is keyed on the RPL-P (8086:a7a0) alone, so the RPL-S capture's derived profile takes another translation key, and every test that loads the committed venues failed (c3::tests x6, guards::no_venue_runs_a_guarded_target_under_robustness_1_alone, profiles::tests x2, integration authored_compile_census and private_corpus_root). Verified (m3-max-34762, msi, at b5d745e599): validation clippy --all-targets --all-features 0; c3:: + candidate:: tests 270/270.
2026-11-15 19:37:36 -08:00
Anees Iqbal aa5511f61e SEMANTICS 2130 / RUNTIME 2406: 16x16x16 simdgroup matrix products: refused as their own feature, Metal's rule below Apple10
What: `air.simdgroup_matrix_16x16x16_[widening_]multiply_accumulate` is now refused in every stage
as `Unsupported{SimdgroupMatrix16x16x16, NotImplemented}` (a new `Feature`), ahead of the 8x8
lowering's kernel-only check. The runtime's `compile_error` answers it as Metal does:
`Needs::MetalGpuFamily(1010)` on a device that does not claim Apple10, `NotImplemented` on one
that does (as `IndirectRenderState`). The owned fixture engine/simd_matrix16 shrinks to one form
per class (float, half, widening signed int8), each with the four transpose-flag pairs, 12
kernels; the probe carries the M3's answer in its header.

Why: Metal itself refuses these products below Apple10. The M3 Max (macOS 27.0.1) refused every
pipeline of the fixture at creation, AGXMetalG15X_M1 code 3, "simdgroup_matrix<T,16,16x16>
operations are supported by GPUFamily10 and later" (job m3-max-34410). No device the runtime
presents claims Apple10: the family lists the "SIMD-scoped matrix multiply operations" row (from
Apple7), refused NotImplemented(SimdgroupMatrix) on every device, and the lod-bias row, a gap. So
the refusal is Metal's own answer, not a device gap: no FAST-PATHS known gap.

Tests: engine_simd_matrix::products_of_16x16x16_are_refused_as_their_own_feature (every
committed profile, the fixture's 12 kernels); runtime_lane::simd_matrix16 (the device's compute
pipeline creation answers MetalGpuFamily of Apple10). REFUSALS.md regenerated, api_signatures
blessed, reach mark added. The engine fixture expectation table and golden hashes take the
fixture's rows on development.

Also: f639b74288 adds the owned fixture (MSL we wrote, compiled by scripts/regen-air-fixtures) and
its Metal probe; 5dbfa3d3d5 imports AirLibrary in the runtime-lane test.

Verified in the lane: m3-max-34499 (msi, at 38d4694b12) clippy -D warnings for metal2vulkan, runtime
and validation (all targets and features) and 45/45 tests, incl. the new engine_simd_matrix test (12
kernels on every committed profile), the error tests, refusal_surface, api_signatures, api_surface;
m3-max-34514 (gem10, at 5dbfa3d3d5) clippy m2v_cpu_icd and runtime_lane::simd_matrix16 on lavapipe
(Needs::MetalGpuFamily(1010) for all 12). Clippy m2v_gpu (34516) still running when landed.

API: adds Feature::SimdgroupMatrix16x16x16 (additive; api_signatures blessed in the lane).
2026-11-15 18:32:00 -08:00
Anees Iqbal ab139e4b6e RUNTIME 2366: Runtime FALLBACK repro bundle at a creation refusal (default-off diagnostic)
What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line
writes for its own failures when it refuses a library or pipeline creation,
where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written).

- The CLI's bundle writer moves into the library as the hidden crate-root
  module metal2vulkan::repro (feature serde), shared by the binary and the
  runtime. A bundle's directory is named by its content
  (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed,
  so an identical failure is written once, across threads, processes and
  runs. The CLI's own bundles keep their files (input, profile.json, the
  descriptor files, repro.sh, repro-command.txt, failure.txt); only the
  directory's name changed, so a bundle written before still replays.
- The CLI takes --device FILE in place of --profile: the JSON of a
  DeviceDescription and DevicePolicy (ReproDevice), which builds the
  runtime's own compile device.
- The runtime hooks each creation where its refusal returns: a library of a
  metallib, a function's lookup, every compute and tile state
  (ComputePipelineState/TileState::create_adding: creations, added binary
  functions, archive adds) and every render state
  (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented
  and Compile refusals but a cancelled compile and a name the library lacks
  (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the
  library's bytes, device.json, the request as the CLI's options and
  descriptor files, and failure.txt with the call, the refusal and what the
  command does not replay. That list comes from a full destructuring of the
  compute, tile and render descriptors (and the stage functions): a new
  descriptor field fails to compile in repro.rs until it is replayed or
  listed.
- Bounded: at most 32 bundles and 256 MiB per process; past either nothing
  more is written and one line says so. Written on the refusing thread; the
  call returns the same refusal; a write failure is said once. Each bundle
  is named in one line through the device's message sink (id name
  metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde.
- Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later
  variant, driver VkPipeline makings, Metal-source libraries.

Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime
README's Errors section, the CLI help.

Tests: runtime CPU tests of the bounds (a tally with the seam's limits);
a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor:
one bundle with the expected parts and command, device.json rebuilding the
runtime's compile device by profile fingerprint and answering the same
refusal, none for a second identical refusal or a missing name, none
without a directory); CLI tests replaying library-written runtime bundles
(compute, and render with a vertex descriptor) through repro.sh to the same
FALLBACK, and --device compiling what --profile does.

Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli,
api_surface and api_signatures 25 passed; runtime repro tests 9 passed;
clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features
0. Lavapipe (m3-max-32978): repro_device writes one bundle that the
CLI replays to the same refusal; a second identical refusal writes
nothing.
2026-11-15 10:14:52 -08:00
Anees Iqbal f851c07e52 SEMANTICS 2123 / RUNTIME 2349: Texture buffers past maxTexelBufferElements bound through views of their parts
Metal makes texture buffers of up to 2^28 texels on every Mac; one texel
buffer view holds at most the device's maxTexelBufferElements (2^27 on ANV
and lavapipe, 2^26 on MoltenVK), and the binding of a wider one was refused
(BindError::TexelBufferTooLarge).

The consumer now states with a texture buffer's binding the views its texels
take (BoundTexture::Buffer::parts, bind::texel_buffer_parts: 1 within the
limit), which its shape carries. A slot whose function only reads, writes,
updates by an atomic or asks the width of the texture buffer, on a device that
indexes texel buffer arrays NonUniform, states RuntimeFact::TexelBufferParts;
where the shape binds more than one part there, the plan asks for the parts
variant (VariantKey::texel_buffer_parts). Under it the slot is an array of
the parts' texel buffers: texel i is texel i - k*P of part
k = min(i / P, parts - 1), P the device's limit rounded down to its texel
buffer offset alignment (bind::part_texels), and the width (parts - 1) * P
plus the last part's. texel_ranges writes one range per part at its array
element (DescriptorRange::element), and the runtime views each.

Each part is the device's own view in the format one view takes, so a read
converts its texel as the one view does: no precision note. A texture buffer
one view holds keeps one view, no variant and its key. The families row
TextureBufferWidth is exact where the parts reach 2^28.

Still refused (TexelBufferTooLarge): a slot read through a sampler or used beyond read/write/atomic/width; a device
without NonUniform indexing of that kind of texel buffer array; formats with several texels a block. Argument-buffer
texture buffers past the limit stay the heap neutral (unnamed-texture-unviewable). New: WorkCounts::texel_buffer_parts_bound,
RuntimeFact::TexelBufferParts (appended), bind::part_texels / texel_buffer_parts, BoundTexture::Buffer.parts,
TextureShape::Buffer.parts (serde default 1), VariantKey/LoweringInputs.texel_buffer_parts (hashed only when non-empty),
DescriptorRange.element. SEMANTICS_VERSION bumped: input once refused now translates.

Evidence (lane jobs, msi): m3-max-32343 at 628264de17: clippy --workspace --all-features --all-targets -D warnings 0;
41 metal2vulkan tests incl. golden_hashes_match_the_table (every fixture's SPIR-V unchanged on every profile: one part is
byte-identical), the binder test (an under-limit slot: no parts entry, empty variant, layout counts 1), the interpreter
parts test (robust and unrobust), api_surface / api_signatures / refusal_surface; families::states_follow_their_sources;
lavapipe texture_buffer_width_device (R32Uint limit+64 texels: both sides of the limit and the last texel read and written,
past the end reads 0 and writes dropped, texel_buffer_parts_bound +3) and buffer_tail_device. Without the fix the device
test fails at bind: TexelBufferTooLarge{elements 134217792, limit 134217728} (m3-max-32140). ANV (2^27) is down; the XTX
(2^29) never parts.

Lane commits: 9fbf7d3c14, 7f7f3ad95e, 9a745ffb3c, 740e9e43dd, 628264de17.
2026-11-15 07:10:59 -08:00
Anees Iqbal 2bd067d6c7 RUNTIME 2254: a command buffer's completion exports as a SYNC_FD sync file
A consumer that composites one GPU's frames on another vendor's GPU has to order the second
device's work after a runtime command buffer. The only semaphore export was
SharedEvent::export_semaphore_fd: a timeline semaphore as OPAQUE_FD, which Vulkan imports only on a
device with the same deviceUUID and driverUUID, so it cannot cross from NVIDIA to RADV. The consumer
waited on the CPU instead, about 3.5 ms a present on its window thread. A cross-driver handle needs
SYNC_FD, which only binary semaphores export.

New (unix only, no Metal counterpart):
- CommandBuffer::add_completion_sync_file(), before the commit: the command buffer's last batch
  also signals a binary semaphore exportable as SYNC_FD, after its to-host barrier. That batch never
  joins a submission group. A command buffer with no GPU work submits the signal alone, after its
  queue's earlier work.
- CommandBuffer::export_completion_sync_file() -> Result<Option<OwnedFd>, Error>, after the
  commit. It blocks only until the signalling batch's vkQueueSubmit has returned, never on the GPU.
  None means the work already ended, or the driver answered -1; the importer imports -1 or skips
  the wait.
- Spec: the export follows the signal's submission (VUID-03254), with copy transference. One export
  per command buffer. Event::reserve_vk_signal's doc carries the contract for a reserved signal
  that the batch waits on.
- The semaphore goes back to an idle pool of up to 8 per device once the command buffer completes
  with its fd exported, and is released otherwise.

Where the host writes the caller's pages after the GPU work (a copied host buffer's merge back, or a
managed two-copy buffer's copy-out), no GPU signal can come after those writes. There the export
waits for completion and answers None, announced by a NEW Degradation: SyncFileAfterHostCopies
(sync-file-after-host-copies, performance). Also new: WorkCounts::sync_files_exported and
sync_files_after_host_copies; RuntimeGap::SyncFileExport, for a device without
VK_KHR_external_semaphore_fd or without binary SYNC_FD export (MoltenVK, an adopted device without
the extension); Problem::SyncFile(SyncFileProblem { Committed, NotCommitted, Exported }).
docs/API.md (catalogue entry), the runtime README, REFUSALS.md (regenerated), the reach table and
api_signatures are updated.

Verified (syncfile, 8f9caba0ae on d72dc03519, msi):
- Runtime suite: 1538 passed, 6 skipped (27758).
- tests::sync_file on lavapipe (27733). llvmpipe exports and imports SYNC_FD. The no-copy buffer
  was imported by pointer. A second VkDevice imported the fd and read every byte filled. The export
  came while the status was Scheduled.
- The lane test a_sync_file_after_host_copies_waits_for_them_announced (27759): the export over a
  copied buffer's merge back waited, the pages held the fill, and the kind was announced once and
  counted.
- clippy plain, m2v_cpu_icd and m2v_gpu 0 (27709, 27737, 27760); rustdoc 0 (27730).
- Owed: the cross-vendor run on um790, the 2080 writing and an XTX VkDevice importing (27739,
  queued).

RUNTIME_VERSION 2253 -> 2254.
2026-11-13 19:06:19 -08:00
Anees Iqbal 977c9da12f RUNTIME 2246: setTriangleFillMode: 2 (MTLTriangleFillModePoints, Apple-private) draws a triangle's vertices as points
Apple's GL renderer sends setTriangleFillMode:2 for glPolygonMode(GL_POINT) under its Intel and
Apple-silicon caps tables. The value is not in the public headers. Our TriangleFillMode had only
Fill and Lines, so the consumer's raw-value conversion failed and its host died. Measured on
Metal: an M3 Max and an Intel UHD 630 draw only a triangle's 3 vertex pixels (a Radeon Pro 5300M
fills it); our own probe on the M3 (m3-max-26811) draws 1-px points whether point_size is 4, 1 or
unwritten, culls them with CullMode Front, and draws them with Back.

Now TriangleFillMode::Points (2) exists. The generator (scripts/regen-metal-enums) takes a
PRIVATE line for it, with its evidence, and a PRIVATE_DOCS doc comment (metal_enum! accepts
variant attributes); generated.rs stays generated and `--check` passes. The runtime draws it as
VK_POLYGON_MODE_POINT. It needs fillModeNonSolid (refused otherwise:
Feature::TriangleFillPoints) and, on a portability-subset device, pointPolygons
(VkFeature::PointPolygons; MoltenVK withholds it, so it refuses Points). New degradation
TrianglePointSize ("triangle-point-size"): Vulkan sizes the points by the PointSize the vertex
function writes, where Metal draws 1 px. An ICB command still refuses set_triangle_fill_mode, as
before. New lane module runtime_lane::triangle_points.

Verified (fillpoints, 6b9927c402 on 25be73dddf):
- lavapipe lane 30/30: points light {(3,3),(3,12),(12,3)} (Metal's 3 vertex pixels); culled
  front none, back the same 3; fill 45 px (the M3 lit 45); lines 27; fill/lines unchanged.
- msi: clippy plain, m2v_gpu and m2v_cpu_icd 0; rustdoc 0; touched tests 102/102.
- Owed: the XTX leg (m3-max-26943).

ARTIFACT_FORMAT_VERSION 519 -> 520 (VkFeature appended to the codec), RUNTIME_VERSION 2245 -> 2246.
2026-11-13 15:26:44 -08:00
Anees Iqbal 4383b55aed SEMANTICS 2096: ANV: a stage heavier than the largest measured to compile in host-sized memory is refused, or keeps the widest pin
ANV's compiler takes memory that grows faster than the stage it compiles, inside the process that
creates the pipeline, well below the 2^20-object bound the serialized stage already keeps under.
Measured on the Iris Xe of RPL-P (Mesa 26.2.6), compute modules created cold through
vkCreateComputePipelines, the resident set sampled every second (job m3-max-26147): entry weights
73,814, 75,886 and 99,109 were created in 45 s, 47 s and 132 s at peaks of 1.76, 2.24 and
3.65 GiB; a module of entry weight 532,213 passed 16 GiB at 358 s without finishing. Job
m3-max-26086: a module of entry weight 796,525, its heap raw-texture arms dead, passed 20 GiB in
under two minutes. Both under the old bound (786,432) would have been handed to the driver: one
pipeline creation that can take a host's memory.

- DriverWorkaround::CompilerMemoryGrowsWithStageSize, keyed on ANV whatever its GPU and release
  (device::derive), documented with those points.
- stage_bound: StageBounds holds both bounds (SERIALIZED_STAGE_WEIGHT 786,432;
  COMPILED_STAGE_WEIGHT 99,109, the largest measured to compile, no margin below it as nothing
  above it is measured to compile). emit keeps a module under every bound its profile's defects
  set, with the same widest-pin retry; a refusal (StageSize, DriverDefect) names the serialized
  stage's defect past 786,432 and the compiler's memory below it. The bound rises when a larger
  compile is measured within host-sized memory.
- The test hooks (compile_bitcode_bounded, compile_stage_bounded) take StageBounds.

Docs: stage_bound's module docs and FAST-PATHS' known-gaps entry state both bounds with the
measured points only (weights, never names), and restate the serialized bound's figures in
entry_weight's units: the faulting stage 1,603,989 (0.683 objects per unit, was 1,565,083 and
0.70 by a count 2.4% lower), the other 21 stages' ratios as counted by that count, which ran 1.9
to 2.7% below entry_weight on the five modules both counted; the shader-object figure likewise
1,603,989. Feature::StageSize's docs and its reach line cover the memory bound; REFUSALS.md
regenerated. api_signatures.tsv blessed with the new variant (the bless also moves
scheduler_slice_rescues to the script's own order).

For a consumer on ANV: a module of entry weight past 99,109 and up to 786,432 that was handed to
the driver is now refused (Unsupported, Feature::StageSize,
Needs::DriverDefect(CompilerMemoryGrowsWithStageSize)) unless its pinned plan fits. Other drivers
are unchanged.

Tests:
- engine_simd_lockstep::a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused covers
  both defects: for each, under a bound the emulated module passes the kernel is planned again
  pinned (exact at 32 lanes), under one its pinned module passes too it is refused naming that
  defect, and past both the serialized stage's defect is named; RADV emits under every bound.
- engine_simd_lockstep::a_kernel_past_the_stage_bound_gets_one_answer_through_either_path on the
  serialized bound through StageBounds.
- device::tests::profile::large_module_defects_are_keyed_on_anv includes the new workaround.

Verified, on msi, read from inside each job:
- m3-max-26184 (this change on 86d362e2aa): cargo fmt --check 0; clippy --workspace
  --all-targets --all-features -D warnings 0; clippy -p metal2vulkan --no-default-features 0;
  clippy with --cfg m2v_gpu (all features) 0; nextest over device::tests, engine_simd_lockstep,
  fast_paths and the refusal_surface, api_signatures, api_surface and feature_vocabulary
  binaries: 189 run, 189 passed.
- m3-max-26212: the stage-bound test with its output shown passed with no SKIPPED line; the
  negative control, the compiled bound's cap set past every module, fails it ("left: Emulated,
  right: Direct" for CompilerMemoryGrowsWithStageSize).

SEMANTICS_VERSION 2095 -> 2096: on ANV a module of entry weight above 99,109 (and up to 786,432) is now
refused or re-planned with the widest pin kept, where it was handed to the driver.
2026-11-13 11:45:50 -08:00
Anees Iqbal c53ea4164e SEMANTICS 2091: on ANV, a stage past the serialized-object bound keeps the widest pin or is refused
Mesa's common pipeline runtime (vk_pipeline.c) serializes every compute stage into a precompiled
shader and reads it back before compiling it. nir_serialize names each object by a 20-bit index
(MAX_OBJECT_IDS 1<<20) checked only by an assert, so a release build wraps past 2^20 objects and
the driver faults inside vkCreateComputePipelines. On Intel Iris this took a consumer's host
process down on a large compute kernel (its translated stage: idx_table_len 1,096,128).

DriverWorkaround::SerializedStageWrapsLargeModules (keyed on ANV) bounds the stage's weight at
SERIALIZED_STAGE_WEIGHT = 786,432 instructions, every call counted as its callee's body. A module
over the bound is never handed to the driver: a kernel that emulated its simdgroups only in place
of the widest mode's pin compiles pinned to 32 lanes again (lower::simd::WidestPin::Kept), and any
other is refused as Unsupported::driver_defect(Feature::StageSize, ..), where Metal compiles it.
The gap is recorded in docs/FAST-PATHS.md's known gaps; REFUSALS regenerated, reach.tsv marks
StageSize rare, api_signatures carries the two new variants.

The bound's basis: 22 stages measured at 0.14-0.99 serialized objects per weight unit; 786,432 is
3/4 of 2^20 at the worst measured ratio of about 1.

Verified: the crash reproduced live on ms01's Iris (job 25723) with both the consumer kernel and a
synthetic 360k-FMA chain; test
a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused; checks job 25736 (msi): clippy
on the workspace, rustdoc, the full metal2vulkan suite, green. Not yet verified: the consumer's
Iris run at the next pin.

SEMANTICS_VERSION 2090 -> 2091: translator output and refusals change on ANV.
2026-11-13 09:05:44 -08:00
Anees Iqbal 10f2539a71 8-bit floats widen through the device's own type where it has one
Owner rule 1: where a device has a native 8-bit float type, its conversion is the only form.
VK_EXT_shader_float8's shaderFloat8 (the SPIR-V capability Float8EXT, SPV_EXT_float8) is now a
VkFeature the device enables and the profile reads (leaf.float8); the SPIR-V IR has
Type::Float8 { encoding } (OpTypeFloat 8 with its FPEncoding, from the regenerated grammar items),
and the interpreter reads OCP's E4M3 and E5M2.

The shared decode, narrow::fp8_to_f32, widens through the device's type where the layout names
one (Fp8Layout::on): each u32 lane bitcast to four 8-bit floats, the low byte's widened by
OpFConvert, so no 8-bit integer type is needed. f8e4m3fn and a tensor's e4m3 take Float8E4M3EXT,
f8e5m2 and a tensor's e5m2 Float8E5M2EXT; the IEEE-like f8e4m3 has no device encoding and keeps
the integer decode. Every site takes it: air.convert's 8-bit float sources, simdgroup-matrix fp8
cells, and matmul2d, whose expansion now widens each element by an air.convert of the tensor's
format (Fp8::TensorE4M3, Fp8::TensorE5M2: Metal's reading, qualified on the M3 Max, e4m3 with no
specials, e5m2's NaNs 0x7FC00000; never parsed from a name, built by Out::air_call). A device
without shaderFloat8 decodes with integers, as before.

Where a tensor's element widens natively the stage records PrecisionNote::NativeFloat8
(native-float8): the device's e4m3 reads 0x7F and 0xFF as NaN where Metal reads 480 and -480,
and an e5m2 NaN's bits are the device's. Validation classes it Unbounded; the conformance suite
lists it among the native notes; FAST-PATHS.md has its device-gap row and API.md its catalogue
entry. The other formats record none: Metal on Apple M3 does not compile them.

The refusal of a matmul2d of 8-bit floats on such a device (Entry::float8_products, the select
check) goes. REFUSALS.md and api_signatures.tsv regenerated.

Tests: matmul2d's fp8 fused sums on the RTX 50 profile (Float8EXT declared, the note recorded,
e4m3 NaN sums) beside MoltenVK, RADV and lavapipe (neither); air.convert widenings on the RTX 50
profile and lavapipe; simdgroup-matrix fp8 cells on the RTX 50 profile too. Not yet built here:
the build and these tests run next on the cluster.
2026-11-13 01:11:22 -08:00
Anees Iqbal 98db2b33e6 A recovery carries compute and tile pipeline states
What: a compute state (and so a tile state's kernel) keeps a chain of programs, one per
generation (pipeline/carry.rs): the state object, its ID, uniqueIdentifier, label and sampler
numbers stay, and its Deref reaches the program of the generation whose command buffer's work the
thread does, else the last. Each state is kept by its generation's carry registry; the recovery,
after the textures, makes its program again on the new generation: the base variant's objects
from the pipeline its creation compiled (Variant::of with the compiled pipeline, or the live
variant the new memo already holds), no translation, and the VkPipeline its creation predicted
queued on the making pool with no wait (make_predicted with waited false). The lost generation's
memo of compiled functions and pipelines is carried first where both generations' profile
fingerprints match (PipelineMemo::carry_from), so later variants and creations translate nothing
again. A state whose making there fails stays the lost generation's, is counted by the notice and
refused where bound with the new RuntimeGap::RemadeAfterRecoveryFailed (compute encoder,
argument encoder and indirect command buffer checks, through ComputePipelineState::bound_device).
The notice says how many states were made again and how many failed. An indirect command
buffer's depth/stencil check now matches the state by its line too, as the encoders' do since the
regression fix. Docs: carry.rs, MadeBeforeRecovery, the new gap, the DeviceRecovered cost
(degradation.rs and docs/API.md, equal), the runtime README; REFUSALS.md, reach.tsv and the API
signature table regenerated.

Why: compute and tile states made before a recovery were refused where bound after it; Metal's
go on.

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes), with the recovery's wall time for 0 and 200 live states.
2026-11-12 16:45:38 -08:00
Anees Iqbal 0a4f4e87f2 Labels: command buffers and encoders take Metal's label, and a lost device's notice names the hang by them
A lost VkDevice's recovery notice named its hang only as "a command buffer (of queue `Q`)",
so an Iris boot's GpuHang (46 victims) left nothing to tell which work hung. The runtime had
no label for a command buffer or an encoder at all.

CommandBuffer::label/set_label (MTLCommandBuffer.label) and label/set_label on the blit,
compute, render and resource state encoders (MTLCommandEncoder.label) now keep what the
program sets. A command buffer has one encoder open at a time, so the open encoder's label
lives on the command buffer's state, and the encoder's record takes it as it ends: each
EndedEncoder reports its label, in its place, a render encoder that ends on the lowering
thread included. The recovery names its culprit from the command buffer's state as it fails
the pending batches: its label and its queue's, then its first 32 ended encoders' places,
kinds and labels, counting the rest, e.g. "command buffer `busy` of queue `relayed` (its 1
encoder: 0 blit `copies`) failed as the hang (`GpuHang`)".

set_label and label are no calls in EncoderCall's numbering. The API table, the Metal and
conformance coverage maps, docs/API.md's DeviceRecovered entry and the runtime README say so.
The table's WorkCounts::spare_command_buffers_freed_past_recorded line moves to where the
script sorts it.

Verified: fmt only on this machine; tests::labels (both lowering policies) and
tests::device_recovery's relayed-loss test, which asserts the named notice, run on lavapipe next.
2026-11-12 12:12:54 -08:00
Anees Iqbal 15866645a8 A generic pointer of no one space is refused as GenericPointer, naming how and where
canon::generic refused every generic pointer it could not give one address space as AddressSpace(8), with no location, so a caller could not tell a pointer of two spaces from one loaded from memory. Feature::GenericPointer (both crates) now names how the pointer gets a space only the run knows (TwoSpaces, Memory, Aggregate, Call, Integer) and the refusal locates the instruction where it does. AddressSpace's doc now lists 8 as defined; the planner treats a generic pointer that survived canonicalization as an invariant breach. FAST-PATHS records the gap, REFUSALS and the API signature table are regenerated, ARCHITECTURE names the pass. runtime_lane::generic_pointers compares generic_spaces and generic_null with the M3 Max's answers (run next on lavapipe).
2026-11-12 07:40:47 -08:00
Anees Iqbal 2b0b59061a Runtime sampler descriptor: lod_bias, read as an Apple9 GPU reads it
SamplerDescriptor gains `lod_bias: f32` (MTLSamplerDescriptor.lodBias,
default 0, serde default), so a guest's bias is carried rather than
having no field to land in.

What Metal does with it, measured on the M3 Max (Apple9, macOS 27.0.1
26A434) with a throwaway Swift probe of runtime-compiled MSL (jobs
m3-max-19665/19666): level L of a 7-level texture held L, so every
sample read its own level of detail. Across 136 row groups no sample
changed with the sampler's bias: fragment implicit, shader bias(),
level(), gradient2d(), min_lod_clamp() and bias+min_lod_clamp; kernel
default, level, gradient and bias; linear and nearest mip filters on
float textures, both on uint ones; a NotMipmapped sampler's min/mag
choice; clamps [1,3], [1.5,MAX], [0,2]; biases -1000 to 1000, 15.99,
16, 16.5, 17, NaN, +-inf. The probe saw levels move with the shader
bias, the clamps, explicit levels and the NotMipmapped filter switch.
With MTL_DEBUG_LAYER=1 every value made a sampler with no assertion and
read back as set. Apple's tables list the bias under Apple10, which no
runtime device claims.

So the Vulkan sampler's mipLodBias stays 0 whatever the descriptor
holds: no bias is past maxSamplerLodBias, and none needs a portability
subset's samplerMipLodBias. The binding shape and the sampler word do
not carry it either. The runtime's state key does: on the M3 (job
m3-max-19683, with and without validation) biases 0 and 1, 1 and
1.0001, and 20 and 30 gave two states each, while 0 and -0, and two
NaNs of one encoding, gave one. The key takes the bits of `bias + 0.0`.

The Apple10 family row stays a gap, its reason now that the biased
level of Apple10 is not built. The conformance suite's SamplerSpec
states the bias too (tag 8, a word only where it is not 0, so no
recording's fingerprint moves), and both legs set it. METAL-COVERAGE
lists lodBias as implemented; CONFORMANCE-COVERAGE and the API
signature table are regenerated.

Tests: metal::sampler::a_lod_bias_makes_the_unbiased_sampler covers
every committed profile, every mip filter, three filter pairs and four
uses plus the unnormalized one, and 15 biases: the Vulkan sampler and
the binding shape are the zero bias's. That includes MoltenVK, which
withholds samplerMipLodBias, and biases past every device's limit.
runtime_lane::lod_bias::a_sampler_s_lod_bias_reads_the_unbiased_level
runs a kernel's biased samples through runtime sampler states of ten
biases, under linear and nearest mip filters, and compares them bit for
bit with the unbiased state's. It also checks the state-sharing rule.
2026-11-12 00:51:28 -08:00
Anees Iqbal d03a45f6ed regen-air-fixtures: air-by-value-buffer, and the read-through-constant kernel fixture
A Core Image kernel of macOS 13.7's frameworks declares its parameter block, read through a
constant pointer, as a read-only device buffer of one char (521f778bf6, abi::check's
read_through_constant). MSL cannot spell that node, so no authored case could be Metal-qualified
over it. The directive `// air-by-value-buffer: <arg>` rewrites the one air.buffer node naming the
argument, a read-only constant buffer, to that node (air.read, air.address_space 1, one char) in
the typed text; the module is metal-as of the rewritten text, as for air-rename. It fails when no
node or several name the argument, or the node is not a read-only constant buffer's.

engine/kernel_read_through_constant is the kernel of 521f778bf6's tests in MSL (out[i] = p->rect +
p->m[i & 3] * p->a + float4(p->n[i % 3], p->e) over a 160-byte Params), compiled with the
directive (Metal 32023.922, SDK 27.2): its .ll and .air.ll carry the by-value node and keep the
constant pointer.

Verified: the script's unit tests (22, two new: the rewrite reaching both companions and --check,
and the four refusals) pass locally with fake tools; the fixture regenerated with the host's Metal
toolchain and LLVM 21 (llvm-as accepts the .ll).
2026-11-11 15:00:04 -08:00
Anees Iqbal 849f7250d9 kernel-holds-gpuvm.bt: probe only the DRM core, key probe counts by probe name, read arg0 before the loop
Three fixes the Asahi run needed, folded into the committed copy:

- The asahi driver's Rust functions (its GEM close callback and its gpuvm
  step_map/step_unmap callbacks) are not in available_filter_functions, so
  their kprobes failed to attach. They are gone, with their three table
  columns; the kernel stacks of the unlinks and puts show those callbacks.
- @n[func] keyed the map by a ksym in kprobe context while the other keys
  are strings; it is @n[probe] now.
- drm_gpuvm_fini read arg0 inside the for-loop over @vbvm, which bpftrace
  rejects; it copies arg0 to $vm first.

Verified: the Asahi session ran the same three fixes as a local copy
(round 3, 19 probes attached, tables and stacks printed). This file is that
copy with the dropped columns removed instead of held at zero; this exact
file has not run yet.
2026-11-11 07:58:49 -08:00
Anees Iqbal 10cd3579b6 kernel-holds-gpuvm.bt: count whether a dma-buf's second import is in the same DRM file as its first 2026-11-11 07:58:49 -08:00
Anees Iqbal ad36ede027 scripts/dma-buf-leak: a per-object trace of the GPU VM bookkeeping, and a properties-query knob in repro.c
kernel-holds-gpuvm.bt follows each GEM object imported from a dma-buf named
m2vleak* and counts its import order among its dma-buf's imports, its vm_bos
created, put, put deferred, moved to the deferred list and destroyed, its
VAs linked and unlinked, the driver's map and unmap steps, its GEM closes and
its reference count at the last handle close; it prints one table for the
objects released and one for those still alive at exit, the kernel stacks of
deferred puts, deferred cleanups and VA unlinks, and the probe's vm_bos still
alive at each VM's teardown.

repro.c -p: 1 queries vkGetMemoryFdPropertiesKHR on each dma-buf before the
import (as the spec requires); 0 skips it (a diagnostic, breaking
VUID-VkMemoryAllocateInfo-memoryTypeIndex-00648); 2 makes the query alone.
The kept dma-bufs on the measured driver each had two GEM imports, which the
query may account for.
2026-11-11 07:58:49 -08:00
Anees Iqbal aa7d8ca855 scripts/dma-buf-leak: a C reproducer of kept dma-buf imports, and a bpftrace script of which layer keeps them
repro.c: plain Vulkan (VK_EXT_external_memory_dma_buf) imports of named
udmabufs of a memfd, from several threads, each keeping a window of imports
alive; every round counts the kernel's bufinfo entries of its name left after
every import was freed. Options add GPU copies, a busy queue, device
addresses and a lock around imports and frees. It needs only a C compiler and
libvulkan.so.1 (it uses the Vulkan headers where present, else declares the
few types it calls).

kernel-holds.bt: follows the dma-bufs named m2vleak* through the generic
PRIME and dma-buf paths (attach, map, PRIME import, handle add and remove,
GEM handle release, unmap, detach, GEM release, PRIME destroy, udmabuf
release) and prints, for those still alive at exit, which steps they went
through, attachments left, the GEM object's references at its handle's
close, and PRIME cache handles left.
2026-11-11 07:58:49 -08:00
Anees Iqbal 2a44c53833 Recapture the Hawk Point 780M's profile at Mesa 26.2.6
amd-780m-hawkpoint-radv (no venue names it) documents itself as the 780M of
Phoenix under another deviceID, captured under the same RADV build; with
amd-780m-radv now captured at 26.2.6 that held only after recapturing it too.
Captured on the cluster's Hawk Point 780M (1002:1900, radeon ICD,
MESA_VK_DEVICE_SELECT=1002:1900!): vulkaninfo reports "AMD Radeon 780M
Graphics (RADV PHOENIX)", driverInfo "Mesa 26.2.6-arch3.1", deviceID 0x1900;
packages mesa and vulkan-radeon 26.2.6, vulkan-icd-loader and vulkan-tools
1.4.363.0.

Regenerated with regen_device_profiles.py --offline from that capture and its
corpus-vulkan --capture-formats supplement (sources pinned in SOURCES). The
document changes only in its identity, provenance and the two fragment
shading rate limits the 780M's own recapture moved
(maxFragmentShadingRateCoverageSamples 32 -> 16, ...RasterizationSamples 8 ->
4), which no translation reads. Against the 26.2.6 capture of the Phoenix
780M, the Hawk Point capture differs in deviceID, the DRM minors, the PCI bus
and deviceUUID only; its formats supplement in device_id only.
2026-11-11 05:50:37 -08:00
Anees Iqbal 4db0484a9d Recapture the Iris Xe venue's profile at Mesa 26.2.6 and declare its identity
The cluster's Iris Xe (RPL-P, 8086:a7a0, homelab ms01) runs Mesa 26.2.6-arch3.1 now, so every
intel-irisxe-rplp-anv run was refused as a venue mismatch against the 26.2.4 profile and
identity.

intel-irisxe-rplp-anv.json is regenerated from a vulkaninfo --json capture and its
corpus-vulkan --capture-formats supplement taken on the venue's device (intel ICD; vulkaninfo
printed deviceName "Intel(R) Iris(R) Xe Graphics (RPL-P)", driverInfo "Mesa 26.2.6-arch3.1",
apiVersion 1.4.354; mesa and vulkan-intel 26.2.6, vulkan-icd-loader and vulkan-tools
1.4.363.0), and c3-venues.json declares the RPL-P's identity at driverVersion 109060102 and that
driverInfo. Against the 26.2.4 capture only the driver version and info and
maxMemoryAllocationSize (24955668480 -> 24950464512, sized from the host's memory, no profile
field) differ; the formats supplement is unchanged in content.

The venue's second device, the UHD Graphics 770 of RPL-S (intel-uhd770-rpls-anv), stays as
captured under ANV 26.2.4: no cluster host has that GPU, so it cannot be recaptured here. Its
capture still derives the venue's translation key (the only difference from the RPL-P's
description is still maxMemoryAllocationSize). The regen script's comment and the two-device
test's doc say which build each capture is of. c3::tests' driver-drift case declares a driver
the profile does not state (now 26.2.7 against the profile's 26.2.6).

Verified: check_device_profiles.py (19 profiles, 0 findings).
2026-11-11 05:50:37 -08:00
Anees Iqbal 6caa5a3924 Recapture the 780M venue's profile at Mesa 26.2.6 and declare its identity
The cluster's Radeon 780M (PHOENIX, 1002:15bf) nodes run Mesa 26.2.6-arch3.1 now, so
every amd-780m-radv run was refused as a venue mismatch against the 26.2.4 profile and
identity, and no row of the venue could be recorded.

amd-780m-radv.json is regenerated from a vulkaninfo --json capture and its
corpus-vulkan --capture-formats supplement taken on the venue's device (homelab
um790's 780M, radeon ICD, MESA_VK_DEVICE_SELECT=1002:15bf!; vulkaninfo printed
deviceName "AMD Radeon 780M Graphics (RADV PHOENIX)", driverInfo
"Mesa 26.2.6-arch3.1", apiVersion 1.4.354), and c3-venues.json declares the venue's
identity at driverVersion 109060102 and that driverInfo. Against the 26.2.4 capture
the profile differs in the driver version and info and in two fragment shading rate
limits (maxFragmentShadingRateCoverageSamples 32 -> 16,
maxFragmentShadingRateRasterizationSamples 8 -> 4 samples), which no translation
reads; the formats supplement is unchanged in content (240 queried, 169 stated).

The venue's rows of 26.2.4 now read stale_device; they are re-recorded on the device
in the commits that follow.

Verified: check_device_profiles.py (19 profiles, 0 findings), the regen script's 41
unit tests.
2026-11-11 05:50:37 -08:00
Anees Iqbal 7d7085f9d0 Remove the host GPU locks: the validation batch's run lock and device-lane's --wrap
GPU work now runs under the cluster scheduler's exclusive GPU hold, which already gives a job
the GPU to itself, so the repo's own cross-process GPU locks only duplicated it.

- vulkan_batch: delete run_lock.rs, the ~/.cache/m2v-gpu/run.lock + run.turn flock that made
  GPU batches on one host take turns run by run, and its two tests. A GPU batch already runs
  one executor at a time (it refuses jobs != 1), and it still reads the hang tripwire before
  every run and writes it on a hang; the tripwire is a stop, not a lock, and stays.
- scripts/device-lane: drop --wrap, which existed to put each shard under a host GPU lock and a
  memory cap; the report's "wrapped" column and totals become the run's.
- docs/VALIDATION.md: the device-lane section says to run it under the host's exclusive GPU
  hold instead of a --wrap lock.
- Comments that told the reader to run probes under `maclock` or spoke of "the Mac's GPU lock"
  now say the run has the GPU to itself (Metal probes, recording.rs, stage-input-split, two
  runtime test modules, which are outside the runtime-sources pin).

Checked on a Linux node before landing: cargo clippy -p metal2vulkan-validation --all-targets
--all-features (plain and --cfg m2v_gpu) -D warnings, the vulkan_batch tests, and the
runtime-sources guard (the pin is unchanged).
2026-11-10 23:19:57 -08:00
Anees Iqbal 5e51dc6023 METAL-COVERAGE names the macOS 27.2 SDK its table was checked against
coverage.py's SDK line still said the macOS 27.0 SDK (Xcode 27.0, 27A266a),
while the M3 has Xcode 27.2 (27B52) and its MacOSX27.2.sdk; the generated
enum tables already name 27.2. The table needed no row change: on the M3,
coverage.py --sdk against MacOSX27.2.sdk answered 'coverage.tsv names every
SDK item (2135)', rc 0 (potluck job m3-max-13567). docs/METAL-COVERAGE.md
regenerated (coverage.py), coverage.py --check current.

(cherry picked from commit ca8424427caaa8636587eb5593e7b91b68afe9b1)
2026-11-10 04:15:05 -08:00
Anees Iqbal 513d792675 REFUSALS: MadeBeforeRecovery's pooled buffers are those in memory the device allocated
A recovery now carries a pooled Shared or Managed buffer that lies in a block of the runtime's own
pages, so the reach note names the pooled buffers left refused as those in memory the device
allocated. docs/REFUSALS.md regenerated (scripts/refusal-surface/refusal_surface.py); no refusal
changed.

(cherry picked from commit b11909130479dbdb8c42c8d6c3950ffa1d9414ed)
2026-11-09 09:51:55 -08:00
Anees Iqbal 33675e87f1 Carry tests, and docs for what a recovery carries and leaves refused
New device tests (tests/device_recovery_carry.rs, under the CPU-ICD and GPU
cfgs):

- One recovery carries a Private buffer (same address, zero after) and a
  buffer in fresh pages. The fresh-page buffer keeps its contents pointer and
  bytes, and the host's writes through that pointer after the recovery reach
  the GPU's copy. It also carries a shared event: its value, its listener's
  notification and a GPU signal after the recovery.
- A pooled Shared buffer stays refused, and the notice counts it. It keeps the
  lost VkDevice, which then holds no empty block and less memory than before
  the loss. Dropping it takes the line back to one live VkDevice.
- Seven recoveries with a carried buffer and event in use between them end
  with one live VkDevice, and eight made.

The device_recovery helpers are shared with the new file.

Docs: RuntimeGap::MadeBeforeRecovery, the DeviceRecovered catalogue entry and
its consequence (runtime and API.md), the runtime README's lost-device
section, line.rs's module and recover_for_test docs, in_place.rs, the
validation lane's docs and the refusal surface's reach mark now say what is
carried and what stays refused. REFUSALS.md is regenerated in the next commit.

Not yet built.

(cherry picked from commit 68d68cdfbdbbac979e5097a8ad286416450790bf)
2026-11-09 04:26:04 -08:00
Anees Iqbal 80b581bee2 Dma-buf export: README, HOWTO, the API table and REFUSALS.md
The runtime README lists exported_as, export_memory_dma_buf and
external_write_done beside the opaque-fd export; HOWTO gains a section on
memory another API writes (a decoder's DRM_PRIME_2 frame), the old
section 7 now 8. The API signatures table is re-blessed for MemoryExport,
BufferDescriptor::exported_as, with_exported_as, the two Buffer calls,
Problem::ExportedNoCopy and RuntimeGap::DmaBufExport, and REFUSALS.md is
regenerated with the new gap's reach (none: a runtime extension).

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit d1510f5588e9e5c3ace5acb1622dcd6570408040)
2026-11-07 19:26:46 -08:00
Anees Iqbal ec9706e6e3 Survive the loss of the VkDevice: the device is a line of generations
Metal's MTLDevice survives a GPU recovery; the runtime's device refused every
call with DeviceLost from the first loss on, and the consumer ends its VM at
the first refusal. Now a device the runtime made is a line of generations
(device/line.rs), each a DeviceShared over its own VkDevice, and the first call
that needs the device after a loss makes a new VkDevice of the same physical
device, options, queue families and extensions.

- Two kinds of handle. The program's device (and its clones) is a root handle:
  it holds the line, pins no generation, and every public Device call goes to
  the generation that serves (each public method forwards to its *_now body).
  Objects hold generation handles, so their Vulkan calls, drops included, reach
  their own VkDevice alone. A generation handle's check is one relaxed load of
  the line's generation (Device::generation_serves).
- A draw pays nothing for it. A command buffer takes its generation once, as
  it is made (CommandBuffer::generation); its encoders' per-draw reaches (work
  counts, fresh-unwritten and alias records, sampler-slot changes, attachment
  read notices) read it there, not through a device handle's kind. A bind's
  device check is one compare of the cells the two handles hold, inlined, its
  refusal (Device::foreign) out of line.
- The state machine (Live, Lost, Failed): the claiming call recovers, every
  other call waits (a notice past 10 s, waiting on); threads command buffers'
  completion depends on never wait. Recovery: the lost generation's command
  buffers in flight fail through its completion path, its queues drain under
  their locks, create_on makes the next VkDevice, the queues are retired.
- Command-buffer answers, as a real loss is one more hang: the oldest
  incomplete batch's command buffer fails GpuHang (exact on one VkQueue; on two
  or more the queue whose oldest incomplete batch was submitted first, said so
  in the notice), counted against its queue so the second revokes it
  (AccessRevoked); the others GpuRecoveryVictim; one committed on the hang's
  queue before the recovery runs nothing and completes with no error; one made
  before and committed after fails GpuRecoveryVictim. One loss names one hang:
  a batch that went to the driver just before the loss and reached the lost
  device's completion after the loss took the pending batches fails with it,
  as a victim (its own wait need not fail: the test hook's VkDevice runs it),
  and no later failure of the lost device names a second hang.
- Command queues survive: a queue is a root handle and a cell of its place on
  one generation (VkQueue, slots, pools, hangs), which a recovery retires and
  the next command buffer re-makes; label and GPU-error count go on.
- Objects made before a recovery are refused where they meet the new VkDevice
  or need their lost one: RuntimeGap::MadeBeforeRecovery, at the 38 lost-device
  checks (Device::lost_refusal) and at every foreign-object check of one line
  (Device::foreign). DeviceLost stays for a device the consumer made.
- Carried across generations: the address space, resource IDs and the passing
  holds a making waits out before it takes one, unique identifiers, counters
  and the announced notice kinds.
- A device handle is an enum of the two kinds (24 bytes, was 16): the shadow
  merge's copy-back dispatch, which holds handles, is boxed (clippy's
  large_enum_variant).
- Device::recover_for_test (public, documented) runs the whole path with no
  GPU fault; RuntimeGap::AdoptedDeviceRecovery on an adopted device.
- Degradation::DeviceRecovered (device-recovered), announced at each recovery
  with the culprit and its time. WorkCounts::vk_devices_live, vk_devices_made,
  device_recoveries: two VkDevices while objects of the lost one live, one
  after.

Docs: docs/API.md catalogue entry, the runtime README's device-loss section,
FAST-PATHS known gap (a make whose own submission first meets the loss is
refused DeviceLost), docs/REFUSALS.md regenerated (refusal_surface.py names a
forwarded body's sites by its public method), api_signatures blessed.

Tests: runtime_lane::device_recovery (hang and victims, command buffers on
their way to the driver at a recovery, MadeBeforeRecovery and the VkDevice
bound, revocation at the second hang, a command buffer made before fails as
victim, all under the validation layer; a recovery that finds nothing of the
queue scheduled names no hang, its command buffers victims),
tests::device_recovery (the hold of the hang's queue between a loss and the
recovery), detach_lost and the MoltenVK lost-device lanes updated to the
recovery's answers.

Verified:
- lavapipe: runtime suite and touched validation tests 1850/1850, surface
  19/19 (m3-max-5695, gem10, before the rebase onto 7e039f062a); on
  7e039f062a, before the one-hang fix, 1853/1853, surface 19/19, clippy clean
  (m3-max-6150, ms01). This tree: clippy clean (m3-max-6278, msi).
- RADV RX 7900 XTX: 81/81 touched device tests (m3-max-5709). Iris Xe (ANV):
  80/81 (m3-max-5766), the 81st kept_images, which fails so at development
  too and the last of these three commits fixes; the recovery tests alone 3
  rounds of 3 (m3-max-5852). RTX 5080 Laptop GPU: 80/81 (b5080 entry
  devloss-devloss-tip1-nine-163410), the 81st the test's own 20 s bound on
  the recovery, which took 39.5 s beside another entry; the test now prints
  the recovery beside the device's first making and bounds neither.
- MoltenVK on the M3 Max: the device_recovery tests 8 rounds of 8
  (m3-max-6135); with the one-hang fix 12 of 12 (m3-max-6242), where without
  it 3 rounds of about 20 failed with a command buffer Completed after the
  hang (m3-max-6219, m3-max-6233). The RTX 5080 failed the second-hang test
  so in 2 runs of 3 (devloss-devloss-rec-alone-170457).
- Recovery time, alone, under the validation layer: llvmpipe 29.9 ms, RX 7900
  XTX 20.4 ms, Iris Xe 15 to 21 ms (its first making 30 to 41 ms), M3 Max
  (MoltenVK) 35 to 40 ms (42 to 50 ms), RTX 5080 530 to 559 ms (602 to 635
  ms). VK_EXT_device_fault listed: llvmpipe 0, XTX 1, Iris 0, 5080 1.
- Per draw (draw_costs, release, --heap, M3 Max, base 7e039f062a and the tip
  alternating, 4 rounds, m3-max-6121): instructions a draw ws +0.03%, many
  -0.05%, 10k -0.31%; draw_primitives +10, +8 and -26 of 17,172, 11,245 and
  7,736 a call; each set_* call +3 to +4 (of 425 to 860); a command buffer's
  creation +170 to +370, an encoder's end +120 to +390.

(cherry picked from commit 3d7758c074fc9895d5d6c9766604c6c4eae9166d)
2026-11-07 18:38:26 -08:00
Anees Iqbal 02562d2a1e Make a shared event whose timeline semaphore another API imports, exported as an opaque fd
reims's ask 2: CUDA signals the event's semaphore on the GPU after a decode
(cuSignalExternalSemaphoresAsync), and waits on it, where it now orders
through the host.

Device::new_exportable_shared_event() makes a shared event as
new_shared_event does, its timeline semaphore made with
VkExportSemaphoreCreateInfo naming VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT;
SharedEvent::export_semaphore_fd() answers a new OwnedFd each call
(vkGetSemaphoreFdKHR), the caller's to close. An event not made exportable is
refused Invalid(Problem::NotExportable). The counter stays the signal index
the interop hooks name: the importer waits for vk_wait's counter and signals
only one reserve_vk_signal reserved; that call's contract now names an
importer's signal beside the device's queues.

The device decides structurally, once: it enables VK_KHR_external_semaphore_fd
wherever listed (adopted: where its consumer enabled it), and asks
vkGetPhysicalDeviceExternalSemaphoreProperties for a timeline semaphore:
OPAQUE_FD exportable and among the compatible types. Lacking either, the
making is refused NotImplemented(RuntimeGap::ExportableSemaphore), with its
REFUSALS row. Lifetime (the event outlives every import and every signal and
wait an importer submitted) and device loss (state lost for the imports; a
device made again exports new semaphores) are in the call and module docs,
interop.rs and the README. api_signatures blessed; exit_guard's KEEPERS
lists exported_semaphore.rs.

Test (device, src/tests/exported_semaphore.rs): the semaphore imported into a
second VkDevice; a command buffer's signal of 5 reaches vk_wait(5)'s counter
there; the second device's host signal of the counter reserved for 9 raises
the event to 9 and releases a command buffer that waited for 9 and then
filled a buffer. Unverified at this commit.

(cherry picked from commit 525580c12be28e6efa0a06ab09cde1f736ebace7)
2026-11-07 16:55:27 -08:00
Anees Iqbal ae0c6c7023 Make a buffer whose memory another API imports, exported as an opaque fd
reims's NVIDIA video lane writes each decoded picture into a runtime buffer
with cuMemcpy2DAsync, so CUDA must import the buffer's memory
(cuImportExternalMemory, cuExternalMemoryGetMappedBuffer); without it the
pictures take a host-pages route of about 2.7 ms a 4K picture.

Device::new_exportable_buffer(length, options) makes a buffer as
new_buffer does, but in an allocation of its own made exportable as
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT: the VkBuffer names the handle
type (VkExternalMemoryBufferCreateInfo) and has the device-address usage of
its own; its memory (VkExportMemoryAllocateInfo) is a block of its own of
the memory type its storage mode takes, the buffer's dedicated allocation
where the device exports only so (DEDICATED_ONLY) or the driver prefers or
requires it (VkMemoryDedicatedRequirements). It is never parked for reuse.
Every other buffer keeps the pooled blocks and pays nothing.

Buffer::export_memory_fd() answers ExportedMemory: a new OwnedFd each call
(vkGetMemoryFdKHR), the caller's to close, the allocation's size, the
buffer's offset and length in it, whether it is dedicated (CUDA's
cudaExternalMemoryDedicated) and its memory type (a Vulkan import names it).
A buffer not made exportable is refused Invalid(Problem::NotExportable).

The device decides structurally, once, as it is made: it enables
VK_KHR_external_memory_fd wherever listed (outside the vocabulary, as the
dma-buf route's names, which enable it too; an adopted device where its
consumer enabled it), and asks vkGetPhysicalDeviceExternalBufferProperties
for a buffer of the runtime's usage: OPAQUE_FD exportable and among the
compatible handle types. Lacking either, the making is refused
NotImplemented(RuntimeGap::ExportableMemory), with its REFUSALS row.

Docs: the module docs, the call docs, interop.rs and the runtime README
state the lifetime rule (the buffer outlives every import) and the
device-loss rule (contents lost for every import; a device made again
exports new allocations, new descriptors). api_signatures blessed (new
method x2, struct and fields, two variants).

Test (device, src/tests/exported_memory.rs): a Shared buffer of a 4K NV12
picture's bytes, written by the host and a GPU fill, exported and imported
into a second VkDevice of the same physical device (dedicated where
exported so), read there; that device's writes read back by the runtime's
blit. A refusal must come from a device that lists no extension or export.
It prints the make cost of Shared and Private exportable buffers beside
plain ones (medians of 8). Unverified at this commit.

(cherry picked from commit fd6d775ef63e350ae1f550d6b2e7ef6af763d21f)
2026-11-07 15:30:55 -08:00
Anees Iqbal c6e1d5a9fd Make a BC1 or BC4 texture over a surface's plane at an offset or pitch off 16
The runtime refused a BC texture over a plane of a surface with planes
whose offset or bytesPerRow is off 16 bytes, as
NotImplemented(SurfacePlaneShape). The M3 Max answers nil for every BC
texture over a surface, so the x86 Macs are the reference (job
m3-max-4779 on macbook-pro-2019: an AMD Radeon Pro 5300M and an Intel
UHD 630 under macOS 26.7.1, surface_texture_envelope.m's bgraat8.bc1 at
offset 8 and bgrarow264.bc1 at 264 bytes a row). Both GPUs' blits and
samples take block row j at the plane's offset + j x bytesPerRow, with
no rounding to 16.

linear_plan::blocks_off_sixteen makes a BC texture of 8-byte blocks
(BC1, BC4) at an offset and bytesPerRow that 8 divides, at least 16
bytes a row. Every BC plane now lies at the CPU's layout on the GPU too
(plan_iosurface_plane's blocks flag): at multiples of 16 the two were
already equal. The CPU calls take the plane's own offset, as the
5300M's getBytes does, while the UHD 630's getBytes and replaceRegion
take a plane at offset 8 from byte 0. That difference is recorded in
docs/API.md's accepted differences. BC4 was not measured off 16; it
takes BC1's 8-byte block rows. BC textures of 16-byte blocks (BC2,
BC3, BC5, BC6H, BC7) off 16, and 8-byte ones off 8 or under 16 bytes a
row, stay refused. SurfacePlaneShape's doc names them, and so does its
reach mark in REFUSALS.md.

Tests: tests::linear_plan makes bgraat8.bc1, bgrarow264.bc1, BC4 at
(8, 264) and BC1 at offset 40, with the GPU layout equal to the CPU's.
It refuses BC3, BC5 and BC7 off 16, BC1 at offset 4 and at 260 bytes a
row, and BC4 at 8 bytes a row. tests::surface_shapes (a device test)
gains bgraat8.bc1, bgrarow264.bc1 and bgraat8.bc4 on every path.

docs: linear_plan.rs's Block-compressed surfaces, the plane call,
SurfacePlaneShape, BufferRefusal::PlaneShape, the FAST-PATHS known gaps
and the API.md accepted differences. Regenerating REFUSALS.md changes
only the reach mark. CONFORMANCE-COVERAGE.md and the API signatures are
unchanged.

(cherry picked from commit ff454bd8b269fff6abf590da85cd050862d539a9)
2026-11-07 14:23:18 -08:00
Anees Iqbal 88ddbf4f90 Keep a colour plane's texels past its surface in a tail of the texture's own
What. A colour texture of a plane of an IOSurface with planes
(Buffer::new_texture_with_iosurface_plane) whose GPU or CPU rows run past
the buffer standing for the surface is made. Its texels inside the surface
are the buffer's bytes, as every texture over a buffer's are; its texels
past it lie in a tail of the texture's own (Texels::past, the form
9ee7323e76 gave a 2D texture past its buffer's length): a Shared buffer,
zero when made, which its functions, blits and CPU calls read and write
alike. The new Degradation::SurfaceTexelsTail (precision,
"surface-texels-tail") announces it once. linear_plan's tail_held names
the shapes that keep no tail and stay NotImplemented(TexelsPastBufferLength):
a two-plane YCbCr, two-plane extended-range, 4:2:2, depth, stencil or BC
texture (another form than a shadow's copies of rows holds their texels),
and a rotated texture's stored frame (turned_plane), whose turned texels
past a surface are not measured.

Why. reims-vgpu's guests make such planes and Metal makes them; the
runtime refused them. On the M3 Max (macOS 27.0.1,
probes/surface_texture_envelope.m's bgra1.64x65, bgra1.64x128 and
420v.p1.32x512) Metal lays those texels out in no one place: its blits
read zeros past the surface, its kernels zeros and 32 KiB on the plane's
rows again, its getBytes zeros and other memory, and its writes there
change no byte of the surface. By the rule of 9ee7323e76, texels Metal
lays out in no one place go in a tail of the texture's own, announced;
the rows inside the surface stay in place.

Docs: API.md's degrade-notice catalogue gains the kind and its accepted
difference names the colour planes; FAST-PATHS.md's known gap and
TexelsPastBufferLength's doc name what stays refused; REFUSALS.md and
reach.tsv regenerated; api_signatures.tsv blessed for the new kind.

Tests: tests::buffer_tail_device::a_plane_past_its_surface_keeps_those_texels_in_its_tail
(64x17 over 4096 bytes and 64x16 from offset 2048: get_bytes, blit and
kernel rows inside and past the surface, a kernel write, a replace_region
past it, the buffers around unchanged, one notice); the validation lane's
a_plane_past_its_surface_is_made_and_announced (the notice beside the
forced shadow, the rows read and written past the surface, the buffer's
bytes kept), listed in degrade_notices; linear_plan's table rows for the
kept and refused shapes.

Verified (at the same tree content on the previous base, replay-27
9a1a8abf1d): lavapipe on homelab-gem10-1 (m3-max-4868) runtime lane
174/174 and validation lane 70/70, clippy --cfg m2v_cpu_icd clean;
msi-laptop (m3-max-4867) clippy plain clean, runtime unit 56/56,
conformance unit 53/53. Negative control: the runtime's sources at the
base with these tests fail a_plane_past_its_surface_keeps_those_texels_in_its_tail
(NotImplemented(TexelsPastBufferLength)). Re-checked on this base by the
branch's check job.

(cherry picked from commit 5ad2ed0b865ff4027488c398a09fc53c0a80ab2f)
2026-11-07 12:44:45 -08:00
Anees Iqbal 803648acd8 Make a texture buffer over a buffer whose texels run past its length, those texels in a tail
What. Buffer::new_texture of a texture buffer whose texels run past
the buffer's length (inside Metal's allocation rule) is made instead
of returning NotImplemented(TexelsPastBufferLength), as a 2D texture
or array already is. Its texels inside the length are the buffer's
bytes; those past it lie in a tail of its own, a zeroed Shared buffer
the runtime owns, laid out from the functions' first byte (the offset
rounded down to 16, as Metal's kernels read a texture buffer).
- GPU: the texture buffer takes the staged form (StagedTextureBuffer,
  announced): its bindings view the tail as their staging buffer. The
  copy in takes the bytes inside the length from the buffer (none
  where the texels lie wholly past it), the copy back gives only those
  bytes back, and a Shared buffer's merge copies the current part from
  and to the buffer and the tail apart (staged_bytes, which now names
  a texture buffer's staging buffer as well as an image's, and
  record_out, which copies the staging buffer's every byte).
- CPU and blits: as for 2D, each row split at the length
  (Texels::past, whose rebase is now the tail's base, tail_base).
Only an IOSurface plane past its surface stays
NotImplemented(TexelsPastBufferLength); the gap's doc, its reach in
scripts/refusal-surface/reach.tsv, the StagedTextureBuffer catalogue
entry and docs/API.md's accepted difference say so.

Why. Plain Metal makes these: reims-vgpu's tbprobe on both x86 oracle
Macs (jobs m3-max-4019, 4046, 4152) and the M3 Max probe
(probes/texture_buffer_past_length.m, job m3-max-4617), whose paths
read and write the bytes past the length as one memory, as a 2D
texture's. The tail gives the 20000-byte buffer's answer for every
shape, as the 2D tail does.

Tests.
- tests/buffer_tail_device.rs: a texture buffer of 64 R32Uint texels
  from 3968 of a 4096-byte buffer (32 past) and from 4096 (all past):
  as made, after a kernel's write across the length (ob1_texel_buffer)
  and after replace_region past it, a kernel, get_bytes and a blit
  read alike; the buffer's words inside the length are written, every
  other word and 16 buffers around it keep theirs.
- linear_plan unit rows: texture buffers past the length made.
- runtime_lane::buffer_textures: the texture buffer at 3968 is made.
- Conformance: buffer-tails-texture-buffer, 1024 R32Uint texels from
  16384 of a 20000-byte buffer (904 inside): ob1_texel_buffer reads
  and writes, getBytes, replaceRegion, blits from and into it, the
  buffer's bytes; recorded on the M3 Max (3 runs, one outcome, every
  site the model's answer).

Verified:
- M3 Max, macOS 27.0.1: the probe (m3-max-4617) and the recording
  (m3-max-4640): buffer-tails-texture-buffer is made, announcing only
  the staged-texture-buffer notice, and the 2D tail cases still are.
- gem10 (m3-max-4635): clippy of the runtime (all targets, all
  features) and of runtime and validation under --cfg m2v_cpu_icd;
  the runtime's unit tests (70 of 70); the runtime lane on lavapipe
  (172 of 172, the new texture-buffer test among them); the
  buffer_textures, texel_swizzles and degrade_notices validation lanes
  (27 of 27).
- gem10 (m3-max-4662): rustdoc of runtime and conformance; the
  conformance unit tests over the tails, refusal, catalogue and
  accepted-difference rows (20 of 20); a lavapipe replay of the six
  buffer-texture cases, all six announced as the ledger expects.
  Clippy there named the shape test's two constant assertions, now
  const blocks; clippy of runtime and conformance and those unit
  tests again on this tree: m3-max-4688.
- Negative control (m3-max-4662): the runtime's sources at 5020e74ebb
  with these tests and cases fail the new device test with
  NotImplemented(TexelsPastBufferLength), and the replay refuses
  buffer-tails-texture-buffer at case/texture.

(cherry picked from commit f0a3390160064eabb820fbdc4f83822e0492fb5f)
2026-11-07 11:19:37 -08:00
Anees Iqbal f118559e73 Binary archives: add mesh pipelines, and load a metallib as an empty archive
Two of the conformance ledger's every-venue rows, both of the runtime's
archive surface.

binary-archive-mesh-adder: BinaryArchive had three of Metal's four
pipeline adders. add_mesh_render_pipeline_functions
(addMeshRenderPipelineFunctionsWithDescriptor:error:) makes the state as
new_mesh_render_pipeline_state does with the default options, answering
its error, and keeps the descriptor's archive key (metal_key::mesh). A
mesh creation compiles its pipeline whole and looks in no archive, so
the add keeps no compiled artifact. Under FAIL_ON_BINARY_ARCHIVE_MISS a
mesh creation, which every listed archive missed before, now hits an
archive holding its key (binary_archive::mesh_missing). Which fields
Metal keys a mesh pipeline by is not measured, so the key holds every
field of the descriptor: a creation hits only an add of an equal
descriptor, where Metal's hits too, and one differing in a field Metal
does not key misses here where Metal's may hit, as the add's and
new_mesh_render_pipeline_state's docs say.

binary-archive-sources: Metal takes a metallib as an archive (the case's
M3 Max recording); container::read refused it as no archive of ours. A
file that parses as a metallib (Library::from_metallib, container tags
alone) now loads as an archive holding nothing: its lookups miss and it
serializes as one nothing was added to. What Metal's archive of a
metallib holds is not measured; new_binary_archive's doc says so.

The suite's runtime side answers the mesh add through the new call. The
ledger's two rows go; api_signatures.tsv gains the method, and
METAL-COVERAGE (coverage.tsv) marks the call implemented. Tests: unit
tests the_mesh_key_holds_every_field_and_a_lookup_names_the_mesh_function
and a_metallib_loads_as_an_archive_holding_nothing; lane test
a_mesh_add_is_found_by_its_own_descriptor_and_a_metallib_loads_as_an_
empty_archive (hit, miss before the add and for another color format,
the add's error, serialize and reload, the metallib's miss and nothing
to serialize). Verified by those tests and a whole lavapipe conformance
replay (see the tip report).

(cherry picked from commit adadb73f7c2063341e1dbe54fe887a5ceddf86b7)
2026-11-07 08:02:57 -08:00
Anees Iqbal 570df3cc95 Answer maxArgumentBufferSamplerCount from the set-1 sampler array and the sampler limit
What: `DeviceProperties::max_argument_buffer_sampler_count`, Metal's
`maxArgumentBufferSamplerCount`: one fewer than the smaller of a set-1
sampler array's elements and the device's maxSamplerAllocationCount
(element 0 of the array, and one of the device's samplers, are the
neutral sampler's; each state the array holds takes an element and a
sampler of its own). The array's elements are a new public translator
function, `pipeline::heap_sampler_capacity`: link's heap capacity for a
heap of one sampler array with set 0 counting no sampler, the least of
the handle table's 65536 entries (TABLE_CAPACITY) and the two
update-after-bind sampler limits, 0 where a function cannot read a set-1
sampler array (the layout's features or the module's non-uniform
sampled-image indexing). Link's heap_capacity now reads the same limit
table (`heap_limits`) and arithmetic (`room`), and heap_set the same
layout-feature check (`heap_layout_lacks`), so the sizing and the answer
cannot drift. The runtime's `Device::sampler_array` (each state's
creation-time check) now calls it too: it was the two update-after-bind
limits without the handle table's reach, 500000 on MoltenVK where link
makes 65536 elements, so a state past 65535 was not announced as it was
made. The device's SamplerCount and the answer read one value, the
identity's maxSamplerAllocationCount.

Why: the consumer computed it as the least of the two update-after-bind
sampler limits and maxSamplerAllocationCount; that misses the handle
table's reach (500000 against our 65535 on the M3) and the neutral's
element (32768 against 32767 on lavapipe, 4000 against 3999 on NVIDIA).

Metal on the M3 Max (macOS 27.0.1) answers 500000 (a Swift query of
MTLCreateSystemDefaultDevice, potluck job m3-max-2496), recorded in the
field's docs and docs/API.md's accepted differences.

Tests: engine_handles::an_argument_sampler_array_has_the_heap_sampler_capacity
(link's array equals the function on every committed profile, follows
lowered limits, 0 without the features); capabilities::
argument_buffer_samplers_are_one_fewer_than_the_array_and_the_sampler_limit
(every committed profile, pinned venue values); the device test
argument_sampler_count (the kernel's array, the device's count, the
driver's limit and the answer agree; elements-1 states unannounced, the
next announced). Verification follows in the branch's report.

(cherry picked from commit 7a2b84f15a1dde81e35cbc0b9367962e54d8332f)
2026-11-05 18:59:21 -08:00
Anees Iqbal c305c66a7f Give mesh pipelines Metal's descriptor limits, state queries and refusals
The mesh descriptor gains Metal's fields, with Metal's defaults:
max_total_threads_per_{object,mesh}_threadgroup, max_total_threadgroups_per_mesh_grid,
the two threadgroup-size-is-multiple-of-width flags, payload_memory_length,
max_vertex_amplification_count (1) and required_threads_per_{object,mesh}_threadgroup. The
descriptor key reads every one.

A compiled mesh pipeline carries MeshPipelineMetalInfo (RenderPipeline::mesh_info), and the
runtime's RenderPipelineState answers Metal's five mesh queries from it, plus the two required
sizes. Each thread limit is the descriptor's maximum, else the function's
[[max_total_threads_per_threadgroup(n)]], else 1024, held to the device's own limit where that is
lower: the task and mesh stages' invocations with VK_EXT_mesh_shader, the compute stage's where
both stages run as compute work. The widths are 32. The grid limit is the descriptor's, else the
object function's [[max_total_threadgroups_per_mesh_grid(n)]], else 2^20, held to
maxMeshWorkGroupTotalCount where mesh functions run natively. Without an object function the
object stage answers 0 and 0, where the M3 Max answers 3 and 32 (an accepted difference).
DeviceProfile::emulates_mesh_shading says how a device runs the stages, so a consumer no longer
copies the compile layer's rule; with the getters, no separate per-stage query is needed.

What Metal refuses is refused as Metal's rule, DescriptorError::MeshPipeline with a
MeshPipelineProblem, measured on the M3 Max (mesh_pipeline_limits.m, plain and under
MTL_DEBUG_LAYER): a required size with an axis of 0, past 1024 threads or past its stage's
maximum, or for an object stage without an object function (process ends); a maximum past 1024,
a function maximum other than the descriptor's, a mesh stage's required size of other threads
than its maximum, and a payload past 16384 bytes (creation errors, codes 3 and 2). An
amplification count of 0 is VertexAmplificationCount, as a render pipeline's; one above 1, which
Metal makes, is NotImplemented(VertexAmplification), recorded in FAST-PATHS' known gaps.

payloadMemoryLength widens the object and mesh functions' payload arena past the declared type
(LoweringInputs::object_payload now reaches the object stage too); an object stage compiled on
its own without it is NeedsInput(ObjectPayload). SEMANTICS_VERSION 1971 and
ARTIFACT_FORMAT_VERSION 488 for that and the new artifact field; the runtime's warm record
format 4 for the descriptor's fields.

Docs: the new_mesh_render_pipeline_state doc now says how each device runs mesh stages, and
what it refuses; API.md's accepted differences gain the mesh pipeline rows. api_signatures
blessed (it also records RuntimeFact::PartialObjectThreadgroups from the partial-threadgroup
commit), api_surface lists MeshPipelineMetalInfo and MeshPipelineProblem, REFUSALS.md,
METAL-COVERAGE.md and CONFORMANCE-COVERAGE.md regenerated.

Tests: engine_mesh's a_mesh_pipeline_answers_metals_mesh_queries_within_the_device and
a_mesh_descriptor_metal_refuses_is_refused_as_its_rule over every committed mesh and
emulating profile; the validation lane's
a_mesh_state_answers_metals_queries_and_refuses_what_metal_refuses on a device. Not yet built:
the next steps are the M3, lavapipe and RTX 5080 runs.

(cherry picked from commit d6934967fad363ca2185c49935204141f253b416)
2026-11-05 17:12:37 -08:00
Anees Iqbal 867c7e506e Make BC, texture-buffer, 1D and one-slice array textures over surfaces
The surface probe (surface_texture_envelope, potluck m3-max-1581, -1596,
-1598) measured which bytes textures over IOSurface planes reach on an AMD
5300M, an Intel UHD 630 and an M3 Max:

- BC over a surface's rows (oracle_surftex 66, 67, 125, 131, 147, 148): both
  x86 GPUs' blits, Private ones too, and getBytes take block row j at the
  plane's offset + j x bytesPerRow; the UHD 630's replaceRegion too. The
  runtime makes BC1 to BC7 there as a shadow image whose copies move those
  block rows (Texels::blocks, block-aware plane_copy_regions and copy unit).
  Over a surface without planes Metal's texel-row height check is kept.
- A texture buffer over a surface (35, 121, 129): contiguous from the plane's
  offset on the M3 and the 5300M. Over a planar surface it may run past a row.
  It now takes the descriptor's options, as a surface's other textures do.
- A 1D texture whose row fits (116) and a 2D array of one slice (117, 127):
  the 2D texture's bytes on all three.

Every other shape Metal makes over a planar surface's plane (wider rows, more
levels, other types) has no one layout across the three GPUs and the CPU
calls: refused NotImplemented(SurfacePlaneShape), where it was Invalid.

Verified: not yet built (next commits fix forward).
(cherry picked from commit a937933adfe5f451bd1d79e1605adb124c841dae)
2026-11-05 15:26:46 -08:00
Anees Iqbal 02e3c4825e State strictLines false in the Vulkan 1.2 floor profile's unrequired properties
VP_LUNARG_minimum_requirements_1_2 states no strictLines, and vk.xml gives
it limittype max, so VK_LAYER_KHRONOS_profiles kept the device's own value
for a run restricted to vk12-floor, while the product's reader takes false
for the absent member. On the NVIDIA RTX 5080 Laptop (strictLines true) the
restriction check refused both vk12-floor runtime lanes (absent_reads and
barycentric_weights: "limits.strict_lines: expected false, queried true").
The M3 (MoltenVK, false) never saw it.

strictLines is the property the generator's m2v_unrequired_properties block
exists for: one the product reads and the layer sets, that the base leaves
open, at the weakest value the specification permits. The block now states
it, and the generator's check that the base does not state a block member
reads VkPhysicalDeviceProperties' nested limits (before, any base limit
would have read as a restatement of limits itself). The product's reading
of vk12-floor is unchanged (false either way).

Verified: python3 -m unittest test_device_profiles (34 tests OK; with the
flattening reverted, the new test_a_limit_is_told_apart_from_the_limits_a_base_states
errors), check_device_profiles.py 19 profiles 0 findings. The 5080 lanes:
expected (run pending).

(cherry picked from commit 47d84ac2719daedeef2cf74751334d826d6fb905)
2026-11-05 05:10:39 -08:00
Anees Iqbal 152987eb54 Read a wrapped macro argument as part of its member in the API signatures
The nightly's rustfmt wraps ir_id!(TypeId, "t") one argument per line, so the signature
script, which reads a macro call's members line by line, derived `TypeId,` where the table
holds `TypeId, "t"`, and api_signatures failed with nothing public changed. A member line
that is only an identifier and a comma now takes the literal on the next line with it, which
reads the wrapped call as the unwrapped one did; a member with more on its line (Degradation's
rows, whose prose follows on its own line) is read as before.

Verified: signatures.py --check passes with the committed table unchanged, on this tree and on
bc127dbec3's pre-nightly sources; metal2vulkan's api_signatures test passes on the nightly.
2026-11-04 00:05:18 -08:00
Anees Iqbal 64b4e42d75 Build on nightly-2026-11-03 with rustc's parallel front end, kache and incremental builds
The owner asked for a nightly toolchain, -Zthreads, kache 2.0 with its incremental cache, and
Rust's incremental compilation on.

- rust-toolchain.toml pins nightly-2026-11-03 (rustc 1.101.0-nightly 1c3a65069), dated so every
  machine runs one rustc, clippy and rustfmt. The published crates keep rust-version 1.98, which
  this build no longer checks by itself (clippy's incompatible_msrv still flags newer std items).
- .cargo/config.toml passes -Zthreads=0 (a thread per core) through Cargo's profile rustflags,
  which add to RUSTFLAGS instead of being replaced by it, so `--cfg m2v_gpu` lanes and CI's
  -Dwarnings keep it.
- scripts/rustc-wrapper hands each compile to kache where kache is on PATH outside CI, and to
  rustc otherwise; `RUSTC_WRAPPER=` (empty) builds without it.
- CARGO_INCREMENTAL=0 is gone from scripts/device-lane, AGENTS.md and CONTRIBUTING.md.
- CI installs the toolchain the file names; both Dockerfiles take the same nightly.

What the nightly asked of the code:
- Its standard library containers take more trait-solver levels (Box -> BoxRaw, RawVec ->
  PhantomData), so proving a RenderCommandEncoder `Send` from a program's crate ran past the
  default recursion limit (tests/consumer_auto_traits.rs failed, a future-incompat lint that will
  become an error). The encoder now holds its own lowering in `OwnLowering`, whose `Send` impl is
  written out over a compile-time proof that `RenderLowering` is `Send`, as `LoweringSlot` already
  was. The runtime crate's own proofs need recursion_limit 256.
- New clippy lints: needless_range_loop, single_element_loop, new_instead_of_clear (a false
  positive on a moved-from Vec: the part's segments are now taken explicitly),
  needless_borrows_for_generic_args, redundant_closure, unnecessary_lazy_evaluations,
  manual_range_patterns; AtomicU64::fetch_update is deprecated for try_update (present in 1.98).
- Cargo warns that `homepage` equals `repository`: homepage removed from the manifests.
- nightly rustfmt formats ir_id! invocations one argument per line.

Verified on the M3 Max: `cargo clippy --workspace --all-targets --all-features -- -D warnings`
clean on the nightly; `cargo build -v` shows -Zthreads on every rustc invocation and
scripts/rustc-wrapper in front of each.
2026-11-03 23:41:19 -08:00