Commit Graph
8821 Commits
Author SHA1 Message Date
Anees Iqbal 2b265713c8 matrix: two comments name the RTX 3090 by its link, not by its host
scripts/matrix/results.py (the per-process level note above HARNESS_ALONE) and its test in
scripts/matrix/test_results.py named the 3090 of rounds b0c08e51b5, 7cda47f536 and 6b535f55c9 by
the machine it sits in. They now name the card and its link: an RTX 3090 on a 20 Gb/s
Thunderbolt 3 link (the link as read from the kernel's own lines on 11-20). Comments only.

Verified: python3 -m unittest of scripts/matrix/test_results.py in the compile job named in the
report.
2026-11-21 17:28:31 -08:00
Anees Iqbal 4a09c07658 Replay player: a play cut after its last frame names the command buffers held there, not an invalid stream
A play cut with --until-frame F (or at its recording range) ended exit 1 with "invalid stream:
command buffers [...] still wait on events at the stream's end" where a command buffer committed
before the cut waited on an event a call past the cut signals (glbench-3090-r4 cut at 400: cbs
128646 and 128648). The calls past the stop may signal it, so the stream is not invalid there.

The player now tells the stream's end from the stop after its last frame. At the stop, the
command buffers still held on events go into Report::held and a `held #ID ...` line, and the
play ends as it would without them (exit 0 for `ok`). At the stream's end a held command buffer
stays the invalid-stream error, a last frame past the end included.

Test: a_play_stopped_after_its_last_frame_names_the_command_buffers_held_there (a synthetic
stream: cut at frame 0 names #4 held and waits for nothing; played whole, the later signal lets
#4 complete; a stream ending with #4 held is invalid with no last frame and with one past its
end). Without the fix the cut play ends Err(Invalid).
2026-11-21 17:27:43 -08:00
Anees Iqbal 28e1026b3d Bless at the pin: golden hashes and the authored compile census under SEMANTICS 2265, and the render descriptor key
The sampler-array form (6c1dff3f09) moved SEMANTICS to 2265. This re-blesses what follows it:

- golden_hashes.tsv: the semantics line, and the two sampler_table_held rows
  (engine/sampler_table.air.ll and engine/sampler_table.ll), one cell per committed profile,
  93d9337e50107f07 -> 32879cde7851084f. The form makes that kernel's chosen-sampler sampling one
  sample through the set-1 sampler array. No other row changed.
- authored-compile.tsv: the artifacts_at line only; no case's row changed.
- the old render descriptor key: d5d9c650... -> e3b2dff0..., which moves with SEMANTICS.

Verified: the M3 bless job m3-max-65272 (golden bless GOLDEN=0, rows removed 3 / added 3;
census exit 0); the render key's value from m3-max-65268. At 6c1dff3f09, the suites m3-max-65270
failed only these two tests (product 4016/4018; validation 1329, conformance 1026 and the
doctests passed), and the quick check m3-max-65269 passed (signatures, clippy in three
configurations, Rustdoc, the lavapipe runtime suite 625/625, conformance on lavapipe).
2026-11-21 17:27:26 -08:00
Anees Iqbal 6c1dff3f09 Translator: under the identity domains, constexpr samplers a lane chooses among beside an argument buffer's texture are one sample through the set-1 sampler array (SEMANTICS 2265)
Some kernels sample a texture their argument buffer holds through a sampler that the run picks
among constexpr samplers with consecutive handles: a program-scope table of samplers read at an
index only the run knows. Under the identity domains, the runtime's, each such sampling was a
switch over the candidates: one arm per candidate, each a NonUniform sample of the heap element
through that candidate's set-1 sampler, and a null arm. RADV wraps each NonUniform sample in its
own waterfall loop (read_first_invocation). The 780M library's heaviest kernel holds 284 such
switches of eight arms, so 2,272 samples and 2,272 driver loops. Its cold create on a 780M peaked
at 7.8 GiB.

select_heap_array now takes the identity domains too. Where every candidate is a constexpr sampler,
their handles are consecutive, the use is not tangled (no fragment implicit level), and every
candidate's sampling is the same but for its sampler, the sampling is one sample. It reads the
set-1 sampler array of its use, NonUniform, at the pushed index (PushField::ConstexprSampler) of
the candidate the handle names. emit::identity_element selects that index among the candidates'
at run time. A handle outside the array still reads zero. finish pushes each candidate's index
and records the use in SamplerPlan::heap_array_identity in place of a binding. Sampling::words
counts each candidate's selection (Source::HeapArray::pushed, 0 outside the identity domains, so
the resident-table domains' weights are unchanged).

Under the identity domains the switch stays where the sampling compares, reads an integer class,
or reads pixel coordinates. Metal's bicubic filter on an argument buffer's texture is refused
before this (bicubic::check). Raw-texel states do not arise here, because the element is read in
its declared class. The resident-table domains keep their form unchanged.

One form for every device: the runtime's floor requires
shaderSampledImageArrayNonUniformIndexing (floor.rs), every committed profile reports it, and a
heap image sampled at all already needs it (texture/slot.rs).

The form is ported from 4b7d9d48ef (steelbrain/privarena-sampler-b, unlanded) and narrowed to the
ruled domain.

SEMANTICS_VERSION 2264 -> 2265. The golden table and the old render descriptor key get
re-blessed at the pin: m3-max-65203 shows "bless due" with exactly 16 cells changed, all
engine/sampler_table.ll sampler_table_held, one per committed profile.

Tests:
- engine_identity's
  chosen_constexpr_samplers_beside_an_argument_buffer_texture_are_one_sample_where_alike
  (replaces ..._is_a_switch_over_them). On every committed profile under the identity domains, a
  kernel's float sample through three chosen constexpr samplers is one sample: one sampled image,
  no switch, one ConstexprSampler pushed per candidate, and L3 passes. The switch stays, with a
  sampled image per candidate, for pixel coordinates (two linear pixel samplers that differ only
  in their border color), an integer texture, a comparison and a fragment's implicit level. The
  resident-table domains take their set-0 array for all but the fragment case, which shows the
  candidates' samplings are alike and only the identity domains' rule keeps the switch.
- argument_sampling's
  every_device_samples_an_argument_buffers_texture_through_a_table_of_constexpr_samplers now reads
  the module the device's translator gives sampler_table_held, asserts 1 sample and 0 switches,
  and prints that, then compares each of the 20 texels with Metal's answer as measured on an
  Apple M3 Max. The fixture has four candidates. The form is the same for any count of two or
  more, so it covers the eight-arm sites, and its texels are M3-measured.

Verified:
- Compile: m3-max-65200 (fmt, signatures, refusal surface, clippy plain / m2v_gpu / m2v_cpu_icd,
  workspace Rustdoc -D warnings), m3-max-65203 (translator suite 3210 passed, lavapipe runtime
  suite 625 passed).
- The execution test passed on llvmpipe (65203), RTX 3090 (65223), RX 7900 XTX (65224) and Iris
  Xe (65225).
- Rows: development 21baf79e79 against this tree, one runner (probe 7faf595d33 / 88125605ae, its
  probe variable choosing the arm), every run cold, validation layer off, arms A B B A in one
  exclusive job per card:
  - ec13339c (780M library, 284 sampler switches) on a Radeon 780M, RADV, job m3-max-65216:
    helper peak 7,772 / 7,773 MiB -> 816 / 819 MiB (89.5% less), driver compile 63.39 / 62.34 s
    -> 21.94 / 21.55 s (65.4% less). Final NIR (RADV_DEBUG=nir): loops 2,571 -> 583,
    read_first_invocation 2,272 -> 568, blocks 34,289 -> 17,533, phis 27,537 -> 13,526.
  - The same kernel on an RTX 3090, job m3-max-65238: 2,447 / 2,443 MiB -> 1,975 / 1,976 MiB
    (19.2% less), 57.72 / 57.70 s -> 51.88 / 51.85 s (10.1% less).
  - d45af8b7 (780M library, 70 sampler switches) on an Iris Xe, ANV, job m3-max-65240:
    4,528 / 4,530 MiB -> 2,622 / 2,622 MiB (42.1% less), 135.54 / 136.55 s -> 67.17 / 67.28 s
    (50.6% less).
- Our module for ec13339c on the 780M's profile (job m3-max-65215): blocks 22,746 -> 19,906,
  explicit-level samples 2,272 -> 284, OpSwitch 625 -> 341, spirv-val clean.
- The ledger over both libraries' 252 rows, plain and partial, both arms (job m3-max-65215): every
  row translates on both arms, none past 20 s, slowest 5.19 s, k12 unchanged at 440.2 MiB, and no
  rise. 20 rows of 10 kernels change, all of the 780M library. The Iris library's kernels sample
  through the program's own switches, one constexpr sampler per case, so no lane chooses a
  sampler there and its modules are byte-equal (probes m3-max-65233, 65241, 65246).
2026-11-21 17:15:11 -08:00
Anees Iqbal 21baf79e79 Validation tests: the loop-exit test names its answer type (clippy type_complexity under the device cfgs) 2026-11-21 16:28:12 -08:00
Anees Iqbal bc36b3775b Translator: a variable written or read by parts takes no store at a loop trip's top
spirv::carry stores an undefined value into a marked variable at each loop
trip's top. Its domain was held only by what the structurizer marks
(demoted and phi variables, which the emitter loads and stores whole); the
pass itself followed access chains as reads and ignored partial stores, so a
marked variable that a trip wrote by parts and the next trip read would have
lost what the earlier trip wrote. The pass now leaves alone every marked
variable one of whose pointer's uses is not a load or a store through it (an
access chain, a phi, a terminator, any other instruction, a store of the
pointer itself), and reads only loads through the variable's own pointer.

