Commit Graph
215 Commits
Author SHA1 Message Date
Anees Iqbal 5aa31f836c Rebind a draw's slots by rebinds the plan works out once for them
A rebound draw that moved buffer offsets spent about 470 instructions
a draw (lavapipe, draws.10k shape) in rebind_slots, and 13% of the
M3's time, writing one 4-byte push word: each draw walked the
template's stages, fields, buffers and vertex buffers again to find
what the changed slots decide, though that depends on the plan and
the slots alone.

BindingPlan::slot_rebinds now works that out once for a list of slots
(a public, opaque SlotRebinds: each changed buffer slot's place among
the descriptor ranges and its push fields, the loose fields, the
vertex buffer places; None where rebind_draw_slots_into answers
Ok(false) whatever the state), and rebind_draw_slots_with rebinds by
it, looking at the state and the commands alone and writing each word
as a fixed-size store. rebind_draw_slots_into is the two in turn, so
there is one implementation; builds with debug assertions check that
the rebinds given are the plan's own for their slots.

The runtime keeps the rebinds with the settled draw (SettledHere),
made at the first draw rebound that changes a list of slots and kept
while the next draws change the same slots; a new settle drops them.

The rebind test now also rebinds each case by rebinds made once per
plan and slot list and holds them to the whole rebind's answer and
commands. docs/API.md describes the two calls; the surface table,
the signature table and docs/REFUSALS.md (a renamed site) follow.

(cherry picked from commit 0397cbb254eb9402d5955d2ed2edab1ea0b2b6dd)
2026-11-07 21:43:27 -08:00
Anees Iqbal b8f7b5a7f9 Answer minimumLinearTextureAlignmentForPixelFormat: from the device's images, per format
The query answered 16 for every format on every device, Metal's answer on an Apple GPU. On RADV a
texture at 16 never goes in place over host pages: its linear images lay rows at multiples of 256
and align their memory to 256, and DRM explicit layouts take only multiples of 256. A guest that
lays its buffers out by the answer then gets shadows where 256 would have given images in place.

The answer is now the device's, worked out lazily at a format's first query. The runtime makes
the images a 2D ShaderRead texture over host pages takes in place (in_place_unbound, the product's
own maker: the driver's linear image made for host allocations at the texture's pitch, else the
DRM_FORMAT_MOD_LINEAR one). It tries each power of two P from 16 to 4096, at widths of 1 to 1920
texels and 3 rows. The answer is the first P at which every width's image lies at
roundup(width * texel, P) and its memory alignment divides P. Each image is released and never
bound.

- The first answer is kept for the device's life.
- Each answer is recorded per driver, runtime and format in the shader cache's content directory.
- A device that imports no host pages, a format no P brings in place, and a failed probe all
  answer Metal's 16.
- New counts: WorkCounts::linear_alignments_probed and linear_alignments_recalled.

Nothing new is refused. LINEAR_ALIGNMENT (16) stays the acceptance rule, and a texture under the
answer is made as before: an image in place where the device takes its layout, else the
announced shadow.

The query moves from DeviceProperties to Device
(Device::minimum_linear_texture_alignment_for_pixel_format), since it needs the device's images.
DeviceProperties::minimum_linear_texture_alignment_for_pixel_format is removed.

The private properties change as follows:
- deviceLinearTextureAlignmentBytes and linearTextureAlignmentBytes are the largest per-format
  answer.
- The iosurface pair stays 16.

Supporting changes:
- texture/in_place_image.rs's in_place_unbound becomes pub(super).
- buffer_texture.rs's texel_bytes becomes pub(super).
- The unit tests now hold Metal's rule (capabilities::linear_alignment_rule).

Tests:
- A record test.
- runtime_lane::linear_alignments:
  - Every format's answer is printed.
  - A texture at the answer over host pages is in place wherever the check passed for reads.
  - A 64-byte-row texture is made, as a shadow, where the answer is larger.
  - A second device of the same driver reads the record and probes nothing.

Regenerated: api_signatures, docs/REFUSALS.md, docs/METAL-COVERAGE.md (coverage.tsv mapping).
Updated: RUNTIME-PORTING.md and the conformance device-queries docs.

Verified: python generators only, so far. The builds, unit tests and the lanes on the M3, RADV,
lavapipe and NVIDIA run next, and their results go with the tip.

(cherry picked from commit d1510f5588e9e5c3ace5acb1622dcd6570408040)
2026-11-07 19:26:46 -08:00
Anees Iqbal ec9706e6e3 Survive the loss of the VkDevice: the device is a line of generations
Metal's MTLDevice survives a GPU recovery; the runtime's device refused every
call with DeviceLost from the first loss on, and the consumer ends its VM at
the first refusal. Now a device the runtime made is a line of generations
(device/line.rs), each a DeviceShared over its own VkDevice, and the first call
that needs the device after a loss makes a new VkDevice of the same physical
device, options, queue families and extensions.

- Two kinds of handle. The program's device (and its clones) is a root handle:
  it holds the line, pins no generation, and every public Device call goes to
  the generation that serves (each public method forwards to its *_now body).
  Objects hold generation handles, so their Vulkan calls, drops included, reach
  their own VkDevice alone. A generation handle's check is one relaxed load of
  the line's generation (Device::generation_serves).
- A draw pays nothing for it. A command buffer takes its generation once, as
  it is made (CommandBuffer::generation); its encoders' per-draw reaches (work
  counts, fresh-unwritten and alias records, sampler-slot changes, attachment
  read notices) read it there, not through a device handle's kind. A bind's
  device check is one compare of the cells the two handles hold, inlined, its
  refusal (Device::foreign) out of line.
- The state machine (Live, Lost, Failed): the claiming call recovers, every
  other call waits (a notice past 10 s, waiting on); threads command buffers'
  completion depends on never wait. Recovery: the lost generation's command
  buffers in flight fail through its completion path, its queues drain under
  their locks, create_on makes the next VkDevice, the queues are retired.
- Command-buffer answers, as a real loss is one more hang: the oldest
  incomplete batch's command buffer fails GpuHang (exact on one VkQueue; on two
  or more the queue whose oldest incomplete batch was submitted first, said so
  in the notice), counted against its queue so the second revokes it
  (AccessRevoked); the others GpuRecoveryVictim; one committed on the hang's
  queue before the recovery runs nothing and completes with no error; one made
  before and committed after fails GpuRecoveryVictim. One loss names one hang:
  a batch that went to the driver just before the loss and reached the lost
  device's completion after the loss took the pending batches fails with it,
  as a victim (its own wait need not fail: the test hook's VkDevice runs it),
  and no later failure of the lost device names a second hang.
- Command queues survive: a queue is a root handle and a cell of its place on
  one generation (VkQueue, slots, pools, hangs), which a recovery retires and
  the next command buffer re-makes; label and GPU-error count go on.
- Objects made before a recovery are refused where they meet the new VkDevice
  or need their lost one: RuntimeGap::MadeBeforeRecovery, at the 38 lost-device
  checks (Device::lost_refusal) and at every foreign-object check of one line
  (Device::foreign). DeviceLost stays for a device the consumer made.
- Carried across generations: the address space, resource IDs and the passing
  holds a making waits out before it takes one, unique identifiers, counters
  and the announced notice kinds.
- A device handle is an enum of the two kinds (24 bytes, was 16): the shadow
  merge's copy-back dispatch, which holds handles, is boxed (clippy's
  large_enum_variant).
- Device::recover_for_test (public, documented) runs the whole path with no
  GPU fault; RuntimeGap::AdoptedDeviceRecovery on an adopted device.
- Degradation::DeviceRecovered (device-recovered), announced at each recovery
  with the culprit and its time. WorkCounts::vk_devices_live, vk_devices_made,
  device_recoveries: two VkDevices while objects of the lost one live, one
  after.

Docs: docs/API.md catalogue entry, the runtime README's device-loss section,
FAST-PATHS known gap (a make whose own submission first meets the loss is
refused DeviceLost), docs/REFUSALS.md regenerated (refusal_surface.py names a
forwarded body's sites by its public method), api_signatures blessed.

Tests: runtime_lane::device_recovery (hang and victims, command buffers on
their way to the driver at a recovery, MadeBeforeRecovery and the VkDevice
bound, revocation at the second hang, a command buffer made before fails as
victim, all under the validation layer; a recovery that finds nothing of the
queue scheduled names no hang, its command buffers victims),
tests::device_recovery (the hold of the hang's queue between a loss and the
recovery), detach_lost and the MoltenVK lost-device lanes updated to the
recovery's answers.

Verified:
- lavapipe: runtime suite and touched validation tests 1850/1850, surface
  19/19 (m3-max-5695, gem10, before the rebase onto 7e039f062a); on
  7e039f062a, before the one-hang fix, 1853/1853, surface 19/19, clippy clean
  (m3-max-6150, ms01). This tree: clippy clean (m3-max-6278, msi).
- RADV RX 7900 XTX: 81/81 touched device tests (m3-max-5709). Iris Xe (ANV):
  80/81 (m3-max-5766), the 81st kept_images, which fails so at development
  too and the last of these three commits fixes; the recovery tests alone 3
  rounds of 3 (m3-max-5852). RTX 5080 Laptop GPU: 80/81 (b5080 entry
  devloss-devloss-tip1-nine-163410), the 81st the test's own 20 s bound on
  the recovery, which took 39.5 s beside another entry; the test now prints
  the recovery beside the device's first making and bounds neither.
- MoltenVK on the M3 Max: the device_recovery tests 8 rounds of 8
  (m3-max-6135); with the one-hang fix 12 of 12 (m3-max-6242), where without
  it 3 rounds of about 20 failed with a command buffer Completed after the
  hang (m3-max-6219, m3-max-6233). The RTX 5080 failed the second-hang test
  so in 2 runs of 3 (devloss-devloss-rec-alone-170457).
- Recovery time, alone, under the validation layer: llvmpipe 29.9 ms, RX 7900
  XTX 20.4 ms, Iris Xe 15 to 21 ms (its first making 30 to 41 ms), M3 Max
  (MoltenVK) 35 to 40 ms (42 to 50 ms), RTX 5080 530 to 559 ms (602 to 635
  ms). VK_EXT_device_fault listed: llvmpipe 0, XTX 1, Iris 0, 5080 1.
- Per draw (draw_costs, release, --heap, M3 Max, base 7e039f062a and the tip
  alternating, 4 rounds, m3-max-6121): instructions a draw ws +0.03%, many
  -0.05%, 10k -0.31%; draw_primitives +10, +8 and -26 of 17,172, 11,245 and
  7,736 a call; each set_* call +3 to +4 (of 425 to 860); a command buffer's
  creation +170 to +370, an encoder's end +120 to +390.

(cherry picked from commit 3d7758c074fc9895d5d6c9766604c6c4eae9166d)
2026-11-07 18:38:26 -08:00
Anees Iqbal 02562d2a1e Make a shared event whose timeline semaphore another API imports, exported as an opaque fd
reims's ask 2: CUDA signals the event's semaphore on the GPU after a decode
(cuSignalExternalSemaphoresAsync), and waits on it, where it now orders
through the host.

Device::new_exportable_shared_event() makes a shared event as
new_shared_event does, its timeline semaphore made with
VkExportSemaphoreCreateInfo naming VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT;
SharedEvent::export_semaphore_fd() answers a new OwnedFd each call
(vkGetSemaphoreFdKHR), the caller's to close. An event not made exportable is
refused Invalid(Problem::NotExportable). The counter stays the signal index
the interop hooks name: the importer waits for vk_wait's counter and signals
only one reserve_vk_signal reserved; that call's contract now names an
importer's signal beside the device's queues.

The device decides structurally, once: it enables VK_KHR_external_semaphore_fd
wherever listed (adopted: where its consumer enabled it), and asks
vkGetPhysicalDeviceExternalSemaphoreProperties for a timeline semaphore:
OPAQUE_FD exportable and among the compatible types. Lacking either, the
making is refused NotImplemented(RuntimeGap::ExportableSemaphore), with its
REFUSALS row. Lifetime (the event outlives every import and every signal and
wait an importer submitted) and device loss (state lost for the imports; a
device made again exports new semaphores) are in the call and module docs,
interop.rs and the README. api_signatures blessed; exit_guard's KEEPERS
lists exported_semaphore.rs.

Test (device, src/tests/exported_semaphore.rs): the semaphore imported into a
second VkDevice; a command buffer's signal of 5 reaches vk_wait(5)'s counter
there; the second device's host signal of the counter reserved for 9 raises
the event to 9 and releases a command buffer that waited for 9 and then
filled a buffer. Unverified at this commit.

(cherry picked from commit 525580c12be28e6efa0a06ab09cde1f736ebace7)
2026-11-07 16:55:27 -08:00
Anees Iqbal ff631aada9 Bump RUNTIME_VERSION to 1839: the in-place check's fresh-pages class lies in fresh pages wherever the device takes them
amdperf-22 (the six picked commits before this): Device::fresh_pages_check_buffer makes the
check's fresh pages whatever the import tax, so RADV checks the class (Passed x3 on the 780M,
m3-max-5640; Unchecked x3 at the parent, 5648), and a copied rebind under an image in place
takes fresh pages where they passed (copied_device 29/29 780M, 33/33 lavapipe, 5667).
CHECK_VERSION 4. Re-pinned; signatures and REFUSALS unchanged. Clippy plain and m2v_gpu
(5701), fast_paths 21/21 (5687).
2026-11-07 16:25:43 -08:00
Anees Iqbal ae0c6c7023 Make a buffer whose memory another API imports, exported as an opaque fd
reims's NVIDIA video lane writes each decoded picture into a runtime buffer
with cuMemcpy2DAsync, so CUDA must import the buffer's memory
(cuImportExternalMemory, cuExternalMemoryGetMappedBuffer); without it the
pictures take a host-pages route of about 2.7 ms a 4K picture.

