Commit Graph
1076 Commits
Author SHA1 Message Date
Anees Iqbal 452c17aa2c Carve MoltenVK on the M3 Max's identity out of DevicePackConversion for the measured forms
reims-vgpu treats precision notes as fatal on Apple GPUs. On the M3 Max (MoltenVK 1.4.2, macOS
27.0.1) the module's air.pack/air.unpack of rgb565 in float, and in half of unorm4x8, snorm4x8,
unorm.rgb10a2 and unorm.rgb565 (both ways) and unorm2x16 and snorm2x16 (packed), answer Metal's
words, so DevicePackConversion was recorded where nothing differs.

What: DriverDeviation::MetalPackConversions (VkProperty::MetalPackConversions), taken by the
APPLE9 MoltenVK row alone. Where taken, select_pack records no note for a form
lower::arith::pack::measured names and the module requires the property
(ArithPlan::metal_packs). The lowering is unchanged on every profile. Kept noted, with the inputs
that differ (probe over the same inputs, fast and precise math): the sRGB format (85,511 of
3,083,776 float packs, 3,286 of 65,536 half packs, every unpack), unorm.rgb10a2 in float (9,163
of 131,072 unpacked words, 1,257 packed floats), the half unpacks of unorm2x16/snorm2x16 (8
lanes: our float quotient rounded twice), and snorm.rgb10a2 (unmeasured).

Docs: Metal's float rgb565 measured to round the product to float first (the exact-product model
misses 55 of the tie set) and to unpack by the float reciprocal; the artifact rustdoc and API.md
said Metal rounds the exact product and divides correctly rounded for every format, now
qualified for rgb565 in float.

Verified (all on this M3 Max):
- Plain Metal running runtime_lane::pack_conversions' own AIR (12 kernels: every code of every
  field, every half in every channel, 68,672 float words incl. 33 around each 5/6-bit tie):
  the lane's model matches Metal in every word.
- runtime_lane::pack_conversions on MoltenVK: no kernel records the note, 0 inputs differ.
- tests::engine_arith::pack_conversions_are_metals_where_measured: all 32 normalized forms on
  lavapipe and moltenvk-m3 (note and property per form); it fails without the deviation row
  (its takes == moltenvk-m3 assertion) and without the select_pack change (the note).
- Focused core run (engine_arith, driver_facts, fast_paths, golden, api_signatures, pack,
  engine_tile, engine_texture): 197 passed.

Also: drops an unused binding the NaN-moves commit left in engine_native_half. The NaN-moves
commit's message gives SEMANTICS_VERSION 1946; since the rebase onto 68074019a3 it is 1948
(ARTIFACT_FORMAT_VERSION 483), which covers this commit too. FAST-PATHS row for air.pack updated.
api_signatures blessed (two variants); golden hashes re-blessed (the moltenvk-m3 profile).

(cherry picked from commit b344f5e515e5b1c586877ca45fedead512ea0ad2)
2026-11-02 13:13:17 -08:00
Anees Iqbal 3e28f68331 Carve MoltenVK on the M3 Max's identity out of NativeNanEncoding for NaN moves
reims-vgpu treats precision notes as fatal on Apple GPUs; NativeNanEncoding was its largest
group of Mac-only failures. Measured on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1), the device's
widening of a half to float, its narrowing back, and float fneg/fabs and half fabs answer
Metal's NaN bits, so the note was recorded where nothing differs.

What: a new DriverDeviation::MetalNanMoves (VkProperty::MetalNanMoves), taken by the APPLE9
MoltenVK row alone. Where taken:
- a float fneg or fabs records no NativeNanEncoding and the module requires the property
  (SPIRV-Cross writes -x and abs(x), Metal's own operators on the same operand);
- a half's widening to float (fpext, air.convert) and a half fabs, and a module's reads and
  encodes of a half's bits, record no note and require the property, but only where the module
  moves its halves through the registers as measured. narrow::moves_unfolded keeps the note
  where a widened half is stored anywhere but a buffer, workgroup memory or a function's float
  variable, passes through a call, return, group, atomic or image operation, has its bits read
  (a bitcast that is not stored, frexp/modf/ldexp: the frexp routines stay noted), or where the
  module holds a float NaN constant other than 0x7fc00000.
- A half fneg stays noted on every profile: the measured shapes matched only because the
  driver's compiler moved the negation onto the half.

By construction: MoltenVK's MSL writes float(as_type<half>(x)) and half(f); Metal's compiler
folds half(float(h)) across selects, phis and a function's local float variable, so moved
halves keep their bits as Metal's do.

Verified (all runs on this M3 Max):
- Plain Metal running the lane's own AIR (8 kernels; every one of the 65,536 half patterns,
  98,368 float words including 65,536 structured NaNs) matches the lane's model in every word.
- runtime_lane::nan_moves on MoltenVK: the note is absent from every kernel but the half fneg,
  and 0 lanes differ from Metal in all 8 kernels.
- Earlier MSL probe, fast and precise math: the same equalities over 262,144 float words.
- New core tests: half_moves_are_metals_only_where_the_device_folds_them (a payload NaN
  constant keeps the note), the frexp negative control in engine_metal_routines,
  float_sign_operations and the class C/D NaN tests with a moves argument, and the driver-facts
  lists.
- Core nextest (metal2vulkan, air, runtime, devtools, --all-features): 4,989 passed.

Docs: API.md (native-nan-encoding exemption), HOWTO.md, the PrecisionNote and deviation rustdoc.
SEMANTICS_VERSION 1946, ARTIFACT_FORMAT_VERSION 483 (a new VkProperty in the codec); these
bumps cover the rest of this branch. api_signatures blessed (two variants); the moltenvk-m3
profile's golden hash re-blessed.

(cherry picked from commit 93ae66b6ddb46b4d0d3db1944a4b043c40911592)
(Note on the development copy: this message names SEMANTICS_VERSION 1946; the commit sets 1948, after a rebase.)
2026-11-02 13:13:17 -08:00
Anees Iqbal 723191efb4 Pin the runtime sources for the video plumbing
The runtime's sources changed for the extra queues, the video feature structures, the shared
event's caller signals, plane textures over the caller's VkImage and Buffer::vk_host_memory.
RUNTIME_VERSION stays: each is a new opt-in surface, and a run that uses none of them (no extra
queue asked, no listed video extension, no caller signal reserved, no plane texture, no host
memory asked for) submits, answers, refuses and announces as before. Recomputed with
pin-compute.py.

(cherry picked from commit 51f7262b7a57a39a8df109626b2d3a39a8e79469)
2026-11-02 12:32:05 -08:00
Anees Iqbal 9613166920 Document the video plumbing; regenerate the refusal surface and the signatures table
- crates/metal2vulkan-runtime/README.md: the extra_queues option, the feature structures the
  listed video extensions take, DeviceHandles' extra queues and the sharing rule for them, the
  shared event's semaphore (signal-index counter, vk_wait, reserve_vk_signal), plane textures
  over the consumer's VkImage and their refusal, and Buffer::vk_host_memory.
- docs/REFUSALS.md regenerated (python3 scripts/refusal-surface/refusal_surface.py) for
  RuntimeGap::VkImagePlaneCopy and WrappedImageProblem::{Plane, PlaneFormat}; reach.tsv marks
  the gap `none` (a runtime extension's path). 0 variants without a reach mark or a basis.
- crates/metal2vulkan/tests/api_signatures.tsv blessed: 28 added records (ExtraQueue,
  VkEventWait, VkEventSignal, VkHostMemory, the new fields, methods and variants), none removed
  or changed.
- The extra-queue device test prints the video features enabled through the runtime's own
  query (listed_structures, listed_reported) and asserts each required one is on where its
  extension is enabled.

docs/METAL-COVERAGE.md and docs/CONFORMANCE-COVERAGE.md check current.

(cherry picked from commit bb2a4c2c6101458026253461402ac463c1bcb323)
2026-11-02 12:32:05 -08:00
Anees Iqbal 4329b26664 Answer where a no-copy buffer's bytes lie in the device's import of the caller's pages
Buffer::vk_host_memory (unsafe, Option) answers the VkDeviceMemory, the offset of byte 0 in
it, the import's bytes from there, its memory type and its handle type
(HOST_ALLOCATION_EXT) where the buffer's bytes are the caller's host pages in place in one
allocation the device imported by their pointer: a no-copy buffer's, or a heap-over-host-memory
buffer's, imported by pointer or bound in a guest RAM chunk's import. A VkBuffer of the
caller's own (a video decode's bitstream source) binds there: the import is never a dedicated
allocation. It is read apart as vk_buffer is (ReadApart::VkBuffer), which keeps a releasable
import imported for good.

None for everything whose memory is not one import of the pages themselves: buffers in the
device's own memory or the caller's VkBuffer, copied host buffers (a copy synced only at the
runtime's commits and completions), dma-buf imports (several sparsely bound allocations),
read-only-view imports (Metal's private bit 24, writes dropped), detached buffers, and the
stand-in of an import that could not be made again. The answer holds until a rebind or a
detach.

Byte 0 lies at the placement's offset plus the pages' offset in it (Device::pages_of's
contract), which a heap's buffer adds its offset in the heap to.

Test (device, m2v_gpu): a no-copy buffer over a pointer 256 bytes into a page answers offset
256 and an 80 KiB window less 256 on the M3 Max (MoltenVK); a VkBuffer made for host
allocations bound there takes a raw vkCmdFillBuffer that the host reads in the pages from byte
0 over the length and nowhere else; a buffer of the device's own memory answers None.
Verified: passes, and passes with no Khronos validation-layer message (probe run, not
committed). Without the pages' offset (answering the placement's alone) it fails: offset 0,
"the fill reached the pages from byte 0".

(cherry picked from commit 16dfe5a626c903ef5c43d790da50be4c479b1de4)
2026-11-02 12:32:04 -08:00
Anees Iqbal 0dbfc43a5d Test the video plumbing on a device: extra queues, the event's semaphore, NV12 planes
Three device tests (compiled under m2v_gpu or m2v_cpu_icd), each printing what the device
reported:

- extra_queues_are_made_or_reported_and_the_video_features_enabled asks for a COMPUTE and a
  VIDEO_DECODE_KHR extra queue with the video extensions optional: each made queue belongs to a
  family containing its flags and takes an empty submission, each absent one is named in the
  metal2vulkan-extra-queues-absent message, the decode queue is made exactly where the device
  has a decode family, and videoMaintenance1 is enabled where its extension is.
- a_raw_submission_is_ordered_by_a_shared_event_s_semaphore: a raw copy on the extra queue
  waits for a command buffer's encodeSignalEvent (value 10 is counter 1) and signals the counter
  reserve_vk_signal(20) gave (2, after 1), which releases a command buffer's encodeWaitForEvent
  for 20; the data flows fill -> raw copy -> blit copy, and the second command buffer has not
  completed before the raw signal.
- a_texture_over_each_plane_of_an_nv12_image_reads_its_bytes: a G8_B8R8_2PLANE_420_UNORM image,
  CONCURRENT across the device's and the raw queue's families, MUTABLE_FORMAT|EXTENDED_USAGE,
  SAMPLED, filled per plane on the raw queue and left in GENERAL, read through R8Unorm and
  RG8Unorm plane textures by invert_texels; every texel matches the plane's bytes, and a blit
  copy of a plane is refused with RuntimeGap::VkImagePlaneCopy.

The raw submissions use only the test's own buffers (wrapped with new_buffer_with_vk_buffer
where Metal-side code uses them): the device's own objects are shared among its queue families
alone, which the extra-queue docs now say.

Verified on the M3 Max (MoltenVK): all three pass, and pass with no warning or error from the
Khronos validation layer (a probe run with VK_LAYER_KHRONOS_validation enabled, not committed).

