Commit Graph
3881 Commits
Author SHA1 Message Date
Anees Iqbal bd987bf8a8 Runtime tests: the GPU-pass rebind leg draws the texture after the execution
Its before-run at 92a2a37461 (job m3-max-16674, lavapipe) passed: the draw came before the
execution, in an instance of its own that the encoder records inline (the pass split before the
execution), so its take was the encoder's, which the encoding again already kept. The draw now
follows the execution, in the instance the commit records in a segment.
2026-11-11 11:10:10 -08:00
Anees Iqbal 4289823b20 Runtime: work recorded again keeps its tiled takes; a batch that fails at its submission gives them back
A tiled texture's copy taken at use is taken by the first use encoded after
its mark; a recording that never runs must hand its take on or give it back.
Three paths lost it:

- A rebind that encodes an encoder again re-recorded the encoder's segments
  (a render pass recorded on the GPU alone, its shadowed textures' copies
  in the segment) into cores that asked the mark, which the first
  recording had cleared: the pass read a copy nothing made. The same held
  for work on the GPU alone a rebind records again without encoding its
  encoder again.
- A host step whose recording failed, and a vkQueueSubmit that failed,
  failed the command buffer outside fail_part: the takes of the batch and
  the later ones were never given back, so the next use read stale levels.

How:
- shadow.rs: one way to decide. ShadowSync::again (take nothing unmet,
  note nothing) is gone; every recording in place of others is
  ShadowSync::over a shared Replaced pool: a use that meets a decision of
  the replaced recordings keeps its take, any other asks the mark. The
  cores recorded during one turn share the pool, so each decision is met
  once, in order.
- State::replaced_takes (was step_takes and replaying_takes) holds the
  pool while a host step, a rebind's encoding again (the first encoding's
  takes and its segments' recordings' takes, State::takes_of) or a
  rebind's recording again on the GPU alone records. segment_raw hands it
  to every core. A spliced encoding again or segment gives back the takes
  of the first recordings it did not meet (Takes::give_back_unheld); a
  refused one gives back its own takes the first did not hold. The
  encoder's record keeps the encoding again's takes.
- State::place joins a placed segment's takes into its encoder's record,
  and CommandBufferShared::never_runs_from (State::give_back_from) gives
  back the takes of every part from the failed batch on, called beside
  each of the scheduler's three failed() calls.
- docs/FAST-PATHS.md, known gaps: a predicated loop's run again records
  its work apart as a new recording that asks the mark, so a
  did_modify_data during the loop is taken mid-loop and the next use
  after it takes nothing. Keeping the first run's takes (over) would copy
  in again at every run, so it stays a recorded gap.
- docs/API.md and the shadow.rs and reencode.rs module docs say the
  above.

Verified: see the next report (lavapipe before/after, the 780M, lint).
2026-11-11 11:10:10 -08:00
Anees Iqbal ce043e791d Runtime tests: the GPU-pass rebind leg's buffer holds a draw the blit resets
Its first run (job m3-max-16608, lavapipe) found the pass recorded by a host step, not on the
GPU alone: the GPU form asks that the records may hold draws, and a reset alone holds none. The
host step then held the index buffer's pages, so the rebind was refused (EncodedUses). The CPU
now writes a triangle draw into command 0, which the blit resets on the GPU before the pass.
2026-11-11 11:10:10 -08:00
Anees Iqbal f154f4dfb7 Runtime tests: tiled takes in a pass a rebind records again, and in batches whose step or submit fails
Three device legs that fail on the tip:

- tiled_texture_reencode: a render pass recorded on the GPU alone (it
  executes indirect commands a blit reset) whose indexed draw reads a
  tiled texture and takes its indices from a no-copy buffer. A rebind of
  that buffer encodes the render encoder again; the pass's segment is
  recorded again, and must take the copy the commit's segment took.
- tiled_texture_step: the host-step leg's setup shared, and a leg whose
  host step's recording fails (CommandBuffer::fail_host_step, a test
  injection after the step records): the batch never runs, so the
  commit's take must be given back.
- tiled_texture_failed: a leg whose batch's vkQueueSubmit fails
  (Device::fail_next_submissions, a test injection in submit_logged that
  makes no call): the take must be given back.

Both injections are cfg(test) only. Not run yet: the before-run is the
next step.
2026-11-11 11:10:10 -08:00
Anees Iqbal 60dfe0eb4b FAST-PATHS: the Shared bus cost drops its OpenCL claim, which the consumer's measurement withdrew
The consumer re-measured (their job m3-max-16759): Apple's OpenCL on Metal makes one Managed
no-copy buffer per cl_mem and synchronizes it as Metal requires; its Shared buffers are
staging. So no OpenCL buffer must stay Shared on a discrete GPU; the Shared bus cost stands
as measured.
2026-11-11 11:09:11 -08:00
Anees Iqbal f696df5065 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 11:08:53 -08:00
Anees Iqbal 8fe1cbef1c RUNTIME_VERSION 2048: far vertex layouts pulled past lavapipe's wrapping fetch; a load-robust merge check
On a driver whose fixed-function vertex fetch wraps at 4 GiB
(RuntimeDriverDefect::VertexFetchWrapsPast4GiB, lavapipe), a layout the draw's own values
reach past 2^32 is pulled; uint-indexed and indirect draws are pulled under
DevicePolicy::vertex_reach = Exact (exact_answers()), announced vertex-fetch-may-wrap
otherwise. The submission-merge check floors each call apart on its own (CHECK_VERSION 8).
Rebased over the unstored-DontCare switch: both DevicePolicy fields kept. Verified on the
branch: lavapipe before 24 elements differ (potluck m3-max-16570), after exact under
exact_answers() (16602); touched tests on lavapipe, the 780M and the M3 (16602, 16642,
16617); full lavapipe lane 5518/5519, the pin alone failing (16647); core 5432/5432 (16666);
lint 16601; ledger tests 34/34 (16712).
2026-11-11 10:55:00 -08:00
Anees Iqbal e05da5d264 FAST-PATHS: the measured cost of VertexReachPolicy::Exact on lavapipe
runtime_lane::far_vertex_fetches::far_reach_costs on lavapipe (Mesa 26.2.4, LLVM 23.1.1, msi;
jobs m3-max-16602 and m3-max-16705): under Exact one pipeline more (the pulled variant, made at
the first uint-indexed draw), and a pass of one draw of 65,536 uint-indexed points 2.3 to 2.8
times as long (medians 0.94 against 2.41 ms beside two builds; 3.5 to 4.8 against 9.7 to 12.0 ms
at a load average of 59 on 24 threads). Not free, so the switch stays opt-in.

