Commit Graph
10126 Commits
Author SHA1 Message Date
Anees Iqbal c06f7e89db Translator, runtime: a texture buffer access the words do not build keeps its own view; a texture buffer held as words there is a gap at the draw or dispatch
The planner's ruling on (A)'s read-through loss, option (ii). Under the identity domains on a
profile that holds some format's texture buffers as words, words::wrap refused the whole module
for a texture buffer access its routines do not build: a read through a sampler, one that
observes residency, one in another numeric class, an sRGB code read, a write of another class or
of fewer than four lanes. The ceilings run (job m3-max-81042) lost three fixture rows that compile
on the base, development 530fb4ea4c: kernel_read_through's rt_buffer, rt_buffer_ow and
rt_arg_buffer, on lavapipe and on the runtime floor.

Such an access now keeps its strategy, the texture's own view, as on a profile that holds no
format as words, and the stage records RuntimeFact::TexelBufferOwnView { stage, texture }: the
slot, or None for a texture buffer reached through a handle. The fact's mechanism is a plan-time
check. The runtime's kernel interface and a render content's draws read it, and a dispatch or
draw that binds a texture buffer held as words at such a slot is Gap::TexelBufferOwnView of the
slot and its format; through a handle, any such dispatch or draw while a texture buffer held as
words is live (the gauge the words twin's handles test reads). Binding no texture buffer held as
words there changes nothing.

Tests: engine_identity's a_read_through_a_sampler_of_a_texture_buffer_takes_its_own_view compiles
the three entries under the identity domains on lavapipe and moltenvk-m3, passes L3, and checks
the fact where the profile holds a format as words and nowhere else (red before this: lavapipe's
compile refused). The runtime's a_read_through_a_sampler_refuses_a_texture_buffer_held_as_words
runs rt_buffer_ow over six formats. Each held directly answers its texels and Metal's white
border: three without a word layout, and three with one, whose border comes from the code. Each
held as words is refused at its dispatch with the gap of slot 0 and its format, and the same
state's next dispatch runs.

docs/REFUSALS.md and the error basis are regenerated. The runtime README's known gaps state the
refusal. api_signatures gains the fact's and the gap's variants.

Verified: not yet built; the ceilings, the gate, lavapipe device tests and the read-through-buffer
conformance replay follow.
2026-12-02 22:11:26 -08:00
Anees Iqbal e46643db97 Translator: a texture buffer's word keeps its border texels unless its format has a word layout
The words change cleared bits 0-11 of every texture buffer's word, on the premise that no texture
buffer is read through a sampler. Metal 4.1 reads one so (`read(sampler, x)`, the fixture
kernel_read_through's rt_buffer, rt_buffer_ow and rt_arg_buffer, the conformance case
read-through-buffer), and under the identity domains such a read takes the border texel from
those bits. So every texture buffer read through a bordered sampler read a zero border on every
device, and one of a format with a word layout read its fields as border texels. The base,
development 530fb4ea4c, kept the bits; found by reading, before any run.

Now TextureWord::of_texture_buffer is the texture word, border texels included, for a format
without a word layout, which is the base's word. A format with a word layout sets bit 13
(TextureWord::TEXEL_BUFFER_LAYOUT, 0 in every other word) and carries its fields in bits 0-10 on
every device. The words' held test requires bit 13, since a plain word's bits 2-7 are border
texels; a handle carries 14 bits of the word (HANDLE_WORD 0x3fff). A slot's read through a
sampler of a texture buffer takes the border texels from bits 0-11 where bit 13 is clear, else
from its format's code (words::border_texels, a choice among the values the word layouts'
formats have, grouped from WORD_FORMATS and metal::sampler::border_texels).

RESOURCE-ID.md and resource_words.tsv state the new word: the texture buffer lines of a word
layout gain bit 13, the others carry their border texels (the texture line's word at the default
swizzle).

Consumer search, the consumer's development 2221a41c20 (git grep -w over *.rs, *.c, *.h, *.m,
*.mm, *.cpp, *.py, *.tsv, *.md): TextureWord, of_texture_buffer, resource_word, resource_words,
BORDER_TEXELS, TEXEL_BUFFER, border_texels, OUT_OF_BOUNDS_ALPHA_ONE, PIXEL_FORMAT_SHIFT: 0 hits
each. The consumer takes each texture's ID from the runtime's gpu_resource_id.

Verified: not yet built. The unit test words::each_code_takes_its_format_s_border_texels holds
each code to its format's border texels; the runtime test and the lavapipe replay of
read-through-buffer come with the next commit.
2026-12-02 22:11:26 -08:00
Anees Iqbal 9240821e85 Docs: texel_buffer_form's doc names the uses it checks, not private constants
The public function's doc linked VIEW_USES and NATIVE_USES, which are private: rustdoc with
-D warnings failed on the three links (the rebased branch's gate, job m3-max-81050, doc step
EXIT=101). The doc now states the uses in words: a uniform texel buffer, a storage texel buffer
and a storage texel buffer written without a format.