(cherry picked from commit e04878dd38ecefd8db4822b2e7bbe20636030deb)
2026-11-02 12:32:04 -08:00
Anees Iqbal 4a33ffeee9 Make textures over a plane of the caller's multi-planar VkImage
Device::new_texture_with_vk_image_plane is newTextureWithDescriptor:iosurface:plane: over a
Vulkan image's plane: a texture of the descriptor's format (R8Unorm or RG8Unorm for NV12's planes,
R16Unorm or RG16Unorm for P010's) at the plane's extent, whose views name the plane's aspect. The
caller makes and keeps the image (only it knows its video profile and picture buffer role): the
runtime never moves its layout (it stays in GENERAL, which VK_KHR_unified_image_layouts lets serve
video too), never takes queue family ownership, and never frees it, as for
new_texture_with_vk_image. Barriers name the colour aspect, which Vulkan takes of a multi-planar
image.

plane_plan checks the image against the descriptor and the contract: a multi-planar format with
that plane (the registry's plane table), a compatible format, the plane's extent, optimal tiling,
MUTABLE_FORMAT and EXTENDED_USAGE, the shader usages, and sharing with the device's families.

The runtime's copies name the colour aspect, which Vulkan refuses of a multi-planar image, so
what would copy the plane is refused as a new gap, RuntimeGap::VkImagePlaneCopy: blit copies,
fills and mipmap generation, a render pass that renders it, and usage and view shadows. Sampling
and shader reads and writes, through its views, run.

Verified: tests::wrapped::a_plane_of_a_multi_planar_image_is_planned_by_its_plane (NV12 and P010
planes, each refusal, the plane table against the format names) and the existing wrapped-image
tests pass; clippy is clean.

(cherry picked from commit 8ae428f79b9bc5888b9a21be11743b1297a8863e)
2026-11-02 12:32:04 -08:00
Anees Iqbal 9e0e3f854f Let the caller's submissions wait for and signal a shared event's values
A consumer that decodes video on its own queue orders that work against the runtime's command
buffers' encodeWaitForEvent: and encodeSignalEvent: through the event's timeline semaphore
(SharedEvent::vk_semaphore). Its counter is a signal index the runtime maps to Metal's values, not
the value itself: Metal's value only rises by maximum and a host set takes effect at once, which
a timeline semaphore cannot carry (VUID-VkSemaphoreSignalInfo-value-03258). So:

- SharedEvent::vk_wait(value) answers the counter value a Metal value is (VkEventWait: Reached,
  Counter, or NotYet while no signal submitted, reserved or set reaches it);
- SharedEvent::reserve_vk_signal(value) reserves the next index for the caller's signal under the
  scheduler's lock, so no batch takes it meanwhile (VkEventSignal: Counter with the index to
  signal and the one to wait for first, or Dropped where Metal's maximum makes it a no-op).

No completion turn sees the caller's signal, so a per-device watcher thread waits for each
reserved index on the host, in reservation order, and observes it as a completion turn does
(EventTimeline::landed): the value rises, host waits wake, notifications post, the scheduler
looks again. It never observes past a signal behind a copied host buffer's merge. Its thread
starts at the first reservation and ends after a second with none left. vk_semaphore's contract
now states the counter's meaning, no binary use, signals only as reserved, and the lifetime.

Verified: tests::event_timeline::the_caller_s_signals_take_the_next_index_and_land_through_the_watcher
and the eleven existing timeline tests pass; clippy is clean.

(cherry picked from commit d00d0f8770f68e6c3d7556cb14d79146e04ae0f8)
2026-11-02 12:32:04 -08:00
Anees Iqbal 5671cdd6bd Make extra queues for the caller beside a created device's own
DeviceOptions::extra_queues asks a created device for queues of given flags (VIDEO_DECODE_KHR for
a consumer that decodes video on the device, for example), one per entry, which
DeviceHandles::extra_queues returns as ExtraQueue (the flags asked, the family, the VkQueue). The
runtime never submits to them.

Each takes a queue the device's own plan leaves free, of the first family whose flags contain the
entry's and has one. Where none is free (MoltenVK's four families of one queue, all the device's
own), the device gives up its last queue of such a family: a presenting reserve first, then the
round robin's last, then the staging queue, never its first queue. A device with no queue for an
entry is made all the same, and says so once in an informational message
(metal2vulkan-extra-queues-absent). ash prints flags only with its debug feature, which stays off,
so the flags print through a small formatter.

Verified: tests::device::extra_queues_take_a_free_queue_else_one_the_device_gives_up covers
NVIDIA's, MoltenVK's, a six-queue and lavapipe's family shapes, the staging fallback and the
message; clippy is clean.

(cherry picked from commit b18b4723daab3845e6ed9ad1517151123d5cc151)
2026-11-02 12:32:04 -08:00
Anees Iqbal 7883f78632 Enable the video maintenance and unified image layouts feature structures of listed extensions
A consumer that decodes video on the runtime's device lists VK_KHR_video_maintenance1,
VK_KHR_video_maintenance2 and VK_KHR_unified_image_layouts. The runtime now knows their feature
structures as it knows swapchainMaintenance1's: where the device lists one, the device enables
videoMaintenance1, videoMaintenance2, or unifiedImageLayouts with unifiedImageLayoutsVideo.
ash 0.38 has the first structure; the other two are laid out from the registry.

Each known feature now says whether Vulkan requires it of every device listing the extension
(the specification's feature requirements). unifiedImageLayoutsVideo is the first optional one:
it is enabled where the device has it, and its absence neither refuses a listed extension nor
leaves an optional one out.

Verified: tests::enables::video_extensions_take_their_features_the_optional_one_where_the_device_has_it
and the two existing listed-extension tests pass.

(cherry picked from commit 4189380ad4db568d0df97f5c5dcbb60c76adcf55)
2026-11-02 12:32:04 -08:00
Anees Iqbal f747833ca5 Pin the runtime sources after recording pixel centres' denormals per form
The note fix edits sources the runtime pin hashes: the sampler
selection, PrecisionNote's documentation and SEMANTICS_VERSION. No run of
an unchanged artifact and plan does anything else (the change moves
which notes a new artifact records, and new artifacts carry
SEMANTICS_VERSION 1947), so RUNTIME_VERSION stays at 1728 and the pin
alone moves (pin-compute.py: 66c5f8bd...).

Verified: the_runtime_sources_are_the_committed_ones passes against a
build of this tree.

(cherry picked from commit 68074019a34494346cb27673aeee32a4388a908e)
2026-11-02 11:36:44 -08:00
Anees Iqbal b0bed82331 Record a pixel sample's centre denormals only where its centre can run
ed08da17f6's pixel-sampler fix recorded PrecisionNote::DeviceDenormals
unconditionally for every texel-centre position, TexelBySpec and
TexelByWord included. Those two are the runtime slot's and the argument
buffer's samples, whose centre `floor(x) + 0.5` sits behind the
NearestPixelSampler specialization or the table word's test: code that
no normalized state reaches. So every stage that samples through a
runtime or argument-buffer sampler, normalized ones included, gained an
unconditional DeviceDenormals at making, which a host that refuses any
precision note on an Apple GPU dies of (cubic stages died of it before
reaching their own BicubicFilterArithmetic, which is unchanged).

The note is real where the centre runs. Measured on the M3 Max with a
21x13 texture and clamp-to-zero and white-border states, at x = -2^-149,
-2^-140 and -2^-127: Metal's nearest pixel sampler reads texel -1 (the
border), MoltenVK's `floor` flushes the subnormal to -0 and reads texel
0. It shows through every centre form: a constexpr nearest sample with
an offset (UnnormalizedTexel), a constexpr edge fetch with an offset, a
constexpr nearest array sample (Texel), a runtime slot under a nearest
pixel state (TexelBySpec) and an argument buffer under one
(TexelByWord). The shader keeps the device's floor (owner's rule 1).

centre_denormals now gives the note per form:
- a constexpr sampler's Texel or UnnormalizedTexel centre, and a fetch
  under an offset: unconditional, as before;
- a runtime slot's TexelBySpec: only under NearestPixelSampler == 1,
  which is 0 for every normalized state; a runtime slot's Texel (an
  integer texture): only where its word has the pixel bit;
- an argument buffer's TexelByWord: none of its own;
  ArgumentPixelSamplerScaling, which the runtime announces only while a
  pixel state lives, records it (its doc now says so).

Tests:
- tests::engine_sampler::normalized_and_cubic_stages_record_no_note_
  their_states_cannot_run (moltenvk-m3) holds the unconditional notes of
  the sampling, handle, argument-buffer, pixel-argument and cubic
  fixtures (plain and the cubic variant under normalized and pixel
  words) to 9f5776bf31's, and checks every specialized DeviceDenormals
  clause tests the nearest-pixel constant or the pixel bit. It fails on
  ed08da17f6's select.rs (DeviceDenormals among the unconditional notes).
- runtime_pixel_accesses_hand_the_device_the_scaled_coordinate now
  checks the nearest kernels' one specialized DeviceDenormals entry and
  that the gather has none.
- runtime_lane::pixel_edges::normalized_states_announce_no_pixel_note
  dispatches the slot and argument-buffer kernels under normalized
  nearest and linear states and asserts no DeviceDenormals or pixel
  note, then a nearest pixel state and asserts DeviceDenormals (slot)
  and ArgumentPixelSamplerScaling (argument buffer). On ed08da17f6 it
  fails on the Apple M3 Max with DeviceDenormals under normalized states.

docs/API.md (device-denormals, argument-pixel-sampler-scaling) and the
DeviceDenormals row of docs/FAST-PATHS.md state the per-form rule and
the measurement. SEMANTICS_VERSION 1947: an artifact's notes changed.

Verified before this commit on MoltenVK (M3 Max, under maclock and
memcap): runtime_lane::pixel_samplers, pixel_edges (the new test
included) and pixel_downscales, 8 of 8; sampler translator tests 121.
The full checks follow on this tree.

