Commit Graph
10176 Commits
Author SHA1 Message Date
Anees Iqbal a0d2d2efdd rt: a failed wake of the completion thread is owed to the next wake, and a failed host wait is made again
vkSignalSemaphore fails only for want of memory or with VK_ERROR_UNKNOWN,
never with a loss. The wake ignored the failure and marked the thread woken,
under a comment that said a failure is a loss. The thread stayed in its GPU
wait with nothing to end it, and every later flight-only wake returned early,
because the thread already waited for the progress semaphore. With work in
flight, a listener or an end then waited for the front batch to complete.
That is a deadlock where that batch waits on a host signal the listener
would give.

The form (the planner's ruling, which withdrew its "next wait is bounded"
form, a record the wait in progress cannot read):
- A failed signal leaves the wake owed. The thread stays marked waiting on
  the GPU, and the next wake from any thread signals again at a higher
  value, flight-only wakes included. The thread clears the debt as it next
  reads the state.
- There is no polling: tests/event_values.rs's thread-does-not-spin
  assertion holds as before.
- The limit, stated in the code: a failed wake that no later wake follows
  waits for the wait's other semaphores.

vkWaitSemaphores (the dma-bufs import's bind wait before vkDestroyBuffer)
and vkDeviceWaitIdle ignored every failure under a comment that named loss
alone. Both now go through complete::wait_through:
- success, a loss the call reports, or a loss the runtime has seen ends the
  wait;
- an out-of-memory or unknown result, which says nothing of what is
  pending, is called again 100 ms (LOSS_POLL) later.
So a lasting out-of-memory result on a live device waits, and no buffer
whose bind may still be pending is destroyed. On a lost device,
vkDeviceWaitIdle returns success or VK_ERROR_DEVICE_LOST in finite time
(Lost Device), so a teardown does not spin on a dead device.

The two tests of the previous commit, failed_waits.rs, turn green here
through the same seams (fail_wakes, fail_waits).
2026-12-02 23:36:31 -08:00
Anees Iqbal ed23a06f5f rt test: a failed wake and a failed idle wait, red before their fix
Two device tests through two test seams on Core, in fail_begins' style:
fail_wakes fails the completion thread's next wakes as vkSignalSemaphore out of
host memory, and fail_waits fails the device's next idle waits before the
driver is called. Each seam is wired into today's path unchanged: the wake
still ignores the failure and marks the thread woken, and the idle wait still
returns.

- a_failed_wake_is_owed_to_the_next_wake: a fill is in flight behind the Busy
  gate, a listener is posted at a value the host already set, and its wake
  fails. The test expects a second fill's commit, a flight-only wake, to
  deliver the owed wake while the gate still holds both fills. Today that
  wake returns early, so the listener waits for the gate.
- a_failed_idle_wait_is_made_again: a fill is in flight behind the gate and
  the idle wait's first call fails. The test expects the idle wait not to
  return while the gate holds the fill. Today it returns at once.

Both are expected to fail at this commit. The next commit is the fix.
2026-12-02 23:36:31 -08:00
Anees Iqbal f606e43b30 Tests: re-bless the golden tables at pin P
The engine inventory, the golden hash table and the air_input printouts, re-blessed at
1a84985dd4 on the M3 (potluck job m3-max-82483: inventory=0, golden=0, printouts=0, and the
metallib half of committed_air_fixtures_parse_and_link un-skipped, linkhalf=0). The texture
buffer words, sRGB draw writes and mul24 work since the last bless added the tb_word_formats,
fpv_srgb_draw_storage and int24_products fixtures and moved SEMANTICS_VERSION to 2332, so the
bless-due tests (engine_fixtures_match_their_golden_printout, inventory_lists_every_fixture_in_order,
golden_hashes_match_the_table, llvm_as parts 4 and 8) read red until this commit.

Files: golden_hashes.tsv, public_fixture_expectations_engine.tsv, and the two new printouts
air_input/tb_word_formats.txt and air_input/fpv_srgb_draw_storage.txt. Nothing else.
2026-12-02 23:35:58 -08:00
Anees Iqbal 1a84985dd4 Validation test: a texture over a no-copy import asserts the copies of the form the run reports
The test a_bytes_form_no_copy_buffer_is_an_import_and_a_descriptor_form_one_a_pool_buffer
asserted one imported over copy: the copy at use of a texture over host memory's import held in
an image of its own. A texture over host memory's import is now in place on an integrated or CPU
device whose external image query takes a linear image for that handle, its bytes saved and
written back once around its move home, so it counts that restore pair: two imported copies and
none at use. On the 780M (Phoenix, RADV, job m3-max-82442) the test read 2 and failed; its line
was "textures over buffers 2: 2 in place, 0 in an image of their own", with 2048 bytes of
host-memory restore. The product's count is the documented one; the test's expectation was
stale.

The test now reads each texture's form from what the run reports and asserts the copies that
form makes:
- #6, the one texture over an import, is in place where the device counts one texture in place
  over an import (textures_in_place_over_imports). Then it takes the restore pair: two imported
  copies and two host-memory restores of equal bytes, each at least the 784 bytes under the
  texture's rows, and none at use. Else it takes one imported copy of its 64 bytes at use, for
  host memory's cause or a linear-image decline.
- #13, over pool buffer #4, is in place where the textures-over line's in-place count, less #6,
  says so, with no copy. Else it takes one pool-side copy of 64 bytes at use.
- The at-use copies by cause sum to the textures in images of their own.
The test prints each texture's form and, where declined, its cause.

Verified on the fix's first form, the same assertions:
- 780M (Phoenix), m3-max-82451: both in place, #6 by its restore pair (2048 bytes), passed.
- Iris Xe, m3-max-82452: both declined for pitch (the linear image's row pitch or start is not
  the texture's 256), one copy each at use, passed. That is why the Iris read 1 before.
- RTX 2080, m3-max-82453: #6 for host memory (a discrete device), #13 for pitch, passed.

Product code is unchanged.
2026-12-02 23:25:26 -08:00
Anees Iqbal 28e4da1f17 Docs: Metal's resolve rounds a tie as its GPU does, and the alpha-to-coverage note's devices at 8 samples
The planner's ruling on resolve rounding: rule 1 counts a resolve among the device's own answers,
and two Macs round an average that lies exactly halfway between two codes differently, so Metal
fixes no answer there for a guest. An Apple M3 Max (macOS 27.0.1) rounds the tie up, as the
conformance recordings sample-positions-default-2x and -4x hold (red 1/255 over half the samples
resolves to 1); an AMD Radeon Pro 5300M (macOS 26.7.1) rounds it to the even code (red 0 at 1 of
2, 2 of 4 and 4 of 8 samples, an alpha of 127.5 to 128; m3-max-82284). The device's own rounding
stands; no behaviour changes and neither Mac's rounding is emulated.

- PrecisionNote::DeviceRoundedResolve's doc and docs/API.md's catalogue entry name both measured
  answers with their sources.
- The seven known-gaps-rt.tsv rows of sample-positions-default-2x and -4x (Iris Xe, RADV, NVIDIA,
  llvmpipe) say they differ only by how a tie rounds, and why that stands;
  docs/CONFORMANCE-COVERAGE.md regenerated from them.
- PrecisionNote::DeviceAlphaCoverage's doc and its catalogue entry say exactly which devices are
  measured at 8 samples: the 5300M (m3-max-82239); the M3 Max, which renders no 8 samples and so
  has no answer there; no device the runtime runs on. They said before both that the 5300M was
  measured at 8 and that 8 was unmeasured on every device.
2026-12-02 23:19:49 -08:00
Anees Iqbal e54cf61edd Translator: SEMANTICS_VERSION 2332 for mul24 and mad24
12cd7bc987 lowers air.mul24 and air.mad24 (both signs, i32 and 2 to 4 of its lanes), which the
translator refused as UnknownIntrinsic, so a kernel that calls one translates under an unchanged
key where it refused before: a cached FALLBACK of it is stale. The golden tables are re-blessed on
development.

Metal's answer: the product of the operands' low 24 bits, zero-extended for u and sign-extended for
s, and for mad24 its 32-bit sum with z, in the specification's range and outside it, at every word
of int24-products-in-range and int24-products-outside-24-bits on the Apple M3 Max under macOS
27.0.1 (m3-max-82247); the AMD Radeon Pro 5300M under macOS 26.7.1 answers both cases with the same
output sha256 as the M3's, 5bf881c0 and f8cce5fb (the fixture compiled at run time, the cases'
buffers; m3-max-82284).

Verified: at this change on ee6911e100 (cab2e25131), clippy plain, --cfg m2v_gpu and
--cfg m2v_cpu_icd and Rustdoc clean; the core suites 3715 passed, 39 skipped; validation 1322
passed, 3 skipped; conformance 1050 passed; doctests 2 passed; both cases Match Metal's rows on
lavapipe (m3-max-82325) and on the AMD Radeon RX 7900 XTX (m3-max-82350); the guest's kernel that
was refused compiles, PASS on the RADV and lavapipe profiles (m3-max-82349). At this change on
86190052f5 (68e8a17200): fmt --check and clippy plain clean, the translator and AIR suites 3437 passed, 37
skipped, both cases Match Metal's rows on lavapipe (m3-max-82408).
Before that: the int24_products kernel PASS with spirv-val clean on all fifteen profiles (m3-max-82287); a states-only play of glbench-780m-r4-recnil on lavapipe, 3756 render and
484 compute states made, 0 refused (m3-max-82292).

Re-laid onto d12395fc12, whose new commits touch no file of this change but the version file's
RUNTIME_VERSION line.
2026-12-02 23:17:29 -08:00
Anees Iqbal 5150424104 Translator: the math sweep takes mul24 and mad24 at 32-bit lanes alone; the signature table's two variants
every_math_entry_decodes_and_checks spells every table entry at every integer width, and read
air.mul24.s.i8 as unknown, which 12cd7bc987 means: mul24 and mad24 are of i32 lanes alone. The
sweep now skips their other widths, as it skips dot's scalars; the decode test of 12cd7bc987
holds those widths unknown.

api_signatures.tsv gets the two variants 12cd7bc987 adds to the published
metal2vulkan-air::intrinsics::MathFn, Mul24(Sign) and Mad24(Sign)
(scripts/api-signatures/signatures.py --bless): an addition, nothing removed or changed.

Both failed in the gate at 12cd7bc987 (m3-max-82287), whose other 3431 translator and AIR tests
passed, the arith sweep's mul24 and mad24 kernels and the new decode test among them.
2026-12-02 23:17:08 -08:00
Anees Iqbal 0d4295e5f6 Tables: int24_products's golden printout, and its inventory rows confirmed by the bless
bless_engine_goldens under the pinned LLVM 21 on the M3 (m3-max-82288) writes the fixture's
printout, its sixteen calls decoded as Mul24 and Mad24 of both signs at 1 to 4 lanes.
bless_engine_inventory in the same job leaves the two int24_products rows of 617853c57b as they
are: the kernel translates on all fifteen profiles from the opaque and the typed text.

The same bless also wrote rows and a printout for engine/tb_word_formats, another change's fixture
already on development; they are left to development's bless, as are the golden hashes.
2026-12-02 23:17:08 -08:00
Anees Iqbal 12cd7bc987 Translator: mul24 and mad24 are the 32-bit product of their operands' low 24 bits
A guest's screen-sharing encoder makes a compute pipeline whose kernel calls air.mul24.u.i32, and
the translator refused it as UnknownIntrinsic. The guest's module declares four of the family
(air.mul24 and air.mad24, s and u, of i32); Apple's compiler spells sixteen
(air.{mul24,mad24}.{s,u}.{i32,v2i32,v3i32,v4i32}, m3-max-82233). All sixteen decode now.

The Metal Shading Language specification (4.1, section 6.4, Table 6.2): mul24 "multiplies two
24-bit integer values x and y and returns the 32-bit integer result. x and y are 32-bit integers
but only the low 24 bits perform the multiplication"; mad24 "uses mul24 ... adds the 32-bit
integer result to the 32-bit integer z". Below the table the product is defined for x and y in
[-2^23, 2^23 - 1] signed and [0, 2^24 - 1] unsigned and implementation-defined outside them.
The Apple M3 Max (macOS 27.0.1) answers outside that range too with the product of the operands'
low 24 bits, zero-extended for u and sign-extended for s: 480 of 480 words of
int24-products-outside-24-bits, where the 32-bit product of the whole operands differs at 386
(m3-max-82247). That outside-range equality is measured on the M3 only.

Now:
- intrinsics::math decodes air.mul24.<s|u>.<T> and air.mad24.<s|u>.<T> as MathFn::Mul24 and
  MathFn::Mad24, for T i32 or a vector of it; any other element width stays undecoded.
- canon::routine replaces each call, after SCCP as it does OpenCL C's mad, by plain AIR in T's
  shape: each operand's low 24 bits (and 0xffffff for u; shl 8 then ashr 8 for s), their 32-bit
  mul, and for mad24 the 32-bit add of c, all without nsw or nuw. One form on every device and no
  precision note: it is the table's own wording, and it equals Metal at every word measured.
- Lowering takes them as it takes any such instructions; a Mul24 or Mad24 call that survived
  canonicalization is an invariant failure, as a mad call is.

Tests: mul24_and_mad24_decode_on_32_bit_lanes_alone (the sixteen names; i16, i64, i8 lanes, a
float, no sign and a prefix stay unknown). The arith sweep's five mul24 and mad24 kernels
(cc5adc7e7c), the int24_products inventory rows (617853c57b) and its two validation cases
(7fcd661645) are the red tests this turns green.
2026-12-02 23:17:08 -08:00
Anees Iqbal cc5adc7e7c Translator test: mul24 and mad24 multiply their operands' low 24 bits on every profile (red)
Five kernels of the arith sweep, each validated and interpreted on every profile:
air.mul24.u.i32 of 0x01FFFFFF and 0x00FFFFFF (0xFE000001, where the 32-bit product of the whole
operands is 0xFD000001), air.mul24.s.i32 of 0x00800000 and 0x7F000003 (bit 23 sign-extends:
0xFE800000, not 0x01800000), air.mad24.u.i32 adding all 32 bits of -1, and per-lane
air.mad24.s.v4i32 and air.mul24.u.v3i32 of operands with bits above bit 23. The expected values
are the product of the operands' low 24 bits, zero-extended for u and sign-extended for s, then the
32-bit sum, as the M3 Max answers the int24_products cases in and outside the specification's
range (m3-max-82247).

Red: the translator refuses each as UnknownIntrinsic.
2026-12-02 23:17:08 -08:00
Anees Iqbal 7fcd661645 Validation cases: Metal's answer for mul24 and mad24 in and outside their 24-bit range (red)
Two authored cases over engine/int24_products, 12 threads, out filled with 0xAB: operands in the
range the Metal Shading Language specification gives mul24 (section 6.4, after Table 6.2:
[0, 2^24 - 1] unsigned, [-2^23, 2^23 - 1] signed), and operands outside it, each beside small
in-range partners, where the specification calls the product implementation-defined. The addends
are full 32-bit words in both. Installed with corpus-case-check (m3-max-82243) and qualified on
Metal on the Apple M3 Max, three executions each (m3-max-82247).

Metal's outputs against the kernel computed on the CPU, word for word (480 words each):
- in range: equal to the 32-bit product of the operands, and equal to the product of their low
  24 bits (zero-extended unsigned, sign-extended signed), which agree there;
- outside the range: equal to the product of the operands' low 24 bits at all 480 words; the
  32-bit product of the whole operands differs at 386 of them.

scripts/qualify-public-cases runs both on lavapipe against those rows. They are red until the
family is lowered: today the translator refuses the kernel as UnknownIntrinsic.
2026-12-02 23:17:08 -08:00
Anees Iqbal 617853c57b Fixtures: int24_products's companions, and its inventory rows written as ok on every profile (red)
The companions come from scripts/regen-air-fixtures on the M3 (job m3-max-82233: Metal 32023.922,
SDK 27.2). Apple's compiler spells the family as sixteen intrinsics, air.mul24.<s|u>.<T>(T, T)
and air.mad24.<s|u>.<T>(T, T, T) for T in i32, v2i32, v3i32 and v4i32, and the fixture's module
declares all sixteen. MSL on macOS spells no wider form: the header's 8- and 16-lane overloads sit
behind __HAVE_NATIVE_WIDE_VECTORS__, which is not defined there, and uint8 and int16 are reserved
names (the same job).

The engine inventory's two rows expect the kernel to translate on every profile. They are red
until the family is lowered: today each profile refuses it as UnknownIntrinsic. The golden
printout under tests/air_input follows the decoder's change.
2026-12-02 23:17:08 -08:00
Anees Iqbal 2c8f839869 Fixtures: int24_products, mul24 and mad24 of both signs at every width MSL spells them (source)
Our own MSL for the air.mul24/air.mad24 family the translator refuses as UnknownIntrinsic (a
guest's screen-sharing encoder meets air.mul24.u.i32 in a compute pipeline). One kernel calls
mul24 and mad24, unsigned and signed, as a scalar and at 2, 3 and 4 lanes, over 12-value operand
rows of each sign rotated per thread, with full 32-bit addends, and stores every lane's bits:
40 words a thread. The companions come from scripts/regen-air-fixtures in the next commit.
2026-12-02 23:17:08 -08:00
Anees Iqbal d12395fc12 Versions: runtime 2557 for supportsTextureSampleCount: answering 8
RUNTIME_VERSION 2556 -> 2557: a device whose framebuffer colour, depth and stencil sample counts
hold 8 answers yes for 8 to supportsTextureSampleCount:, answers getDefaultSamplePositions:count:
at 8 with Vulkan's standard 8 locations instead of refusing it, and a pass at 8 samples takes
custom positions where its answer to programmableSamplePositionsSupported is yes.

runtime-sources.sha256 holds the inputs' new hash, computed as the build script computes it (the
same computation gives development e0fe34be0c's committed 70aa1707cd...).
2026-12-02 23:13:13 -08:00
Anees Iqbal efe893738c Translator, runtime: supportsTextureSampleCount: answers 8 where the device renders it into a colour, a depth and a stencil attachment
The planner's ruling: raster_sample_counts, which supportsTextureSampleCount:,
getDefaultSamplePositions:count: and programmableSamplePositionsSupported read, is the device's
framebufferColorSampleCounts, framebufferDepthSampleCounts and framebufferStencilSampleCounts,
intersected with 1, 2, 4 and 8. A query answer, not a second form: a device that renders 8 into
all three attachments answers yes for 8, as a Mac's AMD GPU does (an AMD Radeon Pro 5300M under
macOS 26.7.1, job 82204) and Apple10 does, where the Apple9 table answered 1, 2 and 4 alone.
TEXTURE_SAMPLE_COUNTS leaves the apple_gpu table, whose other answers are Apple9's.

Nothing else capped at 4: a texture's samples are its format's own (Limit::TextureSamples), the
pipeline link maps 8, the sample mask takes a word, Vulkan's standard locations hold 8, and
interpolate_at_sample reads index & (n - 1).

Metal at 8, measured on the 5300M (job 82239), and where ours can differ:
- interpolate_at_sample: indices 0 to 9, 15, 16, 100, 2^31 - 1 and 2^32 - 1 read sample
  index mod 8, the runtime's answer; InterpolantAt::Sample's doc says so.
- Alpha to coverage: the 5300M covers a pixel at one sample at an alpha of 1/2 or above, every
  pixel alike, and at two, four and eight samples floor(alpha * n + 1 - t), t 1/8 and 3/8 at even
  and odd x of an even row, 5/8 and 3/8 of an odd one; every pixel floor(alpha * n) or
  ceil(alpha * n). The device's own mapping may differ: PrecisionNote::DeviceAlphaCoverage (and
  docs/API.md's catalogue) now states the 5300M's rule beside the M3 Max's and that eight
  samples are unmeasured on every device.
- Default positions at 8: the 5300M's answer is Vulkan's standard 8 locations.

Docs that said 1, 2 and 4: Device::supports_texture_sample_count and default_sample_positions,
the floor's standardSampleLocations line, RenderPassDescriptor::sample_positions, positions.rs,
the runtime README (default positions, the floor table) and metal_properties' field.

Verified: the stacked gate (m3-max-82337, this change on the (i)+(b) hand-over): fmt, clippy in
three configurations, rustdoc, doctests, the validation suite 1322 passed (3 skipped), the
product suite 3725 passed with the five reds development's next bless takes (none of this
change's), the runtime's lavapipe suite 974 passed (4 skipped); the red commit's tests green on
lavapipe (2 translator, 9 runtime). On an RTX 3090 (m3-max-82314), an RX 7900 XTX and a 780M
(m3-max-82315) and an Iris Xe (m3-max-82316), the same patch on 8a2acc84fb: the runtime's 9
sample-count and sample-position tests pass, each device answers yes for 8 with Vulkan's
standard 8 default positions and answers programmableSamplePositionsSupported yes.
2026-12-02 23:12:42 -08:00
Anees Iqbal fda1e3602e Tests: supportsTextureSampleCount: answers Metal's 1, 2, 4 and 8 a device renders into a colour, a depth and a stencil attachment (red)
The planner's ruling: a device answers each of Metal's sample counts, 1, 2, 4 and 8, that its
framebufferColorSampleCounts, framebufferDepthSampleCounts and framebufferStencilSampleCounts all
hold. A Mac with an AMD GPU renders 8 samples (an AMD Radeon Pro 5300M under macOS 26.7.1 answers
supportsTextureSampleCount: yes for 1, 2, 4 and 8 and no for 16, job 82204), as Apple10 does
("Maximum sample count in render passes with MSAA" 8); the runtime answers an Apple9 GPU's 1, 2
and 4 alone today.

- The translator's metal_properties tests hold raster_sample_counts to the three framebuffer
  counts and {1, 2, 4, 8} on every committed profile: lavapipe 1, 4 and 8, moltenvk-m3 1, 2 and 4.
- The runtime's four-sample draw test holds the device's answer at every count from 0 to 64 to
  the same rule from the device's own limits.
- Metal's default positions at 8 samples, the 5300M's getDefaultSamplePositions:count: answer
  (job 82204, Vulkan's standard 8 locations), join the table the runtime's default-positions test
  compares with, which now reaches 8 wherever the device answers yes.

Red until the answer changes: today every profile and device that renders 8 answers no for it.
Verified red at this commit on 8a2acc84fb (m3-max-82304): both translator tests fail (lavapipe's
answer 1 | 2 | 4 where the rule gives 1 | 2 | 4 | 8, and the like on every profile that renders 8),
and the runtime's draw test fails on llvmpipe at 8 samples (framebuffer counts 0xd).
2026-12-02 23:12:41 -08:00
Anees Iqbal c1e6805526 Conformance: the sample positions family at 8 samples, carried from an AMD Radeon Pro 5300M
The oracle, an Apple M3 Max, renders no 8 samples (supportsTextureSampleCount: answers no for 8),
and a Mac with an AMD GPU does. Three rows run the family's pass at 8 samples: the device's own
positions against an edge at 5/8 of the pixel (5 of 8 samples), eight positions at x 0.25 (8 of
8) and one at 0.25 with seven at 0.75 (1 of 8). Their Metal answer is carried from an AMD Radeon
Pro 5300M under macOS 26.7.1, plain and under Metal's API validation layer, which passed the
passes (job 82284, the usage-edges probe sample_positions_8.m): the resolved texels
01 00 00 9f, 01 00 00 ff and 00 00 00 20, record mode forbidden on the oracle.

Each row's coverage avoids a resolve halfway between two codes: there the 5300M rounds to the
even code (4 of 8: red 0, alpha 128; and 1 of 2 and 2 of 4: red 0) where the M3 Max rounds a half
up (red 1), which is the device's own rounding (PrecisionNote::DeviceRoundedResolve), not where
the samples are. The probe's sweep of the default positions, an edge at each even sixteenth,
covered 0 to 8 samples in order, as Vulkan's standard 8 locations do.

The rows are sample-positions-8x-default, -8x-custom-left and -8x-custom-mixed, one prefix that
tests::a_carried_answer_taken_on_another_chip_names_it lists beside managed-named-* as the 5300M's.
Their recordings were written on the oracle by record mode's carried path, which runs no Metal,
with the timing record `times --write` keeps for a case whose Metal leg is forbidden
(m3-max-82412).

Verified: the conformance suite and its clippy (m3-max-82421); the rows replayed through the
runtime on lavapipe (m3-max-82337, m3-max-82421), an RTX 3090 (m3-max-82314), an RX 7900 XTX
(m3-max-82315) and an Iris Xe (m3-max-82316): every byte equal to the 5300M's, each row announced
only by the device's own colour conversion or point size notes. The 2x and 4x default rows, whose
resolve halves a code, stay the known gaps the ledger holds on those cards.
2026-12-02 23:12:41 -08:00
Anees Iqbal febb227781 Conformance probes: a discrete GPU's single-sample readback through Managed textures
alpha_coverage_sweep.m and pull_model_interpolation.m read their single-sample textures through
Shared storage, which a Mac with a discrete GPU does not take for a texture: there the read
texture was never made and every word read zero. On such a Mac (hasUnifiedMemory false) the
single-sample textures are Managed, and a blit synchronizes them before the CPU reads them.

Verified: both probes ran on an AMD Radeon Pro 5300M (macOS 26.7.1, job 82239) and read the
alpha-to-coverage pattern at 1, 2, 4 and 8 samples and interpolate_at_sample at every index of 8
samples, where the Shared form read zero (job 82204).
2026-12-02 23:12:41 -08:00
Anees Iqbal e0fe34be0c Runtime README: a Managed copy-in's own command buffer and barrier, per commit that takes one
On a device that keeps a device copy of a Managed buffer, every commit that takes a copy-in
records its copies into a command buffer of the runtime's own, with one barrier after them (a pair
where textures over the ranges in images of their own take copies in). Since a commit takes only
the ranges of the buffers its own encoders name, plus the first bytes of buffers made since the
last commit, a program that names ranges of several buffers and spreads their uses over several
command buffers pays that command buffer and barrier at each such commit. The known gaps of memory
blocks now say so, with the counters that count them (Metrics::runtime_command_buffers and
Metrics::upload_barriers).

Docs only. The text follows the code at development's tip: capture::copy_in records one
vkCmdCopyBuffer per buffer and record::barrier counted as UploadBarriers, or over::record_side's
pair where textures over the ranges take copies in; Changes::take takes the named ranges of the
buffers the committing command buffer keeps and every buffer made since the last commit. It names
no figure.
2026-12-02 23:08:56 -08:00
Anees Iqbal 86190052f5 Versions: semantics 2331, artifact format 604, runtime 2556 for a texture buffer read through a sampler by its words
SEMANTICS_VERSION 2330 -> 2331: a read through a sampler of a texture buffer held as words is
built by the words (the sampler's addressing, the words' width and the border texel by code), and
no texture buffer access records RuntimeFact::TexelBufferOwnView, which goes.

ARTIFACT_FORMAT_VERSION 603 -> 604: RuntimeFact loses the TexelBufferOwnView variant
(cache/codec.rs).

RUNTIME_VERSION 2555 -> 2556: the runtime no longer refuses a draw or dispatch that binds a
texture buffer held as words where an own-view access reaches it (Gap::TexelBufferOwnView and
its plumbing go).

runtime-sources.sha256 holds the inputs' new hash (device/mechanism.rs, an input, loses the
fact's mechanism row), computed as the build script computes it (the same computation gives
development 13d511cfe9's committed a929dd9581...).
2026-12-02 23:06:13 -08:00
Anees Iqbal 11c211ca64 Translator, runtime: no texture buffer access takes an own view a texture buffer held as words lacks; the own-view fact and gap go
The planner's ruling (b) after (i): with a read through a sampler built by the words, no access
MSL writes leaves a texture buffer on its own view on a device that holds some format as words,
so the runtime's Gap::TexelBufferOwnView and its plumbing (the kernel interface's own views, the
render content's, the encoders' checks before binds_words) go, and with them
RuntimeFact::TexelBufferOwnView, which nothing produces now.