Verified: not yet built; the next gate's doc step checks it.
2026-12-02 22:11:26 -08:00
Anees Iqbal 5a933f58cf Docs: REFUSALS.md regenerated: the render content's stage_module builds RenderPipeline refusals
The words twin moved the stage-module refusals of RenderCompiled::of into stage_module
(python3 scripts/refusal-surface/refusal_surface.py).
2026-12-02 22:11:26 -08:00
Anees Iqbal 72288eb2d5 Runtime README: the words twin's compile cost per state, measured on lavapipe
The planner's ruling for (A): the twin's per-state compile cost is the form's known gap for a
program that binds a texture buffer. On lavapipe (job m3-max-80997, the texture buffer stream
test's tb_word_formats state over five formats) the twin's make took 16.9 to 23.5 ms
(Metrics::word_pipeline_nanos) and the plain pipeline's create at least 2.9 to 5.3 ms
(pipeline_creation_nanos less the twin's), about 4 to 7 times. The five recorded guest streams
declare the constant in no state (job m3-max-80975): 0% of their boots' compile time.
2026-12-02 22:11:26 -08:00
Anees Iqbal e318736ceb Texture buffer stream test: an own view's tolerance is DeviceTexelConversion's recorded bound
The test took an own view's values within one ulp with nothing behind the number. The value
is the device's conversion of each code, which the translator records as
PrecisionNote::DeviceTexelConversion; the test now asserts the fixture's state records that
note, and takes an own view's values within the note's recorded bound (docs/API.md): an 8- or
16-bit code within one f32 ulp, a channel of 6 bits or fewer within one ulp or 0.18 of a code
where the device replicates its bits (ANV, NVIDIA). Words stay bit for bit.

Not yet rerun.
2026-12-02 22:11:25 -08:00
Anees Iqbal 674b837fa7 Texture buffer tests: the handles dispatch binds a buffer at slot 2; an own view's values within one ulp
The handles dispatch passed the read-written values (a Vec<f32> by then) at slot 2, which the
kernel does not use, so the runtime's device tests did not build (job m3-max-80971 on
lavapipe, E0308); it binds the values buffer there. The texture buffer stream compared an own
view's values bit for bit with the CPU's c / (2^n - 1); lavapipe's conversion multiplies by
the reciprocal and lands one f32 ulp off for RGBA8Unorm, R8Unorm and BGRA8Unorm (80971). The
device's own conversion is the answer (the owner's rule 1), so an own view's values are taken
within one ulp; words, our own decode, stay bit for bit (B5G6R5Unorm matched exactly).

Not yet rerun.
2026-12-02 22:11:25 -08:00
Anees Iqbal b8b43ccbaf rt test: the compute tests' Interface names no texture buffer words
Interface gained `words` (the kernel's reach of word-held texture buffers) with the words
twin; the device tests' hand-made Interface (tests/compute.rs, compiled only under m2v_gpu or
m2v_cpu_icd) still lacked it, so the runtime's device tests did not build (job m3-max-80900,
nextest exit 101). Its kernels declare no texture buffer: None.

Not yet built: the lavapipe check reruns as a potluck job.
2026-12-02 22:11:25 -08:00
Anees Iqbal e9ef4503e1 Harness: WORKLOADS holds 47; the texture buffer stream records its descriptors as objects
The two B5G6R5Unorm rows grew the harness's list past its declared 45, which stopped the
harness from compiling (the XTX arms build, job m3-max-80896, E0308). The texture buffer
replay stream passed each descriptor inline, which the player refuses for
newTextureWithDescriptor:offset:bytesPerRow: (job m3-max-80900 on lavapipe: "argument 0 ...
not an object"); it now records each with m2v.textureDescriptor first, as the other
texture-over-buffer streams do.

Not yet built: both checks rerun as potluck jobs.
2026-12-02 22:11:25 -08:00
Anees Iqbal 41b415911e Docs: the runtime's README names Metrics::word_contents 2026-12-02 22:11:25 -08:00
Anees Iqbal bef488e4da Texture buffers: a draw reads a texture buffer through the render content's words twin where the device holds the format as words
The owned fixture tb_word_formats gains tb_word_fragment, which colours the pixel at x with texel
x % 5 of its texture buffer (regenerated with the macOS Metal toolchain and LLVM 21). The
runtime's draw test reads an R8Unorm and a B5G6R5Unorm texture buffer through it, checks every
pixel against the CPU's decode within one code, and that the draw ran the twin exactly where the
device holds the format as words.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 443c614c5e Texture buffers: contents with a words twin counted, a test-only count of twin runs, and the words test through slots and handles
Metrics::word_contents counts the compute and render contents whose module declares
SpecKey::TexelBufferWords; the replay player prints it. A count of the dispatches and draws that
ran a words twin, for the device tests alone, shows which pipeline ran.

The owned fixture tb_word_formats gains tb_word_formats_args, which reads and writes the texture
buffers through an argument buffer's handles (regenerated with the macOS Metal toolchain and
LLVM 21). The runtime's words test runs it after the slots' kernel and checks its values, and
that the slots' dispatch ran the twin exactly where the device holds the format as words, and the
handles' dispatch there too.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 740d12b3a6 Texture buffers: the twin's docs, the player's twin gauges and metrics, and B5G6R5Unorm harness rows
AGENTS rule 2's texture buffer form and the runtime's README name the stage constant, the words
twin made in the same make as each plain pipeline, what picks it, and its second compile and
memory as the form's known gap; docs/API.md and RESOURCE-ID.md name the gate.

The replay player prints the word pipelines' and word-held texture buffers' gauges and the
twins' makes and time beside pipeline_creation_nanos.

The harness's texel_buffer_b5g6r5_write and texel_buffer_b5g6r5_read rows time a format the lab's
cards hold as words, a 2-byte texel written by two atomics and read through the words' routine,
checked against the CPU's exact conversion and decode.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 7a85d3f363 Texture buffers: the words are a stage constant's twin, made with the plain pipeline and picked by what a draw or dispatch binds
SpecKey::TexelBufferWords { stage, handles }, a bool, false by default, which a stage declares
under the identity domains on a profile that holds some format's texture buffer as words, where
it reads, writes or queries a texture buffer. It gates each site's word test, the word bits a
handle carries and the element mask that drops them: false, they are dead code at pipeline
creation and each access is its view's alone.

