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'.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.