(cherry picked from commit 382e940c470becee8cfdf560f2f1284ce2844599)
2026-11-02 11:36:44 -08:00
Anees Iqbal 35006080be Restore three sampler word tests a pixel-sampler commit dropped
888ad9bae9 ("Read a pixel-coordinate sample's texel as Metal's sampler
does") deleted a_sampler_word_answers_the_linear_predicate,
a_samplers_word_holds_metals_levels_on_its_grid and
a_samplers_clamp_is_the_descriptors from metal/sampler.rs through an
over-wide replacement; nothing in that change meant to remove them.

They come back as they were at its parent, with the linear-predicate
test's doc corrected to say what it checks.

Verified: the three tests pass (cargo nextest run -p metal2vulkan
--all-features -E 'test(a_sampler_word_answers_the_linear_predicate) |
test(a_samplers_word_holds_metals_levels_on_its_grid) |
test(a_samplers_clamp_is_the_descriptors)').

(cherry picked from commit 9fa628eab7994de0a4c69e24d7fa6e08bdd4abba)
2026-11-02 11:36:44 -08:00
Anees Iqbal a9e07b6bf4 Bump RUNTIME_VERSION to 1728 and pin the runtime sources for the placements outside the space
What: RUNTIME_VERSION 1722 -> 1728; the runtime-sources pin recomputed on this tree
(`pin-compute.py`, 99e3d83d...).

Why: a run of an unchanged artifact and plan now answers other addresses. The in-place check's
buffers, a device-made texture buffer's texels and a visible function table's words no longer take
ranges of the Metal space, so a program's `Any` buffers made after or beside them answer lower
`gpu_address`es, and a pin there that was refused `PlacementConflict::Held` is made. Bumping it
also renames the in-place check's record, so each host checks once more; its verdicts do not
depend on the placement.

Verified on the M3 Max (MoltenVK), on this tree:
- the runtime suite with `--cfg m2v_gpu`: 1487 passed; plain: 1194 passed;
- the validation lanes for texture buffers, function tables, pools, in-place textures, rebinds,
  memoryless textures, swizzles, render arguments, chosen pointers and indirect executions: 177 of
  178 passed. The one failure, `function_tables::tables_and_handles_answer_as_metal_s_do` (a
  binary function's handle answers None), fails the same way on the base ed08da17f6;
- the two lane tests of c62deff2e3 fail with its two placements set back to `Any` ("out of Device
  memory" for the texture buffer and the table made while the space is held);
- the consumer's repro: exit 1 in 5 of 5 runs on the base (a pin at 2^32 or 2^32 + 16 MiB refused
  `Held` by the check's 40 MiB at 2^32), exit 0 in 5 of 5 runs on this tree (about 110,000 pins
  made while the check ran, 78 to 82 ms; Pointer and Fresh passed, DmaBuf unchecked);
- `the_runtime_sources_are_the_committed_ones` passes against a build of this tree; clippy (all
  features, plain and `--cfg m2v_gpu`) and `signatures.py --check` are clean.

(cherry picked from commit be8a19940bcd68c8700e499417e38f1a56b0e20f)
2026-11-02 10:55:21 -08:00
Anees Iqbal 12aa3ba277 Place device-made texture buffers' texels and function tables' words outside the Metal space
What: a texture buffer the device makes (`newTextureWithDescriptor:`,
`newSharedTextureWithDescriptor:`; `Device::new_texture_buffer`) lies over a buffer made by
`new_buffer_placed` at `AddressPlacement::Outside`, otherwise as `new_buffer` makes it (kept among
the program's resources, announced alike); a visible function table's words buffer is placed
`Outside` instead of `Any`. address.rs's "Outside the space", the two modules' docs and the
runtime README say so.

Why: Metal shows no program an address of either. MTLTexture and MTLVisibleFunctionTable answer
a `gpuResourceID` and no `gpuAddress`, and the runtime exposes neither buffer: no getter answers a
device-made texture buffer's buffer, and a table's words are reached through its binding at a
buffer index, its resource ID in an argument buffer (set 1's function-table array) or its words'
Vulkan device address (`VisibleFunctionTable::listed`). A texture buffer's texels are read
through texel views and the texture table by ID. Nothing reads either relative to the Metal
space, so taking a range of it only moved the program's own `Any` buffers and could refuse its
pins, unlike a texture of its own memory, which takes none. Heap texture buffers stay in their
heap's range, which Metal exposes.

Tests (validation lane, device): `texture_buffers_the_device_makes_lie_outside_the_metal_address_space`
and `a_table_s_words_lie_outside_the_metal_address_space` hold the whole space with one address
pool (`pool_slots::holding_the_space`, which checks that a buffer at `Any` is then refused
`OutOfMemory` and one `Outside` is made), and make a plain and a shareable texture buffer (the
CPU reads back what it wrote) and a function table (a kernel calls the functions it holds once the
space is free again for the dispatch's output).

Verified on the M3 Max (MoltenVK): both pass.

(cherry picked from commit c62deff2e3504ef6d71cd8a49ae914adbbb572d5)
2026-11-02 10:55:21 -08:00
Anees Iqbal cbd20364dd Place the in-place check's buffers outside the Metal address space
What: the device's in-place check (`in_place_check.rs`) makes its 40 MiB buffer per class of
pages at `AddressPlacement::Outside`: the Fresh class through `Device::new_buffer_placed` (what
`new_buffer` does, at a placement; `new_buffer` is it at `Any`), the Pointer and DmaBuf classes
through `no_copy_kept`'s descriptor `with_placement(Outside)`. address.rs's "Outside the space"
and the check's module docs say so.

Why: the check runs on a thread of its own on a new RUNTIME_VERSION's first device per host,
while the program makes its resources. At `Any` its buffers took the lowest free 40 MiB of the
Metal space, from 2^32, so a program pinning there (`AddressPlacement::At`,
`setPinnedGPUAddress:`) got `PlacementConflict::Held` for a range no object of its own held,
breaking address.rs's rule that the runtime's own buffers lie in `[2^47, 2^48)`. The consumer's
repro refused a pin at 2^32 in 5 runs of 5 on MoltenVK. The placement is the only thing that
changes: the address space hands out a number, and the buffers' memory, fresh pages, import,
image and first move do not read it (`placed_new_buffer`, `place_window`), so no verdict can.

Test: `tests::in_place_check::the_in_place_check_takes_no_range_of_the_metal_space` (device
test): with the space past its first GiB held by one address pool and a 16 KiB pin every 16 MiB
of that GiB held through the check (no free run fits a check buffer), the check answers every
class as a reference device's check over an empty space, and the pins between the held ones,
made and released in turn while it runs, are all made. Without the fix it fails every time:
Pointer and Fresh come back Unchecked (their buffers found no range).

Verified on the M3 Max (MoltenVK): the test fails on the base (Pointer and Fresh Unchecked against
Passed) and passes with the fix (Pointer Passed, Fresh Passed, DmaBuf Unchecked, as the
reference; 4921 rounds of pins while the check ran).

(cherry picked from commit 113c132f47b2f9c258c3a22251d949419a9f36e4)
2026-11-02 10:55:21 -08:00
Anees Iqbal bd264821bf Regenerate REFUSALS.md for the draw-shape sites
The per-draw changes moved RenderState's scissor check from set_scissors
to scissor_rects, and the cross-encoder shape memo's layout view now
builds TileAtSampleCount too. refusal_surface.py --check passed with the
old site lists (it does not compare them), so the table went stale.
Regenerated with python3 scripts/refusal-surface/refusal_surface.py; the
diff is the six site-list lines alone.

(cherry picked from commit ed08da17f6ca8d1f7714f76e02053c8ae68d6583)
2026-11-02 10:03:18 -08:00
Anees Iqbal ec9e0546eb Hold a constexpr linear pixel sample to Metal's answer, not the normalized control, off MoltenVK
A constexpr linear pixel sampler now reads through the device's own linear filter in unnormalized
coordinates. On lavapipe that path's arithmetic is its own rather than the normalized filter's at
a moved coordinate: 79 to 107 of 800 cells of clamp to zero and to the border differ from the
normalized control in their last bits (none of clamp to edge), so
`pixel_samplers_answer_metal_s_texels` failed its control rule there. Such a configuration is
the device's native filter (`device-sampling`): where the device's sampler is not Metal's it is
printed and no longer held to the control; on a device with Metal's own sampler it must still
answer Metal's hash, as every constexpr and nearest configuration must.

docs/FAST-PATHS.md's pixel row scopes its nearest claim to the edge probes and says what a
constexpr linear sample is on lavapipe.

Verified: the pixel lanes (pixel_samplers, pixel_edges, pixel_downscales; 7 tests) pass on arm64
lavapipe in linux-gate under --cfg m2v_cpu_icd, where pixel_samplers failed before this change,
and on the M3 Max under MoltenVK; no nearest cell off Metal's rule was printed on either
(`PIXEL-EDGE-DEVICE`). The fast_paths ledger tests pass.

(cherry picked from commit 427ed1fa9dd6fc2ca7a9f8b12bd60a8bfa23d93a)
2026-11-02 10:03:18 -08:00
Anees Iqbal 18c507a4ea Pin the runtime sources after reading pixel samples' texels as Metal does
The pixel sampler change edits sources the runtime pin hashes: the binder's sampler descriptions
and views (`bind/`), the sampler mapping, and a runtime doc comment. No run of an unchanged
artifact and plan does anything else -- the unnormalized sampler, its level-0 view and the
`NearestPixelSampler` constant appear only in artifacts the new translator makes, which carry the
new `SEMANTICS_VERSION` and `ARTIFACT_FORMAT_VERSION` -- so `RUNTIME_VERSION` stays and the pin
alone moves.

Verified: `the_runtime_sources_are_the_committed_ones` passes against a build of this tree.
(cherry picked from commit 70b7ca9f15c054fb074e8d0746cffbf1ec5f361f)
2026-11-02 10:03:18 -08:00
Anees Iqbal 575ac2b103 Read a pixel-coordinate sample's texel as Metal's sampler does
A `coord::pixel` sampler handed the device the coordinate divided by the texture's size. At a
texel edge whose quotient is inexact the device's normalized sampler read the texel before it:
on the consumer's 258x258 matrix 28 of 1042 nearest clamp-to-zero and clamp-to-border cells on
MoltenVK and up to 500 on an RTX 5080. Metal reads `floor(x)` for nearest and quantizes `x - 0.5`
to its 1/256 grid for linear filters and gathers.

Now, decided from the sampler's state and the access's structure:

- A constexpr pixel sampler that Vulkan's unnormalized sampler can state (one filter, no mip
  filter or anisotropy, clamp to edge, zero or border; a 1D or 2D non-array image, no comparison,
  no status read) samples and gathers through the device's own unnormalized sampler at the
  coordinate itself, on a view of level 0 (`CombinedSampler::unnormalized`,
  `SamplerDesc::unnormalized`). A linear sample's or gather's constant offset folds into the
  coordinate; a nearest sample's offset is applied to its texel's centre (`floor(x) + 0.5 + k`).
- A constexpr nearest pixel sampler the unnormalized form cannot take (an array, a mirror mode)
  samples at its texel's centre over the size, `(floor(x) + 0.5) / N`, which the device's
  normalized sampler reads as that texel exactly.
- A runtime slot's sampler takes the centre where a new pipeline constant,
  `SpecKey::NearestPixelSampler`, says the bound state is a nearest pixel sampler (1 only for
  those, so normalized states make no new pipeline); an argument buffer's sampler tests its word
  (`SamplerWord::nearest_pixel`, which replaces `exact_fetch`).
- Linear samples and gathers through runtime or argument-buffer samplers, arrays and 3D,
  comparisons, level queries and status reads keep the scaled coordinate and its note: their
  state is unknown where the shader is made, or Vulkan's unnormalized sampler forbids them.

`PixelSamplerScaling` is now recorded only where a scaled form remains; `DeviceDenormals` where
a centre's `floor` may read a subnormal coordinate as the device does. The pixel_samplers lane
also asserts Metal's answer for every constexpr and nearest configuration on MetalSampler devices.
The conformance case declares `pixel-sampler-scaling` for its linear cases alone, and the
llvmpipe ledger rows follow the run: two `rgba16f-nearest-mirror` rows are gone (Metal's answer
now), seven take the new digests. `SEMANTICS_VERSION` 1945, `ARTIFACT_FORMAT_VERSION` 482. No
`RUNTIME_VERSION` bump: an unchanged artifact (no unnormalized sampler, no new constant) binds and
runs as before.

The new fixture `px_edges` (own MSL, through regen-air-fixtures) samples every form at texel and
block edges, quarter offsets and each border colour on three NPOT sizes, and the new
`runtime_lane::pixel_edges` holds each nearest cell to the CPU's `floor` rule on every device and
every probe to Metal's digests on MetalSampler devices. Fixture comments in `sampling` and
`sampling_completion` no longer say the coordinate is scaled (their AIR bodies are unchanged).

Verified on the M3 Max under MoltenVK 1.4.2: the consumer's matrix compared with Metal's
results, 0 differing cells on every kernel and size (28 of 1042 before on three kernels);
lavapipe 0 before and after; `runtime_lane::pixel_edges`, `pixel_samplers` and `pixel_downscales`
pass; conformance replay of the 23 pixel cases holds the ledger on MoltenVK; on arm64 lavapipe
the whole set's replay departs from the parent's ledger, beyond what the parent's own replay
does, at exactly the nine rows edited here (the answers are the report's own). Core suite 4988
passed; validation suite under `--cfg m2v_gpu` passes the new and pixel tests, its other failures
fail the same on the parent commit; conformance 1007 passed; goldens, hashes and inventory
blessed. Release translation of every px_edges and px_samplers kernel on four profiles: slowest
0.08 s, largest peak 6 MB.

(cherry picked from commit 888ad9bae9f0aaaf769360740e1dd16817245ca4)
2026-11-02 10:03:17 -08:00
Anees Iqbal 6c294fe742 Pin the runtime sources after keeping the pass end's gathering lists
The commit before this one changes the runtime's sources but no run's
answers, refusals, announcements or what it records and submits: a pass
records the same commands and barriers from lists the device kept for it
as from new ones (the per-draw repro's WorkCounts command counts are
unchanged). So RUNTIME_VERSION stays, and only the runtime-sources pin
moves. The translator's bind output is untouched, so SEMANTICS_VERSION
stays.

Verified: pin-compute over the tree, and the validation guard test
the_runtime_sources_are_the_committed_ones passes; the runtime crate's
suite passes (1194 tests) and, under --cfg m2v_gpu on MoltenVK (M3 Max),
1486 of 1486; the conformance suite (1007) passes; clippy (all features,
plain and --cfg m2v_gpu) is clean; api-signatures --check is clean; the
runtime's private intra-doc link diagnostics are 70, its ceiling.

(cherry picked from commit b20c1e18e36d5d15df2063d9b27f447ff5d1bea9)
2026-11-02 08:50:24 -08:00
Anees Iqbal 1c909271db Keep a render encoder's gathering lists for the next pass, and move less at its end
A render pass's end freed what its draws gathered into, and the next
encoder's draws made it again: the first instance's shadowed textures and
buffer bytes (two BTreeMaps), its drawn rectangles and the pass's (two
BTreeSets), and the pass's fragment writes and reads (three key maps). It
also moved the 1.6 KB current instance with the encoder, collected each
tracked part's map into a vector before ordering its keys, looked heap
keys up under the heaps' lock with no live heap, worked out the
attachments' uses twice, and passed its end through the later color groups'
call with none.

Now:
- The device keeps up to 4 emptied draw rooms (render/draw_room.rs: the
  first instance's InstanceShadows and DrawnArea, the pass's DrawnArea and
  PassStartReads), each up to 64 entries; an encoder takes one as it opens
  and its pass's end gives it back. A larger one goes.
- Those lists are sorted vectors that keep their room when cleared, in the
  order the maps and sets they replace iterated, so the uses, ranges and
  rectangles a pass end reads are the same.
- The current instance is boxed, so the encoder's moves at its end carry a
  pointer; earlier instances (a split) stay unboxed.
- EncoderUses::finish_parts orders references to the tracked lists.
- HeapKeys::among returns at once on a device without a live heap.
- shadows::plan takes the attachments' uses end_pass worked out.
- Ended::later_groups runs only for a pass of several color groups.

The pass records the same commands and barriers, tracks the same uses and
holds the same objects; no notice, refusal or counter changes. Over the
repro's runs only scheduling counters moved, by at most 0.03 per command
buffer either way (batch-barrier command buffers, begun ahead, completion
arms, parked buffers).

Verified: unit tests a_room_given_back_is_taken_again_empty,
a_cleared_area_is_a_new_one_with_its_room,
written_ranges_keep_their_lists_when_cleared and
a_cleared_instance_gathers_into_the_room_it_kept (cleared lists keep their
room, and gather the same order as new ones); device test
pass_end_tiles::a_pass_takes_the_room_an_earlier_pass_left (four passes,
loaded, cleared and DontCare, make one room). With the pass end's give
taken out it fails (4 rooms made, not 1). The runtime suite passes
(1194), and the pass-end device tests pass on MoltenVK (M3 Max).

Release, the per-draw repro on the M3 Max over MoltenVK, 35 draws in 6
passes per command buffer, 5 interleaved rounds per configuration (flat
out 3000 command buffers, 60 Hz 1800), base 9f5776bf31, p50 medians:

                     end_encoding us     draw us        CPU per cb us
  cache, flat out    5.67 -> 4.71 (-17%) 4.12 -> 4.17   223.5 -> 213.2
  cache, 60 Hz       7.38 -> 6.62 (-10%) 4.92 -> 4.83   351.9 -> 341.7
  pages, flat out    8.08 -> 7.71 (-5%)  4.12 -> 4.33   231.0 -> 247.3
  pages, 60 Hz      10.83 -> 9.62 (-11%) 5.04 -> 5.04   420.5 -> 396.2

Per-round paired end_encoding ratios have medians of 0.82, 0.90, 0.91 and
0.92; draw p50 is unchanged (paired medians 0.99 to 1.03). CPU per buffer
moves within this host's run-to-run noise (paired medians 0.92 to 1.03),
so no change there is claimed.

(cherry picked from commit 1aaf95c79fdf479e2c15840cefe163713dd1cca9)
2026-11-02 08:50:24 -08:00
Anees Iqbal b46a52da5a Pin the runtime sources after carrying draw shapes across encoders
The commit before this one changes the runtime's sources but no run's
answers, refusals, announcements or what it records and submits: a draw
that takes a kept shape records the same commands its derived shape would
(every WorkCounts command count of the per-draw repro is unchanged, and a
debug build asserts the carried settings equal a fresh derivation). So
RUNTIME_VERSION stays, and only the runtime-sources pin moves. The
translator's bind output is untouched, so SEMANTICS_VERSION stays.

Verified: pin-compute over the tree, and the validation guard test
the_runtime_sources_are_the_committed_ones passes; the runtime crate's
suite passes (1190 tests) and, under --cfg m2v_gpu on MoltenVK (M3 Max),
1481 of 1481; the conformance suite (1007) passes; api-signatures --check
is clean.

(cherry picked from commit 9f5776bf312807f5f2678c19a49469403f6dba0d)
2026-11-02 06:48:38 -08:00
Anees Iqbal 104ded7e34 Carry a draw's shape to a later encoder's first draw of the same values
A render encoder's shape memo finds a draw's settings, draw state and
VkPipeline by the versions of the encoder's state and the instance's
shape, which are new in every encoder. So each encoder's first draw of a
pipeline state derived its shape again, though a frame encodes the same
passes with the same state every time: 16 of the per-draw repro's 35 draws
per command buffer.

Each drawing state now keeps its last 8 shapes by value (KeptShapes, in
render/draw_shape.rs): the assembly and primitives, the pass layout's facts
(its pixel formats, depth and stencil, samples, extent and tile memory),
and the encoder's state but its scissor rectangles and vertex
amplification, floats by their bits and a depth-stencil state by the object
the encoder holds. No key holds an address that can be reused. A draw that
misses its encoder's memo takes the settings of a kept shape of equal
values, with the draw state and VkPipeline a draw of it found once they are
found; the VkPipeline still answers to the instance's compatible pass by
version or value and to the pass's sample positions. A full table evicts
the shape used longest ago. A rate-mapped pass, and a shape whose
derivation announces a notice the device announces at every occurrence,
keep nothing. What a shape reads of the pass layout goes through
LayoutView, whose facts are the key, so a derivation cannot read a value
the key misses; a debug build derives a carried draw's settings again and
asserts they are equal.

New counter WorkCounts::draw_shapes_carried (a public field: the
api-signatures table gains it). draw_shapes_reused now counts a carried
draw that also takes its draw state and VkPipeline; its doc says so. The
conformance cost gate reports draw_shapes_carried beside
draw_shapes_reused and bounds neither: a shape is kept by the same rule,
which moves with the case selection.

Verified: device test draw_shape_notices::
an_encoders_first_draw_takes_the_shape_of_the_same_values encodes two
passes of the same values (the second's first draw is carried), then a
changed cull mode and a changed target size (both miss), then the first
values again (carried); it fails with 0 carried with the carry taken out,
and with the encoder state left out of the key the debug assertion fires.
The draw_shape_notices tests expect one more reused draw per pass. Runtime
unit and device suites, conformance suite and clippy (plain and m2v_gpu)
pass on MoltenVK (M3 Max).

Release, the per-draw repro on the M3 Max over MoltenVK, flat out, 3000
command buffers, 10 interleaved rounds each: a draw with its setters p50
4.06 -> 3.90 us, mean 4.34 -> 4.15; the first draw of its state in its
pass p50 4.81 -> 4.40 us; a later draw unchanged (3.54 -> 3.50);
end_encoding unchanged (p50 4.92 -> 4.92); encoding thread CPU per command
buffer p50 200.0 -> 193.8 us, mean 205.4 -> 198.4. Per buffer
draw_shapes_carried is 16 and draw_shapes_reused goes from 13 to 25; every
other WorkCounts field is unchanged. The repeated-state mode (one state,
many draws) is unchanged within noise.

(cherry picked from commit 192416101676532ddcc42527e38916574a0cc94b)
2026-11-02 06:48:38 -08:00
Anees Iqbal 8463a6e288 Pin the runtime sources after the per-draw changes
The two commits before this one change the runtime's sources but no run's
answers, refusals, announcements or what it records and submits: the scissor
rectangles moved beside the encoder state (each draw records its own scissor
as before) and the hosted-key filter skips a lookup that answered nothing.
So RUNTIME_VERSION stays, and only the runtime-sources pin moves.

Verified: pin-compute.py over the tree; the runtime crate's suite passes
(1189 tests) and, under --cfg m2v_gpu on MoltenVK (M3 Max), 1478 of 1478.

(cherry picked from commit 521c5ee88e01e0921e8f2fe05d3503f7e02667f2)
2026-11-02 05:16:44 -08:00
Anees Iqbal 0ef00e80ed Tell keys of no host-pages buffer apart without the rebinds lock
While a device has a buffer over host pages (a no-copy buffer), every key an
encoder's commands name first is held (rebind::Holds::hold): looked up among
those buffers under Rebinds' lock, the lock a command buffer's first
submission holds while it judges its holds. A compositor's draws each name a
texture of their own, so each looked a texture's key up in turn, and waited
on the scheduler thread's submission under the lock (__psynch_mutexwait under
Holds::hold was about 1.4% of the draw call's samples on the M3).

Rebinds now keeps a filter of the keys it registered (HostedKeys: 4096 bits
by key, set as a no-copy buffer registers its key, before any command can
name it, never cleared). A key whose bit is clear names no buffer over host
pages, for a key is never another resource's: Holds::hold answers None for
it without the lock. A set bit (a hosted key, a key sharing its bit, or a
buffer gone since) is looked up as before. What is held is unchanged.

New counter WorkCounts::host_holds_looked_up (a public field: the
api-signatures table gains it; no consumer breaks) counts the lookups.

Verified: device test host_hold_filter::only_hosted_keys_are_looked_up (a
blit chaining 8 Private buffers after a copy from a no-copy buffer looks up
1 key; the bytes arrive) passes on MoltenVK (M3 Max), and fails with 10
lookups with the filter check removed.

Release, the per-draw repro on the M3 Max over MoltenVK, flat out, cache
mode: no WorkCounts field per buffer changes but the new one
(host_holds_looked_up 6: the RAM buffer once per encoder). The draw timings
are within this host's run-to-run noise (a draw p50 3.96 -> 4.00 us, mean
4.19 -> 4.22 in the quieter interleaved round); the lock's wait leaves the
draw's profile.

(cherry picked from commit d25c36c78c7059e155935cbdfb8ad1c333032a23)
2026-11-02 05:16:44 -08:00
Anees Iqbal a96bd76fef Keep a draw's shape across scissor rectangle changes
A render encoder's draw takes its settings, draw state and VkPipeline from
its shape memo while the encoder's state keeps its version. Setting a
scissor rectangle took the state mutably, so a program that sets one before
each draw, as a window compositor does, derived every draw's shape again:
settings, draw state, and the pipeline lookup by key.

The scissor rectangles now live beside the versioned EncoderState
(render_state::ScissorRects). No piece of a draw's shape reads them but its
draw state's Vulkan scissors, which each draw now sets from the rectangles
it finds, on a draw state it derives or reuses. The commands recorded are
the same: each draw records its own scissor as before.

Verified: a device test (draw_shape_notices::
draws_after_new_scissor_rectangles_reuse_shapes) draws 8 times through 8
rectangles and finds 7 draws reusing their shape and 8 scissors recorded;
with the version bump put back into set_scissor_rect it fails (0 reused).
render_state unit tests and the draw_shape_notices device tests pass on
MoltenVK (M3 Max).

Release, the per-draw repro on the M3 Max over MoltenVK, flat out, cache
mode, 3000 buffers: draws_shapes_reused goes from 0 to 13 per buffer (35
draws, 6 passes; the others are the first draw of their pipeline state in
their encoder); every other WorkCounts field per buffer is unchanged. A
draw with its setters p50 4.25 -> 4.12 us, mean 4.63 -> 4.42 us; the draw
call alone p50 3.92 -> 3.79 us (two interleaved rounds each).

(cherry picked from commit 603c78fcb85c5d0a732ec6004028d990e0ec8d64)
2026-11-02 05:16:44 -08:00
Anees Iqbal 5602a82d8a Leave out pass-end work a pass of one instance that records now never reads
Three pieces of a render encoder's end that ran at every pass for what only some passes read:

- `shadows::plan` made, before its first instance, the uses of the attachments but the colors
  an instance bounds its writes of, and those colors' target uses and usage shadows: read only
  by an instance that bounds its writes by its draws' scissors, one after the pass's first. A
  pass of one instance never does. They are made now at the first instance that does
  (`BoundedWrites`), from the same layout, so its plan is the same. Each error they could
  return is one `attachment_uses` returned first, over the same targets.
- The pass's shadows' truths (`shadows::pass_shadows`), which a pass that records later holds
  for its executions, were gathered at every pass with a shadowed texture. Only a pass with an
  execution, a pending draw or a tile dispatch can record later; others gather none.
- An encoder's summary (`EncoderUses::finish_parts`) flattened its tracked uses and sorted them
  all by key, stably. A resource's uses are one list, so it now sorts the resources' keys,
  each once, and lists each resource's uses in the order recorded: the same order as before.

A compositor-shaped command buffer (35 draws in 6 passes) on the M3 Max over MoltenVK,
release, flat out, cache surfaces; `end_encoding` against the draws of the same run (the
host's speed moved both by up to 30% from run to run), median of 7 runs each:
p50 ratio 1.207 before, 1.098 after (about 9% less `end_encoding`). A probe build timed the
pieces at about 145 ns (`shadows::plan`'s setup), 50 ns (the truths) and 400 ns (the summary,
its sort included) per pass end before.

Verified: runtime unit tests (tracker, shadows, clear_reach); a new tracker test holds a
summary's order (resources by key, each one's ranges in recorded order) and passes before and
after the change.

(cherry picked from commit a5a8ddf96f1beeeb71e7d9d5708ba2164e143f1b)
2026-11-02 04:58:15 -08:00
Anees Iqbal 101fb7f653 Hold the tile counts' note to its unit test, which a plain test build reads
The thread's note of the tile counts a pass end works out (`clear_reach::made`) was read only
by the device test, so a test build without the device cfgs warned that `so_far` is unused.
The count's unit test now checks that each count is noted, one per call.

Verified: `clear_reach` unit tests pass with no warning in the plain test build.
(cherry picked from commit efc3c67b463d9565576fa439e00ee0c86b92117a)
2026-11-02 04:58:15 -08:00
Anees Iqbal 089bbdfb87 Count a pass's tiles only where a count or a clear reads them
A render pass's end worked out two things about the tiles its draws reach at every pass,
whatever read them:

- the count of the 32-pixel tiles its draws' scissors cover against their bounding rectangle
  (`DrawnArea::covered_tiles`), computed at every pass's first instance before `count_colors`
  looked for a shadowed color attachment, where it feeds only
  `shadow_attachment_tiles_covered` and `_bounded`, counted for a shadowed color the pass loads
  within its draws' scissors; and
- the grid of the tiles the draws reach (`DrawnArea::tiles`), made at every pass whose draws
  reach the tiles their primitives touch, where only a `DontCare` load given a clear reads it
  (`ReachClears::plan`); elsewhere only whether it is empty mattered.

Now `count_colors` counts the tiles at the first shadowed color loaded within, once a pass;
the pass end asks whether the rectangles reach any tile with a scan of them
(`DrawnArea::reaches_no_tile`, no grid made) and makes the grid only for a `DontCare` load it
answered. The count itself goes by bands of rows between the rectangles' edges, setting a row's
tiles a word at a time, where it went row by row and tile by tile. The counters keep their
meaning and their values; the commands recorded are the same.

A compositor-shaped command buffer (35 draws in 6 passes, one 3840x2400 framebuffer pass) on
the M3 Max over MoltenVK, release, flat out, cache surfaces (no shadowed attachment), two
interleaved runs of 5000 buffers each:

  end_encoding p50/p95/mean us: before 6.71/33.67/11.36 and 7.75/43.50/13.18,
                                after  5.75/7.79/5.94  and 5.96/7.83/6.05

The count was 49% of `end_encoding`'s CPU samples before. The work counts per buffer are the
same, with surfaces over host pages too (`shadow_attachment_tiles_bounded` 2597, `_covered`
2308 per buffer, as before).

Verified: `clear_reach` unit tests, the count checked against tiles counted one at a time over
200 sets of rectangles, and the scan against the grid; a device test
(`tests/pass_end_tiles.rs`, `--cfg m2v_gpu`, MoltenVK) counts the tile work done on the
encoding thread: none for a pass with no shadowed attachment, loaded or cleared, one grid for a
`DontCare` load, one count for a shadowed attachment it loads. With the eager work put back the
test fails (covered 1, grids 1 for the loaded pass).

(cherry picked from commit 8f62289f04f367e88e369e6351485d3b69819f71)
2026-11-02 04:58:15 -08:00
Anees Iqbal ddccbfac5a Bump RUNTIME_VERSION to 1722 for ASTC passes, storage slots and 4x2 and 8x4 footprints
What: RUNTIME_VERSION 1721 -> 1722; the runtime-sources pin recomputed on this tree
(3314ddbb...); api_signatures.tsv blessed (Degradation::AstcStorageNeutral and
PlanDiagnostic::AstcStorageNeutral added); docs/CONFORMANCE-COVERAGE.md regenerated (one ledger
row fewer, one more module declaring a notice); `cargo fmt` of the footprint case's allowance.

Why: a run of an unchanged artifact and plan now does something else: a pass over an ASTC
attachment drops it instead of refusing, a storage slot over an ASTC texture binds a neutral and
announces `astc-storage-neutral`, and the 4x2 and 8x4 footprints make textures. docs/REFUSALS.md
and docs/METAL-COVERAGE.md regenerate unchanged.

Verified: `signatures.py --bless`, `refusal_surface.py`, `metal-coverage/coverage.py --check`,
`conformance-coverage/coverage.py` on this tree (rebased onto fbc086020f).

(cherry picked from commit a37ab781870cf9d3c1e9672026f9773f3f6dfdf2)
2026-11-02 02:17:10 -08:00
Anees Iqbal 253dedccc3 Drop ASTC attachments from passes and bind a neutral at ASTC storage slots
What: on every device and for every ASTC form (LDR, sRGB, HDR, every footprint, in its own block
or in a carrier):
- a render pass drops an ASTC color attachment that resolves nothing (`render_pass::layout`): it
  loads, clears and stores nothing into it, its level's extent still bounds the pass, and the
  pass's other attachments run as they would. No notice: that is Metal's answer.
- a draw or dispatch binding an ASTC texture at a storage slot binds the slot's neutral
  (`PlanDiagnostic::AstcStorageNeutral`): its writes leave the blocks as they were, its reads
  answer zero. The runtime announces the new `astc-storage-neutral` (precision) once, catalogued
  in docs/API.md, its lane site `ASTC_STORAGE`.
A render pipeline of an ASTC color attachment stays refused (Metal ends the process), as do a
resolve of an ASTC attachment (unmeasured), 1D and multisampled textures and another footprint's
view.

Why: the runtime answers plain Metal, not its validation layer. Plain Metal (an M3 Max under
macOS 27.0.1, probe `astc_passes_writes_footprints`) completes such a pass for every load and
store action, with a draw and without, leaving the blocks unchanged and the other attachment as
without it; it completes a kernel's `write` and `read_write` and stores bytes no format defines
into the blocks (`read_write` reads their decode). No Vulkan format of a block is an attachment's
or a storage image's, so the pass drop is exact and the neutral differs, announced.

Tests that fail before: the translator's `a_stand_in_compile_is_the_compile_of_its_formats_bind_
and_no_other` (every ASTC format at a storage slot plans the neutral with the diagnostic); the
runtime's `degradation_sites` closure (a lane site for the kind); the lane's
`runtime_lane::astc_passes_and_writes`: every one of the 48 ASTC formats at color 0 of four
passes (clear and store, load and draw, dontcare both and draw, clear and draw) with an RGBA8
color 1: the blocks unchanged and color 1 the pass's without the attachment (192 passes); a
pipeline of an ASTC attachment refused; every format bound to `write` and `read_write` kernels:
blocks and texels unchanged, `astc-storage-neutral` announced once.

Verified: MoltenVK lane on the M3 Max, `runtime_lane::astc*` 9 of 9 (192 passes, 96 dispatches);
runtime touched tests.

(cherry picked from commit 68a296589040b208634abd7b8dfa6ce938cf8c96)
2026-11-02 02:17:10 -08:00
Anees Iqbal e972337dd8 Hold ASTC's 4x2 and 8x4 footprints in a carrier with a decoded twin
What: the six ASTC formats of Apple's 4x2 and 8x4 footprints (LDR, sRGB, HDR), which no Vulkan
format holds, are made on every device as the other ASTC formats are on a device without ASTC:
their blocks in the 16-byte carrier (BC7, BC3, BC2, BC5, ETC2 or EAC; one ASTC block over 4 x 4
carrier texels whatever its footprint), their reads through a decoded twin of 8-bit codes (LDR,
sRGB) or halves (HDR). `AstcDecode::of` takes every footprint from `metal::format::block_extent`;
the format table maps them decoded-only (no direct format); the footprint module answers 26
formats now, and the heap size query takes the modelled ASTC block layout for them. Copies map
regions in blocks (`copy_plan::block_bytes`), a partial last block as Metal rounds it.

Why: plain Metal makes every such texture (2D, 2D array, cube, 3D; Shared and Private; read,
write, render-target usage) and copies them in whole blocks, the last ending at the level's edge
(probe `astc_passes_writes_footprints`). The orchestrator's brief suggested an uncompressed
16-byte-texel carrier; the existing compressed carrier already holds any 16-byte block per 4 x 4
carrier texels, so it serves every footprint with the decode passes, CPU decodes, second twins
and copy paths the other ASTC formats use, with no new image kind.

Tests that fail before: the translator's format tests (`astc_4x2_and_8x4_are_named_and_read_
through_their_twin`, counts and twins), the decode digests of 4x2 and 8x4 against Metal's
(`astc_decode` tests, HDR coverage), the runtime's image-plan, heap and pixel-format tests, and
the lane: `runtime_lane::astc_textures` and `astc_hdr_textures` now take every footprint (32 LDR
and sRGB, 16 HDR), the round trip at every level and slice 4x2 and 8x4 (partial blocks at 37x23
and 29), the colour-space views 4x2 and 8x4. The conformance case
`format-footprints-astc-4x2-and-8x4` now makes and round-trips them: its ledger row (the refusal)
is gone and it declares the three notices the carrier announces.

Verified: translator and runtime touched suites; MoltenVK lane (`runtime_lane::astc*`, 9 of 9 on
the M3 Max); conformance replay on MoltenVK of the footprint case and the ASTC cases, compliant
(the footprint case announced, every byte Metal's); lavapipe replay: every byte Metal's, the
notices undeclared before this commit's declaration.

(cherry picked from commit 2a8dd25c6b9d4cc62ff79816fa61d984969b3c22)
2026-11-02 02:17:10 -08:00
Anees Iqbal 6d884c633d Probe what plain Metal does with ASTC passes, kernel writes and 4x2 and 8x4 footprints
What: conformance/probes/astc_passes_writes_footprints.m, one case a process: render pipelines of
every ASTC colour attachment format (each in a child process), passes over an ASTC attachment for
every load and store action with a draw and without, kernel `write` and `read_write` of ASTC
textures, texel digests of seeded blocks of Apple's 4x2 and 8x4 footprints, partial-block copies
(replaceRegion, getBytes, blits) and texture creation per type.

Why: the runtime refused passes into and kernel writes of ASTC textures as Metal's validation
stops them, and held no image of the 4x2 and 8x4 footprints. Plain Metal's answers decide what
the runtime does instead.

Measured on an Apple M3 Max, macOS 27.0.1, without MTL_DEBUG_LAYER:
- a render pipeline of any ASTC colour attachment (LDR, sRGB, HDR, every footprint tried) ends
  the process;
- every ASTC format, 4x2 and 8x4 included, makes 2D, 2D array, cube and 3D textures, Shared, with
  read, write and render-target usage;
- a pass over an ASTC attachment completes for every load (clear, load, dontcare) and store
  (store, dontcare), with a draw and without: the blocks stay as they were and the other
  attachment is cleared and drawn as without it;
- a kernel `write` completes and changes the blocks to bytes no format defines, the same for
  the same value; `read_write` reads the blocks' decode and answers the right size;
- a copy's region rounds out to whole blocks, its last block ending at the level's edge, the 4x2
  and 8x4 footprints as the others, blits too;
- the texel digests of seeded 4x2 and 8x4 blocks (LDR, sRGB, HDR), with 4x4 and 8x8 controls that
  match the committed digests.

(cherry picked from commit 287319c428d63f8ad849c0d7c4104a85b81e64d2)
2026-11-02 02:17:10 -08:00
Anees Iqbal f7ae5be869 Bless the golden rows of the wsm_samples fixture
The multisampled word lane's owned fixture (wsm_samples: a fullscreen
vertex, a per-sample fill, and two kernels reading every sample as
floats and as a view's words) joins the engine fixtures' golden tables:
its air_input printout (tests/air_input/wsm_samples.txt), 8 rows of
golden_hashes.tsv and 8 of public_fixture_expectations_engine.tsv (its
.ll and .air.ll forms, four functions each). wsm_fill is refused
SampleRateShading on the one profile without it, as every
[[sample_id]] fragment is.

Blessed on the tree rebased onto 9193d3e09f with
PATH=/opt/homebrew/opt/llvm/bin:$PATH by bless_engine_goldens,
bless_golden_hashes and bless_engine_inventory. git diff -U0 shows only
additions, every one a wsm_samples row: nothing moved or was removed.
Verified after: engine_fixtures_match_their_golden_printout,
inventory_lists_every_fixture_in_order, golden_hashes_match_the_table,
public_fixtures_engine::llvm_as::part_1_of_8 and metal_as::part_4_of_4
pass.

(cherry picked from commit fbc086020faa1881132b0921b71933ab6fdbe4f2)
2026-11-02 01:32:20 -08:00
Anees Iqbal 1210972f03 Hold multisampled word-format textures in their word's format
Metal makes 2- and 4-sample textures of R8Unorm_sRGB (11), A1BGR5Unorm
(41), ABGR4Unorm (42) and RGB9E5Float (93) for every usage, memoryless
included (our probe msaa_word_formats.m, M3 Max, macOS 27.0.1). The RTX
5080 samples these formats but renders none, so Vulkan states one
sample for their images and the runtime refused each at creation
(TextureSampleCount, FramebufferColorSampleCount(4)).

What changes:
- image_plan::word_samples: where the device samples the format, renders
  it at no count and renders the word's format (R8_UINT, R16_UINT,
  R32_UINT), a multisampled texture's image is the word's format,
  mutable to the format's sampled view (and an 8-bit sRGB format's UNORM
  twin, for its resolve). Every sample holds Metal's word by
  construction: the existing word lowering writes it, clears write
  Metal's clear word, reads decode through the format's view, copies are
  bitwise. Shader writes stay unavailable (Metal writes no multisampled
  texture from a function). A device that renders the format keeps its
  native image.
- The resolve of such an attachment is the crate-owned one: Metal's for
  RGB9E5Float and 8-bit sRGB, a near-equivalent within one code for the
  packed formats, announced as the new Degradation::WordResolve
  (word-resolve). The NotImplemented(Format) refusal of word resolves in
  resolve.rs is gone; an attachment that takes neither input attachment
  usage nor the copy is still refused.
- DeviceOptions::withheld_attachment_formats (doc hidden, a test hook):
  a device made with formats' color attachments withheld, so the word
  path runs on MoltenVK, which renders all four.
- RUNTIME_VERSION 1721. Docs: API.md (word bullets, the multisampled
  word paragraph, the word-resolve catalogue entry), FAST-PATHS known
  gaps (word resolves no longer refused), word.rs, image_plan.rs and
  resolve.rs module docs; runtime-sources pin recomputed.

Routes over the committed profiles (tests::word_samples, pinned): the
word for all four formats at 2 and 4 on NVIDIA's three profiles, for
R8Unorm_sRGB and RGB9E5Float on ANV's four, and RGB9E5Float at 4 on the
gate's lavapipe; native on MoltenVK and RADV; refused where the word's
format renders one sample or the textures take no such count
(swiftshader, lavapipe's profile, the floors).

Verified:
- cargo nextest run -p metal2vulkan-runtime --all-features: 1188 pass
  (the three word_samples planning tests among them).
- Device lane runtime_lane::word_samples_msaa on the M3 Max through
  MoltenVK (--cfg m2v_gpu, maclock), new owned fixture wsm_samples: the
  device as it is (each format natively) and with the four attachments
  withheld (each held in its word, printed per format). On the word path
  every stored sample is Metal's word (all 32 or 64 per shape), reads
  decode them, the sRGB and RGB9E5 resolves are Metal's in every pixel,
  the packed resolves within a code (7-9 of 16 pixels exact after a
  draw, 13-16 after a load), a packed blend's words Metal's in every
  sample. word-resolve and shader-resolve announced. Negative control:
  with word_samples disabled the lane fails.
- clippy -D warnings (default and --cfg m2v_gpu), rustdoc -D warnings,
  private intra-doc links at their ceilings, refusal_surface --check,
  api_signatures --bless (DeviceOptions field, Degradation::WordResolve
  added), METAL-COVERAGE and CONFORMANCE-COVERAGE --check current.

Not in this change: the golden tables for the new fixture
(golden_hashes, the engine inventory, the air_input printout) are
re-blessed on development. Blends of an 8-bit sRGB or RGB9E5Float word
stay refused as the device lacking the format, as they are at one
sample.

(cherry picked from commit ad8b94cd840f3d0bf4bb9552904fbdf2f253b9af)
2026-11-02 01:32:20 -08:00
Anees Iqbal e86fa9b98f Resolve a word attachment's samples by Metal's rules
The crate-owned color resolve gains word forms (ColorResolveFormat::word):
a multisampled attachment held in its word's format (R16_UINT for the
packed 16-bit formats, R32_UINT for RGB9E5Float) is resolved from the
stored words, since no device's AVERAGE reads them as the format.

- RGB9E5Float: each channel's samples decoded, summed in float, scaled
  by 1/n, rounded to the nearest half (ties to even), then encoded with
  the mantissas rounded half up (the exponent raised where one reaches
  512). Metal's resolve, measured with our probe msaa_word_formats.m on
  an M3 Max under macOS 27.0.1: 256 of 256 pixels at 2 and 4 samples,
  in a drawing pass, a loading pass and after a blend.
- Packed 16-bit: each field's mean of the codes, a tie rounded down (a
  one-bit field's up). Metal averages its tile's halves, finer than the
  codes, so this is a near-equivalent (exact() is false): Metal's code
  in 90-99% of the channels a loading pass resolves, 74-88% of a
  drawing pass's, within one code everywhere; alike samples exact.
- An 8-bit sRGB word has no word form: it resolves by the sRGB rules of
  its format through its UNORM twin's views (the runtime's side).

Verified: cargo nextest run -p metal2vulkan --all-features -E
'test(/color_resolve/)' (24 pass; word_tests checks the modules
validate and need nothing of a device, the shared-exponent rule against
the probe's measured vectors and a model over random words, and the
packed rule per field). api_signatures.tsv takes the two new methods.

(cherry picked from commit 3c3681c8decdd166454b9779bfe1be0c1936f898)
2026-11-02 01:32:20 -08:00
Anees Iqbal a7672e9864 Lane-test ASTC HDR textures against Metal's decode on the device
New runtime_lane::astc_hdr_textures (any(m2v_gpu, m2v_cpu_icd)):

- astc_hdr_texels_read_as_metal_s: each of the fourteen _HDR formats,
  natively where the device holds its SFLOAT block, else through the
  carrier and twin. A new texture's zero blocks, then blocks from a CPU
  copy, a blit from a buffer, a fill of an HDR void-extent block and a
  copy from another texture: every texel's read and nearest sample
  compared with the decoder's Metal values (exact, NaN as NaN) where
  the twin carries them or the device samples through Metal's own
  texture unit; get_bytes and a blit into a buffer give the blocks
  back unchanged. It counts the decode passes, asserts
  carried-decoded-twin was announced exactly for the carried formats
  and decoded-texel-precision never, and prints which route ran.
- astc_hdr_textures_of_every_usage_are_made: an ASTC8x8HDR texture of
  read, write, render-target and pixel-format-view usage is made; a
  render pass into it is refused Unsupported and a kernel's write of it
  refused typed (Bind or Unsupported), where Metal's validation stops
  both; a view in the LDR form is refused on a carrier and otherwise
  reads the LDR decode of the same blocks.

The ASTC LDR lane's helpers it shares become pub(super).

Verified (which path each ran, from the lane's printed route line):
- MoltenVK on the M3 Max (--cfg m2v_gpu, through the GPU lock and
  memcap): both pass; 14 formats in their own block, Metal's sampler.
- lavapipe (scripts/linux-gate, --cfg m2v_cpu_icd): both pass; 0 in
  their own block, 14 in a carrier.
- The other five ASTC lanes pass on both devices.

(cherry picked from commit 9193d3e09fc1e0366e55035fcb29a81b9245ffe5)
2026-11-02 01:09:01 -08:00
Anees Iqbal 7130d5d6e7 Make ASTC HDR textures where Metal makes them: native, else a carrier with a twin of halves
Metal on an M3 Max (macOS 27.0.1) makes every 2D ASTC HDR texture
(MTLPixelFormat 222-236) with read, write and render-target usage; the
runtime refused them on every device without the Vulkan SFLOAT block
(the RTX 5080 among them) as a format it cannot hold.

- Translator: bind::AstcDecode decodes the HDR profile, written from
  the Khronos Data Format Specification's ASTC chapter (new hdr.rs):
  HDR endpoint modes 2, 3, 7, 11, 14 and 15, the LNS-to-half mapping,
  LDR modes and void-extent blocks in an HDR texture, and the HDR
  void extent, on the CPU and in the GPU decode kernel (kernel/hdr.rs).
  Where the probe showed Metal's own answer it is the one taken: an
  LDR channel in the HDR profile is C/65536 truncated to a half (1 for
  65535); a void extent's NaN halves read as the quiet NaN; an error
  block reads NaN in every channel. Public API: AstcDecode gains `hdr`,
  AstcTexels gains `Half` (R16G16B16A16_SFLOAT), AstcDecode::form picks
  a profile's compact form, and AstcDecode::texel_bytes is now a method
  (a consumer calling AstcDecode::texel_bytes(texels) writes
  decode.texel_bytes(texels)); api_signatures.tsv blessed.
- Format table: each ASTC HDR format takes its ASTC_*_SFLOAT_BLOCK
  where the device holds it (the device's decode, rule 1), else
  FormatEmulation::Decoded over R16G16B16A16_SFLOAT.
- Runtime: such a texture is the existing carrier (its 16-byte blocks,
  which copies and getBytes move unchanged) and a decoded twin of
  Metal's halves, exact, kept in step by the same GPU and CPU decodes;
  a new texture's twin starts at the error block's NaN. Notices:
  carried-decoded-twin and cpu-block-decode, as for ASTC LDR; no
  decoded-texel-precision (the halves are Metal's). A view in another
  profile (an HDR texture's LDR or sRGB view, or the reverse) is
  refused on a carrier (Feature::TextureView, as another footprint
  is); render passes into one and kernel writes of one stay refused
  typed (the Vulkan formats take neither), where Metal's validation
  stops each.
- Docs: API.md's carried-decoded-twin entry, FAST-PATHS known gaps,
  module docs of bind::astc_decode, astc.rs and decoded_twin.rs.
- Conformance: the 42 ASTC cases now name the twin notices for HDR rows
  too, and the decoder cross-check holds Metal's recorded HDR reads.

Versions: RUNTIME_VERSION 1720 (an HDR texture is now made and read
where it was refused). No SEMANTICS_VERSION or ARTIFACT_FORMAT_VERSION
bump: translation output is unchanged (the Decoded candidate admits
sampling usages only, so no pipeline's format answer moves) and no
encoded artifact carries AstcDecode. Runtime-sources pin recomputed.

Verified:
- CPU decode bit-exact against Metal for 2048 seeded blocks of each of
  the fourteen footprints (every endpoint mode, partitions, dual plane,
  void extents, error blocks), as float and half reads and nearest
  samples (probe `reads`), checked by per-footprint digests and a
  66-block fixture of Metal's float bits (bind::astc_decode::tests::hdr);
  the GPU kernel equals the CPU decode on every texel; the kernels are
  valid on every committed profile; the conformance suite's recorded
  astc-*-hdr reads equal the decoder's.
- Plans: moltenvk-m3 native for all 14; nvidia-rtx5080-laptop,
  lavapipe, amd-780m-radv and intel-arl-anv in a carrier
  (runtime tests::image_plan).
- conformance replay of the 42 ASTC cases on lavapipe (linux-gate,
  --cpu): the 14 HDR rows `announced` (texels exact, carried-decoded-
  twin and cpu-block-decode fired), exit 0; on MoltenVK the 14 HDR rows
  `exact` with no notice.
- Touched tests in metal2vulkan, metal2vulkan-runtime,
  metal2vulkan-conformance; clippy (plain and --cfg m2v_gpu);
  refusal_surface --check, both coverage docs current; private
  intra-doc link loop at its ceilings.

(cherry picked from commit eb6828adddde978fab87dc7d05ea1a2a55738008)
2026-11-02 01:09:01 -08:00
Anees Iqbal 69f4ad114c Probe what plain Metal does with ASTC HDR textures
A from-scratch Objective-C probe of MTLPixelFormat 221-236 (the _HDR
form of every footprint), one case a process:

- create: which descriptors make a texture, by texture type, storage
  mode and usage (ShaderRead, ShaderWrite, RenderTarget, all three);
  each descriptor in a child process, since Metal ends the process at
  some (1D and multisample compressed textures) even without
  validation.
- reads: each texel's read as float4 and as half4 and its nearest
  sample of self-encoded blocks written by replaceRegion, through an
  optional view of another raw format.
- zero, bytes: a new texture's texels; getBytes and blit round trips.
- render, write: a pass storing a clear and a draw into one, and a
  kernel writing one, and what the blocks hold after.

Measured on an Apple M3 Max, macOS 27.0.1, run through the Mac GPU
lock without MTL_DEBUG_LAYER. The answers are stated in the module docs
the following commit writes (bind::astc_decode, the runtime's astc.rs):
every 2D HDR texture is made with read, write and render-target usage;
reads are half-precision values, exact as float and as half; render
passes and kernel writes are stopped by Metal's validation, and plain
Metal's pass stores nothing while its write leaves bytes no format
defines.

(cherry picked from commit b5e51a65272a2f5db0e73dc50070082054d3e064)
2026-11-02 01:09:01 -08:00
Anees Iqbal 498163f1ad Mend two private doc links this effort broke
CI's private intra-doc link step holds each crate to its ceiling; the lane
was over two of them.

- metal2vulkan-air (4, ceiling 3): `const_taint`'s doc linked
  `entry_block_refusal`, which the undefined-constant change removed. It
  now names `Solver` alone, its one user.
- metal2vulkan-runtime (71, ceiling 70): a redundant explicit target on
  `Problem::UnspecializedFunction` in `Library::new_function_with_name`'s
  doc, added with the by-name refusal.

Verified: the step's loop run locally over all six crates (rustdoc
--document-private-items, -Dwarnings): metal2vulkan 0, air 3, runtime 70,
validation 0, conformance 0, devtools 0, each at its ceiling. The
runtime-sources pin covers both files: recomputed (7f8ad7d3) and
the_runtime_sources_are_the_committed_ones passes.

(cherry picked from commit 7da81ee3d8a80992e65167ff1d2c315bd10715c6)
2026-11-01 23:38:40 -08:00
Anees Iqbal 4aac27a548 Ask supportsPullModelInterpolation in the lane's query census
runtime_lane::capabilities asks every Query::ALL member of the lane's
device and panicked on Query::PullModelInterpolation, a query it did not
ask. It now asks it, as it asks supportsSamplerReductionMode: an answer,
no gap.

Verified on the M3 Max (MoltenVK 1.4.2) through the Mac GPU lock,
--cfg m2v_gpu: runtime_lane::capabilities, msaa_32bit and
pull_model_interpolation 8/8.

(cherry picked from commit a27c863842433fa94ee6ece8ffebd5db2e880077)
2026-11-01 23:38:40 -08:00
Anees Iqbal b2625d5688 Name GraphicsState::interpolates_at_sample's source without a private link
The field's doc linked crate::pipeline::Sampling::Interpolant, which is not
public (pipeline::stage_io is crate-private), so public rustdoc failed on a
broken intra-doc link. The doc names the stage interface's sampling in
plain code instead.

Verified: RUSTDOCFLAGS='-D warnings' cargo doc -p metal2vulkan -p
metal2vulkan-air -p metal2vulkan-runtime --all-features --no-deps is clean;
the runtime-sources pin is unchanged (pin-compute.py).

(cherry picked from commit 313d45dc1cf18685f5d0efd9722e3ceb98fc3796)
2026-11-01 23:38:39 -08:00
Anees Iqbal 81441ca877 Regenerate the surfaces for pull-model interpolation
- RUNTIME_VERSION 1719: the runtime answers supportsPullModelInterpolation
  and refuses a draw reading an interpolant at a sample at custom positions.
- scripts/metal-coverage/coverage.tsv: supportsPullModelInterpolation
  implemented (DeviceProperties::supports_pull_model_interpolation);
  docs/METAL-COVERAGE.md and docs/CONFORMANCE-COVERAGE.md regenerated.
- docs/REFUSALS.md regenerated: feature::PullModelInterpolation and
  gap::InterpolateAtSampleWithPositions (reach rows in reach.tsv).
- crates/metal2vulkan/tests/api_signatures.tsv blessed: additions only but
  Query::ALL's length (8 to 9) and value.
- crates/metal2vulkan-runtime/README.md: the query and what differs.
- runtime-sources pin recomputed (pin-compute.py).

Verified: refusal_surface.py --check, signatures.py --check,
metal-coverage --check and conformance-coverage --check all current.

(cherry picked from commit 2dcbbf39b6e5caeb3e87079d7f2f36540ceb0dd0)
2026-11-01 23:38:39 -08:00
Anees Iqbal a8af53b32a Answer supportsPullModelInterpolation and refuse sample reads at custom positions
The runtime had no answer for supportsPullModelInterpolation (the M3 Max, a
Radeon Pro 5300M and a UHD 630 answer 1), so the consumer passed none.

- DeviceProperties::supports_pull_model_interpolation (Query::
  PullModelInterpolation) answers yes where the compile layer lowers every
  interpolation function: DeviceProfile::interpolation_function_needs is
  empty (sampleRateShading, and MoltenVK's
  shaderSampleRateInterpolationFunctions), the same predicate the lowering
  refuses by.
- A draw at custom sample positions through a pipeline whose fragment
  function reads an interpolant at a sample
  (GraphicsState::interpolates_at_sample) is refused
  NotImplemented(RuntimeGap::InterpolateAtSampleWithPositions) in
  settle_draw, which direct and indirect-command draws share: Vulkan takes
  no InterpolateAtSample in a pipeline made with custom sample locations
  (VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524), and
  Metal's answer there is not measured.

Tests:
- runtime tests::capabilities: every committed profile answers from the
  enabled features; every venue (moltenvk-m3, both lavapipe gates, 780M
  RADV, both ANV, RTX 5080) answers yes; vk12-floor no; moltenvk-m3 without
  the portability member no; every query answers on moltenvk-m3.
- validation runtime_lane::pull_model_interpolation (--cfg m2v_gpu or
  m2v_cpu_icd): the probe's lane draws (one triangle of w 1, 2, 4 over 6x6,
  at 1 and 4 samples: center, centroid, each sample, sample_id, five
  offsets, the float2/float/half and half4 interpolants) against Metal's
  reading pull_model_interpolation_m3_max.txt, every sample's coverage
  equal; word for word where the profile takes MetalInterpolation, else
  within the device's interpolation plus the location Vulkan leaves to it;
  the offset pipelines alone record DeviceInterpolationOffset and require
  the device's origin property. A pm_sample draw at custom positions is
  refused; a pm_offset draw there runs.

Verified on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) through the Mac GPU
lock: 25 draws, 14 samples at 1x and 55 at 4x each, every word Metal's
(most apart 0); the refusal and the offset draw at custom positions as
stated. Negative control: the MoltenVK origin set to 1/2 put every offset
draw 0.06 to 0.11 off Metal's. Not run on lavapipe here (no container
runtime up); CI's lavapipe lane runs it. Runtime capabilities, degradation
and families tests 47/47; clippy all features and --cfg m2v_gpu.

(cherry picked from commit e9f45f7c85309ba6d1e6bc57f3b10fd47585893e)
2026-11-01 23:38:39 -08:00
Anees Iqbal ef7a8d6f08 Lower Metal's pull-model interpolation (interpolant inputs)
A fragment function reading an `interpolant<T, P>` input through
interpolate_at_center, _centroid, _sample or _offset was refused as invalid
input (the AIR key air.interpolation_function was unknown), so a guest whose
device answers supportsPullModelInterpolation could not run one.

AIR: the key marks a fragment input `Sampling::Interpolant`, a device-space
handle (`AbiHandle::Interpolant`); `air.interpolate_{center,centroid,sample,
offset}_{perspective,no_perspective}.{f16,f32 x1..4}` parse as
`AirIntrinsic::Interpolate`, decided from the intrinsic family and the
metadata ABI, never names.

Lowering: the interpolant is a float Input variable of its form (NoPerspective
where not perspective), read only through its calls:
- center: as a center varying is read (its pixel-center form at more than
  one sample where the device has one);
- centroid / sample / offset: GLSL.std.450 InterpolateAtCentroid,
  InterpolateAtSample (index & (SampleCount - 1), Metal's i mod n) and
  InterpolateAtOffset (offset moved to the device's origin and NClamped to
  [minInterpolationOffset, maxInterpolationOffset], which Vulkan requires).
  These need sampleRateShading (and MoltenVK's portability member): without
  them the function is refused Unsupported(PullModelInterpolation).
- MoltenVK's SPIRV-Cross hands InterpolateAtOffset(v) to Metal as
  interpolate_at_offset(v + 7/16): such a device gets the new
  VkProperty::InterpolateAtOffsetFromSevenSixteenths and the module moves
  the offset by 7/16 (a module annotation picks the property).
- An interpolant used any other way (a select of two) stays
  NotImplemented(PullModelInterpolation); on RADV
  (InterpolationNeedsTheWholeQuad) a sample or offset read after a discard
  or outside the first block is refused; lavapipe refuses a multisampled
  centroid read as it refuses a centroid varying.
- GraphicsState::interpolates_at_sample states a fragment stage that reads
  at a sample (Vulkan takes no InterpolateAtSample with custom sample
  locations); Sampling::Interpolant carries center/centroid/sample.

Metal measured on the M3 Max, macOS 27.0.1, with the new probe
probes/pull_model_interpolation.m over the owned fixture
pull_model_interpolants (cases origin, grid, samples, centroid, lane): an
offset is read from the pixel's corner as given, no range, no grid, NaN for
a non-finite one; sample i reads i mod n at Vulkan's standard positions;
centroid is the center when the pixel is covered whole, else the lowest
covered sample. The offset's range and grid are the device's:
PrecisionNote::DeviceInterpolationOffset (validation: Recorded), in
docs/API.md's catalogue and FAST-PATHS.md's device gaps; a centroid read
notes MultisamplePosition as a centroid varying does.

Verified: tests::engine_pull_model (309 pipelines over every committed
profile at 1 and 4 samples: instructions, mask's planned SampleCount,
origin, NClamp, note, property, L3; refusals on vk12-floor, RADV after a
discard, lavapipe centroid at 4x; pm_selected refused everywhere),
engine_multisample, engine_fragment, engine_coverage_loop, fast_paths,
api_tests, codec and cache tests, metal2vulkan-air abi/intrinsics tests and
api_surface; runtime degradation and catalogue tests; clippy all features.
Before: every pull_model_interpolants function failed InvalidInput
(Abi(UnknownKey)). Goldens: only new rows and the moltenvk-m3 profile hash
moved (its new property); inventory 24 new rows, 0 moved cells.

SEMANTICS_VERSION 1941 (refusals became translations), ARTIFACT_FORMAT_VERSION
481 (IoSampling, PrecisionNote, VkProperty and GraphicsState encodings).

(cherry picked from commit 70e01b4bd6f8a0d1421ae07ed710714fb4ce985b)
2026-11-01 23:38:39 -08:00
Anees Iqbal ceb666187a Answer Metal's supports32BitMSAA from the device's own textures
The runtime had no answer for supports32BitMSAA (METAL-COVERAGE listed it
missing), so the consumer passed None through. Metal's answer promises a
multisample texture of each 32-bit integer format and the resolve of
each 32-bit float one; the M3 Max, a Radeon Pro 5300M and a UHD 630 all
answer 1.

What the runtime did before was read first: a multisample texture of each
of the nine formats is planned as any texture is (image_plan), within the
device's limits for the image (vkGetPhysicalDeviceImageFormatProperties2),
and refused as a count its format lacks; draws and texture2d_ms reads of
it, the float formats' AVERAGE resolves (Metal's own on MoltenVK,
device-rounded-resolve elsewhere) and the refusal of an integer resolve
(ResolveFormat, as Metal stops it) were all in place. The render
pipeline, sample planes and interleave all take a format's own counts
beside framebufferIntegerColorSampleCounts. Nothing was wrong; the
query was missing.

Device::supports_32bit_msaa answers yes where the device makes every
texture and resolve the answer promises, each probed exactly as
pixel_format_capabilities probes a capability (the probe closure of
families::formats::answers is now a function both share): the texture
sample counts hold 4, a 2D multisample RenderTarget|ShaderRead texture of
each of the nine formats is made at every count above 1 the textures take,
and each float format resolves (its Resolve capability). A device method,
as supports_family is, because it reads the device's per-format limits:
Vulkan floors an integer format at framebufferIntegerColorSampleCounts,
one sample on RADV and lavapipe, while their 32-bit integer formats each
take 1 to 8 (1, 4, 8 on lavapipe), as the venue profiles' captured
per-format counts state.

Tests:
- runtime tests::msaa_32bit: every committed profile pinned, with the
  limits it states (a venue profile's own per-format color attachment
  counts, else Vulkan's floors). Yes on every venue (moltenvk-m3, both
  780M RADV, both gate lavapipe, the ANV and NVIDIA ones) and on the
  Intel and NVIDIA profiles whose floors cover the counts; no on
  amd-rdna2/rdna3-radv, lavapipe, lunarg-desktop-baseline-2023,
  swiftshader and vk12-floor (R32Uint at the lowest count, naming
  FramebufferIntegerColorSampleCount), and roadmap-2022 (no 4 samples).
  A yes agrees with each format's Msaa and float Resolve capabilities;
  the rule needs 4 and every count, and a missing resolve texture says
  so. A negative control that probes 4 samples alone fails two of them.
- validation runtime_lane::msaa_32bit (--cfg m2v_gpu): the answer is what
  the device makes; R32Uint and RGBA32Uint targets at 2 and 4 drawn at
  sample rate hold every bit, read back through texture2d_ms<uint>
  (Metal: every channel as written); an RG32Float 4-sample target keeps
  its samples and resolves to the probe's Metal texels, exact where the
  driver's average is Metal's; an RGBA32Uint resolve is refused.

Verified: runtime tests msaa_32bit, families and capabilities, the
metal_coverage and runtime-sources pin tests; on the M3 Max (MoltenVK
1.4.2, macOS 27.0.1) through the Mac GPU lock, runtime_lane msaa_32bit,
families and capabilities 7/7: supports32BitMSAA true, counts [2, 4],
nothing refused, 0 integer channels differ, 32 of 32 resolved channels
as Metal's, device-rounded-resolve not announced. clippy with all
features and with --cfg m2v_gpu, rustdoc -D warnings, refusal_surface
--check (no refusal moved), api-signatures (one method added),
METAL-COVERAGE and CONFORMANCE-COVERAGE regenerated (the item now
implemented, not yet exercised by the suite).

RUNTIME_VERSION 1718 (a new answer); runtime sources re-pinned.

(cherry picked from commit 2376157b3bf7bf99221579f42a795ef351b8144c)
2026-11-01 22:35:40 -08:00
Anees Iqbal 90622adb95 Probe Metal's 32-bit multisample textures and float resolves
A probe, written from scratch, of what Metal answers behind
supports32BitMSAA, one shape per process:

- query: supports32BitMSAA and supportsTextureSampleCount:.
- make: a 2D multisample RenderTarget|ShaderRead texture of each of the
  nine formats (R32Uint, R32Sint, RG32Uint, RG32Sint, RGBA32Uint,
  RGBA32Sint, R32Float, RG32Float, RGBA32Float) at 2, 4 and 8 samples.
- int-samples: a draw at sample rate writes every sample of an integer
  target (edge words 0x7fffffff, 0x80000000, 0xffffffff, 0x01000001 and a
  hash), read back through texture2d_ms<T>::read.
- float-resolve: a float target drawn the same way with special values
  (order-dependent sums, NaNs with payloads, infinities, a denormal input
  and a denormal average, signed zeros, an overflowing sum) and
  pseudo-random ones, resolved by StoreAndMultisampleResolve or
  MultisampleResolve into a texture of its format, compared with the
  rule runtime_lane::resolve_rounding states.
- int-resolve: an integer target's resolve.

Measured on the M3 Max under macOS 27.0.1, plain Metal through the Mac
GPU lock:
- supports32BitMSAA 1; supportsTextureSampleCount 1, 2, 4 yes, 8, 16 no.
- Every one of the nine formats made at 2 and 4 samples; at 8 Metal stops
  it ("sampleCount (8) is not supported by device").
- int-samples: 0 channels differ from those written, every integer format
  at 2 and 4 (RGBA32Uint at 4 also with MTL_DEBUG_LAYER=1).
- float-resolve: 0 channels differ from the rule (the samples summed in
  order in float from sample 0, denormals flushed to the zero of their
  sign, a NaN anywhere 0x7fc00000), each float format at 2 and 4 under
  both store actions; the stored samples are bit for bit those written.
- int-resolve RGBA32Uint 4: with the validation layer, "PixelFormat
  MTLPixelFormatRGBA32Uint cannot be a MSAA resolve target"; plain Metal
  writes words no sample holds.

(cherry picked from commit f18cf358da5419ceb41896975ad447ea42cff77a)
2026-11-01 22:35:40 -08:00
Anees Iqbal 03264ce9c2 Pace the CPU writer of the copied-log race test
tests::copied_log::a_cpu_write_the_gpu_did_not_make_survives_both_ways_logged_or_not
spawns a thread that writes one byte of the pages and tells the test log of it
in a tight loop, while the main thread runs 2000 rounds of merge back and copy
in. TestLog keeps every write it is told, and each copy in asks it for the
writes since a stamp by scanning them all, so the run time grew with the
square of how far the writer outran the rounds. It took 28 s to 749 s across
recent gates and timed out at nextest's 1200 s limit under an outside load
of about 30 (a sample showed every stack in TestLog::changed's scan).

The writer now sleeps 20 us after each write it tells. Each write is still
told right after it is made, so the last write is always logged, and the
writes still race the copies; the log stays bounded by the test's length.

Verified: the test passes in 0.085 s under a load average of 51, twice.
The runtime-sources pin is unchanged (79fe4b2f).

(Carried to development from steelbrain/reims-graphics-kext 130513884f.)
2026-11-01 21:26:24 -08:00
Anees Iqbal 6f8ec46671 Draw a draw whose own band the translator refuses at the nearest width
A draw whose own band variant the translator refuses where the state's
first band compiled (a varying or push data the draw's variant adds, such
as a shader-side depth test's window depth and depth range, past
maxTessellationEvaluationOutputComponents or maxPushConstantsSize) was
refused with the translator's Unsupported(WideLines). Only its later
draws took the nearest width. That breaks the owner's rule that an
accuracy note is logged and never fatal: the draw can run at the nearest
width.

The draw now takes the nearest width, announced as a state's refusal is
(lines-at-nearest-width, the translator's refusal the reason). The
refusal is still kept per state and primitive (GraphicsState::refuse_band,
two answers a state). A draw's variant key follows from its bind shape,
and its route sets that shape, so a per-key memo would need the shape
before the route. Recording a draw factors what its lines' route decides
(the route, provoking vertex, listed strip, private form, settings) into
RenderLowering::routed_draw and a RoutedDraw. draw_resident settles in a
loop. Where the settle answers the translator's refusal of the draw's band
(LineRoute::refused), it marks the state's primitive refused and routes
the draw again. Routed again it draws no band of the primitive, so it
settles once more at most. settle_draw hands that refusal back to the
caller before its snapshot and shadow retries, as before.

Docs: line_width.rs, the runtime README, FAST-PATHS's known gap, API.md's
and degradation.rs's lines-at-nearest-width (no refusal named any more).
REFUSALS.md does not move (refusal_surface --check passes): the
translator's refusal stays. RUNTIME_VERSION 1717 (a refusal became an
announced draw); runtime sources re-pinned.

Verified: the new pure test
a_draw_whose_band_the_translator_refuses_takes_the_nearest_width covers
every committed profile under both policies, lines and edges, widths 0 to
16. Each band route takes either refusal (not implemented, and the
evaluation-output limit) as its primitive's. Routed again, it is the
nearest width with the refusal as the reason, or the device's lines, and
never a band. A non-WideLines refusal or a runtime gap stands. It does
not compile against be2d725fdb, which had no such decision. A negative
control that drops the decision for lines fails it ("amd-780m-radv,
Device, Lines at 0: left None, right Some(Lines)"). Runtime line_width
tests 4/4 pass. Also clean: clippy with all features and with
--cfg m2v_gpu, refusal_surface --check, the runtime-sources pin test.
Not run: the GPU lane. No draw on MoltenVK reaches this cheaply: the base
key's band and a draw's differ only by shader-side tests' additions or
push data. The orchestrator's gate covers the restructured draw path.

(Carried to development from steelbrain/reims-graphics-kext 06f08298fd.)
2026-11-01 21:26:24 -08:00