The defect's doc names the second lavapipe release measured and the 780M's Mesa.
2026-11-11 10:54:48 -08:00
Anees Iqbal f78c28dcb0 Lane tests: far_vertex_fetches takes AirLibrary for new_library_with_air
The gpucfg build (m3-max-16573) found no new_library_with_air on Device: it is the validation
crate's AirLibrary extension, which the module did not import.
2026-11-11 10:54:48 -08:00
Anees Iqbal e93bb05b26 Lane tests: the assumed-merge tests expect a group only where the device groups
a_held_group_goes_before_another_queue_s_submission_handler_runs and
a_shared_event_wait_for_a_kept_group_s_signal_ends_at_the_next_completion_turn make their device
with DeviceOptions::assume_submissions_merge and asserted a held group wherever the two queues
share a VkQueue. The runtime holds a batch in a group only where the merge check holds and the
queue's failures are not relayed (command_buffer/group.rs `groups`); MoltenVK's are relayed, so
there no group is held whatever the check says, and the group assertions could not pass on the
M3. As 4fc5f5b6e4 did for grouped_submissions' own runs, both tests now read `groups` (merges and
not relayed): the group assertions run where the device groups and the queues share a VkQueue;
where it groups none they assert nothing was kept, grouped or sent as a group, and the waits
and completions are checked as before. Both still assert that the merge held as assumed.
2026-11-11 10:54:47 -08:00
Anees Iqbal 5370917e31 Runtime: the merge check floors each call apart on its own
The merge check compared the least of its rounds of one call of four VkSubmitInfos against the
least of its rounds' sums of four calls of one. A round of the calls apart holds four windows
inside a call, the one call one, so load beside the check that lengthened any one call of a
round lifted that round's sum: every round of the calls apart took a hit about four times as
often, its floor rose where the one call's stayed, and that reads as a merge. On the M3 Max
beside loops of the device tests (MoltenVK 1.4.2), 145 of 15,181 devices answered Holds at 0.29
and up where its quiet tries are 0.81 to 0.91. A relayed queue never groups, so that verdict
mattered only for an adopted MoltenVK device, whose queues are not relayed: there a Holds for
the device's life groups its batches on a driver that runs each VkSubmitInfo as a Metal command
buffer of its own.

No structural fact decides it: Vulkan says nothing of whether a driver merges submit infos, and
the check exists so that no decision reads the driver's identity. So the comparison is made
load-robust instead: the calls apart keep each call's time, and the form's floor is the sum of
each call position's own floor over the rounds (apart_floor). Each floor is then the least of as
many single-call windows as the one call's (eight a half), equally exposed to load; load on one
call of each round, whichever, moves none. The thresholds are unchanged (MERGE_RATIO 0.6 in both
halves; a record needs MERGE_HOLDS_CLEAR 0.5 / MERGE_FAILS_CLEAR 0.75 and MERGE_REPEATS more
tries). Quiet, the sum of the floors is at most the old floor of the sums, so the probe's
quiet ratios (RADV 0.33-0.38, ANV 0.39, MoltenVK 0.98) stay where they were.

CHECK_VERSION 8: what the check measures changed, so no record of 7 is read.

New test: load_on_one_call_of_each_round_apart_answers_no_merge (the M3 Max's quiet floors
under a rotating load: the old floors answer Holds, apart_floor answers Fails; the 780M's
floors under the same load still answer Holds).
2026-11-11 10:54:47 -08:00
Anees Iqbal 4f0813c1d6 Translator tests: the bind state and shape round-trips carry far_vertex_buffers
The serde round-trips of BindState and BindShape name every field, so the new one failed to
compile there (lint job m3-max-16571, core job m3-max-16572).
2026-11-11 10:54:47 -08:00
Anees Iqbal 834b663634 Runtime: pull a far vertex layout on a driver whose fixed-function fetch wraps at 4 GiB
lavapipe's fixed-function vertex input takes an element's displacement modulo 2^32: the
conformance case vertex-fetch-past-4gib-small-buffer reads the wrapped words in 24 elements
where Metal reads zero. Vulkan places the attribute at the whole displacement (28.4 Vertex Input
Address Calculation) and robustBufferAccess2 makes a read past the bound range zero, so the
wrap is the driver's defect: a new RuntimeDriverDefect::VertexFetchWrapsPast4GiB, listed for
MESA_LLVMPIPE alone.