Each access the words do not build now has an outcome that is not wrong output:
- A read that observes its residency is the words': its status word is 0, Metal's for a texture
  that is not sparse, as a texture buffer never is (with_word's 0); words::wrap no longer sends it
  to the own view.
- A read of an sRGB texture's codes is never a texture buffer's: srgb_texels answers false for a
  buffer's shape, so Read::raw is false there. Were one met, the compile refuses it.
- A read or write in another numeric class (LoweringInputs::cross_class): the runtime never sets
  it, and under the identity domains no variant is chosen; on a profile that holds some format
  as words the compile refuses such an access (Feature::Format, not implemented).
- A write of fewer than four lanes: the AIR front end takes a colour texture's write of four lanes
  alone (texture.rs, texel_ok), so such a call is an unknown intrinsic on every profile. The new
  authored case a_texture_buffer_write_of_two_lanes_is_refused_on_every_profile (an inline .ll of
  a8r_buffer_write narrowed to <2 x float>) checks Feature::UnknownIntrinsic on lavapipe and
  moltenvk-m3 under the identity domains.

Docs: words.rs module docs and wrap's doc, the runtime README's known gap rewritten as the
refusals; REFUSALS.md and the error basis regenerated (Gap 32 -> 31); api_signatures drops the
fact's and the gap's variants. The mechanism test's variant count returns to 87.

The fixture census at (i)'s tip, the condition the ruling set before this deletion (scratch job
m3-max-81238, steelbrain/scratch-tb-census): 18 fixtures naming texture buffers, 1477
compilations, no own-view fact on any profile that holds a format as words.