Tests:
- spirv/carry/tests.rs: a three-trip loop whose marked vec2 a trip writes
  through an access chain and the next trip reads takes no store; the same
  loop written whole takes one (the control).
- The loop kernels move to metal2vulkan-devtools (loop_kernels): the vote
  loop a thread leaves early, a loop of three exits, and a nested loop whose
  outer loop has four exits and whose inner loop leaves both, each exit
  reading values defined on its own path, with their answers and trip bounds
  that reach every exit. The product's interpreter tests run them on six
  profiles; validation's new candidate test loop_exits runs them on the test
  device and counts the stores of an undefined value in the SPIR-V the
  dispatch ran (one or more for the exit kernels, none for the predicated
  vote loop).

The structurizer's marked variables are accessed whole, so modules are
expected unchanged; the lane's job compares the module hashes against the
parent.
2026-11-21 16:17:08 -08:00
Anees Iqbal 03a7e267ff Bless at the pin: golden hashes and the authored compile census under SEMANTICS 2264, and the render descriptor key
- golden_hashes.tsv re-blessed on the M3 at 64f96fa242 (job m3-max-65087): 30 rows moved, none added or
  removed, and no row changed between compiled and not_supported. It takes the device profile's smaller
  fingerprint (the 19 unread fields deleted in 99b915bfc6) and semantics 2263 -> 2264 (a structurizer
  variable no later trip reads is ended at each trip's top, 2fbfafe0fe).
- authored-compile.tsv: artifact hashes only, no status word changed (same job).
- The old render descriptor key's pinned value is the one the test printed at 64f96fa242 (m3-max-65100).
2026-11-21 16:12:04 -08:00
Anees Iqbal 64f96fa242 Translator: the trip-top pass's work ticks convert the meter's error
What: spirv::carry's tick helper returns the meter's refusal through ? (the meter's error type is
the front end's), and the empty predecessor and loop lists are taken with unwrap_or_default rather
than a full-range slice.

Why: 2fbfafe0fe did not compile (job m3-max-64064 at the product build: mismatched types at the
tick's return).

Verified: the compile job on this commit.
2026-11-21 15:47:32 -08:00
Anees Iqbal 2fbfafe0fe Translator: a structurizer variable no later trip reads is ended at each loop trip's top (SEMANTICS 2264)
What: spirv::carry::end_dead_carries, run in the stage bound after the uniform-load hoist (and in
pipeline::testing's typed module), stores an undefined value into a demoted value's or a phi's
Function variable at the top of the first block of each loop whose body holds every whole store of
the variable, where the variable is live into that block and the block does not read it before a
store. P8 marks those variables LocalVar::trip_local, only in a walk that is not predicated: the
predicated walk runs a loop's later trips for an invocation that left it, which reads the value of
its own last trip after the loop. The new field rides through roll's renumbering with its variable;
roll's own variables are unmarked. Terminator::for_each_target is the read-only twin of
for_each_target_mut. cache::SEMANTICS_VERSION 2263 to 2264. docs/ARCHITECTURE.md names the pass.

Why: the exit dispatches and pending guards P5 to P7 add give paths from a back edge to a read of
such a variable that pass no store of it. No execution takes them, but the driver keeps the
variable around the back edge as a phi live through the whole loop. In the source the value's
definition dominates each use and the loop's header dominates the definition, so no trip reads the
value an earlier trip left; the store ends it at each trip's top and the driver keeps nothing of it.
Jobs m3-max-65023 (780M and RTX 3090) and m3-max-65024 (Iris Xe) timed the same form, written by a
probe after roll and hoist, cold through the runtime's helper against development, arms alternating
in one job: helper peak and CPU time fell on all three cards.

Tests: tests::engine_trip_carries runs a loop with three exits, the second reading a value its trip
defined, on six profiles: a value is ended at a trip's top, carry::dead_carries finds no variable
left that no later trip reads but the module keeps around a back edge, the module passes spirv-val,
and the interpreter gives the source's words. tests::engine_divergent_barriers adds a vote loop
whose early leavers read their last trip's value after it (loop_leaver_k), run predicated on six
profiles under Vulkan's barrier rule. The compile job, the two tests' red runs without the form and
without the predicated rule, and the states-only plays run on this commit.
2026-11-21 15:42:11 -08:00
Anees Iqbal 9bdced9fb4 Runtime tests: the indirect offset tests print the line that shows they ran
A device test that returns early (the draw test, where llvm-as is missing) passes without
running; the printed line is the evidence the compile job's --no-capture run reads.
2026-11-21 15:33:51 -08:00
Anees Iqbal 325e88c276 Runtime: an indirect offset off 4 is Metal's documented refusal; arguments past the end are ours
Refusal::IndirectOffset covered two cases under one `ours` basis. Metal's headers document
the first: "indirectBufferOffset must be a multiple of 4" (MTLComputeCommandEncoder.h for
dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:,
MTLRenderCommandEncoder.h for the indirect drawPrimitives and drawIndexedPrimitives; Apple's
page for the indirect drawPatches sends its offset to the feature set tables, whose minimum
constant buffer offset alignment is 4 bytes). The headers state no rule for the second,
arguments that run past the buffer's end, which is the runtime's own check because Vulkan's
indirect commands read inside the buffer (VUID-vkCmdDispatchIndirect-offset-00407,
VUID-vkCmdDrawIndirect-drawCount-00487, VUID-vkCmdDrawIndexedIndirect-drawCount-00539).

- IndirectOffset { offset, length } is now the offset-off-4 case alone, Basis:
  metal-documented.
- New IndirectArgumentsPastEnd { offset, length, needed }, Basis: ours, for arguments at a
  multiple of 4 with fewer than `needed` bytes (12 dispatch, 16 draw, 20 indexed draw) after
  the offset, or an end that overflows.
- Both raise sites (the indirect dispatch, and the indirect draws' shared check) test the
  alignment first, then the length.
- Regenerated docs/REFUSALS.md and error/basis.rs (refusal_surface.py), and
  api_signatures.tsv (one variant added). The runtime README's indirect-draw paragraph
  names both refusals.

Tests: every_device_refuses_an_indirect_dispatch_off_4_or_past_the_buffer_s_end (compute)
and every_device_refuses_an_indirect_draw_off_4_or_past_the_buffer_s_end (draw) assert each
variant and its basis(): off 4 at 2 and at an offset that is also past the end (alignment
first), past the end at a multiple of 4 and at an overflowing offset, an indexed draw's 20
bytes where a plain draw's 16 fit; then the arguments in each buffer's last bytes dispatch or
draw and their results are read back. The compute refusal test's two IndirectOffset asserts
moved into the dispatch test.

Checked here: refusal_surface.py --check and signatures.py --check pass (source only).
2026-11-21 15:33:10 -08:00
Anees Iqbal a3786dd88b Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-21 13:52:17 -08:00
Anees Iqbal 1280705fd2 Translator tests: the old render descriptor key takes the value the smaller profile gives
The first commit of this branch drops 19 device-profile fields that nothing
reads. The render descriptor key hashes the profile's fingerprint, so the key
pinned for moltenvk-m3 moves:
- the pin development holds (8ca94bca19, SEMANTICS 2263): ac15f365...
- with the smaller profile: d4257e6b...

The test's first assert pins the fixture's bytes, and it held, so neither the
fixture nor any lowering changed.

Verified: m3-max-64928 (msi-laptop) printed d4257e6b... as the key at
1fb65bf3ef, this commit's parent.
2026-11-21 13:49:26 -08:00
Anees Iqbal 1fb65bf3ef Runtime tests: the device form of the profile test reads the same two README tables
The previous commit taught the committed-profile form of the profile test to
exempt the README's "Enabled, not stated" features. The device form, under
--cfg m2v_gpu or m2v_cpu_icd, kept its own copy of the check, which read only
the "Not enabled" table. On the RTX 3090 (m3-max-64890), the Radeon 780M
(m3-max-64892) and the Iris Xe (m3-max-64891) it still failed on maintenance5,
which those devices report and which creation withholds there or never
states.

Both forms now call one check, all_recorded.
2026-11-21 13:39:55 -08:00
Anees Iqbal a98c0e8586 Runtime tests: a feature the README states is enabled but not stated passes the profile test where creation withholds it
On the RTX 3090 (m3-max-64885), the Radeon 780M (m3-max-64887) and the Iris Xe
(m3-max-64886), the device form of the profile test found that maintenance5
changes the translator's profile and that creation withholds it.

That is now true wherever its rule holds: the previous commit stopped telling
the translator of maintenance5 even where indirect command buffers enable it.
The README's "Enabled, not stated" table records it, so the test exempts what
that table lists as well as what the "Not enabled" table records. The
committed profiles never met this, because they do not hold the feature as one
creation withholds.

The per-card runs are next to verify.
2026-11-21 13:39:54 -08:00
Anees Iqbal 0a4948ee82 Runtime: the translator is not told of maintenance5, which only indirect command buffers enable
Two commits back, the translator's description began to state maintenance5 and
VK_KHR_maintenance5 wherever device creation enabled them. Creation enables
them only on a device that offers indirect command buffers.

The translator holds A8Unorm in A8_UNORM where its profile has
VK_KHR_maintenance5, and in R8_UNORM read as (0, 0, 0, r) otherwise. So
stating them made A8Unorm take a second form, chosen by the indirect-command
query, which is outside the nine query-chosen forms. On lavapipe, which offers
indirect command buffers, two device tests failed:
- tests::texture_buffers ... every_device_refuses_what_metal_refuses_of_a_texture_buffer:
  A8Unorm texel buffers were no longer refused;
- tests::view ... every_device_samples_an_a8_view_of_an_r8_texture: the A8 view
  was refused.
Both failed in m3-max-64830.

Changes:
- The INDIRECT_COMMAND_FEATURES entry for maintenance5 carries no translator
  name again, and shader_extension no longer maps VK_KHR_maintenance5.
- The README gets an "Enabled, not stated" table listing both, with the reason.
- tests::feature_enables reads that table. An item creation enables that the
  translator names must reach the description unless the table lists it. Each
  row must be an item creation enables, that the translator names, and that
  the description does not state.

The README's sentence on borders and A8Unorm ("where indirect command buffers
enable VK_KHR_maintenance5, that changes nothing here") holds again.
2026-11-21 13:39:54 -08:00
Anees Iqbal 38f4c6fca5 Runtime: a test holds the translator's profile to what device creation enables, and the README records each feature it withholds
New test module tests::feature_enables, with three tests and a fourth under
--cfg m2v_gpu or m2v_cpu_icd:

- Every feature in the tables device creation enables (floor::ENABLED) that
  the translator's vocabulary names (VkFeature, by its Vulkan member) carries
  that name in its table entry, so shader_enables states it.
- Every extension creation may enable that the translator names maps through
  shader_extension.
- Not-enabled features, on the committed profiles:
  - For each committed device profile, and the floor's, the test derives the
    translator's profile with each feature the device reports that creation
    does not enable, and checks whether that profile differs from the one
    derived from what is enabled.
  - Any such feature must appear in the README's new "Not enabled" table.
  - Every feature in that table must stay un-enabled.
  - Every feature in that table must be read where some profile reports it.
- The device test does the same check on each device of the cfg's kind.

The exemptions come only from the README table, which records each feature
with the form or the typed refusal a program meets without it. The test keeps
no list of its own.

The table holds:
- the five features held to one form on every device: native float atomic add,
  exact fma, 8-bit floats, raster-order attachment access, robustBufferAccess;
- vertexAttributeInstanceRateZeroDivisor;
- the typed refusals ImageAtomics, StorageImageMultisample, ComputeDerivatives
  and RasterOrderGroups (the per-sample interlock: taking it where a device has
  it would be a second form chosen by a query, outside the nine);
- the storage-buffer update-after-bind and non-uniform indexing pair, which the
  translator's function table never needs (the runtime supplies none).

floor.rs: shader_extension becomes pub(crate) for the test; tests::floor's
at_the_floor and table become pub(super).

Verified (m3-max-64818, msi-laptop, release of this tree's content):
- feature_enables and tests::floor passed 38 of 38 at the profiles;
- the same passed 40 of 40 on lavapipe under --cfg m2v_cpu_icd.

Committed profiles checked: 15 (14 devices plus the floor). The device test
saw the same ten features on llvmpipe.
2026-11-21 13:39:51 -08:00
Anees Iqbal 94e2fa0b83 Runtime tests: the border swizzle test reads the features the translator is told of
The previous commit gives the translator its names for borderColorSwizzle,
borderColorSwizzleFromImage, VK_EXT_border_color_swizzle and
VK_EXT_custom_border_color. This test still asserted that the translator is
never told of them, so it failed on the commit that made it tell.

It now asserts that the description states each of those features and
extensions exactly where device creation enables it, and nothing else.

Verified: tests::floor passed in full (38 of 38) together with the
feature-enable test, both at the floor profile (m3-max-64818, msi-laptop) and
on lavapipe (40 of 40).
2026-11-21 13:39:50 -08:00
Anees Iqbal e734db4be2 Runtime: the translator's description states every feature and extension device creation enables that it names; maintenance4 joins the floor
What: shader_enables, the enable set the translator's description of the device is restricted to
(DeviceDescription::with_enabled), now reads every table of features device creation enables
(floor::ENABLED: the floor, the portability subset, the optional features, the attachment
reads, step rates, min-LOD clamps, fill modes, quad control, the pixel interlock, barycentrics,
the border swizzle, linear attachments, fault reports, and the indirect commands' features, now a
table of their own, INDIRECT_COMMAND_FEATURES, which indirect_commands sets). Each entry the
translator names reaches it where creation enabled it. Entries that were enabled but unnamed now
carry the translator's name: depthBiasClamp, drawIndirectFirstInstance, bresenhamLines and
occlusionQueryPrecise (floor), attachmentFeedbackLoopLayout (the attachment reads),
borderColorSwizzle and borderColorSwizzleFromImage, and maintenance5 (indirect commands).
shader_extension names the extensions those need, and the others creation enables that the
translator names: VK_EXT_line_rasterization, VK_EXT_attachment_feedback_loop_layout,
VK_EXT_border_color_swizzle, VK_EXT_custom_border_color, VK_EXT_external_memory_host and
VK_KHR_maintenance5.

maintenance4 joins the floor (REQUIRED, the README's floor table, runtime-floor.json's
m2v_runtime_floor block and regen_device_profiles.py's RUNTIME_FLOOR): Vulkan 1.3 requires it
of every device, so no device at the floor lacks it. The translator's profile reads it for
spirv-val's --allow-localsizeid alone.

Why: the planner's feature-enable walk (lane texoff, 11-21) found these features enabled at
vkCreateDevice and absent from the translator's profile, the class maintenance8 was in before
38dcc857dd. None changes what the runtime does on its own paths: the runtime sets depth bias,
border colors and indirect draws itself, and the translator's readers of these features
(metal::state::depth_bias, the bind plan's indirect_first_instance_missing, metal::sampler's
opaque-black border) are not on them. The profile now states what the device has. Its fingerprint
moves on every device, and with it every cache key.

64-bit image atomics stay off, and the features the translator reads that the runtime does not
enable are the feature-enable test's (next commit).
2026-11-21 13:39:50 -08:00
Anees Iqbal 99b915bfc6 Translator: the device profile drops the 19 fields nothing reads
Device::from_queries derived these profile fields from the description's features, and no code
consulted any of them: only the profile's fingerprint rendered them, so a device that listed one
moved every cache key and changed nothing a module holds. They go, with the feature reads that
filled them:

- LeafCaps (crate-private): uniform_buffer_8bit, push_constant_8bit, uniform_buffer_16bit,
  push_constant_16bit, workgroup_explicit_layout, workgroup_explicit_layout_8bit,
  workgroup_explicit_layout_16bit, buffer_float32_atomic_min_max, shared_float32_atomic_add,
  shared_float32_atomic_min_max, image_float32_atomic_add, image_float32_atomic_min_max, fma16;
- ImageCaps (public): sampler_filter_minmax, compute_derivative_quads;
- DescriptorCaps (public): variable_descriptor_count;
- FragmentCaps (public): geometry_shader, cull_distance, dynamic_rendering_local_read.

The six public fields are removed from a published crate. The consumer's checkouts hold no use of
any of them: ~/Projects/steelbrain/reims-vgpu at 047a8d162d and clean-slate-reims-vgpu, 0 hits
for each of the six names (and for LeafCaps). This tree holds none outside derive.rs and
profile.rs. tests/api_signatures.tsv loses exactly their six records
(scripts/api-signatures/signatures.py --bless).

The features stay in the vocabulary (VkFeature): requirements name some of them, and a Khronos
profile or a queried device still lists them. Where the translator reads one of these features to
choose a form, it reads it elsewhere (float add: buffer_float32_atomic_add; fma: fma32), unchanged.

Why: the planner's feature-enable walk (lane texoff, 11-21) found every profile field the
translator derives from a feature, and these are the ones nothing reads (R4: delete). Under the
no-dead-code rule a field no code consults is deleted, and the feature-enable test compares the
profile a device's features derive, which an unread field would make differ for no reason.

The profile fingerprint changes on every device that lists one of these features; it is in every
cache key, so no stale artifact is taken. No module changes.
2026-11-21 13:39:50 -08:00
Anees Iqbal 8ca94bca19 Bless at the pin: golden hashes and the authored compile census under SEMANTICS 2263, the render descriptor key, and the signed-remainders fixture's printout and inventory rows
- golden_hashes.tsv re-blessed on the M3 at b20dc87d22 (job m3-max-64905): 1,851 rows moved and 2 added
  (the two kernel_signed_remainders fixtures). No row changed between compiled and not_supported; only
  hashes moved, under semantics 2259 -> 2263 (2260 kept routines, since removed; 2261 signed remainder and
  funnel shift; 2262 arena slot; 2263 the kept routines removed).
- authored-compile.tsv: artifact hashes only; no status word changed (same job).
- The old render descriptor key's pinned value is the one the suite printed at b20dc87d22 (m3-max-64865).
- tests/air_input/kernel_signed_remainders.txt and the fixture's two inventory rows (all profiles ok) were
  written by bless_engine_goldens under LLVM 21 and bless_engine_inventory on the M3 at 16d3037930 (job
  m3-max-64853). Nothing else changed in either. They were missing since the fixture landed, and their absence
  failed three tests.
2026-11-21 13:37:43 -08:00
Anees Iqbal b20dc87d22 Translator: the outline pass goes; a repeated region is written in line again (SEMANTICS 2263)
What: spirv::outline (a repeated region of 500 or more instructions written once, as a kept
routine declared DontInline) is deleted with its tests, its call in the stage bound and in
pipeline::testing, its notes in weights.rs, ir::Function::kept, ModuleBuilder::kept_routine and the
serializer, docs/API.md and docs/ARCHITECTURE.md. roll's items and its spine take back their own
visibility and signature (the loop-body sequences only the outline search read). The
bounded-growth test's chain is all one group again: no pass now folds a repeated graph.
cache::SEMANTICS_VERSION 2262 to 2263. The sampling and texel routines stay kept routines,
DontInline as before.

Why: a regression on NVIDIA. Job m3-max-64837 (RTX 2080, 620.70.06, um790, exclusive) made k7
(610e4b3d of the Iris capture's library, weight 320,401) cold through the runtime's helper, arms
A db5fefc2ce (before the pass), B 71014cd7bc's product (the pass in), C 36ed0d15b2, alternated
A B C A B C. The helper's CPU time and peak resident set (VmHWM):
- A: 37.74 s, 1,749 MiB; 37.90 s, 1,750 MiB.
- B: 85.82 s, 2,040 MiB; 87.44 s, 2,041 MiB (10 kept routines; largest function 195,769
  instructions against A's 336,129).
- C: 87.35 s, 2,049 MiB.
B is 2.3 times A's CPU and 16.6% more memory. The pass's only gain on file was synthetic (one
function called from 50 places, m3-max-64453). RADV and ANV cannot gain from it: Mesa 26.2.6
inlines every function before either backend sees the shader, RADV in radv_shader_spirv_to_nir
(src/amd/vulkan/radv_shader.c:574, nir_inline_functions) and ANV through the common runtime
(src/intel/vulkan/anv_device.c:792 sets the shader ops; src/vulkan/runtime/vk_pipeline.c:211 calls
vk_spirv_to_nir, whose src/vulkan/runtime/vk_nir.c:176 runs nir_inline_functions).

Verified: the compile job of this commit and a states-only play of nine streams against
development follow; the golden table and the render key are re-blessed at the pin.
2026-11-21 13:15:45 -08:00
Anees Iqbal 16d3037930 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-21 13:07:12 -08:00
Anees Iqbal f241ce7712 Translator tests: the arena slot test reaches the arena only in a branch's arms
The slot test's kernel wrote the arena in its entry block, so the body's first
block re-derived the slot in the block the entry hooks end in, and every later
block recalled that one: the test passed without the slot fix on the
derivation count and failed only on the push loads.

Its entry block now reaches no private memory; the arms of its branch and the
join do. As a kernel whose threadgroups may be partial, the hooks end past the
partial guard's construct, in a block other than the one the slot was asked
for in, so without the fix each arm and the join derive the slot again, as the
real arena kernels did (one derivation per block). The test asserts one
derivation per module on every identity profile that keeps the arena in device
memory.
2026-11-21 13:03:02 -08:00
Anees Iqbal 243189eaf8 Semantics 2262: a device private arena's slot made once in the first block, its words one access chain each, and each push member loaded once
The device-arena commits before this one change emitted modules: the
slot is made in the function's first block and placed as a pointer to
its words, a word is one access chain, and the tail guard reuses the
tail field's first load. Output changes under unchanged keys, so the
golden table is bless-due on development.
2026-11-21 12:51:24 -08:00
Anees Iqbal c6651aa3cd Translator: a device private arena's word is one access chain from its slot's words, placed once
ArenaMem::ptr made each word's address from the slot's device address:
a shift, a widening, an add, an OpConvertUToPtr and an access chain, 5
instructions before the load or store (6 for a word at a run-time
index). EmitCx::arena_slot now places the slot once, in the function's
first block, as a PhysicalStorageBuffer pointer to a runtime array of
u32 (device_place, stride 4), and a word is the access chain to its
element: the same address, slot + 4 * word, still Aligned 4.

Test: tests/engine_device_arena.rs measures one access of each shape
as the entry-weight difference between a kernel making it once and
twice (as engine_access_size does). On every identity profile, before
-> after (m3-max-64710, 64737):
- word load at a run-time index: 16 -> 12
- word store at a run-time index: 15 -> 11
- float4 load at a run-time index: 39 -> 23
- word load at a constant index: 6 -> 3
The bounds are the after costs, so the before form fails them.
2026-11-21 12:51:20 -08:00
Anees Iqbal 690dc4e44e Translator: a device private arena's slot is made in the first block, and each push member is loaded once
EmitCx::arena_slot remembered the slot where it was first asked for.
dispatch::emit_entry asks in the entry hooks, after the floor's tail
guard (push::emit_tail_guard) closed a construct, and the memo keeps an
entry only where it was made in the entry block, the block the hooks
end in or the open block's spine: a later hook construct leaves the
slot behind, and every block that reaches the arena derives it again
(24 instructions each). Lane ksizeread counted 2,965 such derivations
in the 780M library's 628,489-weight kernel.

- The slot is now made in the function's first block wherever it is
  first asked for (FunctionBuilder::in_entry_block, remembered at
  entry): its operands are the pushed arena address load_push_fields
  loads there, the invocation's built-ins and constants.
- The entry block is recorded before the hooks run (begin_hooks), so a
  hook after the tail guard's construct recalls the push fields the
  first block loaded instead of loading them again.
- The tail guard reads the tail field from that same load where the
  function reads the field from its member (EmitCx::derives names the
  fields a function derives elsewhere); the tail word, and a derived
  field, are still loaded by the guard.

Test: tests/engine_device_arena.rs, an owned kernel whose 7176-word
arena is reached in four blocks. On every identity profile, with the
default inputs and with partial_threadgroups, the slot is derived once
and each push member is loaded once. Without this change, on the same
kernel at 0429ff1bd4 (m3-max-64752), one member was loaded twice by
default and one three times with partial threadgroups; the slot was
derived once there, so the kernel does not reproduce the re-derivation
the 628,489 kernel shows.
2026-11-21 12:51:20 -08:00
Anees Iqbal 65cd6f18f9 Runtime: a texture over a Managed buffer's copy back is taken where its order with the reader is known
A reader of a Managed buffer's device copy took, as it was encoded, the copy back of any texture
over it that any command buffer had written, submitted or not, and cleared the flag the write's
submission reads. On one queue Metal runs command buffers in commit order, whichever was encoded
first, so:
- W (writes the texture) encoded before R (reads the buffer), R committed first: R copied the
  image back before W ran and cancelled W's copy back; a reader after both completed read the
  old bytes.
- R encoded before W, W committed first: R took nothing as it was encoded and nothing took the
  copy back at R's submission; R read the old bytes. The same held for R on another queue
  committed once the guest saw W complete, or ordered behind W by an event.

Now a reader takes as it is encoded only the copies back owed by earlier writes of its own
command buffer (each segment's written textures carry whether their copy back is still owed).
Those owed by other command buffers' writes, set at the write's submission, are taken by the
upload that leads the reader's submission, as take_into and the capture's copy-in already do:
on the device's one VkQueue that is where the order is known. A segment that reaches a Managed
buffer a texture over which an earlier segment of its held group wrote, its copy back owed,
leads its own group, so the write is submitted first (the capture fix's split). Entry.fresh
goes. No copy is added; the same copies back move to where their order is known.

Tests: three arms of one device test (tests/managed.rs): W encoded first and R committed first;
R encoded first and W committed first; R on another queue encoded first and committed once W
completed. Before this change all three were red on the RTX 5080 where run (64770: arms one and
two; the third arm was added with the fix).
2026-11-21 12:59:55 -08:00
Anees Iqbal bf8146ef59 Runtime tests: a Managed buffer's reader and a write of a texture over it run in commit order, whichever was encoded first
Two device tests on one queue: W copies a pattern into a texture over a Managed buffer in an image
of its own, R copies the whole buffer out; the one encoded later is committed first, then L reads
the buffer once both completed. R reads what the commit order leaves (the buffer's bytes where R
went first, W's pattern where W did) and L reads W's pattern. The line prints the form and the
copies R recorded as it was encoded.
2026-11-21 12:48:51 -08:00
Anees Iqbal 36ed0d15b2 Semantics 2261: the defined signed remainder and the constant-amount funnel shift
Development's 2260 is the kept routines of repeated regions (9356f81e51), which landed first. The signed
remainder's own bump (64d9946757 on its branch, 2259 to 2260) is not replayed; this commit takes the next
number instead. A cached lowering made under 2260 may hold OpSRem or OpSMod, or the six-instruction funnel
shift, where this tree emits the defined remainder and the two-shift rotate.
2026-11-21 12:47:24 -08:00
Anees Iqbal bb743a8df9 Conformance: signed-remainders carries its native Metal times
The case signed-remainders was recorded without times, so the conformance suite's
times::every_case_is_timed::every_case_carries_its_timing failed on it (job m3-max-64669).
`conformance times --runs 8 --write signed-remainders` on the M3 Max (job m3-max-64714) took
Metal's per-call figures into the case's recording: seven calls (buffer, zeroed_buffer, library,
compute_pipeline, dispatch_threads, wait, read_buffer) over 8 rounds. The recorded answers are
unchanged; only the recording's times list is added.
2026-11-21 12:46:21 -08:00
Anees Iqbal 0dbadbe84b Translator: a rotate or funnel shift by a constant amount shifts by two constants
llvm.fshl, llvm.fshr and air.rotate whose amount operand is an integer constant (const_int at
selection) take ArithStrategy::IntFnBy, with k = the amount modulo the width taken at
translation. math::funnel_by emits a (b for fshr) for k = 0, else (a << k) | (b >> (N - k)) left
and (a << (N - k)) | (b >> k) right (a rotate's b is a): three instructions, both shifts in
1..N-1, where the run-time form takes six (OpUMod of the amount, the shift by one, the OpISub
of N - 1 - s, two shifts and the or) so that no shift reaches the width, which SPIR-V leaves
undefined. A run-time amount keeps that form; a vector amount is not a constant here and keeps
it too. The strategy is named arith.int_fn.by_constant.

Why: ksizeread's count found every llvm.fshl in the heavy kernels to be a 32-bit scalar rotate
by a constant amount (8,546 in k7, 8,560 and 8,569 in the two heaviest, 4,273-8,569 in the other
780M kernels), and no llvm.fshr. Each loses three instructions and two constants' worth of work.

Tests: lower::arith::tests::funnel_shifts_by_a_constant_answer_their_definition runs
math::funnel_by for rotate, fshl and fshr at 8, 16, 32 and 64 bits for every amount in 0..2N
against int_ref (the run-time form's reference), over the width's edges and random values.
tests::engine_arith::a_funnel_shift_by_a_constant_shifts_by_constants compiles fshl(a, a, 13),
fshr(a, b, 37) and fshl(a, b, 32) on moltenvk-m3, runtime-floor and amd-rdna3-radv: no OpUMod
and no OpISub in the module (the run-time form holds both), and LLVM's answer on the
interpreter.

Under SEMANTICS_VERSION 2260 with the signed remainder: the same pin, no version of its own.
2026-11-21 12:46:21 -08:00
Anees Iqbal 5d2c0bda2e Conformance: signed remainders of every width and sign, recorded on the M3
The case signed-remainders runs the owned fixture kernel_signed_remainders: each of 238 threads
reads a 64-bit dividend and divisor (17 dividends by 14 divisors: both signs, the most negative
long and int, low words that are the most negative short and char, values past 32 bits) and
writes eight words: the remainder of the low words as int, short and char, the 64-bit remainder's
two words, the exclusive-or of an int2 remainder's lanes, and the low word's remainders by 3 and
-8. Apple's compiler writes srem i32, i16, i64 and <2 x i32> by run-time divisors and srem i32 by
the constants 3 and 8 (x % -8 is x % 8). A remainder MSL leaves undefined (by zero, or of the
most negative value by -1) is never taken: the fixture writes 0xdeadbeef there. Every column
compares exactly.

It holds every device to Metal's answer where the translator's signed remainder (the commit
before last) replaced OpSRem, which Vulkan makes poison for a negative operand without
maintenance8.

Recorded on the M3 Max, macOS 27.0.1 (job m3-max-64656, which also compiled the fixture's
companions with scripts/regen-air-fixtures under Apple metal 32023.922 and LLVM 21; TOOLCHAIN
records the fixture's line). Metal's 1,904 recorded words equal C's truncating remainder for
every operand pair (checked from the recording against a reference written apart from the
fixture). docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py).
2026-11-21 12:46:21 -08:00
Anees Iqbal 02af6dcdd6 Translator tests: the remainder sweep's fold counter no longer shadows the kernel constructor k
The counter of folded results in signed_remainder_kernels was named k, which shadowed the file's
fn k(name, body, want) at the call that builds each kernel (E0618 in job m3-max-64645's clippy).
It is now folds.
2026-11-21 12:46:21 -08:00
Anees Iqbal 759821d3e7 Translator: a signed remainder is the unsigned remainder of the magnitudes, never OpSRem or OpSMod
Vulkan makes OpSRem and OpSMod poison when either operand is negative unless the device enables
maintenance8 (the Vulkan spec, "Precision and Operation of SPIR-V Instructions"; maintenance8 is
optional, and the UHD 630's Windows driver does not list it). LLVM's srem and Metal's % are
defined for every sign but a zero divisor and the most negative value by -1, so a negative
operand gave a guest an undefined answer on such a device.

One form on every device, with no query: FunctionBuilder::signed_remainder takes the operands'
magnitudes (negated where negative, read unsigned, so the most negative value's is 2^(w-1)),
their OpUMod, negated where the dividend is negative; RemainderSign::Divisor then adds the
divisor where the remainder is not zero and the signs differ (OpSMod's sign). A scalar constant
operand's magnitude and sign are computed at translation. Scalars and vectors of every width;
a signed-typed operand is bitcast to the unsigned type for OpUMod and back. The IR's BinOp has
no SRem or SMod any more, so no lowering can emit either: arith's srem (lower/arith/ops.rs) and
the bicubic emulation's repeat and mirror wraps (lower/sampler/bicubic.rs) take the helper; the
wide (two-word) 64-bit path already divided magnitudes. The interpreter's SRem and SMod go with
the variants.

Size, before building (job m3-max-64604, a probe counting sites in every serialized module, no
GPU): every site in the app's two libraries is a 32-bit scalar srem, none an smod. k7 (436,848
function-body instructions) holds 54 and gains about 414 instructions (0.095%); the heaviest
kernels gain 0.07-0.12%. The only rows past 1% are modules of 257 to 787 instructions with one
to four sites.

Tests: tests::engine_arith::no_module_holds_a_signed_remainder_opcode (fails before this
change: every kernel's module holds OpSRem) over srem of i8, i16, i32, i64, <2 x i32> and
<2 x i64> by run-time and constant divisors of both signs, the most negative value among them,
on moltenvk-m3, runtime-floor and amd-rdna3-radv; the same kernels compute LLVM's srem on the
CPU interpreter in arith_kernels_validate_and_compute_on_every_profile. engine_bicubic's
reference test now requires no OpSMod or OpSRem in its modules. The serializer's family test
validates the form on each integer type with both signs; the interpreter's integer test reads
-7 rem 2 = -1 and -7 mod 2 = 1 through the helper.

SEMANTICS_VERSION 2259: srem and the bicubic wraps emit different words.
2026-11-21 12:46:20 -08:00
Anees Iqbal 9987b91878 rt: a memory breach holds the consumer's helper ceiling it was kept under, and a higher ceiling makes it a miss
What: DeviceOptions::stage_memory_ceiling (bytes, default 0) is the memory ceiling the consumer
gives its stage helper. Device::record_stage_breach keeps it after a StageBreach::Memory entry's
byte (the entry grows from 58 to 66 bytes); at a make, a memory breach kept under a ceiling below
the device's is a miss, removed like any miss, so the make answers Error::StageUnfilled with its
request and the consumer's next fill (or a breach kept under the new ceiling) takes the entry's
place. At the breach's ceiling or below it refuses (Gap::StageSize) as before. A memory breach of
its byte alone reads as kept under 0. Time, Compile and CompileRequired breaches keep their one
byte and refuse under every ceiling; data entries are unchanged.

Why: a breach kept under the consumer's lower helper cap kept refusing the pipeline after the
consumer raised the cap, until the driver's version changed, so a host that gains memory stayed
refused for good. The ceiling is a fact about the consumer's helper that rt only stores with a
memory breach and compares at a make; no other path reads it. The entry form changes by a length
rule, with no version: WIRE_VERSION is in every stage key, and bumping it would drop every filled
entry.

Tests: a_memory_breach_holds_to_its_ceiling_and_is_a_miss_above_it (host): a memory breach kept at
A holds at 0, A-1 and A and is a removed miss at A+1; a fill replaces a breach of its key; a breach
of the byte alone holds at 0 and is a miss at 1 and at A; the other three breaches stay 58 bytes
and hold at 0, A and u64::MAX; data reads back at u64::MAX. The foreign-entry test adds a time
breach followed by a ceiling and a memory breach followed by half of one, each a removed miss. The
device test adds: the breach kept at ceiling 0 is StageUnfilled with the same request on a device
given ceiling 1, and a breach kept there refuses there (runs only where the driver writes a
pipeline cache header, so not on lavapipe).
2026-11-21 12:41:03 -08:00
Anees Iqbal ca953d3a73 Runtime tests: the capture test asserts the new-group split, W's group sent ahead of R only in the group held with two copies
What: over_write_before_a_capture reads, once R is scheduled and while the busy work still holds
the GPU, whether a submission went since W's commit, prints it on the path line, and asserts it
went exactly where W is in the group held and the device keeps two copies.

Why: AGENTS.md asks evidence that a device-shaped path ran, not only that the run passed. With two
copies, R takes the copy-in over the buffer W's texture lies over, so it leads its own group
(Captured::names_written) and W's group is submitted as R comes, before the busy work ends; held
for room, or with one copy (no Managed device copy, no split), nothing is submitted before then.

How verified: the compile job and the lavapipe rt suite, and the 5080 and XTX runs of this commit,
are in the lane's report by job id.
2026-11-21 12:34:10 -08:00
Anees Iqbal 71014cd7bc Outline tests: the many-repeats test reads the first search's set
What: the test of eighty equal regions asserts that the first search's set holds all eighty, then
that the outlined module is valid and writes what the regions wrote; it no longer asserts that the
whole pass makes exactly one routine called eighty times.

Why: once the eighty regions are calls, the calls are equal items themselves; with the test's
regions of about 44 instructions and a smallest region of 1, a later search can write runs of 16
or more calls as a routine of their own (calls are CONST_OK operands, as roll's varying_ok says),
so "one routine, eighty calls in the entry" depended on that second search failing. The set the
first search takes is the property the fix (f0a204d6a0) gives: the search as it was took at most
65 of them.

Verified: not yet run; it runs in the next compile job with the rest of spirv::outline.
2026-11-21 12:22:33 -08:00
Anees Iqbal 9356f81e51 Translator: SEMANTICS_VERSION 2260 for the kept routines of repeated regions
What: cache::SEMANTICS_VERSION 2259 to 2260.

Why: the outline pass (a repeated region of 500 or more instructions written once, as a kept
routine) changes the words of any module that holds such a region under an unchanged key. Its
first commit bumped 2258 to 2259; development reached 2259 for the device-address leaf
(d97bf60431) before it landed, so the rebase took that line as already equal and the pass's own
bump is this one.

Verified: the golden table and the old render key are re-blessed at the pin, as for every bump;
the compile job of this branch's tip reports them.
2026-11-21 12:19:27 -08:00
Anees Iqbal f0a204d6a0 Outline: a search counts each extent's occurrences over the whole function
What: find_in compares an extent against every repeat of its seed window in the function (ranges
of keys by prefix hashes), not only the first 64 repeats it extends against, so one search makes
one routine for every occurrence of a region. The context keeps, by layout position, whether a
loop holds it, and the set of loops' continue blocks; apply drops the gone regions' first blocks
from the switches-at-use list once. The bounded-growth test's chain draws each group's two
operations from four by a hash of the group's index.

Why: the compile job of 08455481c5 (m3-max-64636) failed
engine_bounded_growth::compile_cost_grows_linearly_with_the_block_count: doubling its chain of
equal groups multiplied total compile allocation by 3.43 (49,119,827 to 168,331,419 bytes), 26,005
to 83,028 words. A set held at most 65 occurrences and its saving was counted over them, so a
function of N repeats was searched about N/64 times, each search linear in the function: the
quadratic term. Two scans per occurrence over every loop of the module (in_loop, the continue
check) and a retain over switches-at-use per region were the same shape. The test's chain is all
one group repeated, which the pass rightly writes as one routine, so its module stops growing with
the chain ("the generated graph was folded away"); its groups now differ, so the graph it
measures survives whole.

Verified: not yet run; the new test
a_region_repeated_past_the_repeats_tried_is_one_routine_called_at_every_repeat (80 equal regions
are one routine with 80 calls; the search as it was makes two) and the bounded-growth test run in
the next compile job.
2026-11-21 12:18:24 -08:00
Anees Iqbal 7e92b1d0fa Translator: a repeated region of 500 or more instructions is written once, as a kept routine
What: a new pass, spirv::outline, runs on every module after rolling and hoisting. It finds a set
of regions of one function that are the same code (one sequence of the function's spine, loop
bodies included; entered only at the start and left only at the end), each of at least 500
instructions with a call of a kept routine counting one, writes the first as a new kept routine
(Function::kept, declared DontInline, the form ModuleBuilder::kept_routine makes) and replaces
every region with a call of it, then looks again, at most 64 times. Values from before a region
are parameters (one per distinct set of the regions' values; a constant that differs only where
any value may stand); a pointer parameter is a Function, Private, Workgroup or UniformConstant
variable itself or a PhysicalStorageBuffer pointer; values read after a region are the routine's
results (several in a struct). A Function variable only its region uses becomes the routine's
own where the region is in no loop or its first use stores the whole variable in a block the
region always runs; otherwise it is passed. Anything else that differs keeps the regions in line.
Candidates come from the spine's keys (16-item windows hashed, extended both ways); a set whose
exact comparison fails at an operand or result is compared again without that item. The spine
(roll::spine) takes a flag to walk loop bodies as sequences; rolling passes false and is
unchanged. SEMANTICS_VERSION 2259. API.md and ARCHITECTURE.md say the routines exist.

Why: NVIDIA's driver compiles a DontInline routine once and Mesa's drivers inline it either way.
On the RTX 3090 (620.70.06, job m3-max-64453) a generated kernel calling a 1,984-instruction
function from 50 places was created in 21.5 s inlined and 52 ms as a kept routine (51.8 s and
75 ms with 64 values live across every call); its dispatch GPU time was the same with few values
live and 20.6% lower as a routine with 64 live. A 497-instruction function: 0.1% and 19.7% lower.
500 is the smallest size measured within 3%. RADV and ANV (Mesa 26.2.6) compiled identical code
for the call, DontInline and inlined forms (jobs m3-max-64357, m3-max-64379).

How verified: spirv::outline::tests build kernels with three equal regions (a variable, a
selection's phi, a counting loop), a chain where each region reads the previous one's result, a
middle region that differs, and two regions in a loop whose accumulator is read before it is
written; each checks the routine and call counts, the module through the verifier and spirv-val,
and the words the interpreter writes against the unrewritten module's and the expected ones.
2026-11-21 12:18:23 -08:00
Anees Iqbal 0429ff1bd4 Bless at the pin: golden hashes and the authored compile census under SEMANTICS 2259, and the render descriptor key
The named pin carries memleaf (d97bf60431, fffff6e96b: a device-address leaf of whole words is one access, and
under the identity domains a wide pointer is its device address), which bumped SEMANTICS 2258 to 2259.

- golden_hashes.tsv: 1,980 rows re-blessed on the M3 (m3-max-64644 at db5fefc2ce, GOLDEN=0), header semantics 2259.
- authored-compile.tsv: artifact hashes only; no case changed status (2,378 rows, 0 status changes; 64644).
- the_old_render_descriptor_key_keeps_its_value: b3da28b0..., the value the suite at db5fefc2ce printed
  (m3-max-64624); the key hashes the translation's semantics, which moved.
2026-11-21 12:25:27 -08:00
Anees Iqbal db5fefc2ce Translator tests: a volatile pointer load through a loaded pointer is one access
Under the resident-table domains a pointer loaded through a wide pointer is
two whole words reached through PsbMem, which now reads them as one
PhysicalStorageBuffer access (Aligned 4) instead of two word loads. The
test counted two volatile loads; it now counts one and still checks the
value the chased pointer reaches.

Verified: the suite job m3-max-64513 at 428ff0fedd failed this assertion
(left 1, right 2) on moltenvk-m3 robust=true; rerun below.
2026-11-21 11:48:03 -08:00
Anees Iqbal a10c7bd0be Translator tests: the access-size test weighs the typed module (spirv::roll::entry_weight) 2026-11-21 11:48:03 -08:00
Anees Iqbal fffff6e96b Translator: under the identity domains a wide pointer is its device address
A wide pointer under the identity domains was u64vec4(0, a, 0, 0): three
zero fields carried through every GEP (four extracts and a construct around
the 64-bit index arithmetic), phi and select, and extracted at every access.
It is now the address alone, a u64 (DemoteTy::Address): a GEP is the
address's own arithmetic, an access reads no field, a parameter is its slot's
address, a loaded or converted pointer is the loaded word, and the null wide
pointer is 0. Off the identity domains the root-table form keeps its fields.
dynamic::fields gives an identity pointer's fields as constants, and add64
folds the zero host.

Rides SEMANTICS_VERSION 2259 with the whole-word access (both change
device-address modules).
2026-11-21 11:48:03 -08:00
Anees Iqbal d97bf60431 Translator: a device-address leaf of whole words is one access
A load or store of a Path::Vec4, Vec2 or Aligned leaf through a device
address (psb::PsbMem: static slots, wide pointers, the vertex fetch's
sources) moved each 32-bit word with its own address arithmetic, place and
access: a float4 at an unproven 16-byte offset was four loads and about 38
instructions. It is now one PhysicalStorageBuffer access per 16 bytes at the
device address of its first word: the leaf's own type where its register
value is its words' bits in 32-bit lanes (float, int and their vectors), else
a u32 or uvecN converted as the words were. The Aligned operand is what the
offset is proven to be (16 or 8 from a slot's own address, else 4), which
VUID-StandaloneSpirv-PhysicalStorageBuffer64-06314 allows for every type the
form uses. The words read and written are the word path's, at the word
holding the leaf's first byte, so Metal's placement holds. A store ending
inside a word keeps the word path. Descriptor views keep theirs. The
device-address uvec2/uvec4 units this replaces are deleted, and the word
below an access is one mask (psb::split_word) instead of a mask and a
subtract.

SEMANTICS_VERSION 2258 -> 2259: device-address modules change.
2026-11-21 11:48:03 -08:00
Anees Iqbal 550eb670b4 Translator tests: one device access of each AIR shape, counted on a generated module
Each shape is two kernels, one access and two, everything else equal: the
second's entry weight less the first's is one access's instructions, and its
device-address loads and stores less the first's the SPIR-V accesses it
makes. Shapes: wide float, int, float2, float4 loads and a float4 store; a
pointer loaded at a run-time offset of an align-1 constant buffer and a float
through it; a float4 load and store at a uint offset (alignment 4 proven);
a float4 load at a float4 offset (16 proven). On every identity profile each
access of a leaf of whole words must be one device-address access, within
its bound. It fails on the word-by-word form this branch replaces.
2026-11-21 11:48:03 -08:00
Anees Iqbal df7c6bbf0b API signatures: the floor's maintenance8 items
floor::MAINTENANCE8, floor::Maintenance8Features (with its maintenance8 member and its chain
impls), floor::Features::maintenance8 and floor::Capabilities::texel_offset_operand are new, and
OPTIONAL_EXTENSIONS's value ends with MAINTENANCE8. For a consumer: a struct literal of
floor::Features or floor::Capabilities that names every field no longer compiles (both take the
new field); nothing else moves.
2026-11-21 11:38:10 -08:00
Anees Iqbal 51643b170b rt tests: the floor's device check chains maintenance8 where creation enables it
The device-cfg floor test creates each device with the floor's features and destructures them;
the new field broke its build under --cfg m2v_gpu and m2v_cpu_icd (job m3-max-64512).
2026-11-21 11:35:46 -08:00
Anees Iqbal 38dcc857dd Runtime: a sample's run-time texel offset is its own Offset operand where the device has maintenance8
The owner allowed a ninth query-chosen form (Telegram 2465): "I allow the ninth query. Use it
where you can". This answers the texel-offset question inside his compile-time order ("Multi
minute compiles are unacceptable").

What: the floor reads VK_KHR_maintenance8 and its feature maintenance8 where the device lists the
extension (one of OPTIONAL_EXTENSIONS, and one of the OPTIONAL features, each of which chooses one
of two forms; VkPhysicalDeviceMaintenance8FeaturesKHR is bound by hand, as ash 0.38 lacks it, its
layout checked as the crate compiles). Device creation enables both, Capabilities answers
texel_offset_operand, and the translator's description is told of Maintenance8 and
KhrMaintenance8 (shader_enables). The translator already takes a run-time offset on a sample as
the Offset operand where its profile has maintenance8 (lower::sampler::select::dynamic_offset).
Until now the runtime never enabled the feature, so with_enabled dropped it, and every run-time
offset that reached lowering became a switch of up to 256 ConstOffset arms. NVIDIA's compiler
takes minutes to create that switch (lane stagesize: 255 arms 193 s on an RTX 3090, the operand
80 ms). Canonicalization's unroll of a proven small nest is unchanged on every device.

A device without the feature keeps the branch: Intel's Windows driver for the UHD 630 (101.2145)
lists no VK_KHR_maintenance8 (vulkaninfo, job 64024). The runtime README records the branch's
compile time as a known gap of pipeline states, and its floor tables gain the extension and the
optional feature. AGENTS.md rule 2 changes in this commit: "for eight only" becomes "for nine
only", and the list gains run-time texel offsets.

Spec (1.4.366): VUID-RuntimeSpirv-Offset-10213 is the only gate on Offset outside a gather. The
value is OpBitFieldSExtract(v, 0, 4), in [-8, 7], inside the required minTexelOffset <= -8 and
maxTexelOffset >= 7 (VUID-RuntimeSpirv-OpImageSample-06435/06436). Gathers already took Offset
through shaderImageGatherExtended, which the floor requires. Enabling maintenance8 changes no
other path the runtime takes: its blits stay within one 3D image, it names no queue family
ownership transfer flag, and it merges no pipeline caches.

Caches: the translator is unchanged, so SEMANTICS_VERSION stays. The translator's profile
fingerprint (DeviceProfile::fingerprint, over every profile field, ImageCaps::dynamic_sample_offset
among them) moves on a device that has the feature, and with it every FunctionCompileKey and render
record name in the cache directory. A lowering made without the feature is not taken by a device
with it (tests::filter_nest's every_device_keeps_the_operand_s_and_the_switch_s_lowerings_apart).

Tests: tests::floor's a_run_time_texel_offset_is_the_sample_s_operand_where_maintenance8_is_reported
fails without the change (no Maintenance8 among the enables); the_optional_features_decide_the_
capabilities takes the eighth case. tests::filter_nest (device cfgs): the unrolled kernel, the
operand and the switch (a translator told of no maintenance8 on the same device, test-only) write
the same 64 sums; the module needs maintenance8 and holds no OpSwitch where creation enabled it,
and holds a switch otherwise.
2026-11-21 11:27:17 -08:00