Device::new_exportable_buffer(length, options) makes a buffer as
new_buffer does, but in an allocation of its own made exportable as
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT: the VkBuffer names the handle
type (VkExternalMemoryBufferCreateInfo) and has the device-address usage of
its own; its memory (VkExportMemoryAllocateInfo) is a block of its own of
the memory type its storage mode takes, the buffer's dedicated allocation
where the device exports only so (DEDICATED_ONLY) or the driver prefers or
requires it (VkMemoryDedicatedRequirements). It is never parked for reuse.
Every other buffer keeps the pooled blocks and pays nothing.

Buffer::export_memory_fd() answers ExportedMemory: a new OwnedFd each call
(vkGetMemoryFdKHR), the caller's to close, the allocation's size, the
buffer's offset and length in it, whether it is dedicated (CUDA's
cudaExternalMemoryDedicated) and its memory type (a Vulkan import names it).
A buffer not made exportable is refused Invalid(Problem::NotExportable).

The device decides structurally, once, as it is made: it enables
VK_KHR_external_memory_fd wherever listed (outside the vocabulary, as the
dma-buf route's names, which enable it too; an adopted device where its
consumer enabled it), and asks vkGetPhysicalDeviceExternalBufferProperties
for a buffer of the runtime's usage: OPAQUE_FD exportable and among the
compatible handle types. Lacking either, the making is refused
NotImplemented(RuntimeGap::ExportableMemory), with its REFUSALS row.

Docs: the module docs, the call docs, interop.rs and the runtime README
state the lifetime rule (the buffer outlives every import) and the
device-loss rule (contents lost for every import; a device made again
exports new allocations, new descriptors). api_signatures blessed (new
method x2, struct and fields, two variants).

Test (device, src/tests/exported_memory.rs): a Shared buffer of a 4K NV12
picture's bytes, written by the host and a GPU fill, exported and imported
into a second VkDevice of the same physical device (dedicated where
exported so), read there; that device's writes read back by the runtime's
blit. A refusal must come from a device that lists no extension or export.
It prints the make cost of Shared and Private exportable buffers beside
plain ones (medians of 8). Unverified at this commit.

(cherry picked from commit fd6d775ef63e350ae1f550d6b2e7ef6af763d21f)
2026-11-07 15:30:55 -08:00
Anees Iqbal be0a50f1a1 Test and document the blits at a pitch below the row for depth, stencil, buffer-backed and two-plane textures
Unit tests: Depth16Unorm and Stencil8 at a pitch below the row place each row
at y x bytesPerRow both ways, Depth16Unorm on the aligned path too, a pitch
off the unit or of 0 refused; a texture over a buffer's row copy at such a
pitch reads overlapping buffer rows and writes them out in turn, each row but
the last its first bytesPerRow bytes, a last row past the buffer refused.

Device test (src/tests/short_row_kinds.rs): Depth16Unorm, Stencil8, both
aspects of Depth32Float_Stencil8, an RGBA8Unorm texture over a buffer and
RGB10A8_2P_XR10, 32 x 4, at half the row and half plus a texel: in, each
row read whole from y x bytesPerRow; out into a buffer of 0xcc, the rows in
turn, the later row's bytes standing, nothing past the span written.

Docs: CopyProblem::BytesPerRow no longer names depth/stencil or buffer-backed
textures at a pitch below the row (only off the unit or 0); two_planes.rs and
API.md's accepted difference state the probe's answers, the multisampled copy
out staying refused because every probe copy between a buffer and a
multisampled texture, at the packed row too, ended its process in Metal's
blit (SIGABRT). The probe's header records what it answered. REFUSALS.md
regenerated (a new BufferRange site in plan_rows_copy).

(cherry picked from commit e54ac4e63f4e9be0f1451ea2e7cccf8f74b66f34)
2026-11-07 15:23:33 -08:00
Anees Iqbal 8f652b31f1 Write a blit's rows out of a texture below their row in turn, the later row's bytes standing
A copy out of a texture at a bytesPerRow below the region's row was refused
Invalid(Copy(BytesPerRow)), as Metal writes such overlapping rows in no
one order. Metal runs the copy, though, so under rule 2 it may not fail:
on the Apple M3 Max under macOS 27.0.1 (probes/short_row_blits.m, jobs
m3-max-5158 and 5170) every such copy returned, rows lay y x bytesPerRow
apart with nothing past their span written, and of 300 shapes of 12
formats at half the row about a fifth left the later rows' bytes
standing. The later row's bytes are one of Metal's own answers.

placed_rows no longer refuses the copy out at a pitch below a row; the
rows are placed as a copy out at any other pitch off Metal's rules is,
and plan_placed_copy's later_rows_win writes them in turn: the texture
goes to a packed staging buffer in one region, and the staging rows go
to the buffer in one vkCmdCopyBuffer whose destination regions are each
row's bytes no later row writes, disjoint as VUID-vkCmdCopyBuffer-
pRegions-12482 asks, one region a row. No buffer-image region states a
row length below the width (VUID-VkBufferImageCopy-bufferRowLength-09101).

Still refused: a multisampled texture's copy out at such a pitch (where
Metal places its rows there is not measured), a texture over a buffer,
and depth and stencil formats but Depth32Float, as before.

docs/API.md's accepted differences say so; CopyProblem::BytesPerRow's
doc and basis lose the case and REFUSALS.md is regenerated.

Tests: blit_plan's layouts test takes the copies out at a pitch below the
row (rows at y x bytesPerRow); a_copy_out_at_a_pitch_below_the_row_leaves
_the_later_rows (blit_plan, no device) checks the unstaged bytes for a
one-plane YCbCr texture at its described row, RGBA8 at half, RGBA32Float
at three quarters and R8 at a pitch of 0, nothing past the span written
and at most one region a row; described_row_copies' new device test
copies 501, 504 and RGBA8Unorm out at a pitch below the row into a
buffer of 0xcc and reads the later rows' bytes standing.

(cherry picked from commit 73554a28ae7c83ccdcb01d5ebb95787b74928c21)
2026-11-07 14:39:30 -08:00
Anees Iqbal c6e1d5a9fd Make a BC1 or BC4 texture over a surface's plane at an offset or pitch off 16
The runtime refused a BC texture over a plane of a surface with planes
whose offset or bytesPerRow is off 16 bytes, as
NotImplemented(SurfacePlaneShape). The M3 Max answers nil for every BC
texture over a surface, so the x86 Macs are the reference (job
m3-max-4779 on macbook-pro-2019: an AMD Radeon Pro 5300M and an Intel
UHD 630 under macOS 26.7.1, surface_texture_envelope.m's bgraat8.bc1 at
offset 8 and bgrarow264.bc1 at 264 bytes a row). Both GPUs' blits and
samples take block row j at the plane's offset + j x bytesPerRow, with
no rounding to 16.

linear_plan::blocks_off_sixteen makes a BC texture of 8-byte blocks
(BC1, BC4) at an offset and bytesPerRow that 8 divides, at least 16
bytes a row. Every BC plane now lies at the CPU's layout on the GPU too
(plan_iosurface_plane's blocks flag): at multiples of 16 the two were
already equal. The CPU calls take the plane's own offset, as the
5300M's getBytes does, while the UHD 630's getBytes and replaceRegion
take a plane at offset 8 from byte 0. That difference is recorded in
docs/API.md's accepted differences. BC4 was not measured off 16; it
takes BC1's 8-byte block rows. BC textures of 16-byte blocks (BC2,
BC3, BC5, BC6H, BC7) off 16, and 8-byte ones off 8 or under 16 bytes a
row, stay refused. SurfacePlaneShape's doc names them, and so does its
reach mark in REFUSALS.md.

Tests: tests::linear_plan makes bgraat8.bc1, bgrarow264.bc1, BC4 at
(8, 264) and BC1 at offset 40, with the GPU layout equal to the CPU's.
It refuses BC3, BC5 and BC7 off 16, BC1 at offset 4 and at 260 bytes a
row, and BC4 at 8 bytes a row. tests::surface_shapes (a device test)
gains bgraat8.bc1, bgrarow264.bc1 and bgraat8.bc4 on every path.

docs: linear_plan.rs's Block-compressed surfaces, the plane call,
SurfacePlaneShape, BufferRefusal::PlaneShape, the FAST-PATHS known gaps
and the API.md accepted differences. Regenerating REFUSALS.md changes
only the reach mark. CONFORMANCE-COVERAGE.md and the API signatures are
unchanged.

(cherry picked from commit ff454bd8b269fff6abf590da85cd050862d539a9)
2026-11-07 14:23:18 -08:00
Anees Iqbal 6b6a7f522b Make mipmapped, 3D, multisample and sliced textures over a surface's plane
What. Buffer::new_texture_with_iosurface_plane over a plane of a surface
with planes makes three shapes it answered
NotImplemented(SurfacePlaneShape) for:
- a 2D texture of more than one level, a 3D texture and a 2D multisample
  one, of a colour format (linear_plan::apart_from_plane: is_linear and
  tail_held): a texture of the device's own memory
  (Device::surface_texture_apart), zero when made in every storage mode,
  a Private one's too (texture.rs's new Fresh::Zero start, which skips
  Metal's fresh pattern and the uncounted held start), announced by the
  new Degradation::SurfaceTexelsApart ("surface-texels-apart",
  precision). A Memoryless one stays MemorylessSurfacePlane.
- a 2D array of more than one slice, of a colour format, over a plane
  whose offset and bytesPerRow are multiples of 16
  (linear_plan::slices_apart): its first slice over the plane as a 2D
  texture's rows, its others in a tail of the texture's own. The planner
  lays the slices one image apart and gives Placed::kept, the second
  slice's first byte (or the buffer's length where that comes first);
  Texels::kept cuts the tail there instead of at the buffer's length
  (with_tail, past, staging), so the shadow's copies, blits and CPU
  calls take slice 0 from the plane and the rest from the tail.
  Announced by SurfaceTexelsTail, whose doc and cost now name both
  cases.

Why. Metal makes these, and on the M3 Max under macOS 27.0.1
(probes/surface_texture_envelope.m, job m3-max-4776) it lays them out in
no one place: bgra1x2.mips2/mips7, 420v.p0.mips2, bgra1x2.3d.d2,
420v.p0.3d.d2 and bgra1x2.2dms4.private read level 0 or slice 0 by blit
and kernel from other bytes than its blits, replaceRegion and getBytes
put there; bgra1x2.2darray.a2 and .a2.64x64 keep slice 0 over the plane
on every path while slice 1 is read at the plane's offset by blits and
getBytes, one image on by kernels, and written at the plane's offset.
By the rule of 9ee7323e76 what lies in one place stays in place and the
rest goes in memory of the texture's own, announced (the orchestrator's
option A). The x86 Macs under macOS 26.7.1 keep level 0 and slice 0 of
the first shapes over the plane; API.md's accepted differences records
that the runtime does not.

Docs: API.md's catalogue (the new kind, SurfaceTexelsTail rewritten) and
two accepted differences (sliced arrays; mipmapped/3D/multisample);
FAST-PATHS.md's known gap; SurfacePlaneShape's, PlaneShape's and the
plane call's docs; REFUSALS.md regenerated; api_signatures.tsv blessed.