Verified with (i) at 355c902082 (gate m3-max-82186): fmt, clippy in three configurations, rustdoc,
the validation suite 1322 passed (3 skipped), the conformance suite 1050 passed, doctests; the
product suite 3723 passed with four reds a bless clears (the golden printout, the golden hashes,
the inventory, and llvm_as part_3_of_8 for tb_word_formats.ll, which has no rows until then),
the new authored case among them passing; the card legs as (i) lists them.
2026-12-02 23:05:54 -08:00
Anees Iqbal c56000f9e4 Translator: a texture buffer held as words is read through a sampler by the words
A read through a sampler (MSL 4.1's read(sampler, coord)) of a texture buffer took the texture's
own view alone, and where the device held the bound format as words the runtime refused the
draw or dispatch (Gap::TexelBufferOwnView). The words now build it: the site reads the
sampler's state (through::state), addresses the index against the words' width the way the own
view's read addresses it against its size (through::buffer_index, which address() now calls for
a texture buffer: the first texel outside, the nearest where a runtime slot sampler's s mode is
clamp_to_edge, the border where the t mode is clamp_to_zero or clamp_to_border), calls the read
routine at the addressed index, and where it reads the border hands back the border texel of
the format the word's code names (words::border_texels), the alpha 1 of a format without alpha
included. Such a read no longer records RuntimeFact::TexelBufferOwnView; the remaining own-view
accesses are a read that observes residency, a read or write of another numeric class, a read of
an sRGB texture's codes and a write of fewer than four lanes.