The runtime makes each kernel variant's and each render content's words twin in the same make
as its plain pipeline, and a dispatch or draw runs it where a texture buffer held as words is
bound at a texture buffer slot a function declares, or, for a stage that reaches one through a
handle, while one lives on the device. Twins and word-held texture buffers are gauged, the
twins' makes counted with their time.

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 1b48008646 Tables: resource_words.tsv holds the texture buffer word's vectors
Blessed by job m3-max-80671 (bless_resource_words, then the resource_word tests: 2 passed): a
texturebuffer line for every pixel format with a texture buffer word at width 1, and at widths 2
to 4 where its padding changes the word, 251 lines; no texture or sampler line moved.
2026-12-02 22:11:24 -08:00
Anees Iqbal dc3e5ab673 Texture buffers: the site reads the profile's word codes from the plan; the player's word of a texture buffer; a replay stream of texture buffers
The site test read the codes from the module's declarations, which do not hold them; it reads
the plan's. The player compared a texture buffer's recorded ID with TextureWord::of, whose border
texels a texture buffer's word does not carry; it takes TextureWord::of_texture_buffer of the
descriptor's format and width, as RESOURCE-ID.md and REPLAY-STREAM.md now say. rt_replay gains a
stream of texture buffers of five formats (RGBA8Unorm, R8Unorm, BGRA8Unorm, B5G6R5Unorm,
RGBA16Unorm) over a Shared buffer, read, written and read-written by tb_word_formats with the IDs
the program saw recorded, each played on the cfg's device: no id line, the CPU's texels and
values, and each format's form on that device printed. Unbuilt.
2026-12-02 22:11:24 -08:00
Anees Iqbal b694489924 API: the surface table and the signatures name the texture buffer word items and texel_buffer_form
Additions only (50 signature records): metal::format's TexelWords, WordLayout, TexelField,
FieldKind, TexelBufferForm, WORD_FORMATS and its functions, and TextureWord's texture buffer
fields and of_texture_buffer. scripts/api-signatures/signatures.py --bless reports no record
removed or changed. The runtime's texture buffer words test reads each format's form from the
device's profile and names it on each line.
2026-12-02 22:11:24 -08:00
Anees Iqbal 7cdaa1cc3f Texture buffers: each device holds a format as words only where it lacks the format's own view for an access
metal::format::texel_buffer_form is the one place that decides, per format and device: the
format's own view where the device holds it directly as a uniform texel buffer, a storage texel
buffer and a storage texel buffer written without a format; else words where it has a word
layout; else its own view of the first two (whose writes the runtime refuses). The resource ID
word is unchanged and the same on every device; a module takes the codes its profile holds as
words (texel_buffer_word_codes) and tests a word's code against them, emitting nothing of the
words where the profile holds none so. The routines' cases and the precision notes follow those
codes. The runtime's texel_form takes the same answer. AGENTS.md rule 2 gains the fourteenth
form; the runtime's README records the words' cost (7.3x the own view's GPU time for an R8Unorm
texture buffer written on an RTX 3090, job m3-max-80580).

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 0ad55e1468 Docs: the texture buffer word, the formats held as words, their notes; test vectors of the texture buffer word
RESOURCE-ID.md gains the texture buffer word (TextureWord::of_texture_buffer: bits 0-1 padding,
2-7 the code, 8-9 texels per word, 10 a texel of two words; the 39 codes in order) and drops its
stale line that a texture buffer has no index. The runtime's README says which formats a texture
buffer holds as words and which it still refuses; the KosmicKrisp BGRA8Unorm gap is gone. API.md
and PrecisionNote's docs say a texture buffer held as words records SrgbTexelDecode and
DevicePackConversion for its float reads and writes, and that its other conversions are exact.
tests/resource_words.rs writes texture buffer lines (format, width, word); the table is blessed
in a later commit. REFUSALS.md regenerated (one more TextureFormat site).
2026-12-02 22:11:24 -08:00
Anees Iqbal 4208d6ca84 Texture buffers of colour formats Vulkan does not require as storage texel buffers are held as words
A texture buffer of one of 39 colour formats with a word layout (metal::format::texel_words)
is viewed as R32_UINT over its bytes, and shaders convert each texel themselves: the translator's
words routines (lower/texture/words.rs) read, write and ask the width of such a texture buffer,
and a write of a texel of one or two bytes is an atomic AND then an atomic OR on its word, which
keep its neighbours' bits. The texture word of a texture buffer (TextureWord::of_texture_buffer)
carries the format's code, its packing and padding; a handle carries those bits, and the element
mask drops them. The runtime makes the R32_UINT view, its last word ending inside the buffer's
block, and the required-formats test names the formats Vulkan requires as storage texel buffers.

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 22b951f2d1 harness: texture buffer workloads, an R8Unorm one written and four formats read
The harness makes a texture buffer over a plan buffer (plan::TextureSource::Buffer,
ComputeDevice::new_texture_buffer): texel_buffer_r8_write writes 2^24 R8Unorm texels, one a
thread, and texel_buffer_{r8,r16,rgba16,bgra8}_read read 2^24 texels, 16 a thread, each checked
against the CPU's decode. The workloads time a texture buffer's accesses, as the translation of
the formats the runtime holds as words is weighed against their own views.
2026-12-02 22:11:23 -08:00
Anees Iqbal 2ccf487171 rt test: texture buffers of the formats held as words answer the CPU's decode of their bytes
Metal makes texture buffers of A8Unorm, the four 8-bit sRGB formats, RGB9E5Float, the
four packed 16-bit formats, BGR10A2Unorm and the four extended-range formats, for reading,
writing and both (M3 Max, macOS 27.0.1, jobs m3-max-79872 and m3-max-79879). The runtime
refuses each as Gap::TextureFormat on some or all devices, because Vulkan offers no
texel-buffer format for them.

The owned fixture tb_word_formats reads, writes, and reads then writes texture buffers of
five texels with eight threads. The new device test checks each format's answers against
the CPU's decode of the bytes:
- reads in bounds, exact, or within 2^-12 through the sRGB transfer;
- writes of each texel's value store its code, with neighbouring texels in one word kept;
- past the width, the zero texel is read and nothing is written, the rest of the last
  word included;
- the widths are 5.

This is the red half: every format is expected to fail at Buffer::new_texture
(Gap::TextureFormat). The run that shows it is in the handover.
2026-12-02 22:11:23 -08:00
Anees Iqbal 432bbb0a60 Replay player: a noted word in a buffer reached only as texels plays as recorded
The player moved every written word whose value lies in a buffer noted
escaped (AddressMap::move_noted), whatever the buffer it was written into.
In rec-m3-max-80463 it moved 3 RG8 mask words of no-copy buffer #1960,
which the program reads only as texels through texture #1962 over it. Each
play wrote its own host address there, so two plays read different texels
(audit lane, m3-max-81898 and m3-max-81914).

Now the move is decided by the stream's structure:
- read_ahead, which already walks the whole stream, notes each buffer's
  life, keyed by the object and its making's position (as recorded_ids
  is):
  - whether a texture is made over it (it receives
    newTextureWithDescriptor:offset:bytesPerRow:, the tiled form or the
    linear form);
  - whether any call names it as an argument, at any depth of lists and
    maps, but a copy between a buffer and a texture (copyFromBuffer:...
    toTexture:..., copyFromTexture:...toBuffer:...), whose bytes are texels.
  A buffer with a texture over it and no such naming is reached only as
  texels.