Tests: tests::buffer_tail_device::an_array_over_a_plane_keeps_its_second_slice_in_its_tail
(64x32x2 RGBA8 over a 32768-byte plane: slice 0 the plane's bytes and
slice 1 zero on get_bytes, blit and a kernel through 2D views; kernel,
CPU writes read back on every path; the plane past slice 0 and the
buffers around unchanged; one notice) and
a_plane_s_texture_metal_lays_in_no_one_place_lies_apart (2 levels, 3D of
depth 2, 4-sample Private; level 0 zero, levels and slices written and
read back, no byte of the surface changes, one notice);
validation lane a_mipmapped_plane_lies_apart_and_is_announced, listed in
degrade_notices; linear_plan table rows for apart and sliced shapes,
their kept cut, and the off-16 and depth arrays still refused.

Verified by potluck jobs at this commit (clippy plain and m2v_cpu_icd,
runtime unit tests, lavapipe runtime and validation lanes, a negative
control at the runtime sources before it); results in the tip's report.

(cherry picked from commit 463cd6b9ecccc9e0b4263d8ac2452190f0287241)
2026-11-07 14:23:17 -08:00
Anees Iqbal e2491fe2b7 Read a rasterizing state's void-vertex answer from its compile, not a question
2f44dda930's render creations asked whether the vertex function returns a
value on every creation, so each plain creation counted one more linked-use
question, one more specialized stage entry and one more shared one than its
cost record (159 cases over bounds in the whole-set replay, all those counts).

The question now runs only where the state turns on it before its compile:
with rasterization disabled, and in OpenGL mode. A rasterizing state outside
OpenGL mode takes the answer from the vertex entry its compile specializes
anyway: the link refuses a rasterizing render pipeline whose vertex stage
writes no position (new DescriptorError::RasterizedVoidVertex), and the
runtime answers that refusal as Metal's error for a rasterizing void vertex
function, as before. The linked-use answers cache treats the vertex answer as
owed only where the creation asks it.

Tests: a link test refuses a rasterizing void vertex function with and
without a fragment, and makes it with rasterization disabled; a runtime test
counts one plain render creation at two specialized stage entries and two
linked-use questions. api_signatures and REFUSALS.md regenerated.

Not yet verified: suites, clippy and the M3 cost records follow.

(cherry picked from commit 7f8536158d856886ebedac8c0b6130ff32d22a31)
2026-11-07 14:02:58 -08:00
Anees Iqbal 2d3b673067 Take a blit into a texture at a pitch below the row on Metal's aligned path
A copy into a texture from offset 0, of one image, at a bytesPerRow that is
a multiple of 16 below the row was refused Copy(BytesPerRow) as unmeasured.
That is the row MTLPixelFormatGetInfoForDevice describes for the one-plane
YCbCr formats (a byte a texel for YCBCR8_422_1P, two for YCBCR10_444_1P:
half the row), which reims-vgpu's blits use (m3-max-4955 to 4985).

Measured (probes/short_row_blits.m, M3 Max, macOS 27.0.1, m3-max-5158):
every row of a 32 x 8 texture (64 x 8 for R8Unorm) read whole from its own
row's offset at every pitch of the texel from 16 below the row, in eight
formats of 1 to 16 bytes a texel, Private and Shared, 166 of 166. The
aligned path now takes such a pitch, rows at y x pitch; a pitch of 0 and an
offset of 16 or more stay refused.

A copy out at such a pitch stays refused: Metal writes the overlapping rows
in no one order (m3-max-5170: 900 copies out at half the row, 300 shapes of
12 formats in 3 processes, later-row bytes at some widths, even rows' at
others, neither at most, 15 shapes differing between processes). The CPU
copies already move nothing below the row, as Metal's.

Tests: blit_plan's placed-rows test takes three such pitches;
described_row_copies (device) copies in at the described row of both
formats and reads each row from its offset, and holds the copy out refused.
REFUSALS.md regenerated (the basis states the measurement).

Not yet verified: the tests and clippy follow.

(cherry picked from commit 3b174b367547b6f6187671d84f01797f9fe8f8ea)
2026-11-07 14:01:21 -08:00
Anees Iqbal b06871f199 Refuse a cube or cube array over a surface's plane as Metal's own refusal
What. Buffer::new_texture_with_iosurface_plane over a plane of a
surface with planes answers a Cube or CubeArray descriptor
Invalid(BufferTextureProblem::TextureType), where it answered
NotImplemented(SurfacePlaneShape). BufferTextureProblem::TextureType's
doc and basis name the plane's case; SurfacePlaneShape's doc, the
module's Beyond the plane's rows, FAST-PATHS.md's known gap and
REFUSALS.md (regenerated) follow.

Why. Plain Metal itself stops it on the M3 Max under macOS 27.0.1, the
release the runtime imitates: with the API validation layer off it
asserts "carriesComplexTexture || numFaces == 1" in
-[IOGPUMetalTexture initWithDevice:descriptor:iosurface:plane:field:args:argsSize:]
and ends the process, for a cube (bgra1x2.cube.16) and a cube array
(bgra1x2.cubearray.16) alike (probes/surface_texture_envelope.m, run
with --hazard so each shape runs in a child process, job m3-max-4776).
What Metal refuses is a typed Invalid, never a runtime gap.

Tests: linear_plan's a_surface_plane_s_other_shapes_follow_the_probe
expects TextureType for a 64x64 cube and a 16x16 cube array over a
planar surface; it fails without the check (both planned PlaneShape).

Verified (same tree content on the previous base, replay-27 9a1a8abf1d):
runtime unit 56/56 on msi-laptop (m3-max-4867), runtime lane 174/174 on
lavapipe on homelab-gem10-1 (m3-max-4868). Re-checked on this base by the
branch's check job.