The site's word estimate adds the sampler's addressing again and THROUGH_WORDS (the view's size,
the width, the border texels by code).

Tests: engine_identity's read-through test now asserts no own-view fact and a words routine
where the profile holds formats as words. The runtime test reads rt_buffer (mirrored_repeat),
rt_buffer_ow (clamp_to_border, opaque white) and rt_arg_buffer through three runtime sampler
states (clamp_to_edge; t clamp_to_zero; t clamp_to_border opaque black) over six formats in
either form, against Metal's texel in bounds and outside.

Docs: words.rs module docs, the fact's and the gap's docs and Display, the runtime README's known
gap, RESOURCE-ID.md; REFUSALS.md regenerated.

Verified at the hand-over tip 355c902082, with (b), on development 8a2acc84fb: clippy in the
three configurations and the translator's tests (gate m3-max-82186; the read-through and words
tests 120 passed, m3-max-82186's focused step); on lavapipe the runtime's texture buffer tests 13
passed and the stream test passed, and the runtime's whole suite 972 passed, 4 skipped; the
read-through test over the three sampler states and six formats on an Iris Xe (m3-max-82187), an
RTX 3090 (m3-max-82193) and an RX 7900 XTX and a 780M (RADV, m3-max-82282), each format in its
form there (B5G6R5Unorm as words on the 3090, the XTX and the 780M); the read-through-buffer
conformance replay on lavapipe, base 8a2acc84fb against the tip, 0 of 1 cases differ
(m3-max-82188).
2026-12-02 23:05:54 -08:00
Anees Iqbal 13d511cfe9 Docs: unorm_values names its test as text, which a private-items doc build cannot link
The doc comment of lower/texture/words.rs's unorm_values linked `tests::unorm_mirror`, an item of a
cfg(test) module that no doc build has, so `cargo doc -p metal2vulkan --all-features --no-deps
--document-private-items` under -D warnings stopped on rustdoc::broken-intra-doc-links. The test is
named as code text instead. The public doc build, which the gate runs, did not see the link.

Verified: m3-max-82334, fmt --check and the private-items doc build of metal2vulkan EXIT=0.
2026-12-02 22:48:10 -08:00
Anees Iqbal fd93d1695f rt test: a render state's sRGB variant is kept in the bounded map of contents
The draw-side sRGB form keeps each render state's sRGB variant in the device's map of contents
beside its content, under the descriptor's key with its slots. The kernel's variant had a
fill-past-capacity test and the render variant had none, so this adds it: at a cap of 2, the float
fragment writer's content and its variant fill the map, a reuse onto the other twin or an
RGBA8Unorm texture makes nothing, the half writer's content and variant push both out, and the
float writer's next draw onto a twin makes its variant again (translations_at_encode 1, 1, 2, 3;
kernel_entries 2 throughout). each_device's settle then waits for every gauge, render_contents and
kernel_entries among them, to read zero once the device drops. The runtime README's paragraph on
makes at encode is re-wrapped, its words unchanged.
2026-12-02 22:44:30 -08:00
Anees Iqbal ee6911e100 Runtime README: the half simdgroup tree's four forms and their cost on three cards, as a known gap
The gap named the float route alone, measured by forcing it on an RTX 2080 with the shuffle tree
since deleted. It now states the tree's four forms and their two choosers: the SIMD-group
operations query (a subgroup tier takes one clustered reduction per round, the emulated tier its
workgroup tree) and the 16-bit floats query (16 bits under the 16-bit float controls, float
rounded to half each round elsewhere). It also states what the tree costs against the device's
reduction of the float values rounded once, which was faster and not Metal's answer.