- At an object's making the play marks it live as such, or unmarks the id.
- place_words takes the write's target (none for set*Bytes data). Into a
  buffer reached only as texels, the words move_noted would move play as
  recorded and are counted as texel_only_words (AddressMap::count_noted,
  which shares move_noted's pass). The census is unchanged.
- Unchanged: a buffer with no texture over it, including one the stream
  never names (the existing noted-word test), set*Bytes data, and any
  buffer bound, encoded, used, copied buffer to buffer or added to a
  residency set.

texel_only_words is a new stream counter: in FIXED, frame and group lines,
and the report's addresses line. Docs: REPLAY-STREAM.md section 5's
noted-word paragraph and section 10's counts and addresses line. The
counter lists the replay tests spell out gain it.
2026-12-02 21:56:36 -08:00
Anees Iqbal cdb0cad236 Replay test: a noted word in a buffer reached only through a texture over it plays as recorded
Two lavapipe plays of rec-m3-max-80463 differ (audit lane, jobs
m3-max-81898 and m3-max-81914). In frame 3 the player moves 3 words of the
stream's write into no-copy buffer #1960, at offsets 24344, 73104 and
74240. They are RG8 mask bytes whose value falls inside an escaped
buffer's recorded range, and AddressMap::move_noted rewrites them to each
play's own address. #1960 is read only as texels, through texture #1962
over it, so the texture reads other bytes in each play. A shader loads an
address only from memory its command reaches as a buffer: bound, encoded
into an argument or indirect command buffer, or made resident by
useResource:, useHeap: or a residency set. Each of those calls names the
buffer.

New test in replay/tests.rs,
a_noted_word_in_a_buffer_reached_only_through_a_texture_over_it_plays_as_recorded:
- An authored stream makes a buffer, a texture over it
  (newTextureWithDescriptor:offset:bytesPerRow:), notes the buffer escaped
  (kind 0) and writes into it a word inside its own range.
- Reached only through the texture, the word is to play as recorded, and
  be counted as texel_only_words, not noted_words.
- The same buffer also bound by setBuffer:offset:atIndex: still moves the
  word.

Expected red: today the word moves in both arms.
2026-12-02 21:56:36 -08:00
Anees Iqbal bb09d7bb06 Tests: re-bless the golden tables at pin O
The engine inventory, the golden hash table and the air_input printouts, re-blessed at
3ecfe8f034 on the M3 (potluck job m3-max-82095: inventory=0, golden=0, printouts=0, and the
metallib half of committed_air_fixtures_parse_and_link un-skipped, linkhalf=0). The draw
patches and indexed draw patches work since the last bless added the icb_merged_patches and
icb_merged_ipatches fixtures and moved SEMANTICS_VERSION to 2328, so the four bless-due tests
(engine_fixtures_match_their_golden_printout, inventory_lists_every_fixture_in_order,
golden_hashes_match_the_table, llvm_as part 8) read red until this commit.

Files: golden_hashes.tsv, public_fixture_expectations_engine.tsv, and the two new printouts
air_input/icb_merged_patches.txt and air_input/icb_merged_ipatches.txt. Nothing else.
2026-12-02 21:56:13 -08:00
Anees Iqbal 3ecfe8f034 Conformance ledger: the BGRA4Unorm texture buffer's rows follow the device's texel-buffer query
a3fb852de3 (a heap makes texture buffers in place) sizes a heap's texture buffer through the
format's texel form, which takes a format whose buffer features hold both the uniform and the
storage texel buffer. On the Iris Xe, whose ANV holds A4R4G4B4_UNORM_PACK16 so, the heap's size
and alignment of the format-footprints-plain-stragglers BGRA4Unorm texture buffer now answers
(Metal's 128 at 16), and the case reaches its makes-texture site, which the runtime's side refuses
as Refusal::TextureBufferNotOverBuffer, the consumer's contract. The ledger's one row for every
venue refused the size-and-align site, so the Iris's conformance replay went red at pin M
(m3-max-82006: an unlisted makes-texture refusal) while the RTX 3090's held (m3-max-82034).

Now:
- the size-and-align row is one per venue whose device lacks the storage texel buffer of both of
  the format's Vulkan formats (NVIDIA, RADV, llvmpipe, Apple M3 Max, UHD Graphics 630), naming
  a3fb852de3;
- the Iris Xe has a makes-texture row with the consumer's-contract reason the other texture
  buffers' rows carry, naming a3fb852de3;
- each says Metal's validation layer refuses this format for a texture buffer, so what such a
  texture reads is outside documented Metal and no value comparison is owed for it;
- the runtime's README says a texture buffer's answer, the heap's size included, follows the
  format's texel-buffer features: the devices differ by query, not by form.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py; --check
clean), as are the metal-coverage and refusal-surface checks.
2026-12-02 21:47:08 -08:00
Anees Iqbal d4be06a10b Translator: RUNTIME_VERSION 2554 for a Managed range taken at the first commit that names its buffer
On a device that keeps two copies of a Managed buffer, the runtime now takes a range named by
didModifyRange to the device copy at the first commit whose encoders name the buffer (a slot, a
declaration, an indirect, index or other draw buffer, a blit's buffer, a texture over it), not at
the next commit, and a buffer's first bytes at the next commit whatever it names. A run of an
unchanged artifact may therefore submit and record other copies under an unchanged key. None of
the validation crate's runtime inputs changed, so runtime-sources.sha256 holds. SEMANTICS_VERSION
does not move: nothing compiled changed. 2553 is taken by another row landing beside this one.

Verified: the value alone changes; the gate at this tip follows.
2026-12-02 21:46:15 -08:00
Anees Iqbal 09ca2bcb00 Conformance: Metal's times for the five managed-named cases, kept in their recordings
`conformance times --runs 8 --write` over the five cases, built --release at a2f2cad217, on the
Apple M3 Max, macOS 27.0.1 (26A434), job m3-max-81954 (the build: job m3-max-81941). Each
recording gained one time record (native Metal, 8 rounds), a recorded hole whose stopped reason
is the cases' own: the oracle keeps one copy of a Managed buffer, so its leg is forbidden. A
comparison of the JSON before and after shows `times` the one key added and every other key
equal. This is what times::every_case_is_timed::every_case_carries_its_timing asked of the new
cases (it failed in m3-max-81916 at c098a9848e). docs/CONFORMANCE-COVERAGE.md, regenerated,
does not change.
2026-12-02 21:46:14 -08:00
Anees Iqbal bbdf8d4d90 Conformance recordings: the five managed-named cases, carried from the 5300M's measurement
Each recording holds the case's carried answer as record mode writes a carried case's: the
transcript of the reader's content as an AMD Radeon Pro 5300M under macOS 26.7.1 read it, 8
rounds a reader (jobs 81602 and 81644), measured_on amd-radeon-pro-5300m, validated not run. The
compute slot, the declaration, the vertex slot and the blit source read the bytes as of the
reader's commit; the reach through the address alone reads the bytes the GPU's copy last took.
The oracle's own run is forbidden by the cases (one copy), so nothing here ran on Metal.

They were written by record::carried and record::write, the calls record mode makes for a
carried case, through a scratch test of a CPU-only job's own workspace (job m3-max-81916, at
c098a9848e), never committed. docs/CONFORMANCE-COVERAGE.md is regenerated with them
(scripts/conformance-coverage/coverage.py): 192 case modules, 1347 recordings, 85 carried.

Verified: in the same job the conformance suite ran 1050 tests, 1048 passed; the two failures are
the coverage document, regenerated here, and the cases' missing Metal time records, which the
oracle's times run adds next.
2026-12-02 21:46:14 -08:00
Anees Iqbal 4ce4babc7f Conformance: managed_naming's compute reader reads its words as arrays, and takes no unused import
Clippy named the chunks_exact of a constant 4 (as_chunks reads each word as an array, with no
conversion that can fail) and the unused import of call.

Verified: clippy of the conformance crate in job m3-max-81909 (CPU-only build) failed on both;
the next job runs it again.
2026-12-02 21:46:14 -08:00
Anees Iqbal 6469bd9bc0 Runtime: a commit drains the buffers made since the last in place
Clippy's drain_collect named the collect of the made entries into a vector of their own; the loop
now drains them directly, its other borrows being of the change list's other fields.

Verified: clippy of the conformance crate's dependencies in job m3-max-81865 (CPU-only build)
failed on it; the clippy job follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal 367f1f2313 Player: Seconds::named goes, as no commit asks it any more
A commit takes its named ranges through Seconds::take, which answers none where its command
buffer named no buffer with a range, so nothing calls named. The release build of the player warned
of it as dead code.

Verified: the warning is in the player's release build of the frame-396 play job m3-max-81847
(lavapipe); no caller in the tree (grep of seconds' calls). The clippy job follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal 91325782b2 Conformance: managed_naming's reader makes its compute states through the side's stage helper
The reader's own helper took the name of the side's kernel stage helper, a duplicate definition
on RtSide. It is now compute_state, built on that helper, and the render reader takes its two
stages through it as well.

Verified: the recording job m3-max-81836 (a CPU-only build, at the commit before the rebase)
failed to compile the conformance crate on the duplicate; the next job compiles it.
2026-12-02 21:46:14 -08:00
Anees Iqbal 6652825031 Conformance: the watching side forwards managed_naming
Watching forwards every Side method, so a watched run of the managed-named cases answers what the
side it wraps answers rather than Unavailable. The suite's test that compares Side's methods with
Watching's forwards names the missing one without it.

Verified: expected from the forwarding test's name sets. The conformance suite run follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal f77950bf75 rt test: the placed device copy's copy-in is read by a commit that names the Managed buffer
The test every_device_places_a_managed_buffer_s_device_copy_where_the_consumer_says named the
whole buffer, then read the block through a commit that kept only another buffer over the
Private block. Under the rule that a named range is taken at the first commit whose encoders
name the buffer, that commit takes nothing, so the two-copy form read the old bytes. The read's
commit now names the Managed buffer as well.

Verified: lavapipe rt suite job m3-max-81780 at f864a75d35 failed this test alone (958 of 959
passed, 4 skipped) at the copy-in assertion; the rerun follows.
2026-12-02 21:46:14 -08:00
Anees Iqbal bf6a072dd4 Conformance: managed_naming, which commit takes a Managed range to a second copy
Five cases, one a reader, each of the same sequence: a Managed buffer's red
contents written, named and taken by a blit; green written and named, then a
commit of a blit that fills another buffer; the reader encoded, blue written
with no second name, the reader's command buffer committed. The site holds
which of the three the reader read. Readers: a compute slot
(scale_and_offset), useResource: (ab_address), the address alone (ab_address,
no declaration), a vertex slot with a draw (colored_vertex), a blit copy's
source.

Metal's answer is carried from an AMD Radeon Pro 5300M table under macOS
26.7.1, 8 rounds a reader (jobs 81602 and 81644): the readers that name the
buffer read the bytes as of their commit (blue), the address-only reader the
bytes the GPU copy last took (red). The oracle keeps one copy, so record mode
may not replace the table (carried_only), and the case names the chip
(recording::AMD_RADEON_PRO_5300M; the known-families list in
a_carried_answer_taken_on_another_chip_names_it grows by managed-named-).

The runtime's side runs the sequence in the form the device's memory-type
query picks. On a device that keeps one copy the address-only row answers the
venue's gap (a device copy of each Managed buffer), as that row asks what a
second copy holds; the other rows read the bytes as of their commit in either
form, as the 5300M and the one-copy UHD Graphics 630 (jobs 81603, 81645) did.

Recordings follow from a record job on the oracle. Not yet compiled.
2026-12-02 21:46:14 -08:00
Anees Iqbal b7c59c9b9c Runtime: a Managed buffer's first bytes go at the next commit, whatever it names
The first-naming-commit rule (baf1c8a8c9) also held a new Managed buffer's
first `copied` bytes until a commit named the buffer, so a reach before then
read the device copy's old bytes. Metal's device copy holds a buffer's bytes
from its making. Those bytes now go in at the next commit whatever its encoders
name (Changes::made, taken by every commit, merged with the buffer's named
ranges where the same commit takes both); ranges did_modify_range names still
wait for a commit that names the buffer. The made entries are swept as the
named ones are.

Texture::image_bytes, a test helper, now commits a compute encoder that
declares the texture by use_resource, so its commit takes the named ranges of
the buffer the texture lies over.

Lavapipe's full runtime suite at baf1c8a8c9 (m3-max-81741: 957 passed, 2
failed, 4 skipped) failed managed::every_device_places_a_managed_buffer_s_
device_copy_where_the_consumer_says and over::every_device_holds_a_texture_
over_a_buffer_in_place on these two; this fixes both. Not yet compiled.
2026-12-02 21:46:13 -08:00
Anees Iqbal 8be5365553 Player: a two-copy stream's announcement is taken at the first commit that names the buffer
The runtime now takes a Managed range at the first commit whose encoders name
its buffer, as Metal on an AMD Radeon Pro 5300M does (jobs 81602, 81644). The
player's own second copy, which a two-copy stream's Managed buffers take on a
device with unified memory, took every range named at the next commit of any
command buffer; it now follows the runtime's rule.

- second.rs: Seconds keeps, for each command buffer not yet committed, the
  buffers with a second copy its encoders named, themselves or through a
  texture over one (made over the buffer, a tiled one, or a view of one), and
  a commit takes only those buffers' ranges. A released buffer with ranges
  pending stays only while a command buffer not yet committed that named it,
  or a texture over it, can take them; otherwise its place goes back at once.
  A command buffer released uncommitted takes nothing.
- mod.rs: each encoder call's named objects, a render pass's attachments,
  resolve textures and visibility result buffer at its encoder's making, and
  the textures and views made over a second copy feed it. render.rs keeps the
  pass's resolve textures and visibility result buffer by stream id.
- encoders.rs: copy_named takes the committing command buffer's ranges alone.
- stale.rs: a didModifyRange: is pending until a commit whose uses name the
  object takes it, with the bytes written by then (an indirect command
  buffer's command takes it where it is encoded); writes between the
  announcement and that commit are not stale.
- docs/REPLAY-STREAM.md says so.

Tests: rt_replay a_two_copy_stream_s_announcement_is_taken_at_the_first_
commit_that_names_the_buffer (zeros announced, a commit of another buffer, 7s
written with no announcement, a copy of the buffer reads the 7s); tests
an_announcement_is_taken_at_the_first_commit_that_names_its_buffer (the
census counts one stale use where it counted two). Not yet compiled.
2026-12-02 21:46:13 -08:00
Anees Iqbal 51ac48c788 Runtime: a Managed range is taken at the first commit that names its buffer
On a device that keeps a device copy, did_modify_range named a range and the
next commit of any command buffer took every range named since. A consumer
that names a range, commits a command buffer that does not use the buffer,
writes the range again with no second name, then commits the command buffer
that binds it had the GPU read the first bytes. Metal on an AMD Radeon Pro
5300M (macOS 26.7.1, 8 rounds each, jobs 81602 and 81644) takes a named range
at the first commit whose encoders bind the buffer (a compute slot, a vertex
slot with a draw), declare it by useResource: or read it in a blit copy, with
its bytes as of that commit; an unrelated commit takes nothing; a buffer named
to no encoder and reached by address keeps its last synced bytes. The Intel
UHD Graphics 630 keeps one copy (jobs 81603 and 81645).

A commit now takes only the ranges of the buffers its command buffer keeps,
which is every way an encoder names a buffer in the runtime:
- a slot of any stage: compute set_buffer, set_vertex_buffer,
  set_fragment_buffer;
- use_resource on a compute or a render encoder (the runtime has no
  use_resources);
- an index buffer; the indirect arguments of a draw, an indexed draw or a
  dispatch; a patch draw's index and control-point buffers and an indirect
  command buffer's range buffer, kept by the same line of the draw as the
  index buffer and the arguments;
- the tessellation factor buffer and the pass's visibility result buffer;
- a blit: a copy's source or destination, a fill, a copy into or out of a
  texture, a synchronize;
- a texture over the buffer, or a view of one, wherever the command buffer
  keeps it (a slot, use_resource, an attachment, a resolve, a blit).
A heap use names none: Metal refuses a Managed heap (jobs 81602, 81603).

A pending range holds its buffer weakly. The pending list sweeps the entries
of buffers gone once it holds twice the entries its last sweep left (at least
64), so it stays bounded by the live buffers with ranges pending.

Tests (tests::managed): the consumer's six calls (red at e1fbce1486 on
lavapipe's two-copy view, m3-max-81614, and on an RTX 2080, m3-max-81606);
each way above, through compute, render and blit encoders and a texture over
the buffer, with a reach by address alone taking nothing; a buffer no encoder
names keeps the bytes taken last; a narrow named range takes its own bytes
alone (unaudited on Metal); a declaration alone takes, a commit with no
commands takes nothing. over_texture's capture commit now names its buffer.

The did_modify_range doc and the runtime README state the rule and its jobs.
Not yet compiled; the green runs follow.
2026-12-02 21:46:13 -08:00
Anees Iqbal 698acffa48 Runtime test: a Managed range named, then written with no second name, read at the first commit that names its buffer (red)
A consumer writes zeros into a Managed buffer and names the range. It commits a command buffer that
does not name the buffer, and that command buffer completes. It encodes a kernel that reads the
buffer, writes a table over the zeros with no second didModifyRange:, and commits. The test expects
the kernel to read the table, in either form.

Metal on a discrete Mac GPU (an AMD Radeon Pro 5300M) takes a named range at the first commit whose
encoder binds its buffer (Buffer::did_modify_range's doc). The runtime takes it at the next commit of
any command buffer, so with a device copy the kernel reads the zeros. A guest's argument buffer
written this way held a null pointer in the device copy, and its vertex function read through that
pointer.

Red runs follow in the next commit's message.
2026-12-02 21:46:13 -08:00
Anees Iqbal 2b335a8174 rt docs: the memoryless refusal's basis says what is true now
Gap::MemorylessTexture's basis read "render passes are not built", which stopped being true
when render passes were built. It now names the reason the refusal stays: a memoryless
attachment keeps its contents for the whole render encoder, across the renderings the runtime
ends and restarts inside one encoder (barriers after writing draws, the feedback-loop barrier,
copies for textures over buffers and Managed copies, shadow copies), and the image that would
hold them is not built. docs/REFUSALS.md regenerated (scripts/refusal-surface).

Docs only: no behaviour changes. refusal_surface.py --check exits 0.
2026-12-02 21:43:32 -08:00
Anees Iqbal b7e1e435e3 rt docs: texture_copy_cause's causes that hold for every buffer of a kind of memory
Buffer::texture_copy_cause (and new_texture_in_place's TextureNotInPlace cause) now says
which of its answers come from the device's queries of the descriptor and the buffer's kind of
memory alone: HostMemory, DmaBuf, DmaBufs, Dedicated, Surface, Linear and LinearFeatures, all
decided in check_over before any place is read (memory_cause, the external or linear image
query, the linear tiling's features). Spilled, Pitch, Alignment, RenderReach and ImageMemory
depend on the buffer and its place (the block's spill, then in_place_fit's laid image). A
consumer may keep a kind-only answer per descriptor and kind of memory instead of importing
another buffer to ask again; the consumer's census meets four such refusals a run on the M3,
each paying a map and an import first.

Docs only: no behaviour changes. Verified by reading check_over, memory_cause and over_cause at
this commit's parent.
2026-12-02 21:41:48 -08:00
Anees Iqbal ece306e521 Runtime test: a vec16 argument bound 4 past a multiple of 16 beside one at 0, with its dispatches' forms
every_device_places_each_vector_access_at_its_own_address gains a run binding vwp_vec16's a 4
bytes past a multiple of 16 and b at 0: one argument of alignment 16 at a multiple of 4 below its
alignment beside one at its alignment, the shape a guest kernel's refused bind had (index 0 at
offset 1871700, 4 past a multiple of 16, alignment 16). Each run now prints how many of its two
dispatches ran with their buffers bound (Metrics::bound_dispatches) and how many at their
addresses (Metrics::address_dispatches), so a card run shows which form served the bind.

Verified: the test passes on lavapipe (llvmpipe, LLVM 23.1.1), job m3-max-81994, with clippy
-D warnings under --cfg m2v_cpu_icd clean: every run's two dispatches at addresses (lavapipe has
no bound form), the a-at-4, b-at-0 run included. On the RTX 3090, job m3-max-81997, the same run's
two dispatches both ran bound (a in the variant that keeps its address, b through its binding),
the a-at-4, b-at-8 run one bound and one at addresses, and every other run two bound; every
buffer held Metal's words on both.
2026-12-02 21:24:07 -08:00
Anees Iqbal e2ab03dc71 Translator: SEMANTICS_VERSION 2328 for a kernel's indexed patch draws and the records' new tail
dc126ab306 lowers render_command's draw_indexed_patches (it wrote a refusal before) and grows every
command's record tail by 8 bytes: the stride is index() + 48 (was + 40), the sequence index lies at
index() + 24 (was + 16) and the draw's arguments at index() + 28 (DRAW_AT, was 20). So a kernel that
writes, resets or reads any command of an indirect command buffer translates to other words under
an unchanged key. The golden tables are re-blessed on development.


Verified: lavapipe m3-max-81663 (red, then green); 2080 m3-max-81688, XTX and 780M m3-max-81689, lavapipe m3-max-81691 (engine, rt indirect and the 6 range rows against Metal's recording m3-max-81637 on the Apple M3 Max); Iris Xe m3-max-81890 (no VK_EXT_device_generated_commands: refused by name); states-only play m3-max-81856 0 refused; suites and lint m3-max-81855.
2026-12-02 21:14:39 -08:00
Anees Iqbal e4195ee560 Conformance recording: indirect-range-gpu-written-indexed-patch-draws on Metal
Metal's answer for the indexed-patch-draws range row, recorded on the Apple M3 Max (macOS 27.0.1,
26A434) by job m3-max-81637 at 992794d8bd (the AIR commit, d244877fb2 after the rebase onto
685bde8009, the same patch), with its times (8 rounds, the same job). The execution completes, and
commands 1 to 5 draw rows 2 to 11 whole: each command's quad, whose four corners are stored out of
order and named in order by its 16-bit control-point indices, covers its two rows. Each texel
holds the command's mark, the patch index i, the instance and the base instance i, the patch-draws
row's texels exactly.

The ledger's Iris Xe row is the Extension refusal, as for the other range rows: the Iris Xe lists
no VK_EXT_device_generated_commands. CONFORMANCE-COVERAGE.md is regenerated.
2026-12-02 21:09:01 -08:00
Anees Iqbal 39423d92f1 ICB: a kernel's indexed patch draws into an indirect command buffer, executed through a layout of indexed patch draws
The owner's 3406 order, the planner's next indirect command kind: MTLIndirectCommandTypeDrawIndexedPatches.

The records (pipeline::IndirectDrawLayout) grow by 8 bytes a command for every kind. The
control-point indices' address is a third u64 that an execution pushes, and VUID 11103 asks each
token's offset to be at or past the one before it, with the draw token last (VUID 11100). So the
address cannot go after the draw; it lies past the index token's 16 bytes, at index() + 16.
Every command's tail is now 16 + 8 + 4 + 20 = 48 bytes: the stride is index() + 48 (was + 40),
the sequence index's place index() + 24 (was + 16), and the draw's arguments index() + 28 (the
translator's DRAW_AT, was 20). The cost is 8 bytes a command in every buffer: 160 bytes for 7
vertex and 7 fragment slots (was 152, 5% more), 48 for none (was 40), 544 at most (was 536),
which the floor's stride and token-offset limits are checked against. One record shape for every
kind stays: a kernel cannot know a buffer's kind when it is translated, so it writes one shape
whatever buffer it reaches. The main lane accepted this on the condition that the
already-landed kinds' rows run again at the new layout.

Translator (lower/access/icb.rs): a render_command's draw_indexed_patches writes what
draw_patches writes (the draw's VkDrawIndirectCommand of patches, the factors' and the patch
indices' Metal addresses) and the control-point indices' Metal address at the new place
(CONTROL_POINTS_AT, IndirectDrawLayout::control_point_indices). Its operands are draw_patches's,
with the control-point indices at operand 6.

Runtime: Device::new_indirect_command_buffer takes DRAW_INDEXED_PATCHES alone
(CommandDraw::IndexedPatches), refused as patch draws are on a device whose executions run no
tessellation stage (TessellationStages). Its layout pushes the control-point indices' address
where the control stage reads it (FieldValue::ControlPointIndices), holds no index buffer token,
ends in TOKEN_DRAW and names the tessellation stages. An execution checks the state's
control-point index type against the buffer's kind, as a direct draw checks it against the call:
patch draws with a state of an index type are Refusal::PatchDrawWithIndexType, and indexed patch
draws with a state of none Refusal::IndexedPatchDrawWithoutIndexType. This replaces the patch
draws' check through an empty PatchReads.

Docs: the runtime README's ICB section (records, tokens, refusals, floor limits); the API guide's
section 1; METAL-COVERAGE (coverage.tsv); CONFORMANCE-COVERAGE and REFUSALS.md regenerated (the
two refusals gain the draw site); the API signature table blessed for control_point_indices.

Tests: the red commit's engine and runtime device tests; the layout's unit tests at the new
offsets, the reset command's control-point place among them; a unit test of the indexed patch
tokens.
2026-12-02 21:09:00 -08:00
Anees Iqbal 2f93ecaba5 Tests: a kernel's indexed patch draws into an indirect command buffer draw as their draws direct (red)
The engine test of a kernel's patch draws compiles and validates icb_merged_ipatches too, whose
kernel encodes indexed patch draws with 16-bit control-point indices of its own, on every profile.

The runtime's patch-draws device test becomes one body for both kinds. Its new arm,
every_device_draws_encoded_indexed_patch_draws_as_their_draws_direct, uses a state of
icb_merged_ipatches's functions: a float2 corner at attribute 0 of vertex buffer 2, stepped per
patch control point, under the UInt16 control-point index type. Each patch's corners are stored
out of order, and its indices name them in order. The arm asserts that four indexed patch draws
the kernel encodes draw what the same draws direct draw, in the four executions of the patch
draws' arm, and that indexed patch and patch draws together are CommandTypes.

Red: the translator refuses a render_command's draw_indexed_patches
(GpuEncodedIndirectCommands), and the runtime refuses a buffer of DRAW_INDEXED_PATCHES
(CommandTypes).
2026-12-02 21:09:00 -08:00
Anees Iqbal 2e9f37f0ec Fixture: icb_merged_ipatches's AIR companions
Regenerated by scripts/regen-air-fixtures icb_merged_ipatches on the Apple M3 Max (macOS 27.0.1,
Apple metal version 32023.922, macOS SDK 27.2), job m3-max-81619: the .ll and .air.ll of the owned
source, and the fixture's line in TOOLCHAIN. The engine inventory, the golden tables and the
air_input printouts take the fixture when they are re-blessed on development.
2026-12-02 21:09:00 -08:00
Anees Iqbal d0dedfb984 Tests: a kernel's indexed patch draws into an indirect command buffer, a range row of their own (source; red)
The next indirect command kind after patch draws: MTLIndirectCommandTypeDrawIndexedPatches.
icb_merged_ipatches is an owned fixture. Its kernel encodes command i as one quad patch of four
control points from patch i, with no patch index buffer, 16-bit control-point indices and
level-1 half factors, one instance for an even command and two for an odd one, from base
instance i, with vertex buffers 0 to 2 of its own. The post-tessellation vertex function reads its
four corners through a PerPatchControlPoint layout at vertex buffer 2. The points are stored out
of order and the indices name each corner, so a patch that covers its rectangle read its
indices. Each texel then holds its command's mark, the patch index, the instance and the base
instance.

indirect_ranges.rs gains the row indirect-range-gpu-written-indexed-patch-draws: commands 1 to 5,
written by a blit's copy before the pass, as the patch-draws row is. EncodedRange carries the
commands' pipeline's vertex descriptor and tessellation state where a row states them; both
sides set them on that pipeline (the Metal side's tessellation fields through one helper, the
runtime side's through the fields module's descriptors). The fixture's AIR, the Metal recording
and the ledger row follow in their own commits.
2026-12-02 21:09:00 -08:00
Anees Iqbal 8baa784961 rt: a release counts as waiting until the reaper or the block-maker thread has done it
Gauges::releases_waiting counted a release only while it waited for work
in flight. An object then handed to the reaper thread stopped counting
before the reaper freed it, and an imported or exported block or memory of
its own given back to the block-maker thread never counted. So a read of no
release waiting and no command buffer live could find objects still
counted, freed a moment later. The harness's churn rows, the replay
player's settled reads and the matrix take that read for every release
done. Round K's churn_all_day failed so on the RTX 2080 (m3-max-81680: an
iteration's plane stand-in, its export, 4 textures and 3 attachment views
still counted at the 200th read) and on the RTX 5080 (m3-max-81692: a
whole iteration's set counted at the 100th read).

Now a release counts until it is done:
- Reaper::give counts a free or a released image as it queues it, before
  the reaper can take it; the reaper's run and its drain at the core's drop
  count it done once its free ran. A teardown job is no release.
- Pool::give_back_own and give_back_loose count the block given back
  before the block-maker thread can take it; the block-maker thread and
  free_all count it done once it is freed and an import's release ran.
- A release that waited for work and goes on to the reaper rises at the
  give and falls for its wait after, so it counts without a gap.
No sleep and no retry: the settled read waits on the same gauge, which now
covers every queue a release passes through.

Docs: Gauges::releases_waiting and the runtime README's gauge list say what
it counts and that a read of 0 with no command buffer live comes after every
release made before it is done.

Test: argument_tier's every_device_holds_a_release_until_the_work_committed_before_it_retires
holds the reaper across the releases; it now waits for the index to be
vacated, expects the texture's image handed to the held reaper to still
count, and expects the gauge at 0 once the reaper goes on.
2026-12-02 21:06:55 -08:00