(cherry picked from commit 7ea41c39ea9f471fcb14776f9c2c551cb4827209)
2026-11-07 12:44:46 -08:00
Anees Iqbal 88ddbf4f90 Keep a colour plane's texels past its surface in a tail of the texture's own
What. A colour texture of a plane of an IOSurface with planes
(Buffer::new_texture_with_iosurface_plane) whose GPU or CPU rows run past
the buffer standing for the surface is made. Its texels inside the surface
are the buffer's bytes, as every texture over a buffer's are; its texels
past it lie in a tail of the texture's own (Texels::past, the form
9ee7323e76 gave a 2D texture past its buffer's length): a Shared buffer,
zero when made, which its functions, blits and CPU calls read and write
alike. The new Degradation::SurfaceTexelsTail (precision,
"surface-texels-tail") announces it once. linear_plan's tail_held names
the shapes that keep no tail and stay NotImplemented(TexelsPastBufferLength):
a two-plane YCbCr, two-plane extended-range, 4:2:2, depth, stencil or BC
texture (another form than a shadow's copies of rows holds their texels),
and a rotated texture's stored frame (turned_plane), whose turned texels
past a surface are not measured.

Why. reims-vgpu's guests make such planes and Metal makes them; the
runtime refused them. On the M3 Max (macOS 27.0.1,
probes/surface_texture_envelope.m's bgra1.64x65, bgra1.64x128 and
420v.p1.32x512) Metal lays those texels out in no one place: its blits
read zeros past the surface, its kernels zeros and 32 KiB on the plane's
rows again, its getBytes zeros and other memory, and its writes there
change no byte of the surface. By the rule of 9ee7323e76, texels Metal
lays out in no one place go in a tail of the texture's own, announced;
the rows inside the surface stay in place.

Docs: API.md's degrade-notice catalogue gains the kind and its accepted
difference names the colour planes; FAST-PATHS.md's known gap and
TexelsPastBufferLength's doc name what stays refused; REFUSALS.md and
reach.tsv regenerated; api_signatures.tsv blessed for the new kind.

Tests: tests::buffer_tail_device::a_plane_past_its_surface_keeps_those_texels_in_its_tail
(64x17 over 4096 bytes and 64x16 from offset 2048: get_bytes, blit and
kernel rows inside and past the surface, a kernel write, a replace_region
past it, the buffers around unchanged, one notice); the validation lane's
a_plane_past_its_surface_is_made_and_announced (the notice beside the
forced shadow, the rows read and written past the surface, the buffer's
bytes kept), listed in degrade_notices; linear_plan's table rows for the
kept and refused shapes.

Verified (at the same tree content on the previous base, replay-27
9a1a8abf1d): lavapipe on homelab-gem10-1 (m3-max-4868) runtime lane
174/174 and validation lane 70/70, clippy --cfg m2v_cpu_icd clean;
msi-laptop (m3-max-4867) clippy plain clean, runtime unit 56/56,
conformance unit 53/53. Negative control: the runtime's sources at the
base with these tests fail a_plane_past_its_surface_keeps_those_texels_in_its_tail
(NotImplemented(TexelsPastBufferLength)). Re-checked on this base by the
branch's check job.

(cherry picked from commit 5ad2ed0b865ff4027488c398a09fc53c0a80ab2f)
2026-11-07 12:44:45 -08:00
Anees Iqbal 8de3a6023b Regenerate REFUSALS.md and the API signatures for RasterizedVoidVertex and open_gl_mode_enabled
(cherry picked from commit a479dc65fc8840b739a35c2e94b15dc4cdf81afa)
2026-11-07 12:12:33 -08:00
Anees Iqbal 93d2fc8b95 Link a kernel of OpenCL mode as Metal links it: hidden buffers and work-item reads
A compute pipeline Metal makes with openCLModeEnabled (Apple SPI) from a kernel of Apple's
OpenCL compiler (`__entry_<name>` of a library of sourceLanguage 1) binds three hidden buffers
ahead of the kernel's own and reads OpenCL C's work-item functions from the dispatch. Metal
refuses a plain pipeline of such a kernel ("Internal compiler error"). Measured on the M3 Max
(macOS 27.0.1, jobs m3-max-4483 and m3-max-4504): its reflection lists the kernel's arguments,
each buffer 3 past its index and __local memory at its own, then __global_offset_and_num_dims
(index 0, read-only uint), __printf_buffer (1, read-write char) and
__image_order_data_type_table (2, read-only uint), all used; get_global_id adds buffer 0's offset
to the grid position, get_global_offset and get_work_dim read buffer 0, and the other work-item
functions are the global built-ins of their names.

- ComputePipelineDescriptor::open_cl_mode_enabled, carried into LoweringInputs::open_cl_mode
  (part of the key) and SpecRequest::open_cl_mode; the stage-entry cache keys on it.
- air.get_global_offset.i32 and air.get_work_dim.i32 decode as AirIntrinsic::WorkItem.
- canon::opencl, after SCCP and before the global built-ins: appends the three buffers, makes
  get_global_id(c) the lane plus the offset word, the offset and dimension count loads from
  buffer 0, a dimension past 2 OpenCL's 0 or 1, and a dimension the kernel reads from its data a
  select over the three lanes; canon::opencl::entry moves the buffer-indexed arguments 3 on and
  adds the buffers' bindings, which the reflection's unspecialized path uses too.
- Without the mode the kernel compiles as Metal AIR and lowering refuses a WorkItem read
  (Unsupported, Lowering(Dispatch)).
- RuntimeFact::OpenClMode records the mode; a Compiled kernel of the other mode is
  InvalidDescriptor(OpenClMode). The runtime compiles its variants under the descriptor's mode,
  and its warm record carries the field (RECORD_FORMAT 5).
- SEMANTICS_VERSION 1991, ARTIFACT_FORMAT_VERSION 493 (a fact tag added).

Tests: canon::tests::opencl (indices, hidden buffers, the reads' rewrite), the translator's
engine_opencl_mode (the M3's reflection, slot writes, key, the mode check), and the runtime's
opencl_mode device tests (add, lsum, cmul and every work-item function against the M3's values).

(cherry picked from commit e2fdc7b4309c2c239cf1227d0a4c6c54552c1be0)
2026-11-07 11:43:21 -08:00
Anees Iqbal 803648acd8 Make a texture buffer over a buffer whose texels run past its length, those texels in a tail
What. Buffer::new_texture of a texture buffer whose texels run past
the buffer's length (inside Metal's allocation rule) is made instead
of returning NotImplemented(TexelsPastBufferLength), as a 2D texture
or array already is. Its texels inside the length are the buffer's
bytes; those past it lie in a tail of its own, a zeroed Shared buffer
the runtime owns, laid out from the functions' first byte (the offset
rounded down to 16, as Metal's kernels read a texture buffer).
- GPU: the texture buffer takes the staged form (StagedTextureBuffer,
  announced): its bindings view the tail as their staging buffer. The
  copy in takes the bytes inside the length from the buffer (none
  where the texels lie wholly past it), the copy back gives only those
  bytes back, and a Shared buffer's merge copies the current part from
  and to the buffer and the tail apart (staged_bytes, which now names
  a texture buffer's staging buffer as well as an image's, and
  record_out, which copies the staging buffer's every byte).
- CPU and blits: as for 2D, each row split at the length
  (Texels::past, whose rebase is now the tail's base, tail_base).
Only an IOSurface plane past its surface stays
NotImplemented(TexelsPastBufferLength); the gap's doc, its reach in
scripts/refusal-surface/reach.tsv, the StagedTextureBuffer catalogue
entry and docs/API.md's accepted difference say so.

Why. Plain Metal makes these: reims-vgpu's tbprobe on both x86 oracle
Macs (jobs m3-max-4019, 4046, 4152) and the M3 Max probe
(probes/texture_buffer_past_length.m, job m3-max-4617), whose paths
read and write the bytes past the length as one memory, as a 2D
texture's. The tail gives the 20000-byte buffer's answer for every
shape, as the 2D tail does.

Tests.
- tests/buffer_tail_device.rs: a texture buffer of 64 R32Uint texels
  from 3968 of a 4096-byte buffer (32 past) and from 4096 (all past):
  as made, after a kernel's write across the length (ob1_texel_buffer)
  and after replace_region past it, a kernel, get_bytes and a blit
  read alike; the buffer's words inside the length are written, every
  other word and 16 buffers around it keep theirs.
- linear_plan unit rows: texture buffers past the length made.
- runtime_lane::buffer_textures: the texture buffer at 3968 is made.
- Conformance: buffer-tails-texture-buffer, 1024 R32Uint texels from
  16384 of a 20000-byte buffer (904 inside): ob1_texel_buffer reads
  and writes, getBytes, replaceRegion, blits from and into it, the
  buffer's bytes; recorded on the M3 Max (3 runs, one outcome, every
  site the model's answer).

Verified:
- M3 Max, macOS 27.0.1: the probe (m3-max-4617) and the recording
  (m3-max-4640): buffer-tails-texture-buffer is made, announcing only
  the staged-texture-buffer notice, and the 2D tail cases still are.
- gem10 (m3-max-4635): clippy of the runtime (all targets, all
  features) and of runtime and validation under --cfg m2v_cpu_icd;
  the runtime's unit tests (70 of 70); the runtime lane on lavapipe
  (172 of 172, the new texture-buffer test among them); the
  buffer_textures, texel_swizzles and degrade_notices validation lanes
  (27 of 27).
- gem10 (m3-max-4662): rustdoc of runtime and conformance; the
  conformance unit tests over the tails, refusal, catalogue and
  accepted-difference rows (20 of 20); a lavapipe replay of the six
  buffer-texture cases, all six announced as the ledger expects.
  Clippy there named the shape test's two constant assertions, now
  const blocks; clippy of runtime and conformance and those unit
  tests again on this tree: m3-max-4688.
- Negative control (m3-max-4662): the runtime's sources at 5020e74ebb
  with these tests and cases fail the new device test with
  NotImplemented(TexelsPastBufferLength), and the replay refuses
  buffer-tails-texture-buffer at case/texture.

(cherry picked from commit f0a3390160064eabb820fbdc4f83822e0492fb5f)
2026-11-07 11:19:37 -08:00
Anees Iqbal 9ee7323e76 Make a 2D texture over a buffer whose texels run past its length, those texels in a tail
What. Buffer::new_texture and new_linear_texture of a 2D texture or a
2D array whose texels run past the buffer's length (inside Metal's
allocation rule, past which Metal answers nil and so does the plan)
are made instead of returning NotImplemented(TexelsPastBufferLength).
The texels inside the length are the buffer's bytes, exactly as
before; those past it lie in a tail of the texture's own: a zeroed
Shared buffer the runtime owns (Texels::tail), laid out from the
texels' first byte, and no other allocation's memory.
- GPU: such a texture is kept as a shadow image (ShadowedTexture is
  announced). The tail is the shadow's staging buffer; its copy in
  takes the bytes inside the length from the buffer, its copy back
  (staging rows clipped by inside_rows) writes only those bytes back
  to the buffer, and a Shared buffer's merge copies the current part
  from and to the buffer and the tail apart (shadow_merge.rs).
- CPU: getBytes and replaceRegion split each row at the length
  (past_runs, write_past).
- Blits: copies that name the texture's bytes split their rows at
  each side's length (RowsCopy::split) and copy the part past it
  from or to the tail; a copy with an ordinary texture goes through a
  scratch buffer of the encoder; synchronizeResource covers the bytes
  inside the length; the extended-range rewrite announces its note
  rather than binding the buffer's words past the length.
Texture buffers and IOSurface planes past the length stay
NotImplemented(TexelsPastBufferLength), whose doc now says so.

Why. Plain Metal makes these textures: reims-vgpu's oracle on the
AMD 5300M and the UHD 630 (4096-byte buffer, 64x16 and 64x17 at rows
of 256, offsets 0, 256 and 2048) and the M3 Max probe
(probes/texels_past_buffer_length.m, job m3-max-4337) for the same
shapes. Under Policy::Dies the refusal ended the consumer's host. The
M3 Max's paths agree that the bytes past the length are one memory:
the next allocation's over a 4096-byte buffer, the allocation's own
zeros over a 20000-byte one, read and written alike by every path.
The tail is the second answer for every shape; docs/API.md's accepted
differences records that the runtime never reads or writes another
allocation there.

Tests.
- tests/buffer_tail_device.rs (m2v_gpu / m2v_cpu_icd): 64x17 over
  4096 bytes, 64x16 at 2048, 64x80 over 20000 bytes (row 78 across
  the length), 64x1 wholly past, a Private buffer's, and a 2D array
  whose second slice is past the length; each path (kernel, blit,
  CPU) reads what each other path wrote, the buffer keeps its bytes,
  and 16 buffers around it keep theirs.
- Unit tests: linear_plan expectations (2D and array past the length
  made, texture buffers refused), RowsCopy::split, inside_rows.
- Conformance: buffer-tails-kernels (scout_read_u / scout_write_u,
  getBytes, replaceRegion, the buffer's bytes) and buffer-tails-blits
  (blits from a buffer across the length and from a texture past it,
  a copy out into a texture, blit and getBytes reads), RGBA8Uint
  16x256 at offset 4096 over 20000 bytes, recorded on the M3 Max
  (3 runs, one outcome, every value the model's).
- The runtime_lane assertion that a 2D array past the length is
  refused now asserts it is made.
REFUSALS.md and CONFORMANCE-COVERAGE.md regenerated.

Verified:
- M3 Max, macOS 27.0.1: probe m3-max-4337 (the shapes above); record
  m3-max-4492 (both cases, 3 runs, one outcome each, every site the
  model's answer); replay on MoltenVK m3-max-4508: buffer-tails-* and
  the four buffer-texture(s)-* cases announced (every value exact).
- gem10, lavapipe (LLVM 23.1.4, 256 bits), m3-max-4509: unit 71/71
  (linear_plan, buffer_texture, blit_plan, tail); device tests under
  m2v_cpu_icd 139/139 (the four buffer_tail_device tests and every
  buffer_texture, shadow and blit test); runtime_lane::buffer_textures
  7/7; conformance replay of the same six cases: all announced.
- Negative control, same job: the runtime's sources at 0e2c70f08f with
  these tests: the four device tests fail at Buffer::new_texture with
  NotImplemented(TexelsPastBufferLength), and both conformance cases
  are refused with it (case/texture, case/work).
- m3-max-4565: clippy -D warnings (runtime and conformance; runtime
  and validation under m2v_cpu_icd), rustdoc -D warnings, unit
  rows_split, buffer_tails, refusal and api_surface tests.

(cherry picked from commit e483e17c6c4d087a50a95cda297cf291934bee54)
2026-11-07 10:44:25 -08:00
Anees Iqbal 2984f58ae6 Admit an ARGB8Unorm attachment's input attachment for the function's own blend over it
On a device that orders fetch through rasterization-order input
attachments (lavapipe), f15f3b3738 has the fragment function compute
Metal's 8-bit unorm blend of an ARGB8Unorm attachment over its input
attachment where no Vulkan state on its rotated image gives the blend
(RuntimeFact::RotatedInputBlend). Link still refused every input
attachment of an image holding Metal's channels rotated, so each such
pipeline was refused NotImplemented(Format) at color 0: the lavapipe
replay's refusal of argb8-targets-destination-alpha, and the
engine_rotated_colors failure (its input-attachment arm never ran).

The refusal existed because a color input ([[color(n)]]) of such an
attachment would read the image's order. That reason is now structural
at the lowering: lower::fragment::color refuses a color input of a
rotated attachment (not one holding Metal's alpha in red) in the
input-attachment form, NotImplemented(Format) at the attachment, where
it was compiled knowing the attachment is rotated. Link admits a rotated
attachment's input attachment exactly where the stage states
RotatedInputBlend for that color (which fetch::input_blends has already
held to the pipeline's blend and mask), so a stage compiled for another
pipeline that reads one stays refused as before.

New test a_color_input_of_a_rotated_attachment_is_refused_over_its_input_attachment
(engine_fetch_blend8): compiled alone, the read of an ARGB8Unorm color 0
on every input-attachment profile is refused at the lowering; without
this commit it compiled (only link refused it). docs/REFUSALS.md
re-derived (color.rs select_param gains a site).

This changes translation outcomes, so it rides the branch's
SEMANTICS_VERSION (1989) when landed with it, or takes the next number.
Not yet run; the next job runs engine_rotated_colors, the new test and
the lavapipe replay.

(cherry picked from commit 5cf71464048d280e13d64b047bb6fa81df8e84e1)
2026-11-07 10:04:39 -08:00
Anees Iqbal 3a34b49814 Leave copies-only formats to format-footprints in the texture table, and refuse their fills
Two tests from the afb4e8cc2b copies-only change, which never had a whole
suite pass:

- textures' the_table_is_exactly_the_formats_whose_texels_are_metals_bytes
  wanted a texture-round-trip case for ARGB8Unorm_sRGB and the other formats
  now held for copies alone, since byte_format answers their R16_UINT or
  R32_UINT. format_footprints already records the same host round trip of
  each of them (fresh read, replaceRegion: over BEFORE, read back), beside
  the footprints and texture types Metal answers. So the table's predicate
  leaves them to that family.
- blit_fill's every_texture_format_has_a_fill_unit found no fill unit for
  them. A fill of such a texture reached
  internal("a fill of a format the runtime makes no texture of"). Metal's
  fills of these formats are not measured, so a fill is now refused
  Unsupported(Format, NotImplemented), named by its format, as their sparse
  textures are. fill_texture's doc and docs/REFUSALS.md (the new blit_fill.rs
  site, regenerated) say so, and the test excepts the copies-only formats.

Found by m3-max-4172 and m3-max-4304 (ms01).

The previous commit's message (ee5ba4cbab) says
candidates_are_known_formats already skips copies-only formats. The test
that does is direct_formats_round_trip.

(cherry picked from commit 9a22813ff057ffd81cce438c7a49652798f67bf7)
2026-11-07 10:04:13 -08:00
Anees Iqbal e2aa48a1dd Bless the API signatures for RuntimeFact::RotatedInputBlend and regenerate the refusal surface for rows2's sites
The argb8 commits (413c737777, 75e73605c7) add the RuntimeFact variant
RotatedInputBlend and move a Format refusal's sites; neither generated file
was refreshed on the branch. Verified: signatures.py --check passes after
the bless; refusal_surface.py regenerates with this change only.
2026-11-07 09:38:35 -08:00
Anees Iqbal 1fcaa5aa58 Read an executed indirect command's unstrided buffer at stride 2^32-1, as Metal does
An executed indirect command's kernel or vertex buffer set without an
attribute stride (the plain setter, or the stride form at
MTLAttributeStrideStatic), on an indirect command buffer that supports
dynamic attribute strides, under a layout of
MTLBufferLayoutStrideDynamic, was refused
NotImplemented(RuntimeGap::IndirectCommandUnstridedBuffer): plain Metal
reads it at the record's 32-bit stride word, 2^32-1 (measured on an M3
Max under macOS 27.0.1 with markers at bytes 2^32-1 and 2^32 of a buffer
past 4 GiB, compute and render alike; the stride form at 0xFFFFFFFF read
the same), which the 32-bit fetch could not place. The pulled fetch now
places a displacement past 32 bits (its reach check, a80982a04b), so both
executions bind such a buffer at stride u32::MAX
(indirect_execute::unstrided_stride), and without dynamic-stride support
at stride 0 as before. The RuntimeGap variant, its decision function and
the render side's reads_vertex_stride go; so does the validation
checker's rule that authored executions bind such buffers with the
stride form (check_replayed_strides), whose only reason was the gap.

Tests: the runtime's unit test now holds unstrided_stride's two answers;
the lanes a_command_s_unstrided_stage_in_buffer_reads_at_the_record_s_stride
(the plain setter's output equals the stride form's at 2^32-1 and
differs from the case's own) and
an_executed_command_s_unstrided_vertex_buffer_reads_at_the_record_s_stride
(both forms read word 0 then zeros). docs/REFUSALS.md re-derived. Not
yet run.

(cherry picked from commit e27523f44298026d8fefb19d2f65ccf96ee98bf7)
2026-11-07 09:37:11 -08:00
Anees Iqbal 50c03d4b54 Make a mesh render pipeline of maxVertexAmplificationCount above 1, and refuse its amplified draws
Metal makes a mesh render pipeline of maxVertexAmplificationCount 2 and
answers its limits as the plain pipeline's (the
mesh-limits-amplification-2 recording, M3 Max); the translator refused
it at creation, NotImplemented(VertexAmplification). Now it is made,
without multiview (a mesh pipeline draws no amplification as a view, so
graphics_requirements asks no multiview of it), and a draw of one
amplification, Metal's default, draws as a pipeline without
amplification does. The refusal moves to the draw of more than one: the
binder refuses a mesh pipeline's multiview route and its one-at-a-time
route alike NotImplemented(VertexAmplification) (the second was
MeshShading). No exact form is built: multiview may run the task stage
once a view where Metal runs the object function once a draw, and a
draw per amplification reruns it and needs the mesh function to add a
view mapping's offsets.

Test: engine_mesh's an_amplified_mesh_pipeline_draws_one_amplification
(made on every committed profile, no multiview requirement, a draw at
count 1, both routes at count 2 refused); the creation table's amp-2
row now expects the pipeline. docs/FAST-PATHS.md's known gap and
docs/REFUSALS.md follow. Not yet run.

(cherry picked from commit fe4aa26ba199c3bc8aedff48543623d09489122a)
2026-11-07 09:37:11 -08:00
Anees Iqbal 51b8007dd9 Docs for the formats held for copies alone
docs/FAST-PATHS.md's known gap of the 26 footprint formats now says
which twenty are held for copies alone and what stays refused (reads,
writes, renders, views, texel buffers' reads, sparse textures), and why
the four RGB10A8_2P formats stay unheld: Metal lays them out in two
planes, as RGB10A8_2P_XR10, whose blits between textures move both, and
one bytes image of the texel's word would not hold the second plane.
(The previous commit's message said Metal's blits of RGB10A8_2P move
two planes; that is RGB10A8_2P_XR10's measurement, not theirs.)

docs/API.md gains the accepted difference of seven of them, whose host
copies plain Metal leaves as no-ops at 16x16 under ShaderRead (the
format-footprints-padded-wide-channels recording), where the runtime
moves the bytes, as for the padded 10-bit formats Metal keeps
compressed. docs/REFUSALS.md re-derived (the sparse refusal's new
site).

(cherry picked from commit 8b4a0783997511a3ffcda495f3887749da56ca4a)
2026-11-07 09:37:10 -08:00
Anees Iqbal f085d298cb Regenerate REFUSALS.md for kept_bytes::settle's second Render site
kept_bytes::settle now matches NotImplemented(Render) from the pooled
backing of a DontCare colour (it keeps the pass in place there), which the
refusal surface reads as a second site of gap::Render. Regenerated with
python3 scripts/refusal-surface/refusal_surface.py; no refusal changed.

(cherry picked from commit 8ca3ed766dc2d022ace03a294694d78b03faf7a9)
2026-11-07 09:05:40 -08:00
Anees Iqbal 1edd55cb98 Read a stage-in layout bound with MTLAttributeStrideStatic as Metal does
Plain Metal on the M3 Max (macOS 27.0.1) answers each of the compute
encoder's four stride forms bound with MTLAttributeStrideStatic, under a
[[stage_in]] layout of MTLBufferLayoutStrideDynamic, with the element at
the bind offset for the first element and zero for every element past it
(the attribute-stride-* recordings). That is a fetch at the constant's
low 32 bits, 2^32 - 1, by the same truncation every other stride takes:
element 1 lies 2^32 - 1 bytes on, past the buffer (an ICB command read
the real byte there in a buffer that holds it). Ours mapped the constant
to "no stride" and read every element at stride 0 (three divergent
rows), and refused the inline-bytes form (one refused row).

- Runtime: a compute table's stride forms hold the argument's low 32
  bits, the constant included (argument_table::per_bind_stride); the
  plain setters still set none (stride 0), and a render stage's table is
  unchanged. fetch_reach then sees the constant's real reach.
- Bind layer: PushField::StageInStride pushes inline bytes' stride as a
  buffer's; the NotImplemented(KernelStageIn) refusal for bytes at
  u32::MAX is gone (REFUSALS.md regenerated).
- Translator: a kernel stage-in read that steps by thread position
  decides exactly whether its bytes lie in the first 2^32 bytes from the
  bind offset (e * stride + offset + size <= 2^32, without the u32 wrap;
  fetch::within_reach), and in a view whether the bind residual plus the
  displacement still fits; past it the read takes the bind offset and
  yields zero bytes on every device (access::pulled::prepare_within).
  Before, the wrapped displacement landed back inside the buffer (element
  1 at 2^32 - 1 + 4 read byte 3).

Removes the four attribute-stride-* rows of known-gaps.tsv.
SEMANTICS_VERSION 1981 (the orchestrator's number).

Tests: engine_kernel_stage_in::an_element_past_four_gigabytes_reads_zero
(every profile, with and without robustness: the constant on both
layouts, beside a stride of its own, and a stride of 2^32 - 8 whose
element 2 wraps to 2^32 - 16); tests::argument_table::
the_static_constant_is_a_compute_tables_widest_stride.

(cherry picked from commit f4d8011ccd1fe723c5192dd58e6b2eef7553fb37)
2026-11-07 06:26:29 -08:00
Anees Iqbal 2e8e0353b2 Regenerate REFUSALS.md for the input-form shadow's refusals
lower/fragment/input_shadow.rs refuses FramebufferFetch where the device
lacks the interlock, fragment stores, multisampled storage or the
shadow's storage format, and NotImplemented for the shapes it cannot
keep Metal's answer in (python3 scripts/refusal-surface/refusal_surface.py).

(cherry picked from commit 8a9d1405ec2dc326f1d78fd8831065ac75276e70)
2026-11-07 06:19:16 -08:00
Anees Iqbal ba7ed4d150 Bless the API signatures and regenerate the refusal surface for the submission checks and HostRam's dma-bufs
Removed: DriverFact::PointerImportsFollowTheirAddress and
DriverFact::SubmissionsWithoutSignalsMerge (in metal2vulkan::device and the runtime's
re-export). New: HostRam::with_dma_buf, Device::pointer_imports_follow_their_address, the
doc(hidden) Device::submissions_merge, fresh_pages_pay, settle_submit_checks and
submit_check_report, and WorkCounts submit_checks_run, submit_checks_recalled,
submit_check_calls, host_ram_dma_buf_imports and host_ram_pointer_imports_failed.
REFUSALS.md: Problem::DmaBuf gains its site in ram_span_as_dma_buf.

Verified: scripts/api-signatures/signatures.py --bless and
scripts/refusal-surface/refusal_surface.py (both read source only).

(cherry picked from commit 027b38e988e93373d58a26b388d0989a98809b33)
2026-11-07 05:45:53 -08:00
Anees Iqbal c559ed6f84 Docs: the half shadow holds at more than one sample; REFUSALS for the merge's refusals
The extended-range-blends-stored-codes notice (its declaration and the
docs/API.md catalogue entry) now says where it is not announced: a color
whose half shadow the runtime holds, in a pass of one layer on a device that
orders fetch through the pixel interlock alone, at one sample or more, from
the pass's clear or (at one sample) its load; and where the codes stay:
over lavapipe's input attachments, in a multisampled pass that loads the
color, and after a draw the shadow cannot follow. docs/FAST-PATHS.md's word
attachment row no longer says an extended-range color keeps its codes at
more than one sample. docs/REFUSALS.md regenerated
(scripts/refusal-surface/refusal_surface.py): link's second
extended_write_mask site and fetch::unordered_extended_fetch.

How verified: refusal_surface.py wrote the table with 0 variants without a
reach mark or a basis; the catalogue test runs with the runtime suite next.

(cherry picked from commit 70691da1d131573dac3a3c4ae4e6436ad48283f3)
2026-11-05 21:13:17 -08:00
Anees Iqbal b43ba48ee2 Regenerate the signature table and REFUSALS.md
What: api_signatures.tsv gains ComputePipelineProblem, its two variants and
DescriptorError::ComputePipeline; REFUSALS.md's RequiredThreads row says
only what creation refuses.
Why: the new public refusal and the corrected problem doc.
Verified: signatures.py --bless and refusal_surface.py on msi (job
m3-max-2689).

(cherry picked from commit 301047b4dc4f5f4f3a4d1725c9966e152f5b4fb0)
2026-11-05 21:13:15 -08:00
Anees Iqbal ee4a6c5b52 Bound texture ID placement by the handle table's reach
What: the runtime's set-1 image array capacity (resource_ids.rs
`texture_arrays`, which texture placements and texture reservations are
checked against) is now the least of the handle table's 65536 entries
(bind::HANDLE_TABLE_CAPACITY, within which link sizes every heap array) and
the update-after-bind image limits. Before, it was the limits alone. Each
array carries what bounds it (`ArrayBound`): a device limit, named in the
refusal as before, or the table. An ID past the table is refused
Unsupported(ArgumentBufferTextures, NotImplemented), since no heap array on
any device reaches it. `texture_arrays` and `check_capacity` are now free
functions over the compile profile, so a test reaches them without a device.

Why: this is the same gap `sampler_array` had before the samplercount work.
MoltenVK reports 1,000,000 update-after-bind sampled and storage images,
lavapipe 1,015,808, RADV 8388606, and ANV and NVIDIA more, so a texture
reservation between 65536 and those limits was accepted. Yet no set-1 array
holds such an ID: a texture placed there reads the neutral through its ID.
Placements are unaffected in practice, since Metal's placement limit (16381)
lies below the table's reach. Reservations of 65536 and more are now
refused where they were taken.

Tests: resource_ids::texture_arrays_reach_no_further_than_the_handle_table
checks every committed profile: each array is at most the reach, the ID
below its count is taken, and the ID at its count is refused naming its
bound. It pins MoltenVK, lavapipe, RADV, ANV and NVIDIA to the table and the
desktop baseline to its 128 sampled and 8 storage images a stage. Without
the fix, the pins fail (moltenvk-m3: 1000000). A new device test,
runtime_lane::resource_ids::a_texture_reservation_at_the_handle_table_s_reach_is_refused,
reserves texture ID 65536 (refused, not implemented, where the device's
limits reach past it) and 65535 (taken), printing a TEXTURE_RESERVATION
line. REFUSALS.md is regenerated (check_capacity, 2 sites). Verification
runs follow in the branch report.

(cherry picked from commit 9629f473e25790aa573b03d6c4419d99127f33ce)
2026-11-05 21:13:10 -08:00
Anees Iqbal 7d813def6f Regenerate the derived tables at stack 35's picks
The private-doc-link mend shortened the degradations! macro's note link and a refusal's doc link
to in-scope paths, which moves the macro's template in api_signatures.tsv and one row of
docs/REFUSALS.md; no item's signature changed for a consumer. The mesh change runs a partial object
threadgroup, so the two mesh-object-draws-partial-threadgroup cases leave the conformance ledger
(1378 rows to 1376) in docs/CONFORMANCE-COVERAGE.md, whose conflict the pick resolved to the
earlier text.

Verified: signatures.py --check, refusal_surface.py --check and conformance-coverage --check pass
on this tree; metal-coverage is current.
2026-11-05 17:14:20 -08:00
Anees Iqbal c305c66a7f Give mesh pipelines Metal's descriptor limits, state queries and refusals
The mesh descriptor gains Metal's fields, with Metal's defaults:
max_total_threads_per_{object,mesh}_threadgroup, max_total_threadgroups_per_mesh_grid,
the two threadgroup-size-is-multiple-of-width flags, payload_memory_length,
max_vertex_amplification_count (1) and required_threads_per_{object,mesh}_threadgroup. The
descriptor key reads every one.

A compiled mesh pipeline carries MeshPipelineMetalInfo (RenderPipeline::mesh_info), and the
runtime's RenderPipelineState answers Metal's five mesh queries from it, plus the two required
sizes. Each thread limit is the descriptor's maximum, else the function's
[[max_total_threads_per_threadgroup(n)]], else 1024, held to the device's own limit where that is
lower: the task and mesh stages' invocations with VK_EXT_mesh_shader, the compute stage's where
both stages run as compute work. The widths are 32. The grid limit is the descriptor's, else the
object function's [[max_total_threadgroups_per_mesh_grid(n)]], else 2^20, held to
maxMeshWorkGroupTotalCount where mesh functions run natively. Without an object function the
object stage answers 0 and 0, where the M3 Max answers 3 and 32 (an accepted difference).
DeviceProfile::emulates_mesh_shading says how a device runs the stages, so a consumer no longer
copies the compile layer's rule; with the getters, no separate per-stage query is needed.

What Metal refuses is refused as Metal's rule, DescriptorError::MeshPipeline with a
MeshPipelineProblem, measured on the M3 Max (mesh_pipeline_limits.m, plain and under
MTL_DEBUG_LAYER): a required size with an axis of 0, past 1024 threads or past its stage's
maximum, or for an object stage without an object function (process ends); a maximum past 1024,
a function maximum other than the descriptor's, a mesh stage's required size of other threads
than its maximum, and a payload past 16384 bytes (creation errors, codes 3 and 2). An
amplification count of 0 is VertexAmplificationCount, as a render pipeline's; one above 1, which
Metal makes, is NotImplemented(VertexAmplification), recorded in FAST-PATHS' known gaps.

payloadMemoryLength widens the object and mesh functions' payload arena past the declared type
(LoweringInputs::object_payload now reaches the object stage too); an object stage compiled on
its own without it is NeedsInput(ObjectPayload). SEMANTICS_VERSION 1971 and
ARTIFACT_FORMAT_VERSION 488 for that and the new artifact field; the runtime's warm record
format 4 for the descriptor's fields.

Docs: the new_mesh_render_pipeline_state doc now says how each device runs mesh stages, and
what it refuses; API.md's accepted differences gain the mesh pipeline rows. api_signatures
blessed (it also records RuntimeFact::PartialObjectThreadgroups from the partial-threadgroup
commit), api_surface lists MeshPipelineMetalInfo and MeshPipelineProblem, REFUSALS.md,
METAL-COVERAGE.md and CONFORMANCE-COVERAGE.md regenerated.

Tests: engine_mesh's a_mesh_pipeline_answers_metals_mesh_queries_within_the_device and
a_mesh_descriptor_metal_refuses_is_refused_as_its_rule over every committed mesh and
emulating profile; the validation lane's
a_mesh_state_answers_metals_queries_and_refuses_what_metal_refuses on a device. Not yet built:
the next steps are the M3, lavapipe and RTX 5080 runs.

(cherry picked from commit d6934967fad363ca2185c49935204141f253b416)
2026-11-05 17:12:37 -08:00
Anees Iqbal 5080707c8c Document the surface shapes and BC textures the runtime makes
linear_plan.rs gains **Block-compressed surfaces** and **Beyond the
plane's rows** (the probe's measurements and what the runtime holds);
new_texture_with_iosurface_plane names the new shapes and the
SurfacePlaneShape refusal; TexelsPastBufferLength records where the M3
Max puts rows past a surface's end and that the x86 Macs' are
unmeasured; FAST-PATHS.md's known gaps record the refused shapes and
the taller-than-plane divergence on the x86 Macs, which IoSurfacePlane
cannot hold as it carries no plane height. Regenerated docs/REFUSALS.md
and api_signatures.tsv (RuntimeGap::SurfacePlaneShape).

Verified: refusal_surface.py (0 variants without reach or basis);
signatures.py --bless. Rustdoc runs in the next M3 job.

(cherry picked from commit d3bb1dfa2aab94728518529a0b2020da4a3e76aa)
2026-11-05 15:26:47 -08:00
Anees Iqbal a0bebe78f1 runtime: copy runs of a guest RAM to and from a buffer on the GPU, from the chunk imports
`BlitCommandEncoder::copy_from_host_ram(ram, runs, destination, destination_offset)` gathers runs
of a `HostRam` the device uses into consecutive bytes of a buffer, and
`copy_to_host_ram(source, source_offset, ram, runs)` scatters them back (a runtime extension:
Metal has none). A surface that is a scatter of guest pages is copied straight from the RAM's
64 MiB chunk imports, with no view mapped per surface (one mmap per run) and no import made per
surface.

How: adjacent ascending runs merge, descending neighbours stay apart; runs are cut at chunk ends;
the 4 KiB pages become a table in the command buffer's upload arena, and each chunk the runs touch
takes one dispatch of the new `bind::pages_copy_module` (more only past the storage-buffer range
or the workgroup count). A chunk not imported yet is imported, or its pending import waited for,
as an object over it does.

Ordering: each chunk a copy uses gets a resource key placed over the chunk's host bytes in the
host-alias placements, the way no-copy buffers and heaps are placed, so the copy's chunk uses
(joined to at most 16 ranges per chunk) order against other copies and against every no-copy
object over the RAM's own addresses, in one encoder and across encoders; the buffer side is
tracked like any blit. A scatter's writes reach the RAM's dirty log as the GPU's in place, so a
copied backing over those pages takes them in at its next commit. Objects made over another
mapping of the pages (a view resolved through `with_runs`) are not ordered against the copies.

Refused with `Problem::HostRam`: an empty run, one off 4 KiB, one outside the RAM, a RAM the
device does not use, buffer bytes off a 4-byte word; no host import is `Unsupported`; bytes past
the buffer are `RangeOutOfBounds`. Replayed at rebinds (`BlitCall::HostRamCopy`). New counters
`host_ram_copies`, `host_ram_copy_bytes`, `host_ram_copy_dispatches`. README, HOWTO, the
API signature rows and docs/REFUSALS.md updated.

Verified:
- On this M3 Max (MoltenVK), --cfg m2v_gpu under nextest: the five new device tests
  (`tests::host_ram_copy_device`: round trips byte for byte over ascending, descending, adjacent,
  repeated and chunk-crossing runs into Shared and Private buffers; CPU writes before the commit
  gathered and a scatter's bytes in the pages after completion; the two hazard cases in one
  encoder and across encoders; a copied backing over the pages taking a scatter at the next
  commit; the refusals) and the ten `tests::host_ram_device` tests: 15 passed.
- Negative controls, each a saved build: merging descending neighbours fails
  `adjacent_ascending_runs_merge_and_descending_ones_stay_apart` and
  `a_gather_and_a_scatter_move_every_runs_bytes_in_order` ("the gathered bytes"); not placing the
  chunk keys over the host bytes fails
  `copies_are_ordered_against_a_no_copy_buffer_over_the_same_pages` ("a later reader sees the
  scatter"). The first control found the test pattern repeating every 1 KiB, so a page swap
  went unseen; the pattern now differs per page.
- The `host_ram::copy` unit tests (merge, refusals, chunk cuts, the plan, the joined uses) and
  `consumer_auto_traits`; clippy --workspace --all-targets --all-features -D warnings, plain and
  --cfg m2v_gpu; rustdoc -D warnings; `signatures.py --check` after the bless; the refusal
  surface `--check`.
- The ignored release bench `tests::host_ram_copy_bench` on the M3, a 3840x2054 BGRA8 surface
  (31,549,440 bytes, 31,551,488 in whole pages) scattered over 1 GiB of shared RAM: 7703 4 KiB
  runs (5490 descending neighbours, 7279 runs after the merge) take 16 dispatches, 0.35 ms of CPU in the call, 0.59 ms of GPU and 0.64 ms from commit to completion
  for a gather (scatter 0.37 / 0.58 / 0.64). The view path at the host's 16 KiB page (1926 runs:
  a view mapped run by run, a buffer `with_runs`, a buffer-to-buffer copy, the release) takes
  1.58 ms to map, 2.36 ms to make the buffer, 0.99 ms commit to completion and 0.78 ms to
  release; the gather of the same 1926 runs takes 0.14 ms CPU and 0.60 ms commit to completion.
Ported onto gate/stack27, where the device's thread imports a window of chunks ahead of the
objects (paced, with the memory lock released, short of maxMemoryAllocationCount and giving back
what no object took). The conflict was `RamOnDevice`'s fields alone: the copies' `ChunkKeys` sit
beside the window and its wake, and the old cursor is gone. The copy still takes each chunk
through `RamOnDevice::chunk(.., By::Object)`, the objects' own path, which now moves the window
past it, wakes the thread and clears the chunk's untaken mark; there is no second import path. The
copy module docs and HOWTO say so. The ignored release bench waited for every chunk imported
ahead, which the window never does; its warm-up copy now imports the chunks the runs touch.

The verification above was on the old base; this tree's is in the commit that follows.

(cherry picked from commit 923718777c198bef526dd07f701fc71a71e07b00)
(cherry picked from commit fa00224f7b29ab0359c8305a47da9c9273fc5d37)
2026-11-05 00:43:50 -08:00
Anees Iqbal 61a9508e92 Build visibilityResultType: Accumulate takes a pass's results into the buffer's words
RenderPassDescriptor gains visibility_result_type (MTLVisibilityResultType: Reset, the default
and today's behaviour, and Accumulate). Under Accumulate no query result is copied over its
offset's word: every query of an offset, the first one too, is copied into the upload region the
continuations already use, and the crate-owned combine takes them into the word as the buffer
holds it. The combine already loaded the destination word as its accumulator, so Accumulate is
the first query becoming one more source. A `Boolean` word ORs the device's results in; a
`Counting` word is summed in through a new table mode of the combine, into the word's low 32 bits
alone, wrapping there, its high 32 bits kept (ContinuedResult::low_half / in_low_half). That last
part is what the M3 Max answered when recorded: 0xffff_fff8 plus 16 samples writes 8, and
0xffff_ffff_ffff_fff8 plus 16 writes 0xffff_ffff_0000_0008. A plain 64-bit sum was divergent there.
An offset set with no draw after it keeps its word, because a query with no draw adds 0. Where a
no-copy buffer's bytes start off a multiple of 8, so the results land in an upload region, the
words are now copied into that region before the combine (Landing::inward). Reset records exactly
what it did before.

Conformance: RenderPass gains visibility_type (typed()), and words() appends it only where it is
not Reset, so existing fingerprints read as before. Both sides set it. There are four new
visibility cases, recorded on the M3 Max (macOS 27.0.1): visibility-counting-accumulate (two
command buffers; words 100/5/7/0xffff_fff8/u64::MAX-7), visibility-counting-accumulate-one-command-buffer
(two passes in one command buffer, read once), visibility-counting-accumulate-revisit, and
visibility-boolean-accumulate (words 0/2/3 under covering and non-covering draws, an offset set
with no draw, then a second command buffer). The family's acts key states the type, and a joined
shape adds a command-buffer input. Cost and timing records for the new cases are not written here.

Lane tests (runtime_lane): accumulated_counts_add_to_the_words,
accumulated_booleans_or_into_the_words, and
host_bytes::accumulated_visibility_results_land_where_their_bytes_lie. Unit tests: the combine's
accumulated_counts_are_summed_into_the_low_half, its plan's table mode, and the type's raw values.

Coverage: coverage.tsv marks MTLRenderPassDescriptor.visibilityResultType implemented (its unused
"visibility" group is removed), and METAL-COVERAGE.md is regenerated. MTLVisibilityResultType joins
the enum table, so metal_enumerators.tsv and CONFORMANCE-COVERAGE.md are regenerated. The API
signatures are re-blessed. REFUSALS.md is regenerated: VisibilityResultType::from_raw is one more
UndefinedValue site. The regeneration also picks up two bind/graphics.rs sites the committed file
was missing. The degrade docs (landed results, Boolean) state Accumulate.

Verified on the M3 Max under MoltenVK 1.4.2:
- The 52 visibility-touching lane tests pass: visibility, host_bytes, depth_never, amplified_draws,
  degrade_notices and the framebuffer_fetch split pass.
- The visibility family's replay is all announced (no divergence), after the low-half change.
- Negative control with Accumulate forced to Reset: all three Accumulate lane tests fail, and all
  four new cases replay divergent.
- Negative control with no inward copy: the landing test fails at 4 bytes past a page (2 read 0,
  100 read 16).
- Before the low-half change, visibility-counting-accumulate replayed divergent at words 3 and 4.
- The combine's low-half test fails on the interpreter without the high-half select ([8, 1] for
  [8, 0]).
clippy (plain and --cfg m2v_gpu), rustdoc and scripts/api-docs are clean.

SEMANTICS_VERSION: no translated shader changes, but the owned combine module's words do
(main's call). RUNTIME_VERSION and the runtime-sources pin are not touched here.

(cherry picked from commit 1c172968ad6492cebcae2a568fc99e90565d4d11)
(cherry picked from commit 9f47ebcf006920f7561a16a77f77e422de7201c1)
2026-11-03 11:08:01 -08:00
Anees Iqbal 51c7059a40 Regenerate docs/REFUSALS.md: KernelStageIn's site and the rebind_slots range refusals
python3 scripts/refusal-surface/refusal_surface.py on this tree. Two rows move:
- KernelStageIn's runtime site is indirect_execute.rs's dispatch now, where the kept recordings
  of unchanged indirect commands moved the refusal (two commits back), not record;
- BufferRange and DescriptorRangeExceeded gain bind/graphics.rs's rebind_slots, a site the base
  had added without regenerating the table.
The device replay's ReplayFaults::ADDRESS was no refusal, so its removal moves no row;
tests/api_surface.rs names ReplayFaults alone, and api_signatures.tsv dropped the constant with
it (scripts/api-signatures --check passes).

Needs no version bump: a generated document.

(cherry picked from commit 07d7e05255a3d15ba98094389a680e96440eefa0)
(cherry picked from commit 3d66d7436109ffbd80c5e6adf0ef1d92b26d70e5)
2026-11-03 09:25:30 -08:00
Anees Iqbal 510e0c0cca Share VkQueues between command queues where the GPU idles at each switch, with an unshared opt-out
What: a new DevicePolicy switch, queue_sharing: QueueSharingPolicy { Adaptive (default),
PerQueue }; exact_answers() selects PerQueue. Under Adaptive, on a device whose own self-check
finds its GPU idle when consecutive work comes from another VkQueue, a command queue chooses its
VkQueue again each time it makes a command buffer while it holds no other uncompleted one (the
slot take with held.all == 1, under its slots lock): it joins the busy VkQueue of its family
whose oldest batch has run under 0.5 ms, the most batches in flight first, then the latest
submission (Device::pick_vk_queue: one pass of atomics over the round robin's VkQueues, no lock).
A queue whose batch ran over 2 ms as its VkQueue's oldest is marked long by the waiter that saw
it complete, under the completion's pending lock, before the turn that finishes it
(command_buffer/completion.rs); no queue joins a long queue's VkQueue, and the long queue moves
once more at its next idle point, to the least recently used idle VkQueue no long or unshared
queue holds. Its mark moves with it and a dropped queue subtracts its marks. Presenting queues and
a queue that lent its VkQueue (with_vk_queue, pinned from then on) never move. A queue's vk_queue
is now an atomic; everything that reads it does so between a command buffer's make and its
completion, when no move can happen.

The self-check (queue_switch_check.rs) is the runtime's own, kept like the in-place check's, not
a DriverFact row: on a thread of its own, once per driver, release and runtime, 24 rounds of two
timestamp-only batches held behind one host-signalled gate on two same-family VkQueues against
24 on one; the switch cost is the difference of the median gaps; Idles above 20 us, DoesNotIdle
below, Unchecked where the device has no calibrated timestamps, no two VkQueues of one family, or
a run failed. Its verdict is written as one record in the shader cache's content directory and
read back as the next device of the same driver, release and runtime is made. Before the verdict,
every queue keeps the VkQueue it took at creation.

Device::new_command_queue_unshared(count): a queue that never moves and that no adaptive queue
joins; a queue already on its VkQueue leaves at its next idle point. Placement where the device
shares: a round-robin VkQueue no command queue holds, least recently used first; else one no
long or unshared queue holds, the fewest queues first; else the round robin's next. Why that
order: an empty VkQueue gives isolation at once, with no wait for another queue's idle point; of
the empty ones the least recently used is the one least likely to hold a moving queue's work in
flight (a queue that just left it may still have batches there, and the unshared queue would
wait behind those); where none is empty, the least held one has the fewest queues to move off,
each at its own next idle point, so isolation arrives soonest, and a VkQueue a long or unshared
queue holds is never taken since that would put the opt-out behind exactly the work it opts out
of. A queue's claim of a VkQueue and an unshared queue's are ordered so that two at once never
both succeed: each counts itself there first, then reads the other's count (SeqCst both sides).
Under PerQueue, and where the device does not share, it is
new_command_queue_with_max_command_buffer_count. A count of 0 and a lost device are refused.

Why: NVIDIA 615.71.09 on the RTX 5080 Laptop GPU leaves the GPU idle 56 to 62 us whenever its
next work comes from another VkQueue, so one VkQueue per command queue, round robin, capped eight
threads' one-draw command buffers at 25,800 to 29,500 a second (GPU idle 60% of its time at the
switches), where one VkQueue ran 54,700 to 58,700 (the audit that set this design). Moving only
at idle points keeps every queue's own order without a cross-queue fence. The cost is the
runtime Degradation kind QueueSharing ("queue-sharing", performance), announced once per device
at the first join, in CommandQueue::command_buffer on the making thread: the first long command
buffer of a queue that shared holds the command buffers committed behind it on its VkQueue for
its whole length. The opt-out exists so a compositor never pays even that one stall.

Counted: WorkCounts::queue_moves, queue_joins, queues_gone_long, long_queue_settles,
queue_moves_off_unshared, joins_withheld_from_unshared, queue_switch_checks_run and
queue_switch_checks_recalled. The policy keys no profile (tests::fast_paths), so
SEMANTICS_VERSION does not move. Docs: FAST-PATHS row, docs/API.md (the policy and the notice
catalogue), the runtime README (the opt-out, with_vk_queue's pin), queue.rs's module doc on
isolation; REFUSALS regenerated (the new site of MaxCommandBufferCount); api_surface and
api_signatures (additions only). The example queue_share runs the workloads under either policy.

Verified: cargo clippy --workspace --all-targets --all-features -D warnings, and the runtime and
validation crates with --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc --workspace
--all-features --no-deps; nextest of tests::queue_share (the choice, settling, the unshared order,
the record), tests::fast_paths, tests::degradation*, api_surface, work_counts: 66 passed. On the
RTX 5080 Laptop GPU (release) the check answered Idles at 51.3 us, and its form measured 49.0 to
50.7 us in five more runs, where a chained form measured 53.2 to 59.3 us. The device tests
(tests::queue_share_device, runtime_lane::command_queues::a_queue_joining_...) are not yet run
on a GPU in this commit.

(cherry picked from commit a2f17a5132faf0312fb3953d634e21c927cde62e)
(cherry picked from commit 862b2cb49a9481d0a2a19fb1bc3acec79932d1bd)
2026-11-03 02:49:35 -08:00
Anees Iqbal 888dbbbf2f Refuse each constants-block record outside the typed model by LLVM's name
What: `Feature::Constant { code: u32 }` becomes
`Feature::Constant { record: ConstantRecord }`, in the front end and the
translator, which re-exports the new `ConstantRecord`. ConstantRecord is
non-exhaustive, one variant per LLVM name:
- Select, ExtractElement, InsertElement, Compare;
- ShuffleVector (CE_SHUFFLEVEC and CE_SHUFVEC_EX);
- BlockAddress, UnaryOp, DsoLocalEquivalent, NoCfi, GepWithInrange;
- PtrAuth (PTRAUTH and PTRAUTH2), Byte (BYTE and WIDE_BYTE);
- PtrToAddr: a CE_CAST of `CAST_PTRTOADDR`.
Each record is matched from its code (`codes::cst_unsupported`). A code
LLVM does not define stays `UnknownRecord`.

A refusal now reads `Constant { record: Select }` where it read
`Constant { code: 13 }`. The names and codes come from
`LLVMBitCodes.h` of the local LLVM 21.1.8 and 23.1.4 toolchains
(`ConstantsCodes`, `CastOpcodes`).

WIDE_INTEGER stays malformed, on purpose, with a comment that says why.
LLVM writes it only for an integer wider than 64 bits. The type table
already refuses those types (`Feature::Type`). So a WIDE_INTEGER that
reaches the constants block has a type of at most 64 bits, which LLVM
never writes.

Why: a refusal should name what it refuses. The inline assembly record
(code 30) reached a consumer as a bare `Constant { code: 30 }`; it now
decodes, and this names the rest of the class.

Verified (debug):
- metal2vulkan-air suite passes, including `constant_errors_are_typed`:
  - each of the 15 refused codes yields its name;
  - CE_CAST opcode 13 yields PtrToAddr, opcode 14 is malformed;
  - WIDE_INTEGER of an i32 is malformed;
  - code 60 is UnknownRecord.
  At the base the test does not compile (no ConstantRecord), and the
  refusal there was the bare code.
- The translator's api_surface, api_signatures (blessed: the new enum,
  its variants, the changed variant) and refusal_surface tests pass.
- clippy -D warnings, workspace, all targets, plain and --cfg m2v_gpu.
- docs/REFUSALS.md regenerated (the row's doc text).

The census changes no outcome: no private-corpus row was refused with a
constants-block code at d3e66f9415 or after the bit-manipulation change
(nvidia-rtx5080-laptop and moltenvk-m3).

SEMANTICS_VERSION 1954 -> 1956 (a refusal's class changes): the lane's
value plus one after f19e887e4a takes 1955.

Golden tables: none move (no fixture holds such a record).

(cherry picked from commit 2af3e7891ee1ce7893107ff69f32ea879a06a56c)
(cherry picked from commit 94412279d2b277a2b9cfc11a83fc1e231ef91ecb)
(cherry picked from commit 3f5560c3fd7da0edab9a10d6b951986d8fcc6f80)
2026-11-03 02:25:30 -08:00
Anees Iqbal 1e44dcf8da Drop the call of MSL's empty inline assembly at decode: asm sideeffect "", "" of void ()
What: decode drops a call whose callee is the inline assembly expression `asm sideeffect "",
""` at the call type `void ()`, the way it drops the markers: the call takes a record number
but no instruction. The match is structural and exact:
- the call type is `void ()`, not vararg, with no arguments;
- the template and the constraint string are empty (no operand, result or clobber);
- `sideeffect` is the only flag (no alignstack, inteldialect or unwind).
Any other inline assembly stays an indirect call through its constant. post_check refuses it
as InlineAsm by name where an entry reaches it.

Why: MSL accepts exactly one asm statement, an empty `asm("")` / `asm volatile("")`. A
template, an operand or a clobber is "illegal asm statement" (Metal 32023.922). That statement
always compiles to this call, attributes {convergent nounwind}. It assembles to no
instruction and names nothing it reads or writes. Its `sideeffect` only constrains Metal's
optimizers: they may not remove it or move a memory access across it, and a loop holding it
is kept. A shader generator writes it into loop bodies for that reason. No value a race-free
program computes depends on it. The decode-only refusal of the previous commit still ended
the consumer's VM, so the drop is what fixes their S1. Refusing it would refuse every
pipeline whose generator writes it.

The edge, documented in docs/API.md's accepted differences ("Inline assembly"): a racy spin
loop over plain (non-atomic) memory could tell the barrier is gone, and MSL's memory model
leaves that loop undefined. A loop with a visible effect runs every iteration either way.
The drop records no note and no degrade: it is no precision difference, no value changes.

Fixture: engine/kernel_inline_asm's asm_in_loop now stores every partial sum, the final sum
and its iteration count. The trip count comes from a buffer. All three entries translate.
REFUSALS.md is regenerated: InlineAsm's doc and its reach mark, now `none`, since only
hand-written AIR can hold another asm.

Verified (M3, macOS 27):
- engine_inline_asm, through both llvm-as and xcrun metal-as:
  - asm_in_loop, asm_in_helper and asm_free translate, link and validate on all 19 committed
    profiles;
  - asm_in_loop on the CPU interpreter with n = 6 over 4 threads writes every expected word
    in both scheduling orders: every iteration stored;
  - synthetic modules with "nop", "~{memory}", an "=r" result, no sideeffect, and alignstack
    each refuse as InlineAsm naming the expression; the empty one translates.
- Negative control: with the drop disabled, all three engine tests fail.
- metal2vulkan-air suite: 492 pass.
- metal2vulkan: the air_input, air_canon and air_abi sweeps and the api surface and
  signatures checks pass. The text-shape sweep discounts the dropped call, as it does the
  markers.
- clippy -D warnings in both configurations.
- Golden printout of kernel_inline_asm re-blessed: only that file.

Still owed a bless on development, new rows only:
- golden_hashes.tsv: the fixture's cells, all new;
- public_fixture_expectations_engine.tsv: 2 fixtures.
SEMANTICS_VERSION stays 1950, landing together with the previous commit.

(cherry picked from commit 53c6faaf4d2215fc3e629b39803f47979d71f765)
(cherry picked from commit f9361582833d1f5ca0c151d42d68e3cfa7e228af)
2026-11-03 01:11:49 -08:00
Anees Iqbal 6e67fd2a08 Decode inline assembly constants; refuse a reached call of one as InlineAsm
What: the bitcode reader now decodes CONSTANTS_BLOCK record 30 (INLINEASM, LLVM 13+, which
names its function type) and the older spellings 18, 23 and 28 (typed by their pointer's
pointee) into a new constant, Const::InlineAsm, which keeps the template, the constraint
string and the four flags as written. A call through it stays Callee::Indirect. Canon's
post_check refuses such a call that an entry reaches as Unsupported(InlineAsm), not
implemented, naming the expression (`asm sideeffect "", ""`). An entry that reaches none
translates, even when other functions of its module call assembly.
- The verifier holds the constant to LLVM's rules: a `ptr` in address space 0, never another
  constant's operand or a global's initializer, and only ever a call's callee.
- A record that does not fit its spelling is MalformedRecord: an undefined flag bit, a
  function type that is none, a string past the record, a byte above 255, a trailing operand,
  or an old spelling over an opaque pointer.
- Feature::InlineAsm is new in both crates (REFUSALS.md regenerated, reach mark `app`).
- The validation AIR writer spells the constant back.
- The constant interner charges the strings to the ledger.

Why: the consumer's sweep refused a whole render pipeline as `Constant { code: 30 }` (a
WebGPU deferred-rendering page in Safari), so the pass drew nothing. The record was refused
as it was read, so every entry of the module was lost, whether or not it called the assembly.
MSL accepts exactly one asm statement: an empty template with no operands and no clobbers.
`asm("nop")`, `asm volatile("" ::: "memory")` and `asm volatile("" : "+r"(x))` are all
"illegal asm statement" (Metal 32023.922). It always compiles to `call void asm sideeffect
"", ""()`, attributes `convergent nounwind`.

Fixture: engine/kernel_inline_asm, our own MSL, holds three entries.
- asm_in_loop: the statement in a loop body.
- asm_in_helper: the statement in a noinline helper.
- asm_free: no assembly of its own.
Its .ll and .air.ll are from scripts/regen-air-fixtures (LLVM 21), and its golden printout
is blessed (tests/air_input/kernel_inline_asm.txt, only that file changed).

Verified (M3, macOS 27):
- New reader tests: every spelling decodes, every malformed form is typed, and an aggregate
  holding the asm fails verification.
- New engine tests, through both llvm-as and xcrun metal-as: asm_free translates, links and
  validates on all 19 committed profiles; asm_in_loop and asm_in_helper refuse as InlineAsm by
  name.
- Negative control: with record 30 refused as before, all four tests fail.
- metal2vulkan-air suite: 492 tests pass.
- metal2vulkan: the air_input, air_canon and air_abi sweeps and the api surface and
  signatures checks pass.
- metal2vulkan-validation fixture, writer and audit tests: 74 pass.
- clippy -D warnings in both configurations, plain and --cfg m2v_gpu.

Tables owed a bless on development, new rows only:
- golden_hashes.tsv: 114 new cells, 3 entries x 19 profiles x 2 spellings.
- public_fixture_expectations_engine.tsv: 2 new fixtures.

SEMANTICS_VERSION 1950: refusals change class (Constant -> InlineAsm, or a translation).
api_signatures.tsv is blessed: additive (the InlineAsm struct and variants). A consumer that
matches Const or Feature exhaustively must add the new variants.

On the lane: SEMANTICS_VERSION is 1953 here, after the specialization folding's 1952.
(cherry picked from commit 8b418fbd6c)
(cherry picked from commit c8a7e910204a6cedad2b257a10cb095d83c213e3)
2026-11-03 01:11:48 -08:00
Anees Iqbal fd7c93af53 Run a command buffer's completion-seen handlers where its completion is seen
What: `CommandBuffer::add_completion_seen_handler`, a runtime extension with no Metal
counterpart. Its handlers run as the command buffer's transition to `Completed` or `Error`
runs, right after its status, error and GPU times are final, before its completed handlers
and before `wait_until_completed` returns. A transition with completion-seen handlers and no
completed handler runs where seen (`Transition::where_seen`, `Run::runs_where_seen`), on the
queue's waiter, as a plain one does: no handler-pool turn. Where the transition is posted (a
completed handler, an earlier transition of the queue in its context, a deallocator of the
program's held), the handlers run in it on the handler thread, so they keep the queue's commit
order against every completed handler. A wait in one for what has not happened is refused
with the new `DeadlockCause::CompletionSeenHandler`, as a submission handler's is, wherever it
runs. `Contexts::run_here` takes the predicate its caller may run: the waiters and the
scheduler (`exit_guard::serving_completion`) run where-seen items, any other thread plain
ones only.

Why: the consumer's per-command-buffer completion pays a handler-pool wake after the waiter
(about 100 us from an idle CPU on the RTX 5080 laptop, and its p90 tail). Its completed
handler is short and posts a record; moved into a completion-seen handler, the command buffer
finishes on the waiter with one wake fewer.

Order choice: the handler runs inside its transition, never ahead of it, so a command buffer's
completion-seen handler cannot run before an earlier command buffer's completed handler on the
same queue's context; it runs at the turn only where that context holds nothing else.

Counted: `WorkCounts::completion_seen_handlers_run` and
`completion_seen_handlers_where_seen`.

Verified (M3 Max, MoltenVK, under the GPU lock): `tests::completion_here` (the new
`a_completion_seen_handler_runs_where_the_completion_is_seen`: 20 of 20 ran on
`metal2vulkan-queue-wait-*`, status `Completed`, GPU end positive, own completion wait refused,
own scheduling wait returned; with a completed handler 0 of 20 where seen, each before the
completed handler), `tests::own`, `tests::contexts` (the new where-seen run_here test): 24
passed. Negative control: with completion-seen handlers making the transition not where-seen,
the new test fails (0 of 20). Workspace clippy (all targets, all features) and runtime clippy
under `--cfg m2v_gpu` clean. api_signatures blessed, docs/REFUSALS.md regenerated.

(cherry picked from commit bb7fd805045a9903a3a1ae06595e264ad771049c)
2026-11-02 22:30:22 -08:00
Anees Iqbal 66d39ceb8e Regenerate the refusal surface for buffer_into_texture's sites
What: docs/REFUSALS.md regenerated (python3 scripts/refusal-surface/refusal_surface.py). Three
refusals' sites (OverlappingSurfaceRows, MultisampledBufferCopy, Copy) now name
blit_texture.rs's buffer_into_texture, where the previous commit moved
copy_from_buffer_to_texture's body so a fill's row copies share it.

Why: the generated surface names each refusal's building function; no refusal, RuntimeGap or
basis changed (0 variants without a reach mark, 0 without a basis).

(cherry picked from commit ead4b73a198ad597b502de5f20b246c64c9424c2)
2026-11-02 13:13:18 -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 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 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 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 b3d483fd72 Draw triangles' wide edges as bands, and refused bands at the nearest width
Metal draws a triangle in fill mode Lines at a width other than 1 as its
three edges, each the line parallelogram, facing as the triangle does and
culled by it, its flat inputs from the provoking vertex (the probe's
`edges` case, committed with the lane before this). The runtime drew
those edges with the device's lines, at the nearest width they draw (1
pixel on MoltenVK), announced.

Translator: the band variant takes a primitive (`BandPrimitive`, in
`VariantKey::line_band`, `LineBandState::primitive`, `BindState` and
`BindShape::line_band`). A triangle's patch is its three vertices in the
quad domain at outer levels (11, 1, 6, 1) and inner levels (3, 2): the
inner ring degenerates to a segment, so the spec's deterministic fans
from its two vertices cover the u = 0 and u = 1 edges, and the
evaluation stage places those fans' vertices at the corners of the
edges' parallelograms (from the vertex of the largest w, which never
moves at the near plane), every other triangle degenerate. The band
faces as the triangle (the sign of its homogeneous determinant, a
zero-area one back) by turning the minor axis, so the draw's own cull
mode, front face and depth bias apply. `LineBandState::PATCH_CONTROL_POINTS`
gives way to `BandPrimitive::patch_control_points`. A pure test checks
the fan tables against the spec's triangulation: every triangle is
degenerate or one of the nine that cover the parallelograms once, and
each winds as a line's band, turned by the facing.

Runtime: a triangle's edges (lists, strips, fans, Metal's private
triangle types) route as lines do: the device's lines where they draw
the width, else the band, on every device with tessellationShader;
strips are listed, the last provoking vertex read from the list led by
it. The band's depth bias is the device's per band triangle: announced
(new `Degradation::WideEdgeDepthBias`) under a slope factor or a
constant over a float depth. A pipeline state whose band variant the
translator refuses (barycentric weights, a selected slice or viewport,
synthesized geometry, multiview, too many outputs) now draws its lines
and edges at the nearest width, announced with the refusal as the
reason, instead of failing the draw: the state's first band compiles
the variant of its base key and remembers a refusal per primitive
(`Unrouted::Refused`). Mesh draws and tessellated patches keep the
nearest width. Docs: line_width.rs, band.rs, the runtime README,
FAST-PATHS (row and known gap), API.md (band variant, catalogue),
REFUSALS.md regenerated; api_signatures blessed (BandPrimitive added,
LineBandState::PATCH_CONTROL_POINTS removed, the three line_band fields
now carry the primitive). SEMANTICS_VERSION 1940, RUNTIME_VERSION 1716;
runtime sources re-pinned.

Verified (M3 Max, MoltenVK, --cfg m2v_gpu, maclock and memcap):
runtime_lane::line_widths 7/7 pass under both policies; 148 cases, 145
drawn as Metal's pixel for pixel, 28 of the 31 wide edge cases (facing,
culling, zero-area, strips, flat IDs and primitive IDs at both provoking
modes, depth across an edge, 4 samples), the other 3 the depth-bias edge
cases, announced (two differ from Metal, by slope and by exponent; the
uniform-depth one matches); 93 draws as bands, 0 at the nearest width.
Before this commit the same lane failed 4 of 7 (31 edge cases at the
nearest width, refused bands refused). Also: engine_line_band and the
band's fan tests, golden_hashes_match_the_table and the engine inventory
parts unchanged (no bless), runtime line_width tests (the route table
for lines and edges on every profile under both policies, refused rows),
api_surface, api_signatures, refusal_surface --check, clippy with all
features and with --cfg m2v_gpu, rustdoc with -D warnings.

(Carried to development from steelbrain/reims-graphics-kext be2d725fdb.)
2026-11-01 21:26:24 -08:00
Anees Iqbal b5e18d8fb3 Document the nearest-width line route; name its cause in the notice
Follows the previous commit, which drew at the nearest width what neither
line route draws. Its nearest width is Metal's drawn width: w', and 1/16
at w' = 0 (Metal draws 0 as 1/16, the width-0 commit this rebased onto),
clamped into lineWidthRange where the device enables wideLines, else 1.

- line_width.rs: module docs for the Nearest route and what still
  refuses (a strip's band whose segment list cannot be drawn; the band
  variant's forms the translator does not build). The
  lines-at-nearest-width notice's object names the edges or lines drawn,
  its reason the width drawn, lineWidthRange (or no wideLines) and the
  cause.
- The runtime README's line widths, FAST-PATHS.md's wide_lines row
  (counter nearest_width_line_draws) and its known gap (what is drawn at
  the nearest width, announced, instead of refused), RUNTIME-PORTING's
  SetLineWidth row.
- refusal_surface reach.tsv: gap WideLines now reaches only a strip's
  band list; feature WideLines only the translator's band forms.
  REFUSALS.md regenerated (gap::WideLines sites 5 -> 1, the runtime's
  Unsupported(WideLines) site gone).
- api_signatures blessed: Degradation::LinesAtNearestWidth,
  WorkCounts::nearest_width_line_draws.
- RUNTIME_VERSION 1715 (a refusal became a run, a new announcement);
  runtime-sources pin recomputed on this tree (pin-compute.py, which
  reproduces 9ada26c9fa's pin on that tree).

Verified: refusal_surface.py --check exit 0; cargo nextest run -p
metal2vulkan-runtime -p metal2vulkan --all-features -E
'test(/line_width|degradation|api_signatures|api_surface|refusal_surface|apple_only|error_kinds|draw_shape|call_checks/)'
27 passed; cargo clippy --workspace --all-targets --all-features -D
warnings clean.

(Carried to development from steelbrain/reims-graphics-kext 7aed54b621.)
2026-11-01 21:26:23 -08:00
Anees Iqbal 815c8af707 Re-pin the runtime sources at the branch tip
The previous commit changed runtime-sources inputs (the runtime's pipeline
sources), so the committed digest no longer described the sources and
`the_runtime_sources_are_the_committed_ones` would fail. Recomputed over the
same inputs with pin-compute.py on the tree rebased onto 7cf79c50ed.

REFUSALS.md regenerated on the same tree: beside nothing of this branch, it
picks up the base's rename of `line_width.rs`'s `line_route` to `route`, which
the base left out of the generated document.

(Carried to development from steelbrain/reims-graphics-kext 6fd1ce74b1.)
2026-11-01 21:26:22 -08:00