Rows: a kernel of two simd_sum of half4 on the subgroup tier at 16 bits, GPU time at the 50th
percentile over three alternated rounds with a same-arm pair (carry bin/hsum2: base 7fe0a001 =
development e1e6f52848's product, clus 8cb0caa5 = the clustered tree, eaf11e5c63 before this
series' rebase), exclusive, a device line in every run:
- Iris Xe (RPL-P, ANV), m3-max-81581: 1274.5-1317.9 us against 825.7-880.9 us, medians 1275.2
  and 827.8, +54.0%.
- RTX 2080, m3-max-81598: 805.0-808.3 us against 660.1-665.0 us, medians 807.5 and 662.6,
  +21.9%.
- RX 7900 XTX (RADV NAVI31), m3-max-81839: 7525.8-7538.0 us against 7474.9-7478.9 us, medians
  7526.85 and 7475.55, +0.7%.
The Iris is the slowest GPU, and the clustered form is the fastest right form on it; the 16-bit
shuffle tree ran 2278 us there. The loss on the others is this gap, as ruled.

Verified: docs only; the rows are those jobs'.
2026-12-02 22:40:58 -08:00
Anees Iqbal 3457e092cb Translator: SEMANTICS_VERSION 2330 for Metal's half simdgroup and quad trees
The series lowers a half simd_sum and simd_product as Metal's tree of rounded half operations
(clustered reductions on the subgroup tiers, the workgroup tree on the emulated tier) and an
emulated or quad half step as the 16-bit instruction under the 16-bit float controls, so a module
with any of them translates to other words under an unchanged key. Its first commit's
"SEMANTICS_VERSION 2325 -> 2326" was taken at development by other changes; development reads
2329 at this rebase, so this series takes 2330. The golden tables are re-blessed on development.
2026-12-02 22:40:58 -08:00
Anees Iqbal 4d44991351 Translator: a half simdgroup tree's rounds are clustered reductions, as fast as Metal's tree goes on the slowest GPU
The tree of xor shuffles (16-bit, two halves to a word, or in f32) ran a real kernel of two
simd_sum of half4 2.76 times as long as the device's reduction on an Iris Xe (ANV): Mesa's Intel
backend moves a shuffled lane by indirect addressing, about 150 us of that run per packed word a
round, where a clustered reduction's step is a register-region operation. Round d (1, 2, 4, 8,
16) is now one OpGroupNonUniformFAdd or FMul ClusteredReduce over clusters of 2d lanes in which
the first lane of each d-lane block that takes part brings its block's partial and every other
lane the identity (-0 for a sum, 1 for a product). Each cluster so combines exactly its two
blocks' partials in one rounded operation whatever order the device's reduction takes, and every
lane of it holds the result: Metal's tree. A lane that takes no part adds nothing, so a block
with none leaves the other's partial, as Metal counts such a lane as the identity. In a block
every lane executes a block's first lane is the lane whose index is a multiple of d; where the
group may be partly live it is the lowest set bit of the ballot of the active lanes in the
block. The shuffle code (pack, unpack, the xor and ballot rounds, HalfTree::step) is deleted,
and ops::f16_binary is whole again.

The partials are held as before: at 16 bits under the 16-bit float controls (half_controls, the
16-bit floats query), a 16-bit reduction whose rounding a driver that folds a conversion's round
trip keeps (shaderSubgroupExtendedTypes is in the runtime's floor); elsewhere in f32, each
round's result rounded to half, where the f32 product of two halves is exact and their f32 sum
rounds to the half their sum does (24 >= 2 x 11 + 2). The identity is an f32 constant there, so
a module without 16-bit floats declares none.

Forms of a half simdgroup sum or product in a kernel: 4, two choosers, both in the owner's rule
2 list. The subgroup tier (Direct or Cluster32, the SIMD-group operations query; the class is now
CLUSTERED where it was SHUFFLE) takes these clustered rounds, at 16 bits or in f32 by the 16-bit
floats query; the Emulated tier (the same query finds no subgroup tier, as on runtime-floor,
which offers BASIC alone, or ANV's widest-pin rule) takes its workgroup-memory tree, at 16 bits
or in f32 by the same query.

Verified: rows in the runtime README's known gap and the hand-over (Iris, RTX 2080, RX 7900
XTX, exclusive, three alternated rounds); the engine tests of Metal's half trees and the device
test of full, masked and quad words, named with their jobs in the hand-over.
2026-12-02 22:40:50 -08:00
Anees Iqbal 0cd07d6612 Docs: API.md states the local size contract of a kernel on subgroups, which its shuffles rely on
A translator consumer that is not metal2vulkan-runtime read nowhere in docs/API.md that a
kernel stating RuntimeFact::LocalSizeConstraint runs only threadgroups whose size is a multiple
of it, and that a dispatch at any other size runs the kernel's EmulatedSimdgroups variant. A
half simdgroup sum or product on the Direct and Cluster32 tiers now reads its sibling lanes by
xor shuffles in a block every lane executes, which name an inactive lane in a partial subgroup.
Section 6 now says so, and that the emulated variant gives Metal's answers for the partial
simdgroup, as the runtime's variant choice does (pipeline.rs: a module with multiples gets
KernelVariant::EmulatedSimdgroups).

Verified: docs only; the contract read from device::subgroup::requirement and the runtime's
variant choice.
2026-12-02 22:40:50 -08:00
Anees Iqbal 06ee627760 Tests: the simdgroup products fixture runs each tier at the threadgroup sizes its variant runs at
engine_simd_products ran the Direct variant (32 lanes) and the Cluster32 variant (64 lanes) at
a threadgroup of 40 threads, and Cluster32 at 96 as well. Neither variant is ever dispatched at
those sizes: subgroup::requirement gives both full subgroups and a local size that is a
multiple of the subgroup size (RuntimeFact::LocalSizeConstraint), and the runtime gives such a
kernel its emulated variant (KernelVariant::EmulatedSimdgroups), which runs every other size.
The group instructions the half product used before tolerated the partial subgroup on the
interpreter. The half tree's xor shuffles name lane L ^ d, and the interpreter traps on an
inactive lane (InactiveLane { lane: 8 } at Direct, { lane: 40 } at Cluster32), as SPIR-V makes
that read poison. The runtime's variant choice is the guarantee: Direct and Cluster32 need
full subgroups (LocalSizeConstraint), and any other threadgroup size takes EmulatedSimdgroups,
so a 40-thread dispatch keeps Metal's partial-simdgroup answer through the emulated tier. So the
fixture now runs each tier at the sizes its requirement admits, and the partial simdgroup (40
threads) keeps its run on the Emulated tier at 8, 16, 32 and 64 lanes.

Verified: the gate's suites (81303, at 501f2c0b16) failed these two tests with those
traps and nothing else but the golden table; this commit's run of engine_simd_products and
clippy is recorded in the hand-over.
2026-12-02 22:40:49 -08:00
Anees Iqbal fd97053681 Tests: the runtime half reductions test's model type named, for clippy's type_complexity
Under --cfg m2v_gpu and --cfg m2v_cpu_icd, clippy's type_complexity rejected the cases' array
type in the runtime's half_simd_reductions device test (a tuple holding a function pointer).
The model's type is now the alias `Model`; the cases are unchanged.

Verified: the gate's clippy steps (plain, m2v_gpu, m2v_cpu_icd) rerun on this commit.
2026-12-02 22:40:49 -08:00
Anees Iqbal 7364fcd49b Tests: the half quad model's operation type named, for clippy's type_complexity
Clippy's type_complexity rejected the pair of function-pointer types in the quad model
(`quads`), so the gate's three clippy configurations failed in metal2vulkan-devtools. The
operation type is now the private alias `Operation`; the model is unchanged.

Verified: the gate's clippy steps (plain, m2v_gpu, m2v_cpu_icd) rerun on this commit.
2026-12-02 22:40:49 -08:00
Anees Iqbal faf822ee57 Runtime README: the half simdgroup tree held in float, on devices outside the 16-bit float controls, as a known gap
A half simdgroup sum or product is Metal's tree of rounded half operations on every device.
Which form the tree takes is the 16-bit floats query (narrow::half_controls, read through
group::sixteen_bit_half by HalfTree and workgroup::combine): a module that computes half under
the 16-bit float controls holds the tree at 16 bits; every other module holds it in float and
rounds each step to half. Of the committed profiles, moltenvk-m3 (shaderFloat16 but controls the
module cannot declare), nvidia-pascal-linux (no shaderFloat16) and runtime-floor (no
shaderFloat16) take the float route (engine_native_half's
a_controlled_conversion_rounds_half_where_the_float_controls_allow asserts the split); the ANV,
RADV, RTX 50 series and lavapipe profiles take the 16-bit one. It is that query's existing second
form, not a new one: a module under the controls never reaches the float tree, since both
callers test the same predicate.