On a listed driver the render lowering names the fixed-function layouts a draw may fetch past
2^32 bytes of their bind offset in a new BindState/BindShape field, far_vertex_buffers, and the
binder pulls them (the existing pulled-vertex-buffer variant, whose fetch reads past 2^32 as
zero). The reach is the existing furthest_element: a draw's last vertex, 65535 plus the base
vertex for ushort indices, the base instance plus the last instance over the rate. Those are
pulled by default. A per-vertex layout of a uint-indexed draw, and an indirect draw's, has its
reach stated by GPU memory; pulling it costs a variant for every such draw, so it is behind a
new runtime-only DevicePolicy switch, vertex_reach (VertexReachPolicy::Bounded by default,
Exact in exact_answers()). Under Bounded such a draw keeps fixed function and is announced
vertex-fetch-may-wrap (Precision). The draw-again paths (rebound, restated) compare the pulled
set; the host-step precompile names none; the GPU replay derives it from its indirect draw.
WorkCounts::far_vertex_fetch_pulled_draws counts the pulled draws.

The conformance case's known-gaps row is removed: replay runs under Exact. FAST-PATHS gets the
switch's row (its lavapipe cost is measured next, in a later commit). New tests: the binder
pulls a named layout; far_layouts under both policies; runtime_lane::far_vertex_fetches
measures the defect on every device under both values, and far_reach_costs (ignored) measures
the exact form's cost.

SEMANTICS_VERSION is unchanged: an empty far_vertex_buffers, every existing shape's, plans as
before, so no output changes under an unchanged key.

Verified so far: api_signatures blessed (signatures.py), refusal_surface --check, the
conformance and Metal coverage checks; builds and tests follow as potluck jobs.
2026-11-11 10:54:47 -08:00
Anees Iqbal 5fcae9d307 WIP lowbugs: decisions for item 1 and the plan for both items (no code yet)
Paused by main for a higher-priority bug. This commit has no code changes. It
records where the work stands so the branch can resume from here.

Item 1 (vertex-fetch-past-4gib-small-buffer on lavapipe):
- Spec reading (main agreed): Vulkan forbids the 2^32 wrap. 28.4's
  attribAddress = bufferBindingAddress + vertexIndex * stride + offset gives
  no width or modulus. 28.4.1 sends an attribAddress outside the bound vertex
  buffer to Shader Out-of-Bounds Memory Access, and under robustBufferAccess2
  a vertex input read outside the range produces zero (9.6.2). No VU or limit
  keeps vertexIndex * stride below 2^32 (fullDrawIndexUint32 allows index
  2^32-1, and maxVertexInputBindingStride is at least 2048). So the wrap is
  lavapipe's defect.
- Gate: a RuntimeDriverDefect row on MESA_LLVMPIPE's driverID
  (runtime/driver_defects.rs), measured on each device by a runtime_lane
  test. It is not a DriverFact: those cover answers Vulkan leaves open.
- Decided with main (rule 1):
  - Default, exact, no switch: on a device with the defect, pull a
    fixed-function layout when its reach reaches 2^32 bytes or more past the
    bind offset. The reach is the draw's own O(1) bound times the stride,
    plus the attribute's offset and size. The bound is the last vertex of a
    non-indexed draw, 65535 + base vertex for u16 indices, and baseInstance
    + (instanceCount-1)/rate for per-instance layouts.
  - Opt-in switch: a new DevicePolicy field, included in exact_answers().
    It also pulls u32-indexed and indirect draws, whose reach GPU memory
    states. Without it they keep fixed function, and the wrap stays.
  - FAST-PATHS row for the switch, with the measured lavapipe cost: pipeline
    creations and draw time, pulled vs fixed function, for a u32-indexed
    draw. Tests of both settings.
  - Ledger: conformance replay runs under Exact, so with the switch in
    exact_answers() the case passes there and its known-gaps row goes. The
    ledger has no policy scope, so the default-policy divergence (the two
    far u32-indexed draws at stride 4) is described in FAST-PATHS. Tell main
    about this.
- Mechanism found:
  - BindState/BindShape get a per-draw field, the Metal vertex buffer
    indices to pull, part of the shape like private_list.
  - The binder (bind/graphics.rs, the vertex-buffer loop near
    `if !fetchable`) adds them to pulled_vertex_buffers, the existing
    pulled-vertex-buffer variant (link/vertex.rs item 7).
  - The runtime fills the field in settle_draw (render.rs, the reshape.field
    lines) from pipeline.base().vertex_input.bindings and attributes, the
    encoder's per-bind strides and the draw. Reuse
    render/vertex_reach.rs furthest_element and fetch_reach::reach.
  - Also cover render/draw_again/rebound.rs and render/executions.rs, which
    call check_vertex_reach.
  - Regenerate api_signatures.tsv (scripts/api-signatures), REFUSALS.md
    (scripts/refusal-surface) and the fast_paths choices list.

Item 2 (submit_check merge verdict, assume_submissions_merge tests): not
started. Notes so far:
- groups() in command_buffer/group.rs needs Grouped, submissions_merge_now
  and an unrelayed queue (flights(queue).is_none()).
- An adopted MoltenVK device is unrelayed (device/relay.rs "Not relayed").
  So skipping the check on relayed devices alone would not fix the case
  that matters; the timing or the structure must decide there.
- The merge check compares the floor of one vkQueueSubmit of four infos
  against four calls of one. The four-call arm sees four times the load
  exposure.