The float route's cost goes in the pipeline states' known gaps with its rows, the closest
measure: that form forced on an RTX 2080 (which itself takes the 16-bit route) for a real kernel
of two simd_sum of half4, GPU time at the 50th percentile over three alternated rounds,
m3-max-81173: 691.6-695.4 us against 659.1-660.7 us for the reduction it replaces (+5.1%), where
the 16-bit tree ran 613.3-614.1 us (-7.0%). The line says it applies to that route alone.

Verified: docs only; the rows are m3-max-81173's.
2026-12-02 22:40:49 -08:00
Anees Iqbal c35952d868 Translator: an emulated or quad half sum or product step is the 16-bit instruction under the 16-bit float controls
The emulated tier's tree (workgroup::tree_fold), its prefix sums and the quad tree (quad_tree, on
every tier) combine their half values by workgroup::combine, which ran the f32 operation and
rounded it to half by narrow::round. Where the module computes half under the 16-bit float
controls that rounding is the controlled conversion pair, which a driver's compiler may fold
into the f32 value it started from (NVIDIA's does, narrow.rs), leaving the step unrounded; and
the module records NativeHalfConversion for the pair.

combine now takes the device's 16-bit instruction, kept apart, for a half sum or product where
the module computes half on it (group::sixteen_bit_half, which HalfTree uses too): the choice
half + and * make there (ops::f16_binary), whose rounding a folding driver keeps. Elsewhere it
is the f32 operation rounded by narrow::round, as before. Each step rounds the same exact result
once, so where the pair rounds the values are unchanged. Quad prefix operations on the subgroup
tiers (group::lane_scan) keep their own step.

The engine test of the emulated tier asserts that lavapipe's profile computes half under the
controls and the runtime floor's does not, so the 16-bit step and the rounded f32 step are both
checked against Metal's 64 answers at every subgroup width on the CPU interpreter.

lavapipe (8-lane subgroups, the emulated tier) gives Metal's simdgroup sums and products both
without this commit and with it once T3 is underneath (m3-max-81129: 0 of 256 and 0 of 768 words
differ in each arm); what changes there is that the pipelines no longer round through the pair
and no longer record NativeHalfConversion (notes [NativeHalfConversion, NativeNanEncoding,
DeviceHalfDenormals] before, [DeviceHalfDenormals] after). The quad kernel of the previous commit
is the device check of the quad step on the RTX 2080 and the 780M.

Verified: m3-max-81129 (CPU only, at this series' f32-held arm and at this commit): the
engine tests 5 passed; lavapipe as above.
2026-12-02 22:40:49 -08:00
Anees Iqbal e79b8d0fed Tests: Metal's half quad sums, products and quad prefix operations, on every device
Metal's quad_sum and quad_product of half operands are (x0 op x1) op (x2 op x3) with each
operation rounded to half, and its quad prefix sums and products the lane-order chain over the
quad's lanes with each operation rounded, the empty exclusive sum -0 and product 1. Measured on
the M3 Max (macOS 27.0.1), fast math on and off alike, over the operands of
metal2vulkan_devtools::half_simd_reductions, all 256 threads (m3-max-81130, our own MSL): those
models match every thread; the float result rounded once misses 48 of the quad sums, 64 of the
products and 6 to 25 of each prefix operation.

half_simd_reductions gains a third kernel, QUADS: thread t takes entry t of SUM_OPERANDS and
PRODUCT_OPERANDS and writes five words, its quad reductions, its quad prefix sums and its quad
prefix products, then its simdgroup prefix sums and products. devtools::half_simd_reductions::quads
answers the first three words from those models (a small exact half rounding of an f64 sum or
product). Metal's simdgroup half prefix order matches none of the models (the lane-order chain,
Hillis and Steele, and the float result rounded once miss 60 to 137 threads each), so those two
words are written, not compared: they make the kernel a simdgroup user, which a device with
subgroups narrower than 32 lanes (lavapipe's 8) runs on the emulated tier, quad operations
included.

The runtime's device test runs the kernel on every device beside the two simdgroup kernels and
prints how many of the compared words differ. This is the test of the quad half step the next
commit moves to the 16-bit instruction under the 16-bit float controls.

Verified: cargo fmt only (this Mac runs no builds); the device runs are the timing job's
correctness leg on the RTX 2080, the 780M and lavapipe.
2026-12-02 22:40:49 -08:00
Anees Iqbal 91279f4c7f Translator: a half simdgroup tree under the 16-bit float controls holds its partials at 16 bits
The half simdgroup sum and product tree (group::half_fold) held its partials in f32 on every
route: each of its five rounds shuffled the f32 lanes, narrowed the sibling's partial, ran the
16-bit instruction and widened the result. On the RTX 2080 that form costs 4.7% GPU time on a
real two-simd_sum(half4) kernel against the native f32 reduction it replaces (m3-max-81045,
three alternating rounds, p50 662.5/663.6/664.5 us old against 693.4/696.3/694.7 new),
above the 3% bar.

Where the module computes half under the 16-bit float controls the tree now holds its partials
at 16 bits: the operand narrowed once and the result widened once (both exact, they are half
values), each step the device's 16-bit instruction (ops::f16_instruction, split out of
ops::f16_binary, the same instruction and NoContraction / fma-with--0 form half + and * take
there), and each shuffle moving the partial's lanes two to a 32-bit word, an odd lane count
padded with a zero lane the tree drops. A half4 round is two 32-bit shuffles and the 16-bit
instruction, where the f32 tree took four shuffles and the conversions. The values are the same
bits: each step rounds the same exact result once. Without the controls the tree is the f32
operation rounded by the module's rounding, as before.

The engine test runs the full and masked kernels on NVIDIA's Linux profile too, which computes
half under the controls, so the 16-bit tree is checked against Metal's 64 answers on the CPU
interpreter beside the f32 tree on MoltenVK's and the wave64 profile.

Verified: cargo fmt only so far (this Mac runs no builds). The engine tests, the device test on
the 2080 and the 780M, and the old/f32-tree/16-bit-tree timing on the 2080 are the next job.
2026-12-02 22:40:49 -08:00
Anees Iqbal a1f82878ff Translator: a half simdgroup sum or product is Metal's tree of rounded half operations on every tier
Metal's simd_sum and simd_product of half operands work as a tree. In round d (1, 2, 4, 8, 16),
each aligned block of 2d lanes holds its lower and upper halves' results, combined and rounded
to half. A lane that takes no part counts as the identity. Measured on an M3 Max, macOS 27.0.1,
our own MSL, fast math on and off alike:
- sums: m3-max-80839;
- products: m3-max-80879;
- three masks of active lanes: m3-max-80890.

The Direct and Cluster32 tiers folded the f32-held values with OpGroupNonUniformFAdd or FMul and
rounded once. Rounding once misses five of the eight measured sums (0x3c10 where Metal answers
0x3c0f), four of the eight products, and ten of the 48 masked results. The emulated tier's
exchange rounds already were the tree.

group::half_fold:
- New form. Five rounds; each combines the lane's partial with its sibling block's partial
  through half_step.
- In a block every lane executes, the sibling partial comes from OpGroupNonUniformShuffleXor
  by d. A mask below 32 stays inside a Cluster32 cluster.
- Where the group may be partly live, the sibling partial is the first active lane of the
  sibling block, read with the live lanes' ballot. A block with none leaves the lane's own
  partial: the identity, as the masked probe measured.

half_step:
- On a module that computes half under the 16-bit float controls, it is ops::f16_binary. That
  is the device's 16-bit instruction, whose rounding survives a driver that folds a
  conversion's round trip (NVIDIA's does).
- Elsewhere it is ops::float_binary.
- This is the same choice half + and * make.

There is no 16-bit route for group operations: half group ops run on f32-held values on every
profile, so this covers every route.

Other changes in this commit:
- reads_lanes is true for these operations, so partly_live tracks them.
- direct_ops and cluster_ops need the shuffle class; partly_live adds the ballot.
- words() bounds the five rounds.
- A half simdgroup sum or product no longer records PrecisionNote::ReductionOrder. float and
  double sums and products, every float prefix sum or product, and the matrix and AGX
  multiply-adds still record it.
- The note's doc and docs/API.md's catalogue entry say this per route. They also record that
  Metal's half prefix-sum order is not measured: it matches none of f32 rounded once per lane,
  a lane-order chain of half additions, or a Hillis-Steele scan of them (m3-max-80839).
- Validation's REDUCTIONS table drops simd.reduce.fadd.half and simd.reduce.fmul.half, so a
  comparison holds them exactly. Its tests now name the half scan.
- bfloat has no group operations: decode refuses them.

SEMANTICS_VERSION 2325 -> 2326.

Tests:
- lower::simd::tests::half_sums_and_products_are_shuffle_trees covers the classes and the
  lane reads.
- engine_simd's float_sums_record_their_precision now holds that a float sum records the note
  and a half sum does not.
- The red tests of the previous commit carry Metal's bits.

Verified: cargo fmt only on this host. The red and green device jobs, and the timing on a real
half-reduction kernel, follow before landing.
2026-12-02 22:40:48 -08:00
Anees Iqbal 2695dca124 Tests: Metal's half simdgroup sums and products are trees of rounded half operations (red)
Metal's simd_sum and simd_product of half operands combine the lanes as a tree. In round d
(1, 2, 4, 8, 16), each aligned block of 2d lanes holds its two halves' results combined and
rounded to half, and a lane that takes no part counts as the identity. Measured on an M3 Max
(macOS 27.0.1, our own MSL, fast math on and off alike):
- sums: potluck job m3-max-80839;
- products: m3-max-80879;
- sums and products over three masks of active lanes: m3-max-80890.
The tree matches every answer. The float result rounded once misses five of the eight sums,
four of the eight products and ten of the 48 masked results. The tree over the active lanes
packed together misses three masked sums.

metal2vulkan-devtools' half_simd_reductions holds two kernels of our own AIR, the operands and
Metal's answers:
- half_simd_reductions: eight simdgroups summing and multiplying their lanes in a uniform block;
- half_simd_reductions_masked: the same in blocks only a mask of lanes executes.

Three tests run them:
- engine_simd: the Direct tier at 32 lanes and the Cluster32 tier at 64, on the CPU
  interpreter. Red: those tiers fold the f32-held values with OpGroupNonUniformFAdd or FMul
  and round once.
- engine_simd_emulated: the emulated tier's pairwise tree at every width, on lavapipe's and
  the floor's profiles. Its rounded combine is Metal's tree, so this test is expected green.
- the runtime's half_simd_reductions: under a device cfg, every device of the cfg's kind. It
  prints the kernel subgroup sizes and each pipeline's precision notes.

Verified: none of these tests has run yet; their jobs follow. cargo fmt only on this host.
2026-12-02 22:40:48 -08:00
Anees Iqbal fac3e9cfc0 Runtime: a draw writing an 8-bit sRGB texture runs the render state's sRGB variant
A vertex or fragment function that writes, at a slot it does not read, a texture whose storage
element is its UNORM twin's view was Gap::StorageElement at the draw. It now takes the form the
kernel took: the render encoder finds the texture slots each function the state lowers from its
AIR writes and does not read that hold a twin (TextureObject::encodes) beside the buffer slots it
holds to 4, and draws through the state's content for both (RenderPipelineState::for_draws, made
at the first such draw and kept in the device's map of contents under the descriptor's key with
the slots), which lowers those slots under LoweringInputs::srgb_storage, so each write there is
encoded by the MSL transfer through the device's conversion. KernelKey's srgb is a mask per stage
(the kernel's or the vertex function's, then the fragment function's). The facts skip a slot the
content encodes; read_write stays refused, and so does a twin at a slot of a function the
consumer compiled, which has no variant. A render state whose vertex or fragment function writes
a texture slot it does not read announces PrecisionNote::DevicePackConversion from its creation.
No new query and no second form: the twin's view and its query are the kernel's.

The runtime's README moves the draw out of the sRGB texture's known gap and names the content
among the makes at encode; docs/REFUSALS.md regenerated with no change (the StorageElement sites
are the same; refusal_surface.py --check exit 0). Proof jobs follow.
2026-12-02 22:21:38 -08:00
Anees Iqbal cb98ac0cb5 Conformance: srgb-storage-fragment-writes recorded on Metal, the coverage regenerated
Metal's run on an Apple M3 Max with its validation layer (job m3-max-82183, record then times
--runs 8 --write): each fragment's write stores the same bytes the kernel case's writes store, all
four stored sites equal to srgb-storage-writes' recording. On the runtime at development's tip the
case's draw is Gap::StorageElement; the runtime's draw test is red on lavapipe (job m3-max-82181,
filtered, 3 tests: 2 passed, 1 failed, the new one, refused StorageElement Absent).
2026-12-02 22:21:37 -08:00
Anees Iqbal ea5b786eb4 Red: draw-side writes to an 8-bit sRGB texture, the conformance case and the runtime's test
fpv_srgb_draw_storage's companions (regen-air-fixtures on the Mac, job m3-max-82169). The
conformance case srgb-storage-fragment-writes is the fragment twin of srgb-storage-writes: the same
values, formats, texture and layout, written by fpv_srgb_fragment_write and its half form behind
one triangle over a 256 by 2 RGBA8Unorm attachment. The runtime's test draws the fragment writers
and the vertex writer (rasterization off) onto RGBA8Unorm_sRGB and BGRA8Unorm_sRGB textures with
their twins' storage views, and expects the draw to run through the render state's sRGB variant:
the encode in the bytes, one make at encode, and the state's DevicePackConversion note. At
development's tip the draw is Gap::StorageElement, so the test is red; the Metal recording and the
lavapipe run follow.
2026-12-02 22:21:37 -08:00
Anees Iqbal 8a735791c4 Fixtures: fpv_srgb_draw_storage, vertex and fragment functions writing an 8-bit sRGB texture
Owned MSL for the draw-side sRGB storage lane: a cover vertex function, fragment writers of
float4 and half4 at their pixel, and a vertex writer at its vertex ID's place, each from buffer 0
in a row buffer 1 wide. The companions follow from regen-air-fixtures on the Mac.
2026-12-02 22:21:37 -08:00
Anees Iqbal 8a2acc84fb Runtime README: the Iris's read_write refusal beside the words' measured cost there
The planner closed holding a format as words where its own view lacks the read without a
format (a whole-format move): on the Iris Xe it serves read_write but slows every other read of
those formats, and trades the refusal for another (a read through a sampler would be
Gap::TexelBufferOwnView). The read_write refusal stays the typed known gap
(Gap::StorageElement, ReadWithoutFormat).

The row now records, so nobody times it again:
- job m3-max-82136, Iris Xe (RPL-P), ANV (Mesa 26.2.6, read on the node by job
  m3-max-82150): GPU p50 of texel_buffer_bgra8_read 11857.1 us as words against 9007.0 us as
  its own view (+31.6%), texel_buffer_b5g6r5_read 12133.8 us against 9215.2 us (+31.7%); the
  median of 8 rounds of 500 runs, the two builds alternating, the own view's build against
  itself within 0.1%, every run's values checked against the CPU references;
- job m3-max-82025's listing: the committed ANV profiles (irisxe-rplp, irisxe, uhd770) answer
  the same for seven formats (adding RG11B10Float, RGB10A2Unorm and RGB10A2Uint), and no other
  committed profile does;
- the trigger: no further form is built; that changes on a guest's run or stream that meets the
  refusal.
2026-12-02 22:11:56 -08:00
Anees Iqbal 6589b1df9d Texture buffers: an own view that reads none without a format refuses read_write by name
On the Iris Xe (RPL-P, ANV) the buffer features of BGRA8Unorm, B5G6R5Unorm,
BGR5A1Unorm and BGR10A2Unorm take a uniform texel buffer, a storage texel
buffer and the storage write without a format, so texel_buffer_form holds
them as their own views, but lack VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT.
A dispatch reading one through access::read_write is Gap::StorageElement
(ReadWithoutFormat): job m3-max-81883 failed the runtime test on B5G6R5Unorm,
BGR5A1Unorm and BGR10A2Unorm and the stream test on BGRA8Unorm there.

With that dispatch refused, the runtime test's reads and writes through handles now run on the
Iris for B5G6R5Unorm and BGR5A1Unorm as their own views, whose values are ANV's conversion: it
widens a 5- or 6-bit field by replicating its bits (job m3-max-82043: B5G6R5Unorm's texel 2 read
0.5176471 against the CPU's 16/31). The test takes a normalized format held as its own view within
PrecisionNote::DeviceTexelConversion's recorded bound (docs/API.md's catalogue: one f32 ulp, or
0.18 of a code of a 5- or 6-bit field and 0.015 of a code of a 10-bit one the device widens by
replicating its bits), as the stream test already did.