2026-11-11 10:53:35 -08:00
Anees Iqbal 49eb39ded0 Re-bless the golden tables at 600b535875
What moved since 5e0659ba7c's bless. Blessed on the M3 (dv-m3).
2026-11-11 10:46:17 -08:00
Anees Iqbal 968a0d47c7 Re-bless the authored compile census at 600b535875
Its product fingerprint follows the runtime-sources pin at 600b535875 (dv-m3).
2026-11-11 10:46:17 -08:00
Anees Iqbal 90c21ad2f7 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 10:45:23 -08:00
Anees Iqbal b734af7649 RUNTIME_VERSION 2047: separate depth and stencil textures' unstored DontCare loads follow the DontCare policy
Each aspect of a pass's separate depth and stencil textures loaded DontCare and not stored
now clears the scratch to its clear value where UnstoredDontCarePolicy clears (Cleared, or a
driver with UnstoredClearNoSlower), else stays DONT_CARE with dont-care-unstored-load
announced. Verified on the branch: Metal on the M3 Max 120/120 (potluck m3-max-16522);
before the fix lavapipe and the M3 fail (16542, 16558: 48/120); after it lavapipe 2/2 lane,
1972/1972 lanes, 2130/2130 suite (16550, 16609), M3 120/120 and 180/180 lanes (16606,
16643); lint 16552; fast_paths/api tables 40/40 (16569).

Correction to cd81764912's message: MoltenVK's earlier DONT_CARE read a stencil of 0
(verified, 16558); the depth read neither the poison nor the clear value, and 1.0 was not
verified.
2026-11-11 10:35:17 -08:00
Anees Iqbal 9a67d986e6 Separate depth and stencil textures: an unstored DontCare aspect follows UnstoredDontCarePolicy in the scratch image
A pass whose depth and stencil attachments are two textures renders through a scratch image of
the combined format (depth_stencil_scratch.rs), and clear_reach::dont_care_loads skipped it: an
aspect loaded DontCare and not stored took the scratch's DONT_CARE load under every policy, with
no notice. So under exact_answers() its draws read what the new scratch image held (on MoltenVK
a stencil of 0 and a depth of 1.0, Metal's defaults for a load that names no clear value), where
Metal's read the pass's clear value: measured on the M3 Max under macOS 27.0.1 by the lane's
passes through Metal itself (job m3-max-16522), each aspect apart, whether the other aspect is so
loaded or loaded and stored.

Now such an aspect takes the answer of any attachment so loaded, each aspect apart: in a pass
whose draws reach a tile, the scratch's Clear to the aspect's clear value under
UnstoredDontCarePolicy::Cleared and on a driver with DriverFact::UnstoredClearNoSlower (the
scratch image is a combined depth/stencil attachment, the shape the fact measured), else its
DONT_CARE, announced dont-care-unstored-load naming the aspect. Nothing is copied into the
aspect before the pass (only Load aspects are), so no earlier bytes reach it. An aspect the pass
stores keeps the scratch's DONT_CARE load as before.

Docs: clear_reach.rs records Metal's answer for separate textures and the rule; the scratch
module, the notice's rustdoc and catalogue entry, UnstoredDontCarePolicy's rustdoc, API.md's
section and the FAST-PATHS row name separate textures; the known gap is removed.
2026-11-11 10:35:17 -08:00
Anees Iqbal 876309a4c4 Lane dont_care_unstored: separate depth and stencil textures loaded DontCare and not stored, against Metal
A pass of a Depth32Float and a Stencil8 texture apart, which the runtime renders through a
scratch image of the combined format: in three modes it loads both DontCare and stores neither,
or one so and the other Load and Store; dcs_mark writes MARK (stencil 1, depth 0.125 through the
viewport's depth), then dcs_flag draws over the whole target under a stencil test (Equal 0, the
poison's 0xAB, the pass's clear value 0x5C) or a depth test (Equal the poison's 0.625, the clear
value 0.375). Two sizes, two runs each, under the default policy and exact_answers().

Metal's answer, measured on the M3 Max under macOS 27.0.1 by the same passes through Metal itself
(a throwaway Swift probe of the fixture's MSL, job m3-max-16522, with and without API validation,
120 of 120 cases): an aspect loaded DontCare and not stored reads the pass's clear value, one
loaded reads the poison, whatever the other aspect does. The lane expects that under
exact_answers() and on a driver with UnstoredClearNoSlower, and dont-care-unstored-load exactly
where the runtime leaves the load to the driver; elsewhere it prints the reads.

The runtime at this commit loads the scratch DONT_CARE under every policy and announces nothing:
the new test fails here, and the next commit fixes the runtime. The existing test's mismatches
helper now takes the expectation as a closure, and Draws a depth format.
2026-11-11 10:35:17 -08:00
Anees Iqbal 56c3037d68 FAST-PATHS: a Shared buffer over host pages runs at the bus's speed on a discrete GPU, OpenCL on Metal's included
Measured by the consumer on the RTX 5080 Laptop GPU and a Radeon Pro 5300M (their jobs
16447, 16453, 16455, 16554): Shared no-copy 5.3 GB/s against Private 328 GB/s on the 5080;
6.1 against 96.1 on the 5300M. Apple's OpenCL on Metal synchronizes its Managed buffers on
its map path only, so a second copy would go stale; its buffers stay Shared on a discrete
GPU, a cost recorded here.
2026-11-11 10:15:27 -08:00
Anees Iqbal 600b535875 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 10:05:09 -08:00
Anees Iqbal c654ccaa29 RUNTIME_VERSION 2046: a re-recorded segment keeps its tiled takes; a dropped uncommitted command buffer gives them back
A host step's recording in place of the commit's follows the old recording's decisions and
keeps its takes, giving back those it never met; a command buffer dropped before its commit
gives back every take of its ended encoders. Verified on the branch: before the fix lavapipe
fails both legs (potluck m3-max-16466, 16507); after it lavapipe and RADV PHOENIX 39/39
(m3-max-16508, 16509) and 268/268 broad selection (16467, 16468); lint m3-max-16510.
2026-11-11 10:02:16 -08:00
Anees Iqbal 19e7cb90ce Runtime tests: the host-step leg reads the texture through an argument buffer
Metal makes no state for indirect command buffers whose function takes a texture directly (the
runtime answers IndirectCommandsDirectArgument as Metal does: lavapipe m3-max-16487, the 780M
m3-max-16488), so the leg's sample_level command could not be made. An indirect command reaches a
texture only through an argument buffer naming its resource ID, the texture made resident.

The leg now runs rt_heap_zero (engine/kernel_read_through.ll), which reads texel (1, 1) of level 1
of the argument buffer's texture, with the tiled texture made resident by useResource. The
commit's recording takes the copy; the host step records the execution again after the CPU writes
the command; the read must find level 1's grey, and the next use must take no copy and read every
level as taken.
2026-11-11 10:02:16 -08:00
Anees Iqbal 014e0eb11b Runtime tests: the host-step leg samples the texture its execution inherits
The leg's first form made the texture resident with useResource under a kernel of plain buffers.
Its commands reach no resident texture, so no recording took the copy and the leg passed with or
without the fix (lavapipe m3-max-16466/16467, the 780M m3-max-16468: the next use took the
copy).

Now the indirect command buffer inherits the encoder's bindings (inherit_buffers) and its command
runs sample_level, which samples the texture the encoder set at LOD 1. The commit's recording of
the execution takes the copy; the host step records it again after the CPU writes the command.
The leg checks that the step's recording made the copy (the samples read level 1's grey), and
that the next use takes none and reads every level as taken.
2026-11-11 10:02:16 -08:00
Anees Iqbal 56c25f8b7a Runtime: a host step's recording keeps the takes of the one it replaces; a dropped command buffer gives its takes back
A tiled texture's copy taken at use was lost in two places where nothing ran it:

- Work the commit recorded and a host step records again (an execution of indirect commands the
  CPU wrote since the commit): the step's cores decided by the mark, which the commit's recording
  had cleared, so the recording that runs took no copy and the texture read stale levels. Now the
  step hands the replaced recording's takes to the cores it records into (State::step_takes, read
  by EncoderCore::segment_raw, under the step's turn): ShadowSync::over follows each decision
  that recording made, keeping its take and number, and decides a use it never met by the mark.
  As the step's recording replaces the commit's, a take of the commit's it never met is given
  back (Takes::give_back_unheld). TakeBy::Mark carries the replaced decisions; a core with none
  decides as before.
- A command buffer dropped without a commit kept its encoders' takes. Its drop now gives back
  every take of its ended encoders and of its segments' recordings while its status is still
  NotEnqueued.

Unit test tests::shadow::a_recording_in_place_of_another_keeps_its_takes covers the follow, the
by-mark decision of an unmet use, the give-back of an unmet take and of none kept, and a kept
no-take after did_modify_data. The device legs are in the previous commit. docs/API.md's tiled
texture paragraph says both.
2026-11-11 10:02:16 -08:00
Anees Iqbal 65c95f610d Runtime tests: a tiled texture's take in a dropped command buffer and in a host step's recording
Two device legs of a tiled texture whose first use's take is lost today:

- tiled_texture_failed: a command buffer whose blit takes the copy is dropped without a commit.
  Nothing of it ran, so the next use must take the copy and read the grey in every level.
- tiled_texture_step (new): a compute encoder makes the texture resident and executes an indirect
  command buffer the CPU encoded, behind a shared-event wait; the CPU writes the command again
  after the commit, so the host step records the execution again (counted in
  host_steps_recorded). The commit's recording took the copy and never runs; the step's must take
  it there, so the next use takes no copy and reads the grey as taken.

Both fail before the fix: the next use takes no copy and reads zeros.
2026-11-11 10:02:16 -08:00
Anees Iqbal 97ccae1e16 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 09:59:43 -08:00
Anees Iqbal 11354cea40 RUNTIME_VERSION 2045: an unstored DontCare load clears where the driver clears no slower, else is announced
DevicePolicy::unstored_dont_care_loads (Driver by default, Cleared under exact_answers()):
a DontCare load the pass does not store clears on a driver with
DriverFact::UnstoredClearNoSlower (MoltenVK on the M3 Max, RADV on the 780M, measured) and
elsewhere stays DONT_CARE with the dont-care-unstored-load notice. Verified on the branch:
M3 lane and 111/111 lanes (potluck m3-max-16385), lavapipe 112/112 lanes and 2097/2097
device suite (m3-max-16387), clippy three ways and rustdoc (m3-max-16438). The new fixture
dcs_dont_care_split's golden tables are re-blessed on development.
2026-11-11 09:59:05 -08:00
Anees Iqbal 02a20709a5 FAST-PATHS and the fact's measurements: NVIDIA's RTX 5080 Laptop GPU clears 3.2 us slower, so no row
The same probe through the 5080 batch loop (b1111-091522-t, job m3-max-16381, exclusive): 74.4 and
74.6 us a pass with CLEAR against 71.2 and 71.4 with DONT_CARE, the rounds' spreads apart (73.6 to
75.1 against 70.2 to 72.6). NVIDIA keeps DONT_CARE under the default, announced; the RTX 3090 is
unmeasured (um870 stayed behind exclusive boots) and takes the same.
2026-11-11 09:59:04 -08:00
Anees Iqbal 3ea24d4b5c driver_facts test: the Radeon 780M's facts include UnstoredClearNoSlower
a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone failed at 468712b4ab (m3-max-16386):
its Phoenix set lacked the new row; the XTX, the RX 550 and an unnamed RADV GPU still take none.
2026-11-11 09:59:04 -08:00
Anees Iqbal 4c3f45136f Lane dont_care_unstored: the site of dont-care-unstored-load, which degrade_notices takes
degrade_notices::every_kind_has_a_site_a_lane_test_takes failed on the M3 (m3-max-16380): the new
kind had no lane site. dont_care_unstored declares UNSTORED_LOADS and asserts it where the runtime
leaves the load to the driver.
2026-11-11 09:59:04 -08:00
Anees Iqbal 35c68796d3 Unstored DontCare loads: a DevicePolicy switch, cleared by default where the driver clears no slower
The fix before this cleared every attachment a pass loads `DontCare` and does not store, Metal's
answer (lane dont_care_unstored). Measured, that clear is no cost on some drivers and a cost on
others, so by rule 1 it is now a speed-for-accuracy choice with both forms kept:

- DevicePolicy::unstored_dont_care_loads: UnstoredDontCarePolicy::Driver (the default) clears
  such an attachment on a driver with DriverFact::UnstoredClearNoSlower and leaves it DONT_CARE
  elsewhere, announced `dont-care-unstored-load` (a new precision notice); ::Cleared, which
  exact_answers() selects, clears it everywhere. The runtime's choice alone: no profile carries it.
- DriverFact::UnstoredClearNoSlower, a cost fact, one row per GPU measured no slower with CLEAR
  than DONT_CARE (a probe of eight 3648x2038 passes a frame, an RG16Float colour and a
  Depth32Float_Stencil8 loaded by the form and stored DontCare, GPU time per pass, medians of 15
  frames in two rounds): RADV, Mesa 26.2.6, on the Radeon 780M (861 and 865 us against 1147 and
  988, job m3-max-16320) and MoltenVK 1.4.2 on the M3 Max (218 and 218 against 224 and 217,
  within one form's spread, m3-max-16341). Measured slower, so no row: lavapipe (10480 and 10744
  against 7280 and 7259, m3-max-16321) and ANV, Mesa 26.2.6, on the Iris Xe (1936 and 1936
  against 1907 and 1151, m3-max-16343).
- The lane dont_care_unstored expects Metal's answer under exact_answers() and on a driver with
  the fact, lavapipe's earlier texels under the default there, and the notice exactly where the
  load is left to the driver.
- dont-care-store's text names the new answer after such a pass: where the pass loads the
  attachment DontCare and clears it, a tile no draw touches holds zero or the clear value.
- docs/FAST-PATHS.md: the switch's row with the per-driver numbers, and a known gap: separate
  depth and stencil textures (the scratch path) still load DONT_CARE under every policy.

NVIDIA is not measured yet; its row follows with the measurement.
2026-11-11 09:59:04 -08:00
Anees Iqbal f3f6696eb9 An unstored DontCare load in a pass that draws clears, as Metal's draws read it
Metal (an M3 Max, macOS 27.0.1, lane dont_care_unstored): an attachment a pass loads `DontCare`
and does not store reads zero (a color) or the pass's clear value (a stencil) wherever the pass's
draws read it, never its earlier texels. The runtime left such an attachment `DONT_CARE`
(clear_reach::dont_care_loads skipped every attachment the pass does not store): the first
instance's DONT_CARE load read 0 for the stencil (MoltenVK names no clear value there), later
instances of a split pass LOAD what the first left, so the tiles it did not reach read the
earlier texels, and a color the only instance leaves out (fetched through the pixel interlock)
read its earlier texels everywhere.

Now such an attachment (not memoryless, not separate depth and stencil textures) takes `Clear`
in a pass whose draws reach a tile: zero for a color (dont_care_clear), the attachment's clear
value for depth and stencil, by the first instance's load operation over the render area, and a
color that instance leaves out is cleared before the pass by the existing path for cleared
storage colors (cleared_ahead, or the reach pass over the render area). It is not tile-bounded
and not announced: no fragment reads a tile no draw touches, so the answer is Metal's wherever it
is read. `dont-care-load-tiles`' text, rustdoc and catalogue entry are scoped to stored
attachments; clear_reach.rs records Metal's measured answer and the rule.
2026-11-11 09:59:04 -08:00
Anees Iqbal 51c488062e Lane dont_care_unstored: a DontCare load the pass does not store, read by its draws, against Metal
A pass loads a second RG16Float color and a Stencil8 `DontCare` and stores neither; its draws
read them through a framebuffer fetch and a stencil test, in seven arms: a pass whose first draw
reaches some 32x32 tiles and a later one every tile (which splits the pass where the device
fetches through the pixel interlock), a pass of the fetch alone (the second color left out of the
only instance), and passes of no fetch testing the stencil against 0, the poison's 0xAB and the
pass's clear value 0x5C. Each arm runs twice over the same textures, at 224x128 and 128x128,
under the default policy and exact_answers().

The expected classes are Metal's, measured on the M3 Max (macOS 27.0.1) by running the same MSL
through Metal itself (probe jobs m3-max-16192 and m3-max-16205): the color reads zero and the
stencil the pass's clear value wherever a draw reads them. The runtime at this commit reads the
poison's second color in the tiles a split pass's first instance does not reach and everywhere
in the fetch-only pass, and a stencil of 0 (Vulkan's DONT_CARE) or the poison, where Metal reads
0x5C: the lane fails here, and the next commit fixes the runtime.

The fixture dcs_dont_care_split is our own MSL, its companions from
scripts/regen-air-fixtures.
2026-11-11 09:59:04 -08:00
Anees Iqbal 4f9d4c75d0 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 09:59:00 -08:00
Anees Iqbal 28bfb8cd45 SEMANTICS_VERSION 2034, RUNTIME_VERSION 2044: OpenCL-mode images reflect as the textures bound; a copy after a failed import names why
The branch's own bump to 2033 collided with clswizzle's identical one, so its reflection change
takes 2034. The runtime's copied-host-pages notice now names the failed import's cause.
Verified on the branch: lavapipe 114 touched tests (potluck m3-max-16426) and 52/52 at the tip
(m3-max-16434), RTX 3090 6/6 (m3-max-16470), clippy three ways and rustdoc (16424, 16465, 16477).
2026-11-11 09:54:27 -08:00
Anees Iqbal 169df1e9c5 tests::copied_device: a failed pointer import's copy names the failure in its notice
The device test's sink now keeps each notice's reason with its kind. The buffer and the rebind
whose pointer import fails (Device::fail_next_host_imports, the driver's out of device memory)
assert their copied-host-pages reason opens "their pointer's import failed: out of", the
failure the commit before names; before it, the reason was "their import failed". This runs
the failed-import cause on every device that imports pointers, lavapipe among them, not only on
NVIDIA's unpinnable pages.
2026-11-11 09:54:16 -08:00
Anees Iqbal eaeb951313 tests::host_memory: the unix-only host-page test keeps its cfg
The copy-cause test was inserted between the_host_page_is_known_on_unix and its #[cfg(unix)],
which then guarded the new test and left the host-page test unguarded. Each has its own now: the
cause test runs everywhere, the host-page test on unix alone, as before.
2026-11-11 09:54:16 -08:00
Anees Iqbal 37996ddd03 canon::opencl::entry: its docs name the 1D-to-2D texture types in words, linking no private item
entry is public; its doc linked the private bound_texture, which rustdoc refuses under -D warnings
(AGENTS.md: public docs never link to private items). No code change.
2026-11-11 09:54:16 -08:00
Anees Iqbal 8a25f74631 Runtime: the copy notice's reason is typed as a str where the failure's words join the fixed causes
degrade_copied's reason took a String's borrow in one arm of a nested match whose other arms are
string literals; the binding is now typed &str and the arm borrows the String as one, so every
arm coerces to the same type. No behaviour change.
2026-11-11 09:54:16 -08:00
Anees Iqbal 2fc317f6e3 Translator: OpenCL-mode image arguments reflect as the textures bound, of no data type
What: AIR names an OpenCL C image's component `unknown` (`texture1d<unknown, read>`), which the
reflection's type grammar did not parse, so a pipeline of OpenCL mode with an image argument had
no reflection (Unsupported, Feature::Reflection, naming the type). Now:
- reflection/types.rs: a texture whose component AIR names `unknown` reflects data type
  DataType::None;
- canon::opencl::entry, the entry as a pipeline of OpenCL mode binds it: a 1D image's texture is
  the 2D one Metal's OpenCL binds (`texture1d<..>` -> `texture2d<..>`, `texture1d_array<..>` ->
  `texture2d_array<..>`, bound_texture), as canon::opencl_1d already reads it, so its binding
  reflects TextureType::Type2D / Type2DArray.
Only the reflection reads an argument's type name; lowering and binding are unchanged.

Why: Metal states exactly that. The probe opencl_image_reflection on the M3 Max (macOS 27.0.1,
job m3-max-16390) reflects every image of an OpenCL-mode pipeline as MTLDataTypeNone, whether
read as float, int, uint or half, written, only queried or unused; image1d_t as 2D and
image1d_array_t as 2DArray (as the clmode-images probe found on the M3 Max and a Radeon Pro
5300M). The data type is not the element type a kernel reads: Metal answers None for every one.

Tests: engine_opencl_mode::an_opencl_mode_pipeline_reflects_its_images_as_the_textures_bound_of_no_data_type
reflects an owned fixture (image1d_t arguments read as float, int, uint and half, an
image1d_array_t, a write-only image1d_t, a buffer) and holds each texture binding to the M3 Max's
answer (type, None, access, not depth, length 1) and the buffers to theirs; before this commit
its reflection is refused. reflection::tests::the_type_grammar_names_textures parses the
`unknown` component.

Docs: canon::opencl's module docs and docs/API.md's OpenCL-mode images.

SEMANTICS_VERSION 2033: a reflection the translator refused it now answers.
2026-11-11 09:54:16 -08:00
Anees Iqbal 49175d0a24 Runtime: a copy made after a failed import of no-copy pages names the failure in its notice
What: the copied-host-pages announcement of a no-copy buffer, heap or rebind made a copy because
the import the device and the gate admitted failed (WorkCounts::copied_host_buffers_degraded)
said only "their import failed". It now names the failure (FailedImport::cause in
buffer_descriptor.rs): for pages the runtime kept from a driver whose failed import of
unpinnable pages breaks it (RuntimeDriverDefect::UnpinnablePagesBreakHostMemory, NVIDIA's), that
the kernel cannot pin some of them (a dma-buf's mapping, VM_PFNMAP, or one it could not ask
about), and whether a source of their dma-bufs was asked (none given or the device imports no
dma-buf; or the caller's source made none, or the device refused them); for an out-of-memory or
other Vulkan failure, whose import failed (the pointer's, or the caller's dma-bufs' after the
pointer's refusal) and the error. The copy path carries the failure and whether the source was
asked (CopiedFor::Failed(FailedImport), the rebind's Err(Some(FailedImport))); copied_pages
borrows the error. Nothing else changes: the counts, the copies and every refusal are as before.

Why: on the RTX 5080 the consumer's no-copy buffer over a view mapped through two udmabufs was
copied (copied_host_buffers_degraded 1) with no notice line saying why, and finding the cause took
a round trip.

Docs: the CopiedHostPages declaration and docs/API.md's catalogue entry say the reason names the
cause.

Tests: tests::host_memory::a_copy_after_a_failed_import_names_the_failure (no device) holds the
four causes' words. tests::host_ram_device::pages_refused_before_the_driver_with_no_source_are_copied
now announces each copied-host-pages (DeviceOptions::announce_each) and, on a driver with the
defect, asserts each of the buffer's, heap's and rebind's three reasons names the unpinnable
pages, the defect and that no source was asked, printing each (HOST-RAM-COPIED). Before this
commit each reason was "their import failed", which names none of them.
2026-11-11 09:54:03 -08:00
Anees Iqbal 733f7bb292 Probe opencl_image_reflection: what Metal's OpenCL-mode reflection states for images
Run on the M3 Max under macOS 27.0.1 (potluck job m3-max-16390): every image argument of a
pipeline of OpenCL mode reflects texture data type 0 (MTLDataTypeNone), through `arguments` and
`bindings` alike, whether the kernel reads it with read_imagef, read_imagei, read_imageui or
read_imageh, writes it as float, int or uint, only queries it, leaves it unused, or reads it
through a sampler; two images of one kernel read as float and int both answer None. image1d_t
reflects MTLTextureType2D, image1d_array_t 2DArray, image2d_t 2D and image3d_t 3D; read-only and
write-only as declared; not depth; array length 1. A __read_write image1d_t (OpenCL C 2.0) makes
no library ("Undefined symbol(s) for architecture 'air64'").

The library's serialization, meant to show the AIR's type names, is dropped: Metal answers
"MTLLibrary is not formatted as a MetalLib file" for a library of OpenCL C. The reflection part
is unchanged from the run.
2026-11-11 09:54:03 -08:00
Anees Iqbal 5e5906c737 Probe: what Metal's OpenCL-mode reflection states for image arguments, and the AIR's type names
Our own OpenCL C kernels, one library each: image1d_t, image1d_array_t, image2d_t and image3d_t
arguments read with read_imagef, read_imagei, read_imageui (and read_imageh where the compiler
takes cl_khr_fp16), written, only queried, unused, read through a sampler, two images of two
element types, and a __read_write image. For each, the pipeline of OpenCL mode's reflection
(arguments and bindings: texture type, texture data type, access, depth, array length) and the
texture templates the serialized library's AIR names.

Not yet run.
2026-11-11 09:54:03 -08:00
Anees Iqbal e899813c2a Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 09:47:20 -08:00
Anees Iqbal e1bcce1d42 RUNTIME_VERSION 2043: WorkCounts count what an unshared queue's long waits waited behind
Four always-on O(1) counters for an unshared queue's waits over 16 ms: the batches in flight
ahead of it (summed and most), the longest single run during it, and the waits behind one
run over 16 ms. They tell many batches queued ahead from one long batch, which decides the
compositor-isolation work on one-graphics-queue drivers. The queue_share example's frames
mode measured both shapes on the 780M (potluck m3-max-16449).
2026-11-11 09:44:37 -08:00
Anees Iqbal 614d97a5b0 Runtime: count what an unshared queue's long waits waited behind
The compositor-isolation decision needs to know, for an unshared queue's command buffers that wait
over 16 ms behind another command queue's work on a one-queue GPU, whether they wait behind many
batches queued ahead or behind one long batch. Four counters, always on, for those waits:

- WorkCounts::unshared_waits_over_16ms_batches_ahead: the batches in flight ahead of each on its
  VkQueue as its first batch took its value (timeline values past the one the host saw complete),
  summed; ..._most_batches_ahead the most;
- ..._longest_runs_nanos: the longest run each waited for, summed, where a run is the host's view of
  how long the VkQueue's oldest batch in flight was so (completion seen to completion seen, or from
  its submission onto a VkQueue the host saw idle);
- ..._behind_one_long_run: those whose longest run alone was over 16 ms.

How (queue_wait.rs): each VkQueue keeps the host time its oldest batch became so, and, while a wait
is timed, a sliding maximum of the runs seen since the oldest timed wait began (a deque falling from
the front; a wait's longest run is its front once runs from before it are dropped). O(1) a
completion amortized, plus one clock read per completion; no more runs kept than the batches the
oldest wait was behind.

The queue_share example gains a `frames` mode: a compositor committing one draw every --period-ms
(16) beside an application keeping --in-flight long command buffers of --long-ms (30) in flight,
with the compositor's latencies, the application's rate and these counts.

The API signatures table is re-blessed (scripts/api-signatures/signatures.py --bless).
2026-11-11 09:44:37 -08:00
Anees Iqbal 3812c6d5ac Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-11 09:42:22 -08:00
Anees Iqbal f138496f02 RUNTIME_VERSION 2042: a failed command buffer gives its tiled textures' takes back
A command buffer part that runs nothing gives its encoders' takes of a tiled texture's
copy back at State::fail_part, so the next use takes the copy again. Verified by the
branch's runs: lavapipe 3 of 4 new tests fail before (potluck m3-max-16419), 228/228
after (m3-max-16430); RADV PHOENIX 228/228 (m3-max-16429); lint m3-max-16404.
2026-11-11 09:41:44 -08:00