The ruled query stays. The runtime test and the replay stream test now expect
that refusal by name wherever the device's own view of the format lacks the
read without a format, and the runtime test still checks the format's reads
and writes through handles there. The runtime README records the refusal on
those four formats on the Iris as a known gap, naming the missing feature.
The predicate's docs name the three uses its checks cover (a read through the
uniform texel buffer, the storage texel buffer the view's usage takes, a write
through it without a format) instead of "every access".

runtime-sources.sha256 takes the runtime inputs' new hash: texel_words.rs, an input, changed in
its doc comments alone, which change no behaviour of a run.

Verified with this change on development ece306e521 (its tip then, ee46e48714):
- Iris Xe, job m3-max-82058: the stream test passed (BGRA8Unorm and B5G6R5Unorm play
  their recorded IDs, then the read-written one is refused by name at the dispatch;
  RGBA8Unorm, R8Unorm and RGBA16Unorm the CPU's texels and values); the runtime's
  texture buffer tests 11 of 11 (B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm answer
  within the bound, their read_write refused by name);
- RTX 3090, job m3-max-82043 (976685a17e, before the bound, which its words do not
  take): stream passed, runtime texture buffer tests 11 of 11;
- lavapipe and CPU, job m3-max-82057: clippy in the three configurations, rustdoc,
  validation 1320 passed, conformance 1048 passed, the runtime's suite 964 passed
  (4 skipped), texture buffer tests 13 of 13, the stream test passed.
2026-12-02 22:11:27 -08:00
Anees Iqbal 58f2768bae Runtime README: the words twin's B5G6R5Unorm read against the same words with no stage constant
The planner accepted the twin's read of a B5G6R5Unorm texture buffer held as words at 2.3% more
GPU time than the same words compiled with no stage constant (the per-format query's form) on
the RTX 3090, and let the known gap carry the row. The words-cost known gap now gives it, with
the RX 7900 XTX's 2.1%:

- RTX 3090, exclusive job m3-max-81336, 4 rounds rotating the arms, median of each round's GPU
  p50: read 167.6 us (spread 1.01%) against 163.8 us (1.16%); write 312.0 us against 310.9 us.
- RX 7900 XTX (RADV), exclusive job m3-max-81364, the same: read 93.1 us (1.07%) against
  91.2 us (0.88%); write 85.9 us against 86.0 us.

On both cards the device's profile holds B5G6R5Unorm as words; base refuses the format there.
Documentation only.
2026-12-02 22:11:27 -08:00
Anees Iqbal 0573a6fe47 Versions: semantics 2329, artifact format 603, runtime 2555 for texture buffers held as words
SEMANTICS_VERSION 2328 -> 2329: on a profile that holds a colour format's texture buffers as
words, a function reaching a texture buffer emits the words routines and declares
SpecKey::TexelBufferWords (its words twin), records RuntimeFact::TexelBufferWords and, for an
access the words do not build, RuntimeFact::TexelBufferOwnView, and records
DeviceTexelConversion, SrgbTexelDecode and DevicePackConversion where the words convert so; a
texture buffer's word keeps its border texels unless its format has a word layout.

ARTIFACT_FORMAT_VERSION 602 -> 603: RuntimeFact gains the TexelBufferWords and
TexelBufferOwnView variants (cache/codec.rs).

RUNTIME_VERSION 2554 -> 2555: the runtime holds a texture buffer of a format the device lacks for
one of its accesses as an R32_UINT view whose texels the shaders convert, runs a content's words
twin where a draw or dispatch binds one, sizes an indirect execution's shape per pipeline, and
refuses a texture buffer held as words at a slot an own-view access reaches (the runtime gap).

The validation crate's runtime inputs take metal/format/texel_words.rs (build.rs): the runtime
decides each texture buffer's form and word layout through it (texel_buffer_form), and the
runtime-sources guard found metal/format/mod.rs, an input, reaching it unlisted.
runtime-sources.sha256 holds the inputs' new hash, computed as the build script computes it (the
same computation gives development 3ecfe8f034's committed b5a8df0e75...).

The golden tables, the engine fixture inventory and its llvm_as part, are blessed on
development: the semantics bump and the new fixture tb_word_formats move them.
2026-12-02 22:11:27 -08:00
Anees Iqbal 7cb1fd23b5 rt test: an indirect execution of patch draws through the words twin sizes its own shape too
The pipeline-keyed shape (the previous fix) holds for every layout the execution draws with: a
content of patch draws (DRAW PATCHES' CommandDraw::Patches, a post-tessellation vertex function,
PATCH_LIST) has a words twin beside its patch pipeline where a stage reaches a texture buffer, and
an execution through the twin takes the preprocess requirements of the twin.

The shape test now sizes both pipelines of two contents, each with tb_word_fragment: plain
draws (TRIANGLE_LIST, CommandDraw::Plain) as before, and patch draws (icb_merged_patch_vertex,
PATCH_LIST, CommandDraw::Patches) on a device whose executions run tessellation stages, saying
so where they do not.
2026-12-02 22:11:27 -08:00
Anees Iqbal 2ca533c65d rt: an indirect execution's shape is keyed on the pipeline it binds, the words twin apart
An execution shape holds the preprocess requirements vkGetGeneratedCommandsMemoryRequirementsEXT
answers for the pipeline the execution binds, and VUID-VkGeneratedCommandsInfoEXT-preprocessSize-
11071 asks an execution's preprocess size of the requirements of its matching inputs, that
pipeline among them. The shape cache keyed a shape on the content's id and the raster state, which
chose the content's pipeline until the words twin: under one raster state a content now has two,
the plain one and its twin, and an execution that ran the twin took the shape the plain pipeline
sized.

The key now holds the pipeline itself in place of the raster state: one per class and raster
state, the twin's apart from the plain one's. A content's pipelines live as long as it does and
its id is never another's, so no stale shape matches. Indirect::shape takes (content, pipeline);
the draw and the execution part pass the pipeline they bind. The runtime README's line on the
shapes the device keeps says so.

Red/green: the test of the previous commit asks for two shapes from the plain pipeline and the
twin of a content that reads a texture buffer; the device run is in the hand-over checks.
2026-12-02 22:11:27 -08:00
Anees Iqbal 4f3bbdfa94 rt test: an indirect execution through the words twin sizes its own shape (red)
An indirect command buffer's execution shape (indirect::Shape) holds its command layout and the
preprocess requirements vkGetGeneratedCommandsMemoryRequirementsEXT answers for the pipeline the
execution binds, and VUID-VkGeneratedCommandsInfoEXT-preprocessSize-11071 asks the execution's
preprocess size of the requirements of the matching inputs, the pipeline's among them. The shape
cache keys a shape on the content's id and the raster state, so an execution that runs a
content's words twin reuses the shape the plain pipeline of the same raster state sized.

The test makes a content whose fragment function reads a texture buffer (tb_word_fragment), for
indirect command buffers, takes its plain pipeline and its words twin at the default raster
state, and sizes a shape for each: it asks for two. Red here on a device with indirect command
buffers that holds a format as words (one shape); it skips, saying so, on a device without them.
2026-12-02 22:11:26 -08:00
Anees Iqbal a43933062e Harness: a B5G6R5Unorm texture buffer read's sum takes DeviceTexelConversion's recorded bound
On the Iris Xe (ANV, Mesa 26.2.6; job m3-max-81344, and its diagnostic m3-max-81378),
texel_buffer_b5g6r5_read failed its check in every arm, base 2bfb9b5bd3 included, which holds
B5G6R5Unorm through its own view there: "buffer 1: 959978 values differ; the first, [0], is
41.34902, not 41.343575 +- 0.0009765625". The row sums 16 texels' four channels against the
CPU's c / (2^b - 1) within 1/1024, but ANV widens a 5- or 6-bit channel by replicating its bits,
which the translator records as PrecisionNote::DeviceTexelConversion with a recorded bound of 0.18
of a code (docs/API.md). The row's tolerance now adds that bound for each 5- or 6-bit channel of
the 16 texels a sum reads: 16 x 0.18 x (2/31 + 1/63), about 0.23. Other formats' rows keep 1/1024
(an 8- or 16-bit code's one ulp is inside it). On the RTX 3090 and the RX 7900 XTX the row runs
through the words (base refuses the format there), bit for bit, and passed.

Verification pending: the row on the Iris Xe with this harness.
2026-12-02 22:11:26 -08:00
Anees Iqbal 5701c1a4b5 Tests: the indirect tests' draws literal names the own views
The runtime's Draws gained own_views in 5f5a42681f; the indirect tests' literal lacked it (E0063,
job m3-max-81152's clippy). It names none, as the content reads nothing else.

Verified: not yet built; job of the next dispatch.
2026-12-02 22:11:26 -08:00