Commit Graph
622 Commits
Author SHA1 Message Date
Anees Iqbal 8eb3b6df31 Lay a heap's one-plane YCbCr texture in Metal's rows, not the carrier's tiles
Apple's nine one-plane YCbCr formats (501, 504, 521, 524, 560, 562, 563, 590,
607), held for copies alone in R16Uint or R32Uint, took the carrier's tiled
heap layout in a placement heap: their texels lay in R32Uint/R16Uint tiles,
and the texture took the carrier's tiled answer, where the size query answers
Metal's packed rows (reims-vgpu's jobs m3-max-4955 to 4985).

Metal lays them as rows (probes/one_plane_ycbcr_heap_rows.m on the M3 Max,
jobs m3-max-5055 and 5064, every format alike): a 2D texture's rows one
packed row apart where the row is a multiple of 16 bytes, a 1D texture's one
row, an array's slices at multiples of 128. The runtime now answers them
through planes_answer (one_plane_heap_answer, HeapLayout::Measured) and holds
them as the 4:2:2 textures are held, always a shadow of the heap's bytes in
rows (HeapTextureShape::rows); heap_plane_layout lays a one-plane array's
slices at 128 and heap_planes copies such slices a region each.

Shapes Metal lays no one way are announced, new Degradation
HeapOnePlaneLayout (heap-one-plane-layout): rows off 16 bytes, which Metal's
blits lay the row rounded down to 16 apart, lie packed; a mipmapped or 3D
texture, whose first level Metal addresses past its answer, lies apart from
the heap's bytes (AliasRoute::Unaliased) at Metal's answer.

Tests: heap_one_plane_rows (device): six shapes in a 4:2:2 and a 4:4:4
format, every byte of the heap after the copies in and every texel of the
copies out where Metal's are, allocatedSize Metal's answer; and the two
announced shapes reading what they wrote. The probe header gains what it
measured. API.md catalogue entry, api_signatures regenerated.

Not yet verified: the device tests, clippy and a control follow.

(cherry picked from commit 1e59e4c80f3e28c97ea80c8496e51dd6a94c4c83)
2026-11-07 14:10:20 -08:00
Anees Iqbal 3312a0ad84 Make a texture over host pages before its verdict without waiting for the in-place check
A texture over host pages made while its class's in-place verdict was pending started the check
and waited for that verdict as it was made, up to in_place::VERDICT_WAIT (5 s). The check's
rounds take seconds on some devices and builds: on um870's Radeon 780M (RADV, Mesa 26.2.6), in a
debug build, the first of the consumer's odd-width surfaces (3662x16, rows of 14656 bytes,
ShaderRead | RenderTarget) took 1.75 s and 1.86 s to make (job m3-max-5168), past the ~2 s the
consumer's guest waits for the COMPLETE of its next message. reims-vgpu's
on_vulkan_a_presented_surface_at_an_odd_width_reads_row_for_row failed there ("a COMPLETE") from
the wait's landing on; every command buffer of the same shape completed in under 2 ms.

A texture made before its verdict is a shadow again (ShadowCause::CheckPending, counted in
host_texture_shadows_check_pending), and its making starts the check and waits for none of it.
A program that makes such textures as it starts, and wants them in place on a driver's first
run, starts the check earlier with Device::settle_in_place_checks and a zero timeout; a device
whose record holds the verdicts knows them as it is made, as before. VERDICT_WAIT,
InPlaceChecks::wait_for and WorkCounts::in_place_verdicts_waited go (api_signatures.tsv).

Test: tests::first_host_texture, the consumer's shape: six surfaces over no-copy buffers at widths
3662, 1831 and 1001 (rows padded to 64 bytes), ShaderRead | RenderTarget then ShaderRead, each
copied out by a blit and read at its own pixels by a draw. The first is a shadow made before its
verdict; before this change it waited and was counted 0 there (m3-max-5168), so the assertion
fails without the fix. fresh_pages's in-place test settles the check before its texture, as a
texture made before its verdict is a shadow now. The waiter's unit test goes with wait_for.

Docs: in_place.rs, docs/API.md, docs/HOWTO.md, the FAST-PATHS in-place row.
(cherry picked from commit eca12ad708a8f1ad53521c967d4340a9b2635a22)
2026-11-07 13:48:35 -08:00
Anees Iqbal eb6c13f52b Give a render target in place over host pages the storage usage its snapshot reads fetch through
On the Iris Xe (m3-max-4845, the self_reads lane, a 3662x2039 BGRA8 surface over host pages, 30
pairs of a 600x400 draw, a render-target barrier and a draw reading the target at its own
pixel), a surface in place (557d9f0905) split every reading draw: 30 splits a frame, 30 copies
of the whole surface into the reader's copy (224M texels copied in), 22.4 and 27.2 ms of GPU a
frame, where its shadow took the snapshot (cut A, 60b9a69d39): 30 snapshotted draws, no split,
4.7 and 4.3 ms. The in-place image took the feedback loop usage (aliases 1) but not the storage
usage, which a snapshot's fetch of the attachment in the pixel interlock reads through
(RenderLowering::keeps_own_attachment), so snapshot_wanted fell back to the split: the image
was the texture's declared plan's, where a shadow takes undeclared usages (with_undeclared_usage).

A texture over host pages that renders, in place, now takes the storage usage too
(framebuffer_fetch::storage_candidate over the feedback loop plan, with the view in another
format a fetch stores through where the device needs one: ANV's RGBA twin of a BGRA format)
where the device's check passed for a shader's writes over the pages' class and the texel is one
the check's kernel stores (4, 8 or 16 bytes): with that usage a shader writes the texels in
place, which the check's writes cover. Tried first, then the feedback loop plan, then the
declared plan: the first the device makes the image in place with. Elsewhere its readers split
as before. A rebind asks the writes verdict of an image with storage usage already.

Tests: tests::in_place_storage (new, device): a render target in place over host pages has the
storage usage only where the check passed for writes there, with the feedback loop usage and a
fetch through storage. runtime_lane::snapshot_reads::a_surfaces_readers_take_the_snapshot_at_any_area
expects a snapshot for an image in place only where it took the storage usage (Pointer writes:
Passed), as for a shadow.

Docs: in_place_image.rs (its usage), API.md (textures over host pages in place), FAST-PATHS.md
(the attachment-read row: images over host pages, and the shadow only where a texture is one).

Verified: cargo fmt; the build, clippy, lavapipe and the Iris A/B and snapshot lane follow in the
tip's evidence.

(cherry picked from commit e4d61153702293e23bd874cf0830ff22d6be307a)
2026-11-07 13:24:34 -08:00
Anees Iqbal 6276d55b25 Textures a shader writes over host pages in place, where the device's check passes for their writes
A texture over host pages whose usage writes it through a shader (`ShaderWrite` or `ShaderAtomic`)
was a shadow on every device: its texels copied in before each use and merged back after each
write. The owner's ruling of 11-07 (confirmed for discrete GPUs) has CPU-visible memory worked on
in place wherever the device can, slower or not, with a shadow only where in place is impossible,
announced and counted. This takes such a texture in place on the same terms as one that renders,
from the parked branch park/shaderwrite-in-place, onto the per-class, per-access check, with no
device-type rule: a discrete GPU takes it in place too.

- `in_place.rs`: a third access, `Access::Writes`, which a texture of `ShaderWrite` or
  `ShaderAtomic` usage takes; a texture is tried in place where its class's check passed for each
  access it takes (`Access::takes`: renders, writes, or reads where it does neither), asked in
  that order until one did not pass. A texture a shader writes of texels of 1 or 2 bytes, which
  the check's kernel stores none of, is a shadow (`ShadowCause::StoreWidth`); `ShadowCause::
  ShaderWrite` is gone. Nine verdicts a record (CHECK_VERSION 3).
- `in_place_check.rs`: the storage rounds, per class: a texture of `ShaderWrite` usage over the
  pattern, every texel stored by the crate-owned copy-in kernel through an unsigned-integer view
  (`Texture::store_in_place`, from a buffer outside the Metal address space), its first move
  first, while the writer writes the bytes between rows and after the image; every texel must read
  the kernel's bytes, every other byte the writer's or the pattern. `STORE_SHAPES`: 4, 8 and 16-byte
  texels, packed, padded at 512 bytes (widths no multiple of 4, odd heights) and at a tight 16-byte
  pitch, and 1920x1080.
- `WorkCounts`: `host_textures_in_place_written` (of `host_textures_in_place`, those a shader
  writes) and `host_texture_shadows_store_width` are new; `host_texture_shadows_shader_write` is now
  the subtotal of the shadows a shader writes, as `host_texture_shadows_render_target` is of those
  that render. The rebind of a texture in fresh pages asks every access its image's usage takes.

Tests: the decision test covers every usage, texel width and combination of the three accesses'
verdicts, and the order in which they are asked; the cause words and the record of nine verdicts.
Lanes: in_place_textures gains `written_textures_over_host_pages_take_the_path_their_checks_answered`
(64x64 `RGBA16Float` at 1024 and 512 bytes, 61x64 at 496, signaling-NaN halves beside the texels:
in place exactly where `Pointer writes` passed, a kernel's writes reaching the pages, every other
byte kept), and `textures_that_render_or_write_take_the_path_their_checks_answered` replaces the
test that counted every written texture a shadow; no_copy_textures and pitched_surfaces take a
written texture in place where its texels are 4, 8 or 16 bytes.

Docs: in_place.rs, in_place_check.rs, the policy's docs, API.md (the in-place paragraph, the
shadow paragraph, the `shadowed-texture` notice), HOWTO.md, the runtime README and FAST-PATHS.md's
in-place row and host-pages bullet.

(cherry picked from commit c3ffb08376251b87e16b7b417b39f1458e271085)
2026-11-07 13:24:33 -08:00
Anees Iqbal 24ceac6e88 Make device copies on a discrete GPU of Managed textures over host pages alone
On a discrete GPU, a texture over host pages that only samples or reads, over memory that carries a
log of its writes, was a device copy (a shadow in VRAM whose copies in take the rows the log
reports) whatever its storage mode: a speed choice, so the GPU read the surface from its own
memory instead of across the bus. The owner's ruling of 11-07 (confirmed for discrete): Shared
and IOSurface memory over guest pages is used in place over the import, never shadowed to VRAM
for speed; Managed keeps Metal's two copies on a discrete Mac. So `Texels::device_copy` now also
asks for `Managed` storage and a buffer's bytes (not an IOSurface plane's, whose memory is one copy
whatever the descriptor's storage mode): a Shared texture and an IOSurface's are in place over the
import where the device's check passed, as on every other device.

Tests: the runtime's `a_logged_device_copy_sampled_in_an_inline_pass_is_copied_in_before_the_pass`
and the device_copies lane make their buffers Managed (`over_logged_as`, `over_as`); the new lane
test `a_shared_surface_over_logged_pages_is_no_device_copy` asserts a Shared surface over logged
pages is no device copy on any device, in place exactly where the check passed for pointer pages,
and that its reads hold the pages' texels before and after a logged CPU write.

Docs: API.md, the runtime README, FAST-PATHS.md's in-place row, the WorkCounts field and the
lanes' module docs.

(cherry picked from commit fd9fc11dd372a0985fdbc921adb2bc971ff78a3d)
2026-11-07 13:24:33 -08:00
Anees Iqbal 158f7220ff Pages the process maps read-only are a copy whose GPU writes are dropped, on every device
On Linux, a no-copy buffer, heap or rebind over pages the process maps read-only went to the
caller's dma-buf source wherever it gave one, and so did pages an import alignment above the
host page left with no pointer import (by_pointer false), which skip the gate. A dma-buf of the
pages takes the GPU's writes, which Metal drops (an M3 Max under macOS 27.0.1: the CPU reads
read-only pages as they were). The runtime announced that as read-only-pages-written. Without a
source the pages were refused, where Metal makes the buffer. The owner's rule (10-23) is to drop
such writes on every device, never refuse them.

Such pages are now a copy whose GPU writes are dropped (copied.rs), with or without a source,
which is never called for them. The gate is still asked first where the pointer would be
imported, and its refusal is still counted as a refusal. Counted:
WorkCounts::copied_unwritable_pages (new, public), announced as copied-host-pages with its own
cause. Degradation::ReadOnlyPagesWritten is removed (public: api_signatures, docs/API.md's
catalogue, the lane's notice registry), and so are HostWindow::unwritable and
degrade_read_only_pages.

Tests: the dma_buf_imports lane test is now read_only_pages_are_a_copy_whose_gpu_writes_are_
dropped. It fails at the base, where the sourced buffer's fill reaches the file's pages and the
unsourced one is refused. The host_memory lane test a_read_only_page_is_a_copy_on_linux_and_
read_elsewhere replaces the refusal test. The runtime's copied_device tests cover a new buffer
and a rebind over read-only pages whose gate admits them: a copy, the source unasked. The
keep-alive order test uses writable memfd pages, which RADV imports as dma-bufs all the same.

(cherry picked from commit 68805d8a5742590e157b089f336c17e8e1dc4ef4)
2026-11-07 13:13:19 -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 23ffb2f64f Name the in-place check's record by the driver and the check alone; wait for the verdict
The record of the device's in-place check was named by RUNTIME_VERSION too, which moves at almost
every pin: every reims boot after a pin move ran the check again, and the textures made before it
answered (WindowServer's framebuffers, made at its start) were shadows for that boot's life.

- in_place.rs: the record's name and body hold the check's tag, kind and version and the driver's
  identity (vendor, device, driver version, driver ID, name, info, device UUID), not the runtime
  version; the body loses its runtime field. CHECK_VERSION is the version of what decides the
  answer: the check, and the images over host pages it checks as the product makes them. Asked
  by main for the owner's 11-07 ruling.
- A texture made while its class's verdict for its access is pending starts the check and waits
  for that verdict as it is made, up to in_place::VERDICT_WAIT (5 s), instead of taking a shadow
  for its life (InPlaceChecks::wait_for, woken by each verdict set and by the settle; counted
  WorkCounts::in_place_verdicts_waited). Past the wait it is a shadow, counted check_pending.
- self_reads prints the check's time (SELF-READ-CHECK ... took).

Tests: tests::in_place pins the record name to the identity and check alone (a hash computed in
the test), drops the runtime field from the frame tests, and checks a waiter wakes on its own
verdict and on the settle.

Docs: in_place.rs, in_place_check.rs, docs/API.md, docs/HOWTO.md, docs/FAST-PATHS.md's row;
api_signatures.tsv gains WorkCounts.in_place_verdicts_waited.

Verified: build, clippy and the touched tests in the follow-up jobs named in the tip's report.
(cherry picked from commit 841a92b0020f1d43e943c9bc04245cffb7fcf503)
2026-11-07 12:33:50 -08:00
Anees Iqbal 8ab8a8c0fe Render targets over host pages in place, where the device's check passes for them
A texture over host pages whose usage renders into it (an IOSurface's render target, the guest
desktop's framebuffer) was always a shadow: in_place() refused RenderTarget usage by policy, so
every render pass instance over one copied the whole texture in, kept it and merged it back (on
the Iris Xe of RPL-P, ~3 ms an instance at 3662x2039 in reims's measurements, 90-98% of the
desktop's GPU time a composite). ANV makes the linear image such a texture needs at every pitch
probed (BGRA8 at widths 3662, 1920, 2560, 3840, 1366 and 1440, packed and padded to 16, 64, 128,
256 and 512 bytes, with color attachment and feedback loop usage, for host allocations; job
m3-max-4631), so nothing on the device kept it out.

The owner's rulings (10-27: render targets in place where the driver leaves the bytes alone;
11-07: CPU-visible memory worked on in place even where a linear image is slower) take such a
texture in place where the device's own check shows the operations Vulkan lets touch the bytes
beside the texels leave them alone. So:

- in_place.rs: the check's verdicts are per class and access (Access::Reads, Access::Renders):
  a texture that renders asks its class's render verdict; only a shader write (ShaderWrite,
  ShaderAtomic, Unknown) is refused by usage. ShadowCause::RenderTarget is gone; the pending,
  failed and unchecked causes name the access. The record holds six verdicts (CHECK_VERSION 2).
- in_place_check.rs: rounds of their own for an image that renders: the texture made with
  RenderTarget usage, the writer writing the bytes between rows and after the image alone,
  through the first move, the moves into ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT and back where the
  image has that usage (Texture::settle_feedback_moves, render_target::feedback_moves, recorded as
  moved_barriers records them), and a render pass of the check's own queue that clears at load
  and stores. Every texel must read zero after, every other byte the CPU's write or the pattern.
- in_place_image.rs: a texture that renders takes the feedback loop usage where the device makes
  the image with it (counted feedback_loop_alias_images), so a self-read after a render-target
  barrier reads through a snapshot rather than a split; else the declared plan's image.
- texture.rs: on a discrete GPU, the device copy (dirty-log shadow) stays for textures that only
  sample or read; one that renders works on the pages in place.
- WorkCounts::host_texture_shadows_render_target now counts, of the shadows counted by cause,
  those that render: the render targets still shadowed, whatever the cause.

Docs: in_place.rs and in_place_check.rs module docs, HostPageTexturePolicy, the runtime README,
docs/API.md, docs/FAST-PATHS.md's in-place row and host-pages bullet. Lanes: in_place_textures
(render targets in place where "Pointer renders: Passed", recalled verdicts 6),
no_copy_textures (render targets may alias; passes_blend_load_and_store_as_private_textures runs
under both policies, so in-place render targets are checked byte for byte against a private
texture with the padding untouched), pitched_surfaces (render targets may alias in the _in_place
runs), attachment_read_costs::self_reads (settles the check first, prints textures in place).

Verified: build, clippy and the touched tests in the follow-up jobs named in the tip's report.
(cherry picked from commit 557d9f090525801183aaff5958c4738c0cfabe46)
2026-11-07 12:33:49 -08:00
Anees Iqbal fe494f10cd Run a one-row threadgroup of a lockstep-only kernel on its own pipeline
OpenCL C's scale kernel (if (i < n) b[i] *= k) uses no simdgroup
operation, yet on the RTX 5080 a dispatch in threadgroups of 16 paid a
second compile on emulated simdgroups and its degrade notice. The
lockstep pass orders b[i]'s read and write: two threads of a simdgroup
share their grid position's x where the threadgroup is narrower than 32
and taller than one row. The pair stands where only some threads run, so
its barrier is a subgroup barrier (a tangle barrier under maximal
reconvergence), which pins the kernel to the Direct tier's whole 32-lane
subgroups, and a 16-thread region was a partial simdgroup for the
emulated variant. In a threadgroup of one row no two threads of a
simdgroup share an x, so no pair meets and no barrier is needed.

- The lockstep analysis runs its pairs a second time where each
  simdgroup lies within one row (a position's x then differs by 1 to 31
  between two threads, as an index does), only where a subgroup barrier
  keeps a 32-lane tier; Lockstep::rows records that none conflicts.
- Lowering takes the inserted simdgroup barriers' class after selection,
  so it knows whether they are the kernel's only simdgroup semantics;
  then, on a flattened tier, the kernel records RuntimeFact::RowLockstep.
- The binder runs a one-row region of such a kernel on the planned
  pipeline whatever its width, that region without
  REQUIRE_FULL_SUBGROUPS where it is not whole subgroups. A partial
  region of two rows still takes the emulated variant.

Tests: the binder's rules (one row of 1, 16, 48 threads planned and
unflagged, 32 and 64 flagged, a 100-thread grid's edge, two-row partial
regions on the variant, no fact no exception); and on the RTX 5080
profile the scale shape keeps Direct, records RowLockstep and plans 1,
16 and 48 threads on its one pipeline, while b[gid >> 1] and a kernel
reading its lane do not.

(cherry picked from commit a6c76c206d4438e3948b05464cef7d65fd63d5ab)
2026-11-07 11:43:21 -08:00
Anees Iqbal f87e50df30 Cap a kernel's threadgroup at its required work-group size (air.work_group_size)
OpenCL C's reqd_work_group_size(x, y, z) reaches the AIR as a trailing
kernel attribute, !{"air.work_group_size", i32 x, i32 y, i32 z}, which
the decoder refused as an unknown stage attribute. It is now
Stage::Kernel's work_group_size (each dimension at least 1, stated once,
kernels only), carried in KernelFacts, and caps the pipeline's
maxTotalThreadsPerThreadgroup, Metal's answer and the device's, at
x * y * z: the M3 Max answers 64 for (64, 1, 1) and 1024 without, and
runs the kernel in threadgroups of 64 and of 32 (job m3-max-4483). No
refusal is added: a descriptor maximum beside it is unmeasured.

Tests: the ABI decode (size, zero, twice, a vertex function); the
engine's maxima of a kernel with and without it on the M3 profile; and
the runtime device test of wg in groups of 64 and 32.

(cherry picked from commit b9fc38d7abef4bab73ad0821efa30560f136d997)
2026-11-07 11:43:21 -08:00
Anees Iqbal c0965318a6 Decode an argument passed by value (air.constant) as a constant buffer of its own size
Apple's OpenCL compiler writes each scalar, vector or struct kernel
parameter as an air.constant node: a location, an optional
air.struct_type_info, the type size and alignment, the type and argument
names, and no access or address space. The entry loads the value from a
constant-space pointer, so the role is a read-only constant buffer
holding exactly its bytes, as a constant T& reference is (buffer_size is
the type size). Only a kernel takes one. Reflection then answers as the
M3 Max does in OpenCL mode: float k Float 4/4, struct {float; int} Struct
8/4, 3 past its index.

Tests: the ABI decode of the node (role, layout, refused keys, missing
size, device pointer, vertex stage); the engine reflection of a float and
a struct by value; and on the runtime device tests scale (by bytes and by
buffers at offsets), st and items with d passed by value, against the M3
Max's answers (job m3-max-4483).

(cherry picked from commit ee4ebc233112c297bbb9680535d0fffab4fb153e)
2026-11-07 11:43:21 -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 76f46963b6 Driver facts: RADV on the RX 7900 XTX decodes BC1 to BC3 as Metal does
The XTX's BC1 to BC3 texels, unorm and sRGB, read as Metal's decode in
the runtime lane `compressed_decode::bc1_to_bc5_texels_read_the_device_s_decode`:
0 of 4096 channels off for each of the six formats (RADV, Mesa 26.2.6,
job m3-max-4261 on homelab-gem10's XTX, MESA_VK_DEVICE_SELECT 1002:744c!),
the 780M's reading exactly. Its BC4 and BC5 read as the 780M's do
too (BC4 snorm 10 channels up to 1.6/255, BC5 snorm 44 up to 1.726/255),
so `ChannelBlockDecodeIsMetals` stays off for both.

So `ColorBlockDecodeIsMetals` gains a RADV row on the XTX (0x744c, the
new AMD_RX_7900_XTX), and a BC1 to BC3 texture there no longer announces
`compressed-texel-decode`. The notice's doc, docs/API.md's catalogue,
docs/FAST-PATHS.md's row and the fact's measurement doc name the XTX.
The 12 RADV ledger rows of bc1/bc2/bc3-rgba-srgb now state that the block
decode is measured to be Metal's on both GPUs, so the sRGB decode is
what differs.

Test: `a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone`
presented the 780M under the XTX's deviceID as a GPU no row names; it
now expects the XTX's two facts (the driver-wide zero fetch and BC1 to
BC3's decode) there and the driver-wide fact alone under 0x1114, at
another release too.

Pinned files change (driver_facts.rs, degradation.rs): the runtime pin
and RUNTIME_VERSION are the orchestrator's.

(cherry picked from commit 18101735f400ebe243e775a67b7d8da19ea2ad5a)
2026-11-07 11:10:56 -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 32c15dd1b8 Follow a texel call's status word through member insertions and extractions
Apple's GL code generator writes a texture read it swizzles back into the read's own
{ <4 x float>, i8 } with insertvalue and takes the texel out again. The status analysis knew a
carrier only as the call or a whole copy (phi, select, freeze), so any insertvalue exposed the
word and every GL texture-buffer shader on the 5080 guest was refused as
Unsupported(Lowering(Texture), NotImplemented).

A carrier is now a value plus the member path at which it holds a call's word: [1] in the call's
own result, empty in the word itself. Copies keep the path. An insertvalue into a carrier carries
it unless it overwrites the word's member, and an insertvalue of a carrier carries it below the
member it writes. An extractvalue shortens the path, observes nothing when it takes another
member, and takes the word at its own member. A word re-inserted whole demands no bits there:
they are demanded where it is taken again. Every other use of a carrier (a store, a call, a
return) still exposes the word and is refused. This holds for every call the analysis already
followed: read, sample, sample_grad and gather, compare forms included, on every texture type.

Tests (engine_texture_tail): four new carrier forms. The texel reinserted, a {T, i8} rebuilt
from its members, a read nested in a larger aggregate, and a select of a read and its rewritten
copy. Each, and a word overwritten, compiles on every profile with the texel only taken, with
Metal's texels on the interpreter. Each carries resident() to a lowered residency read, plain
and sparse. Each refuses the whole word taken after it, as does a read stored whole.

(cherry picked from commit bb664f60be54c6e443cc13a619760542663ba5bc)
2026-11-07 10:07:03 -08:00
Anees Iqbal a0eda5a037 State which integer operations are folded for an OpenCL kernel's immediates
The API guide said an integer operation on a narrow width is folded over constants; SCCP folds
ctpop, bitreverse and bswap alone (94d75b4fad), and a narrow min or max is refused.

(cherry picked from commit 12cc0037e02e018d5196e3c6145ceb88bdcdc593)
2026-11-07 09:53:32 -08:00
Anees Iqbal 89d8e46d26 Bind an intrinsic's immediates from the call sites of the function passing them on
Metal's compiler leaves OpenCL C's barrier(flags) and mem_fence(flags) out of line: an internal
function passes its parameter on as air.wg.barrier's flags, and mem_fence computes
air.atomic.fence's flags from it through llvm.bitreverse.i2. Every call site passes a constant.
Decode refused the call (Intrinsic(ImmediateNotConstant)), and so every OpenCL kernel that
synchronizes was refused.

Decode now keeps such a call as Callee::Unbound, with the family its declaration names
(intrinsics::Template). Once inlining has made the parameter the call site's constant, SCCP's
edit binds it in the same rebuild, with no pass of its own. SCCP also folds the integer llvm.*
operations (min/max, ctpop, bitreverse, bswap) over constants. LlvmIntrinsic::NarrowInt decodes
those operations on widths no SPIR-V type has (i2), so the fence's flags fold. An immediate still
not constant after canonicalization is refused at the call, in post_check, with the inlined
entry's function location. A NarrowInt that survives is refused as Lowering(Arith).

Tests:
- canon::tests::unbound_immediates: each call site binds its own flags; binding meters no more
  work than the constant twin (264 vs 265 units) and prints the same module; the i2 fence binds
  after folding; flags read from a buffer are refused at the call.
- intrinsics::tests: the narrow-width decode.
- runtime tests::opencl_kernels: a barrier and a fence out of line compute what the M3 and the
  Intel UHD 630 compute.

Verified on the same changes at base c956a4236c: metal2vulkan-air 516/516 (m3-max-4223), the
runtime test on lavapipe (m3-max-4223), and the consumer's glcheck b, b0, f and f0 passing with
the 5080 and 780M profiles (m3-max-4227).

(cherry picked from commit f49960f427b2f1371468b97a215788dea8018d45)
2026-11-07 09:53:17 -08:00
Anees Iqbal f15f3b3738 Blend ARGB8Unorm in the shader where no Vulkan state on its rotated image gives Metal's blend
An ARGB8Unorm attachment is an R8G8B8A8_UNORM image holding Metal's alpha,
red, green and blue in its red, green, blue and alpha. A blend whose factors
read Metal's destination alpha in a colour factor (or the saturated source
alpha, the blend colour's red, green or blue, or different colour and alpha
operations) has no Vulkan factor on that image, and the pipeline was refused
NotImplemented(Format) on every device, where plain Metal makes and runs it.

Metal blends the format as RGBA8Unorm with its channels rotated (recorded by
argb8-targets-destination-alpha). So the fragment function now computes
Metal's 8-bit unorm blend (extended_range::Blend::unorm8, the model the storage
form already uses for RGBA8Unorm) over the texel rotated into Metal's order:

- where the device orders fetch through the pixel interlock alone (MoltenVK,
  RADV, ANV, NVIDIA), in the interlocked storage form: StorageView::rotated
  rotates each texel read and written, the storage form now takes the
  RotatedView emulation, and unorm8_format includes ARGB8Unorm;
- where it orders fetch through rasterization-order input attachments
  (lavapipe, SwiftShader), over the input attachment: a new
  RotatedInputBlend plan and RuntimeFact::RotatedInputBlend, the blended
  value written through the rotated output, link giving no Vulkan blend;
- on a device with neither ordering, the pipeline is refused
  FramebufferFetch needing either one (fetch::unordered_extended_fetch).

The routing predicate is color_writes::shader_rotated_blend (rotated_blend
refuses the blend NotImplemented(Format), and no factor reads the second
source). Second-source factors stay refused. The device's conversion of the
result is noted (DeviceColorConversion); a module stating no math is noted as
other unorm8 storage blends are.

SEMANTICS_VERSION 1985 and ARTIFACT_FORMAT_VERSION 491 are provisional (a new
RuntimeFact variant changes the encoding): renumber at landing if taken.

Verified: none yet; build, tests and the conformance case follow.
(cherry picked from commit 413c7377771fc524b7d974747b25062260ea5646)
2026-11-07 09:37:29 -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 c418a1f55b device-texel-conversion: state RADV's nearest-sample flush of a denormal float texel
PrecisionNote::DeviceTexelConversion's recorded bound named NVIDIA's
gathers, which flush a 32-bit float texel's denormal to a zero of its
sign, and answered Metal's value for every other class. On RADV (Mesa
26.2.6, both the RX 7900 XTX and the Radeon 780M on 2026-11-07),
denormal-word-fetches differed at its four nearest-sample sites alone:
each differing word is a denormal against the zero of its sign (largest
difference 0x7FFFFF, a whole mantissa), and none of its gather sites
differs. So the device's samples flush and its gathers keep. That is
the device's native answer (rule 1), announced for the case as
device-texel-conversion, and the note's documentation now says so, in
artifact.rs and in docs/API.md's catalogue entry. The case's module doc
records the RADV reading beside its runtime_lane one.

Doc comments only: no product path changes. artifact.rs is outside the
runtime sources pin, and degradation.rs is not touched. Verified: the
replays m3-max-4102 and 4108 (the four lines, identical on both GPUs),
and the driver version read with vulkaninfo (m3-max-4201).

(cherry picked from commit 7fc262b99f7ab4b080e9efb506021908fa9121e4)
2026-11-07 09:14:32 -08:00
Anees Iqbal 1b5c55ed02 Linux exit: wait for the runtime's work within the bound, then run the earlier exit handlers
On Linux with glibc the exit hook waited for nothing: with another thread's section or a CPU
device's work in flight it wrote the at-once notice and called _exit, so every exit handler
registered before the runtime's last registration was skipped. QEMU registers its exit notifiers
(usb-host's re-attach of host USB devices to their drivers, tap's downscript, the pidfile unlink)
and its terminal restore before the device exists; a quit in that window left a user's host USB
devices detached. Metal's exit runs those handlers.

The hook now waits there as on macOS: for the sections in progress at most BOUND (2 s), at most
MAKING_BOUND (60 s, with its notice) while a pipeline's making is in progress, then for a CPU
device's work within what is left; once they ended it returns and the earlier handlers run. Only
past the bound does it end the process at once with the exit's status (the notice now names the
bounds), which keeps a driver deadlocked inside a submission (the GPU-assisted validation layer's)
from holding the exit and keeps destructors from running beside the driver's work.

After the hook returns no call of the runtime's is in flight: a section publishes its calls'
results before it ends, and none starts once the guard closed. What may still call the driver is
the program's own threads (their race, as before) and the driver's own threads (Mesa's thread
queues, which its own exit handler joins after the hook): the module docs say so.

Tests: an_exit_runs_the_handlers_before_the_hook_once_the_work_ended (a section, and a CPU
device's work, ending 100 ms into the exit: the handler registered before the hook runs, no
notice), which fails where the hook waits for nothing; a_busy_exit_past_the_bound_ends_at_once_
with_its_status (stuck section or CPU work: the exit's status, the notice, after 2 s and within
3 s); the_at_once_notice_names_the_bounds. The exits lane expects the wait on Linux as on macOS.
Docs: exit_guard.rs, pool.rs, shader_cache/worker.rs, docs/API.md's accepted difference.

(cherry picked from commit ec4b802fce26f18920ba0586eeadf32fe694816e)
2026-11-07 09:13:10 -08:00
Anees Iqbal 231a7d86f7 Put a DontCare colour's kept texels behind DontCareColorPolicy::Kept
The owner's rule 1 keeps the fast form of every speed-for-accuracy choice the
default. A colour attachment of a texture's own image stored DontCare now
stores as the driver stores it by default (DONT_CARE where the driver is
measured to keep one of Metal's answers or to store as Metal's own, else
STORE), announced dont-care-store, and renders through the pooled backing
that keeps its earlier texels only under the new opt-in switch
DevicePolicy::dont_care_colors = DontCareColorPolicy::Kept, which
DevicePolicy::exact_answers() selects.

- metal2vulkan: the new public field DevicePolicy::dont_care_colors and enum
  DontCareColorPolicy { Driver (default), Kept }. Its docs give each form,
  its cost and Metal's documentation ("You need to assume that GPU discarded
  the texture's contents"). The runtime alone reads it, so no profile carries
  it (tests::fast_paths checks that no fingerprint moves).
- runtime: kept_bytes::settle takes the backing only under Kept. The docs of
  kept_bytes, render_target, attachment_stand_in, degradation and
  WorkCounts::kept_texels_passes, which counts only the Kept form's passes,
  now say which policy they describe.
- docs/FAST-PATHS.md: the choice moves from "Costs of matching Metal" into the
  table, as a row with its default, its switch, its bound and its measured
  cost. docs/API.md's dont-care-store entry and the Render passes accepted
  difference name the policy.
- Tests of both settings. dont_care_stores' default-policy tests are back to
  their earlier form (each texel one of Metal's two answers, announced where
  the driver does not store as Metal's own) and assert that no pass took a
  backing. The new exact_answers_keep_a_dont_care_color_s_earlier_texels_on_
  every_driver runs under Kept: the single-sample cases, both barriers and the
  two 4x colours keep their texels exactly and are counted.
  deferred_calls's refused-end test is back to its DontCare form.
  clear_reach gains lane_with.
- conformance: the Policy::Exact doc lists queue_sharing and dont_care_colors.
  The colour case's dont-care-store comment says what each policy gives.
- The known-gaps ledger keeps the eight pass-sequence-color-actions rows
  removed. It is held against `conformance replay`, which takes the exact
  policy, as the BGRA10_XR compressed-blit rows already are.
- The API signatures are blessed and docs/CONFORMANCE-COVERAGE.md is
  re-derived (its ledger table had kept the rows that both families removed).
  REFUSALS.md does not change.

Verified: cargo fmt only. The Linux clippy, rustdoc, suites and lavapipe
replays under both policies follow as potluck jobs.

(cherry picked from commit ec3479464c0f72ab5443223a28e23e84ec23e78d)
2026-11-07 09:05:59 -08:00
Anees Iqbal 3eb84d76c6 Off macOS, drop the GPU's writes to bit-24 no-copy memory through a copy
Metal drops what a shader or the blit engine writes into no-copy memory
made with its private option bit 24: the write completes with no error,
a later command of the same command buffer may read it back, and neither
a later command buffer nor the CPU sees it (probes/readonly_gpu_writes.m,
an M3 Max under macOS 27.0.1; the owner's ruling of 10-23: drop, never
refuse, on every driver). macOS imports the pages through a read-only
view of them. Elsewhere the import was of the caller's own pages, so the
GPU's writes reached the pages, the CPU and later command buffers
(host-page-writes-kernel-store-read-only and
host-page-writes-visibility-read-only diverged on llvmpipe and the RTX
5080), announced as private-resource-option. No import can keep the
writes out there: Linux drivers pin imported pages for writing, and ANV
lost the device and RADV failed every submission over read-only imported
pages.

So off macOS such a buffer, heap or rebind is made over a copy of the
pages whose GPU writes are dropped, the mechanism copied.rs already has
for pages the process maps read-only: each commit copies in what the CPU
changed, later commands of the batch read the GPU's writes, and the
batch's completion puts every byte the GPU changed back, writing nothing
to the pages. The gate is not asked (nothing is imported), the copy joins
no other buffer over the bytes, and a rebind whose bytes moved in their
page is now a copy laid out at the old offset rather than refused.

- buffer_descriptor.rs: buffer_over_host_memory makes the copy
  (CopiedFor::ReadOnly) where drops_writes and the system maps no
  read-only view; the rebind path copies the same way (read_only_copy);
  copied_buffer takes why it copies, and passes read_only to
  CopiedBuffers::add and drops_writes to the buffer's HostCell.
  no_copy_options moves here from degradation.rs and no longer
  announces private-resource-option off macOS (that notice stays for a
  heap of the runtime's memory and an indirect command buffer).
- copied.rs: add() takes read_only, which drops the copy's GPU writes
  whatever the pages' protection.
- buffer.rs: BufferParts carries drops_writes into host_lie.
- New: CopiedBecause::ReadOnly, WorkCounts::copied_read_only_memory.
- Docs: read_only_view.rs, copied.rs, capabilities.rs (the answer stays
  no off macOS), values.rs, host_backing.rs, interop.rs, host_aliases.rs,
  error.rs (RebindTextures is macOS-only now), degradation.rs, docs/API.md
  (private-resource-option, copied-host-pages), docs/HOWTO.md and the
  docs/FAST-PATHS.md known gap: off macOS a command buffer committed while
  the writer is in flight still reads its writes, and a render pass's
  store-out into the copy completes where Metal's faults.
- Tests: degrade_notices' bit-24 lane tests assert the writes are
  dropped on every driver and count the copies (3 and 1 off macOS, 0 on
  it) and the kinds (copied-host-pages off macOS, none on it);
  copied_surfaces' dropping buffer is a copy of its own off macOS.
- host-page-writes read-only rows declare copied-host-pages in place of
  private-resource-option; their 8 ledger rows are removed.
- api_signatures.tsv blessed for the new field.

Verified: see the replay and lane-test jobs named in the branch report
(lavapipe, the RTX 5080 through b5080, MoltenVK on the M3).

(cherry picked from commit 1f24b1f035d61f093ecf2c76fae4b9c2e4b541d9)
2026-11-07 09:05:40 -08:00
Anees Iqbal e08ad161e6 WIP: a DontCare color of a texture's own image keeps its texels through a pooled backing
(cherry picked from commit 568dd0d59b0ae6b30a6308a2f7587cfe7c4a41dd)
2026-11-07 09:05:39 -08:00
Anees Iqbal d158a960dd Read the sparse move rows through uncompressed textures
The move family's rows (inside-the-level, past-the-destination's-row,
clipped-source) read a tile a move rebound as 0 in 3,968 of its 4,096
words on Metal and whole on ours. probes/sparse_move_compression.m (job
m3-max-3570, an M3 Max under macOS 27.0.1, five descriptors, two runs
each, one outcome) shows that is lossless compression's: under the
case's own descriptor (ShaderRead, allowGPUOptimizedContents YES) a
moved tile kept its word in 128 texels, the first 4 by 2 of each 16 by
16 block, and with allowGPUOptimizedContents off, ShaderWrite or
PixelFormatView usage both moved tiles read whole. Controls: untouched
tiles whole, moved-from tiles zero, every command buffer completed,
usedSize unchanged.

A move is documented to move the tile's mapping, and the rows read
which tiles it moved, so they now make both textures with
allowGPUOptimizedContents off:

- SparseTextureSpec gains gpu_optimized (Metal's default, true) and
  unoptimized(); both sides forward it to their descriptor. An
  unoptimized texture adds a byte to its fingerprint and a site suffix
  where the default adds none, so every other sparse case's recording
  keeps its fingerprint.
- moved() builds its two textures unoptimized; the four move rows'
  recordings are re-taken on the M3 in the next commit.
- docs/API.md's accepted differences gain the compressed case: Metal's
  moved tile may read only part of its texels, ours reads all of them
  under every descriptor; the runtime does not reproduce the loss.
- The probe's header records its results.

(cherry picked from commit b3f8f28dbf18ce6756587702dd012ebd282c4f3a)
2026-11-07 06:26:30 -08:00
Anees Iqbal 08ca74da22 Charge a sparse heap for a mapping update of a slice past the texture's
Plain Metal takes a sparse mapping update whose slice is past the
texture's own (its API validation refuses it) and charges its heap's
usedSize exactly what the same region on an in-bounds slice costs: one
page a tile of the region clipped to the level's tiles, idempotent per
tile, given back on an unmap of that tile, never below where it stood
(probes/sparse_indirect_usedsize.m and sparse_mapping_past_the_bounds.m
on the M3 Max, macOS 27.0.1, both selectors). Ours counted nothing, so
sparse-mapping-a-slice-past-the-textures read 65,536 where Metal read
81,920 at used-size/2, /3 and /4.

UnitGrid::clipped_region now names such a region's units at the slice
(past_slices tells them apart); sparse/bind.rs's apply takes and gives
back their heap room into SparseState::charged and binds nothing for
them, and undo reverts them with the rest. The move keeps the slice
bound (clipped_size), as measured.

The texels plain Metal's page reaches (read/4: a 16 by 16 block of slice
0's tile (0, 0) reads its unwritten pattern) are not mirrored, on the
owner's call via the orchestrator: an accepted difference in docs/API.md
section 10 (Vulkan binds nothing past an image's layers,
VUID-VkSparseImageMemoryBindInfo-subresource-01723, and the address is
not derivable), which the remaining ledger row now names.

Removes the three used-size rows of known-gaps.tsv. tests::sparse holds
the counts against Metal's readings row by row (every row now equal).

(cherry picked from commit 636522137c717715521cdda950fbb7213e00089f)
2026-11-07 06:26:30 -08:00
Anees Iqbal 9175e22891 Degrade catalogue: lavapipe's passes hold the extended-range shadow beside the input attachment
docs/API.md's entry for extended-range-blends-stored-codes said every
pass over input attachments keeps the codes; on a device with the pixel
interlock, fragment stores and Rgba16f storage images the pass holds the
shadow, and the notice fires there only where the shadow cannot follow
(a multisampled load, a refused shadowed variant) and, for a masked
word write, only where the pass holds no shadow. The four
xr-masked-bgr10xr notice rows that went in 9b264b29fe are that last
case. Degradation::ExtendedRangeBlendsStoredCodes' doc says the same.

Verified: doc text; the runtime suite's catalogue test runs with the
suites.

(cherry picked from commit 536615e3c3460673f6defce426dfa72fc51f8f3f)
2026-11-07 06:19:16 -08:00
Anees Iqbal 14e55e0c6c A reset compute pipeline descriptor is a fresh one: an accepted difference
MTLComputePipeline.h documents -[MTLComputePipelineDescriptor reset] as
"Restore all compute pipeline descriptor properties to their default
values", and maxTotalThreadsPerThreadgroup as "If it is not set,
returns zero". The runtime's reset is ComputePipelineDescriptor::new,
every field at its default. Metal's reset on the M3 Max (macOS 27.0.1)
keeps threadGroupSizeIsMultipleOfThreadExecutionWidth,
maxTotalThreadsPerThreadgroup and requiredThreadsPerThreadgroup as the
program set them (true, 96 and 8 by 6 by 2 in compute-descriptor-reset),
while the tile and mesh descriptors' resets restore every field on the
same machine. The owner's decision: the header's contract is Metal's,
and the compute descriptor's kept fields read as one release's defect.

docs/API.md section 10 (Kernels) states it. compute-descriptor-reset
loosens its five thread-shape sites to the runtime's default alone
(AnyOf the default, so Metal's kept value is still a divergence),
justified by that entry, and its five known-gaps rows go. A module test
holds the entry, the five paths and the defaults; the other two shapes
loosen nothing. CONFORMANCE-COVERAGE.md regenerated.

Verified: the conformance suite and clippy run on this branch next.
(cherry picked from commit 3dbd14b8fa45f6fcb836603b32aace527d009c0e)
2026-11-07 05:47:31 -08:00
Anees Iqbal 85685b7941 Link a visible-function reference to a definition of another type by position
A pipeline refused a linked function whose definition's type differed from
the reference's (InvalidDescriptor(LinkedFunction { problem: Signature })).
Metal makes those pipelines and passes the arguments by position: MPS's
reduce_stitched declares float reductionStitched::write_fn([8 x i8], float,
float), and the stitcher defines write_fn as float([8 x i8], float), which is
how Geekbench's Background Blur and Face Tracking failed on the consumer.

What Metal does was measured with the probe linked_function_signatures.m
(m3-max-3238, M3 Max, macOS 27.0.1) and the consumer's probes (m3-max-3228,
Radeon Pro 5300M and UHD 630, macOS 26.7.1): every pipeline is made; an
extra trailing argument is dropped (5 on all three); a missing trailing
parameter reads 0 (all three); a same-width plain value is reinterpreted
bit for bit, arguments and results alike (all three); another width is
undefined on the M3 and the 630 and the low bits on the 5300M; a pointer for
a value, a value for a pointer, another address space and an aggregate of
another type are undefined on the M3.

Now a stub whose type differs from its definition's resolves to an adapter
(canon/adapt.rs): an internal function of the stub's type that calls the
definition with the arguments by position, which inlining takes. Dropped
trailing arguments, zero for missing parameters, bitcast at one width, low
bits or zero-filled bits at another (scalars and vectors of int and float, a
bool as one bit, widths up to 64 bits), the result likewise, zero from a void
definition, dropped by a void reference. Anything else (pointer/value,
address space, aggregate of another type, vararg, isomorphic structs of other
identity) is Unsupported(Linking, not implemented) at a surviving call, where
it was an InvalidRequest that claimed Metal refuses it. Stub::Resolved keeps
the definition (the linked function, for the call-stack model) apart from the
function its calls call. The import pairs the definition's type with the
reference's by position, so a definition of another arity still takes the
reference's identified structs.

LinkProblem::Signature had no producer left and is removed (a public
variant of metal2vulkan-air, re-exported by metal2vulkan; api_signatures.tsv
re-blessed). SEMANTICS_VERSION 1976 -> 1977: refused inputs now translate.
docs/API.md section 3 states the contract and section 10 the choices where
Metal's answer is undefined and the refused shapes; REFUSALS.md regenerated
(unchanged).

Tests: link_tests (extra arguments, missing parameters, one-width bits,
other widths, void results, the refused shapes), engine_linking's renamed
linked_scale now links and computes, error/tests maps another LinkProblem.

(cherry picked from commit 493bc2dabe979e2280aea2d3fcbf5d17e2446f28)
2026-11-07 05:19:22 -08:00
Anees Iqbal 3d5bb02ba0 Hold sRGB and blue-first read-write textures in an argument buffer
Metal reads and writes an RGBA8Unorm_sRGB, BGRA8Unorm_sRGB or
BGR10A2Unorm texture through access::read_write, and through an argument
buffer too (read-write-tier-held's `beyond` rows). The heap binder
refused such a member's storage element, NotImplemented
(ArgumentBufferTextures), wherever its storage choice was an alias:
lavapipe and NVIDIA store no 8-bit sRGB format and no A2R10G10B10, so
the dispatch's bind state was refused there, where a slot of the same
texture converts in the shader through the alias.

The heap now does what the slot does, keyed by what the handle carries:

- bind::heap::storage_conversions(profile) lists, per texel class index
  and red-blue order, the formats whose heap storage choice is an alias a
  function converts by (SwizzleBgra, SrgbEncode, SrgbEncodeBgra), one
  class per key; a key whose formats choose otherwise converts nothing.
  The binder views a member of such a choice through its alias (which its
  image lists among its view formats) instead of refusing it; another
  alias (RGB9E5Float's word, ARGB8's rotation, an RGBX format) and a
  swizzle that loses the class are still refused.
- A blue-first format shares its texel class with its red-first kin
  (BGR10A2Unorm with RGB10A2Unorm), so the handle-table entry gains
  FLAG_RED_BLUE (bit 2, metal::format::red_blue_exchanged: BGRA8Unorm,
  BGRA8Unorm_sRGB, BGR10A2Unorm), carried in handle bit 30 by a new
  Lookup::Flagged field where a module converts.
- lower::texture::heap_storage_conversions gives a heap storage read or
  write of a float or half texel the same list; emit::heap_converted
  exchanges red and blue and decodes or encodes the sRGB codes where the
  handle's key is listed, as from_image and to_image do for the slot
  classes. A read's decode notes SrgbTexelDecode and a write's encode
  DevicePackConversion, the slot's notes (rule 1: the device's own
  transfer), recorded outright as other heap accesses' are. On the M3
  Max's MoltenVK, which stores each of these formats itself, the list is
  empty: no conversion, no new note.

Tests: the binder's storage-member test now expects the aliased view
(lavapipe's three formats) and a refusal for the rest; a new test pins
lavapipe's and the M3's conversion lists; metal::format's new test ties
red_blue_exchanged to every committed profile's red-blue choices; the
search's host model and masks cover the new carried bit; an engine test
checks the notes and the carried bit on lavapipe and their absence on the
M3. SEMANTICS_VERSION 1978. docs/API.md's two note entries name the
argument-buffer form.

Verification: Linux unit tests and lavapipe and 5080 replays of
read-write-tier-held follow this commit (sent with the tip).

(cherry picked from commit f4c1fbd1702877f44060593d006dc3372838a112)
2026-11-07 04:56:07 -08:00
Anees Iqbal e9b236a978 Pull a FloatRGB9E5 vertex attribute on every device
Lavapipe reports VERTEX_BUFFER for E5B9G9R9_UFLOAT_PACK32, so a
FloatRGB9E5 attribute went to fixed-function input there, and lavapipe
answered 0 in the fourth component (Metal and Vulkan both say 1) and
other values in the first three: vertex-format-float4 and -half4
differed in 32 (LLVM 21.1.8) or 38 (LLVM 23.1) elements by up to 65409,
and vertex-format-instance-step in its 12 fourth components.

The decision is now structural, made from the format, not the driver:
fetch_as pulls the shared-exponent format on every profile
(fixed_function_format). Vulkan requires no device to fetch it as vertex
input (Table 95, "Mandatory Format Support: 64-bit/uneven Components",
lists only sampled-image features for it), and its decode has no rounding
to leave to the device: each component m * 2^(e - 24) is an f32 and the
fourth is 1. So the module's own decode (lower::stage_io::fetch) gives
the answer a conformant fixed-function fetch gives, and lavapipe gives it
too. FloatRG11B10, the other packed float, stays fixed function: its NaN
widening is the device's.

The vertex-format sweeps now compile two modules where they compiled one
(the pulled format's), and the engine tests say so. SEMANTICS_VERSION
1977: a FloatRGB9E5 attribute's projection and module change. The three
RGB9E5 rows of known-gaps.tsv go (vertex-format-float4 and -half4 on
LLVM 21.1.8, -instance-step on llvmpipe); the LLVM 23.1 pair went in
613a98e22d. docs/API.md's vertex_input entry says it.

Verification: in the commit after this (Linux unit tests, lavapipe
replays on CachyOS LLVM 23.1.4, LLVM 23.1.1 and Ubuntu LLVM 21.1.8, the
5080 and the M3 Max).

(cherry picked from commit 6f2a6f3572b130db513bf457a9daf365ea241951)
2026-11-07 04:56:07 -08:00
Anees Iqbal e1c3821e23 Announce DevicePointSize only at a draw that rasterizes points
What: `PrecisionNote::DevicePointSize` (a vertex function's `[[point_size]]`, or a mesh
function's `set_point_size`, on a device whose `pointSizeRange` ends below Metal's 511
pixels: ANV 255, lavapipe 256) was announced by `Device::degrade_stages` at the variant's
making and at every bind, whatever the draw's primitive. A point size sizes points alone:
Metal has no point fill mode, and Vulkan reads `PointSize` only where it rasterizes points,
so a triangle or line draw of such a state is Metal's exactly. reims's
`gpu::encode_render` many_passes tests on ANV (Iris Xe) draw only triangles through a
vertex function writing `psize [[point_size]] = 1.0`, and died in strict mode at
drawPrimitives on this false notice.

How: `degrade_stages` skips the note, as it skips `ArgumentPixelSamplerScaling`, and
`Device::degrade_point_size` announces it from a draw's settings
(`ShapeInputs::settings`, the place `UnsizedPoints` is announced, so an execution's
command announces it where the runtime records it) where the draw rasterizes points: a
`POINT_LIST` draw, or a mesh draw whose mesh function outputs points
(`GraphicsState::mesh_corners == Some(1)`), without rasterizer discard. The draw shape
memo keeps it as it keeps every settings notice (announced once, or at every draw on a
device that announces the kind at each occurrence, through `EachWatch`).

The conformance allowances that hid it are narrowed to the cases that draw points:
render-draw-forms declares `device-point-size` from its rows (points and empty draw
points; triangles and lines do not), with a module test that the declaration follows the
rows; sample-positions (triangles only) drops it; topology-class declares it for the
point-size function's point draws; primitive-type-crossings keeps it for its `Point`
cells, its comment saying so. The validation lane's `making_kinds` mirrors the runtime.
docs/API.md's catalogue entry says where it is announced.

Test: `tests::point_size_notices` draws a point-size state as triangles, lines, strips
and points on a device that announces the kind at every occurrence, and asserts the
creation and every non-point draw announce nothing and each point draw announces it once
where the device's largest point is below 511 (none where it is not).

(cherry picked from commit db5a2306aceeb4f9994002e68ff6b2ac3fea0813)
2026-11-07 04:26:25 -08:00
Anees Iqbal a988acb096 Hand a mipmapped sampler a minLod past every last level, not FLT_MAX
Metal's lodMinClamp of FLT_MAX reads a texture's last level. The translator handed it to the
device as minLod itself, and lavapipe on x86-64 (CI's Ubuntu 26.04 Mesa 26.0.8 and msi's 26.2.4,
both 256 bits) reads that sampler at level 0: sampler-mip-nearest and sampler-mip-linear's
clamp-float-max sites answer 1.0 (level 0) where Metal answers 2001 (level 2), 16 elements each.

Vulkan clamps the level into [minLod, maxLod] and then to the view's last level, so every bound at
or past LAST_WORD_LEVEL (15, past every Metal texture's last level, 14) reads the same level. A
mipmapped sampler's minLod is now its lodMinClamp clamped into [0, 15] (`mipmapped_min_lod`); a
bound up to 15 is handed as before, and maxLod stays the descriptor's (never below minLod).
Nothing keys on a device: the bound is exact on every one.

SEMANTICS_VERSION 1973 -> 1974: a sampler descriptor's minLod changes for lodMinClamp above 15.
docs/API.md's device-sampling entry says the bound is handed as 15.

metal/sampler.rs is one of the runtime-sources pin's inputs, so the pin moves with this commit
(RUNTIME_VERSION and the pin are left to the landing).

Verified: `a_mipmapped_samplers_min_lod_is_held_past_every_last_level` fails without the change
(minLod f32::MAX, not 15) and checks every view of 1 to 15 levels reads Metal's clamped level under
the handed bounds; the venue replay is the lavapipe evidence.

Landed with SEMANTICS_VERSION 1976: the branch took 1974, which stack 37 and the heap YCbCr notes
(1975) had already taken.

(cherry picked from commit bdb7efa414f579579e73c33d8f82fd7b312a61c6)
2026-11-07 02:59:40 -08:00
Anees Iqbal b37276fa4c Note a heap texture's YCbCr filter where its handles and sampler can reach one that filters
What. A filtered `half` or `float` sample of a texture an argument buffer holds (a heap's) now
records `PrecisionNote::HalfSampleFilter` / `FloatSampleFilter` on a device that samples through
Metal's own sampler (MoltenVK), as a slot's sample does, under clauses the plan answers at each
draw or dispatch:
- `SpecKey::HeapYCbCrTextures(stage)`: a heap member of the command reaching the stage (a texture
  it makes resident, or binds at a texture slot of the stage) is of a two-plane YCbCr class
  (`TexelFormat::two_plane_ycbcr`);
- through an argument buffer's sampler, `SpecKey::FilteringArgumentSampler`: a listed argument
  sampler (`BindShape::argument_samplers`, every live state) has a linear min, mag or mip filter,
  anisotropy or a cubic filter; through a runtime slot, the bound word (`filtering_word`); a
  constexpr sampler that reads one texel of one level records nothing.
Only a 2D, one-layer, color, single-sample heap sample can reach a two-plane texture, so 3D, array,
depth and multisample heap samples record nothing. The plan computes both keys in `record_noted`
(which now takes the heap's stage reach), so they are a function of the bind shape: the runtime's
bound-value memo, keyed by (variant, plan, specialization), stays valid. The runtime announces a
holding heap clause as `ycbcr-filter-not-exact` (`degrade_clauses`), naming the stage.

Why. A probe on the M3 Max (MoltenVK) showed a 4:4:4 two-plane texture (identity address-mode map:
`YCBCR8_444_2P`, `YCBCR10_444_2P`, their sRGB twins, the packed 10-bit one) held by an argument
buffer and sampled linearly through a constexpr, runtime-slot or argument-buffer sampler ran and
announced nothing, where Metal's own sampler filters the kept image's float texels, not Metal's
exact filter: an under-announcement. (4:2:0, 4:2:2 and the code-reading 4:4:4 textures reached
through handles are refused, `MappedTextureSampling { through: Handles }`; a slot texture sampled
through an argument buffer's sampler is refused at translation, `ArgumentBufferTextures`.) Which
sampler state an argument buffer holds is in its memory, which no plan reads (the binder's rule:
argument samplers come from object lifetimes), so the argument-sampler test is "a live state
filters": a program whose live states are all nearest announces nothing.

SEMANTICS_VERSION 1973 -> 1974 (precision notes change for heap samples on metal-sampler
profiles); ARTIFACT_FORMAT_VERSION 489 -> 490 (two `SpecKey` variants in the codec). The golden
table does not move (no SPIR-V changes). `api_signatures.tsv` gains the two variants.
heap_linear_samples_are_the_device_s now expects the specialized note on MoltenVK 2D samples.

Verified (potluck):
- M3 Max, MoltenVK, GPU (job m3-max-2786): 64/64 lane tests (ycbcr_textures, ycbcr_in_place,
  degrade_notices, pixel_samplers, ycbcr_device_reads, argument_linear_samples), the new
  a_ycbcr_texture_through_an_argument_buffer_announces_its_filter_only_where_it_can_filter
  printing, for YCBCR8_444_2P and YCBCR10_444_2P_sRGB: constexpr linear 1, runtime nearest 0,
  runtime linear 1, argument nearest 0, argument linear 1, argument nearest with a linear state
  alive 1; RGBA16Float 0 in every case.
- lavapipe (msi, llvmpipe LLVM 23.1.1; job m3-max-2775): the same 64/64; announced only where
  the device converted the 8-bit 4:4:4 texture itself.
- M3 unit tests (jobs m3-max-2767, m3-max-2774): the new
  tests::engine_heap_binder::a_heap_texture_s_ycbcr_filter_note_holds_where_its_sampler_can_filter
  and 134 more (engine_heap_binder, engine_ycbcr_in_place, engine_handles, golden_hashes, cache),
  api_signatures/api_surface/refusal_surface 19/19, runtime tests::degradation 17/17; clippy
  plain, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings clean.
- Negative controls, both failing: no heap note (the unit test, and the lane's constexpr linear
  case announcing nothing on the M3); a plan answering 1 for both keys (the unit test at
  "YCBCR84442P beside none", the lane's argument nearest case announcing on the M3).
- Release CLI on moltenvk-m3, tip against 80d2dc465f, 3 runs: tail_argument_samplers
  argument_sampler_sample 0.02 s / 25.1 MB both; handles argument_buffer_runtime_sampler 0.02 s /
  25.6 MB both; grd_half_many_samples 0.05 s / 25.9 MB both.

(cherry picked from commit 8403d3746182d6c1acf7795666fc46fea811e660)
2026-11-07 02:57:47 -08:00
Anees Iqbal c3cbf1e76b Conformance: the RTX 5080's XR rows at the multisampled shadow; lavapipe's BGR10_XR masks merge
The RTX 5080 (b5080 entry xr2-replay-xr, every xr-* case at b026d47db4) now matches the M3's
four-sample gamut counts (226/295 elements, one code; sRGB 547/548, up to four codes), where the
ledger had 542/543 and 610/622 from before the per-sample shadow: those ten rows take the M3's
counts and text. New rows for the 5080: the eight gradient cases (blended 134/142/109/145
elements, one code; unblended 39/44 and sRGB 56/86, the same counts as lavapipe's, the device's
float arithmetic of the gradient), the BGR10_XR masks (the M3's counts: 37, 41, 9, 14) and the
padded sRGB fill (92). The 5080's other unlisted xr-* divergences (blend, clears, clear-routes,
draw, planes, two-plane samples, two-planes) are in cases this branch does not touch; they are
left out here.

lavapipe at 36239bb3ab (msi's LLVM 23.1.1 and Ubuntu 26.04's Mesa with LLVM 21.1.8, the CI
image's): the four BGR10_XR partial-mask cases no longer refuse. Their texels match Metal's
(linear) or sit one code off (sRGB: 14 and 9 elements, the M3's counts), but the runtime announces
extended-range-blends-stored-codes at the merging draw: it reads the color over an input attachment,
where no half shadow is held, and the pipeline's state does not tell a read that only keeps codes
from the function's own fetch. The ledger records that as our gap (case/notices rows), and the
notice's documentation (degradation.rs, API.md) says it fires there. A base build (cbc30cb2c5) on
msi's lavapipe shows the same 99 older unlisted xr-* divergences as the tip, none new.

Also: `BGR10_XR_sRGB` spelled whole in the masked rows, and the llvmpipe four-sample rows' open
gap narrowed to the shadow over an input attachment. CONFORMANCE-COVERAGE regenerated.

(cherry picked from commit b982d02d53bf879382f09638a7c8c780fce89af9)
2026-11-05 21:13:40 -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 7c6b61b76d Leave the mesh limits whose Metal answers follow compiler history out of the cases; ledger the amplification refusal
What: the mesh-limits family drops its 16 rows of a required threadgroup
size or a function's own thread maximum, the fixture its two functions of
one, and MeshLimitsSpec its required sizes. mesh_pipeline_limits.m and
docs/API.md (accepted differences) record why: on the M3 Max each such
answer changes with what the compiler compiled before (a first compile
refuses a required size of 32 under a maximum of 64 in either stage and
makes it after a compile under 64; a first compile of a function of
max_total_threads_per_threadgroup(64) answered 32), so the recorded
mesh-limits-required-mesh-32-max-64 made where the probe and a first
compile refuse. known-gaps.tsv lists mesh-limits-amplification-2's
refusal on every venue.
Why: a recording of those rows holds the compiler's history, not an
answer; the amplification refusal is an open gap.
Verified: fresh-source creations on the M3 Max (jobs m3-max-2717 and
m3-max-2725); the family re-records in the next job.

(cherry picked from commit 187f1b12c0b8282a0dcf1e43ab530123ccf1d2fa)
2026-11-05 21:13:15 -08:00
Anees Iqbal 8f2f973478 Announce a runtime sampler slot's YCbCr filter note only where the bound sampler filters
What: a filtered sample's note of a two-plane YCbCr format through Metal's own sampler
(`PrecisionNote::HalfSampleFilter`, `FloatSampleFilter`, announced `ycbcr-filter-not-exact`)
through a runtime sampler slot now holds only where the word of the sampler bound there filters.
`lower::sampler::linear::filter_note` crosses the bound-format clauses with two tests of the bound
word (`NoteOn::BoundSampler`, `SpecKey::BoundSamplerWord`, which the plan already records for
noted keys): a linear min or mag filter, anisotropy or a cubic filter (any of those bits), or a
linear mip filter, the constexpr rule `linear::unfiltered` read from the word. A constexpr
sampler keeps its rule; an argument buffer's sampler, whose word no slot test reads, keeps the
format-only clauses.

Runtime: such a clause tests a bound value, so `Device::degrade_bound_values` reads it at each
draw or dispatch. It now also answers `SpecKey::BoundTexelFormat` from the command's formats (the
class `bound_texel_format` gives; a slot bound to nothing fails the clause, as
`degrade_bound_formats` reads it; unknown formats hold), checks a filter note's kind as
`ycbcr-filter-not-exact` (one atomic load once announced), and `degrade_clauses` announces a
filter note's slot of unknown format (an execution of GPU-written commands) as that kind, naming
"a format the GPU's commands bind", as `degrade_bound_formats` does. Which clauses hold stays a
function of the plan (the shape it is planned for holds each bound format and sampler word), so
render.rs's `QuietBoundValues` holds.

Why: a runtime sampler slot announced the note whatever its sampler state, so a nearest runtime
sampler on a texture that keeps its image (a 4:2:2 or 4:4:4 one on the M3) announced it though
a nearest sample reads the one texel the view holds, Metal's read; the consumer runs notes fatal
on Apple GPUs.

Validation: `run_kinds` (degrade_notices) evaluates the bound formats through the same closure,
and `bound_value_kinds` maps a filter note to `ycbcr-filter-not-exact`.

Tests: `tests::engine_ycbcr_in_place::a_runtime_sampler_s_filter_note_holds_only_where_the_bound_word_filters`
(clauses on moltenvk-m3 hold for linear min, mag, mip and anisotropic words over YCbCr formats,
not for nearest words or other formats; lavapipe records none) and the lane test
`runtime_lane::ycbcr_textures::a_runtime_sampler_announces_the_ycbcr_filter_only_where_it_filters`.

Docs: the notes' rustdoc, `YCbCrFilterNotExact`, docs/API.md's two entries.
SEMANTICS_VERSION 1973: the artifact's specialized notes change (no SPIR-V changes).

Verified: cargo fmt; builds and runs follow.
(cherry picked from commit d464b1d36f998cd8c69a9f2c9252288df64d13d9)
2026-11-05 21:13:11 -08:00
Anees Iqbal 570df3cc95 Answer maxArgumentBufferSamplerCount from the set-1 sampler array and the sampler limit
What: `DeviceProperties::max_argument_buffer_sampler_count`, Metal's
`maxArgumentBufferSamplerCount`: one fewer than the smaller of a set-1
sampler array's elements and the device's maxSamplerAllocationCount
(element 0 of the array, and one of the device's samplers, are the
neutral sampler's; each state the array holds takes an element and a
sampler of its own). The array's elements are a new public translator
function, `pipeline::heap_sampler_capacity`: link's heap capacity for a
heap of one sampler array with set 0 counting no sampler, the least of
the handle table's 65536 entries (TABLE_CAPACITY) and the two
update-after-bind sampler limits, 0 where a function cannot read a set-1
sampler array (the layout's features or the module's non-uniform
sampled-image indexing). Link's heap_capacity now reads the same limit
table (`heap_limits`) and arithmetic (`room`), and heap_set the same
layout-feature check (`heap_layout_lacks`), so the sizing and the answer
cannot drift. The runtime's `Device::sampler_array` (each state's
creation-time check) now calls it too: it was the two update-after-bind
limits without the handle table's reach, 500000 on MoltenVK where link
makes 65536 elements, so a state past 65535 was not announced as it was
made. The device's SamplerCount and the answer read one value, the
identity's maxSamplerAllocationCount.

Why: the consumer computed it as the least of the two update-after-bind
sampler limits and maxSamplerAllocationCount; that misses the handle
table's reach (500000 against our 65535 on the M3) and the neutral's
element (32768 against 32767 on lavapipe, 4000 against 3999 on NVIDIA).

Metal on the M3 Max (macOS 27.0.1) answers 500000 (a Swift query of
MTLCreateSystemDefaultDevice, potluck job m3-max-2496), recorded in the
field's docs and docs/API.md's accepted differences.

Tests: engine_handles::an_argument_sampler_array_has_the_heap_sampler_capacity
(link's array equals the function on every committed profile, follows
lowered limits, 0 without the features); capabilities::
argument_buffer_samplers_are_one_fewer_than_the_array_and_the_sampler_limit
(every committed profile, pinned venue values); the device test
argument_sampler_count (the kernel's array, the device's count, the
driver's limit and the answer agree; elements-1 states unannounced, the
next announced). Verification follows in the branch's report.

(cherry picked from commit 7a2b84f15a1dde81e35cbc0b9367962e54d8332f)
2026-11-05 18:59:21 -08:00
Anees Iqbal 296723b362 Test a filter notice's bound format against the format the slot's binding presents
The consumer's own-format view test died on the M3 Max (MoltenVK) in strict mode at a sample of
an 8-bit 4:2:0 texture's 2D array view in its own format: `ycbcr-filter-not-exact`, "texture 0
bound as YCBCR84202P". That view is the luma view (`Texture::luma_view`): an `R8G8B8A8_UNORM`
image of the codes, read as the code-reading format `RGB8_420_2P` through a swizzle, which
Metal's own sampler filters as Metal filters that format (the lane already holds the view's
linear sample to that format's, and Metal's view to it bit for bit). The binding plan reads the
bound record's format (`ViewRecord::bound`, `RGB8_420_2P`), but the notice's bound-format test
read `Texture::pixel_format`, the view's own (`YCBCR8_420_2P`), whose class carries the 1/2048
field `FloatSampleFilter`'s clause tests. So the note was wrong: no float texels are filtered
there. The 10-bit views (`RGB10_420_2P` codes, `A2B10G10R10_UNORM_PACK32`) and the `_sRGB`
twins' views announced it alike.

`Tables::bound_format` now reads the format the texture's bindings present
(`Texture::bound_pixel_format`, `ViewRecord::bound`), the one its slot's code was specialized
for. That changes what the bound-format notices test and name for every texture that reads its
image in another format: the luma views; views in other channels of their image's bits, whose
class is their image's; and converted textures over a P3 surface, whose image is the
code-reading format's codes. A P3 texture's linear sample is no longer announced: Metal's
filter of it is not measured, now a FAST-PATHS known gap. Notices only: no pipeline, binding or
answer changes.

Docs: ycbcr.rs (views; linear filtering, with the in-place form's 4:2:0-only reach), the
YCbCrFilterNotExact declaration and its API.md entry, and the FAST-PATHS known gap.

Verified: cargo fmt. The lane check of the previous commit fails without this on the M3 Max;
device runs follow.

(cherry picked from commit 37a50861dd4e105619690a520a290c30bd3208d5)
2026-11-05 18:59: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 a57e6c770a Copy a standing shadow in whole at its command buffer's first use
A pass that loads a shadow and draws under a scissor copied in only the
scissor's texels, so the image held only those: a later command of the
same command buffer reading every texel copied them all in again (beyond
what it held), and the command buffer's end, holding less than every
texel, left no standing. On the M3 the padded Private plane's Write frame
(a scissored pass, then a pass sampling the surface whole) planned
9478144 texels in a frame and skipped only the scissor's 262144 (job
m3-max-1937); WriteThenReadApart's writer never stood.

At a command buffer's first use of a shadow that may stand across
command buffers, the copy in takes every texel, as over logged host
pages: it moves nothing where the image stands, and leaves the image
holding every texel for the command buffer's later commands and its end.

The device test adds a pass that draws inside four rows: its load takes
the standing image, and the next command buffer's read stands and holds
the pass's rows over the earlier texels. API.md's catalogue entry says
the scissor cut does not apply to that first use.

Verified: runs next on the M3 with the controls.
(cherry picked from commit 258964cc06d8c4da64866b6991ec8b46906fa504)
2026-11-05 13:14:47 -08:00
Anees Iqbal 66ea975bdb Take a command buffer's tracked uses as its writes, whatever the logs collected
The standing let go of every shadow at each command buffer whose uses the
device's logs of host pages did not collect (`unnoted`), taking that as a
command buffer that may reach memory no use names. But `unnoted` only
says no log or copied host buffer lived to collect them (`note_dirty`):
the tracker's summary of every encoder holds its tracked uses either way.
So on a device with no logs every command buffer let go of every
standing, and none ever held (M3 job m3-max-1916: the second read of the
Private plane skipped no copy in).

Only `State::reaches_unnamed` (a root table, work resolved from records)
lets go of all now. A shadow over a buffer whose own uses are untracked,
whose writes no summary holds, never stands: the plane's texture takes
its descriptor's tracking, not the buffer's. The module docs and the
API.md catalogue entry say both.

Verified: runs next on the M3, with the negative controls.
(cherry picked from commit dcc32875db5aee8a8903ef9443235edce8de97cf)
2026-11-05 13:14:47 -08:00
Anees Iqbal 660f69188b Name the cross-command-buffer standing apart from a carry's, and say its cost
The standing commit's `shadow_standing::Standing` collided with shadow.rs's
own `Standing` (a carry entry's Unread/Current/Lost), which failed the
build (E0255). It is `StandingAcross` now.

The ShadowedTexture notice's cost said every use copies in; over a tracked
private buffer of the runtime's own a later command buffer now copies in
only once another command buffer wrote it. The cost text and the API.md
catalogue entry say so, and the entry names the conditions (the buffer's
kind, no handed-out VkBuffer, a command buffer reaching unnamed memory
letting go) and the counter.

Verified: the M3 build that failed on E0255 (job m3-max-1857); this
commit's build and the catalogue test run next.

(cherry picked from commit 52986e4c999b6fbdb593c177265fd577cdcfe553)
2026-11-05 13:14:47 -08:00
Anees Iqbal 39639ef473 Follow struct members in the narrow analysis: mixed-select merges and a read's noted bits
What. Two analyses in lower/arith/narrow.rs looked only at whole values, so a value carried
inside a composite slipped past both:

- `merges_mixed_selects` (now `narrow::merges`) decides whether a module merges a select of a
  widened `half` against a value it does not hold widened with another widened value. Metal's
  compiler answers 2045 of the 2046 `half` NaNs of that merge `0x7E00` (measured on the M3 Max,
  2026-11-03), so a module that does it stays outside `DriverDeviation::MetalNanMoves`. It
  checked only scalar selects at phis and stores, and missed the same merge when a struct (a
  texel read's `{T, i8}`), an array or a vector carried the select and the other value. The new
  module records how each value is made (construct, insert, extract, copy, select, phi) and asks
  member by member, by a path of literal indices, whether a merged value holds a mixed select
  where another merged value holds a widened one. Walks are bounded (256 steps per question, 256
  members per type; past a bound the answer is the conservative one), and the records are charged
  to the meter.
- `known_bits` reused a `half`'s read bits only when the stored value was the read itself. A
  store of the read's value pulled back out of a struct (`{T, i8}` built from the read, then
  `OpCompositeExtract`) encoded the `half` again, which is the device's narrowing and loses a NaN's
  bits. The builder now records each struct construct, insert and extract it emits
  (`ModuleBuilder::structs`, counted in its footprint), and `FunctionBuilder::member_source`
  walks an extract back to the value that supplies the member wholly. A later insert into part
  of the path, a struct the builder did not make, a load or a phi gives no source. `known_bits`
  follows it before looking up noted bits.

Both decide from IR structure only (types, composite paths, operands), never from names.

Why. The coordinator's bug: `narrow::merges_mixed_selects` misses struct-wrapped merges, and a
store of a read's value does not see noted bits through the `{T, i8}` extract.

Docs: driver_facts.rs (the MetalNanMoves measurement) and docs/API.md's native-nan-encoding
entry now say the merge is followed member by member, and that a `half` moved unchanged from its
read keeps its bits through a struct's member too. The member-by-member reading is not measured
through a composite; the code and the docs say so.

SEMANTICS_VERSION 1968 -> 1969: translations change. The golden table moves 30 cells, all
`engine/rfs_imageblock_cover{.ll,.air.ll} | cover_two_word`, on every one of the 15 profiles.
That kernel's `as_type<half>` result is now stored from its noted bits through the struct
member instead of being encoded again. The table is re-blessed on development, not here.

Verified on the M3 Max (potluck, debug):
- New tests:
  - `lower::arith::tests::narrow::narrow_members_move_as_bits_through_structs`: every
    pattern of every narrow form, through a construct, inserts, a nested struct, and a
    replaced member, compared exactly.
  - `lower::arith::tests::narrow::a_merge_of_a_select_is_followed_through_struct_members`:
    builder-made `OpPhi`s of a plain select and of structs carrying it by construct, insert
    and extract are merges; a struct holding the select apart from the other value's member,
    and a merge with a constant, are not.
  - `tests::engine_arith::half_moves_are_metals_only_where_the_device_folds_them` gains
    kernel `member_kept`: a `half` read, inserted into `{half, i8}` and extracted keeps its
    bits (0xFE01) and widens nothing.
  All three, plus engine_cross_class and engine_float_call_notes, pass: 15/15, job
  m3-max-1192.
- Negative controls, with the translator sources of fd1029d6c9 under these tests (job
  m3-max-1195): all three fail.
  - The merge test fails at `Struct` (false, want true).
  - The members test fails "Form { held: Float(Half), lanes: 1 } through a struct
    (construct): 2045 of 65536 cases differ".
  - `member_kept` widens on lavapipe (true, want false).
- Note sets: a census of every public fixture's entries (2914 rows per stem) on moltenvk-m3 and
  lavapipe. It recorded each row's precision notes and whether it requires MetalNanMoves, before
  (fd1029d6c9's sources) and after. The two files are byte-identical (job m3-max-1195), so no
  fixture gains or loses a note on either device.
- Full metal2vulkan suite at an earlier stage of this change: 3335 passed. The 2 failures were a
  since-corrected test expectation and the golden table above (job m3-max-1190).

(cherry picked from commit a4c235fb867a6a32098b77e39387c43a97a28862)
2026-11-05 07:39:33 -08:00
Anees Iqbal be34c40f1d Bound a packed blend by the code its sample was stored at
The multisampled word lane compares each blended sample of a format the
device renders itself with Metal's within one code. The blend reads the
sample the device's fill stored, which the lane already accepts a code from
Metal's (the device's conversion, `device-color-conversion`), and the device
blends over that code by its own arithmetic, so the two native differences add.
On lavapipe (Mesa 26.2.4, LLVM 23.1.1) `A1BGR5Unorm` at 4 samples, pixel 12:
the fill stored 0x9ea1 where Metal stored 0x9e61 (green 26 against 25), and
source-over at alpha 0.102 stored 0x9ea5 against Metal's 0x9e23 (green 26
against 24, blue 18 against 17); the exact blend over the device's own sample
is green 25.31, blue 17.44, so the device's blend is itself within a code.

The lane now allows a blended sample one code more for each code its stored
sample lies from Metal's (none on the word path, whose fill is exact).
`PrecisionNote::DeviceColorConversion`, `Degradation::DeviceColorConversion`
and docs/API.md's catalogue record the measured lavapipe bound: within 2
codes over a sample stored a code from Metal's.

Verified on msi-laptop, lavapipe (Mesa 26.2.4), `--cfg m2v_cpu_icd`: at
b23d78eb50 `multisampled_word_formats_store_read_resolve_and_blend_as_metal`
fails on that one sample (word 0x9ea5 against Metal's 0x9e23), every other
blended sample within one code; the words above came from a scratch
diagnostic run (not committed).

(cherry picked from commit 5a4a8ca8fc297b03f19b39cf675eee1ada29742c)
2026-11-05 07:39:32 -08:00
Anees Iqbal d261d6ed46 Announce device-subpixel-snap where the band draws on a driver not measured to snap a half step as Metal
line_widths' wide_lines_draw_metal_s_parallelograms (and its exact-answers
twin) failed on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, b5080 entries
nvlane-lane2-a2f and nvlane-lane3-a2f at a2f4c50f94) and on lavapipe
(llvmpipe, LLVM 23.1.1, Mesa 26.2.4, nvlane-lvplines-a2f) at "rows
offset by (r - 32) / 512 width 0": both drew the map's rows 18 to 49
where Metal draws 17 to 48. Before a5e1d20bd9 the 5080 failed earlier in
that test, at "LANE strip 1", so this case had not run there.

The case draws lines at y = r + 0.5 + (r - 32) / 512, which the band
draws at width 1/16 (half width 16/512). band.rs leaves the corners'
snap to 1/256 pixel to the device's rasterizer, where Metal snaps the
endpoints first, a half step rounded up, and offsets them after; the two
agree on the grid, and for odd r the endpoint lies half a step off it.
Half steps rounded down give the device's map exactly: odd r covers its
row for r in 19..49 and even r for 18..48, against Metal's 17..48 (round
to even gives the same rows here). The band's arithmetic is exact at
these values (side 64, every conversion a power of two), so the rounding
is the rasterizer's, which Vulkan leaves to the implementation: the
device's own answer, so it is announced, not emulated.

- DriverFact::SubpixelSnapIsMetals (appended): the driver's rasterizer
  snaps a vertex half a step off its 1/256-pixel grid as Metal snaps a
  line's endpoint, up. Row: MoltenVK on the M3 Max (APPLE9), where this
  lane's maps pass (a2f4c50f94, m3-max-994: 1847 of 1847). NVIDIA and
  lavapipe drew otherwise, so neither takes it; every other driver is
  unmeasured.
- Degradation::DeviceSubpixelSnap ("device-subpixel-snap", precision):
  announced by line_route at each draw the band draws on a driver
  without the fact. Its catalogue entry in docs/API.md, a FAST-PATHS
  known gap, and the conformance suite's NATIVE_NOTES (the device's own
  answer) take it. band.rs's and line_width.rs's docs say where the two
  snaps differ.
- The lane announces it per draw; a band case with a vertex an odd
  multiple of 1/512 pixel off (in framebuffer pixels) is left unchecked
  where it is announced, and every other band case is still compared
  with Metal's map. Held to the fact: never announced where the driver
  has it, and some case unchecked where it does not and the device
  tessellates. degrade_notices lists SUBPIXEL_SNAP as its site.
- driver_facts' profile test expects the fact on moltenvk-m3.

Note sets: MoltenVK on the M3 Max takes the fact, so it announces
nothing new. NVIDIA, lavapipe, RADV and ANV now announce
device-subpixel-snap at band draws. api_signatures.tsv gains the three
items (blessed); docs/REFUSALS.md regenerates unchanged. driver_facts.rs,
degradation.rs and line_width.rs are runtime pin inputs, so
RUNTIME_VERSION and the pin are the orchestrator's to move.

Verified: cargo fmt; scripts/api-signatures --check after --bless;
refusal_surface.py. Builds, clippy, the unit tests and the 5080, M3 and
lavapipe lane reruns are in the next jobs.

(cherry picked from commit 2574f4bb084656035feae4ef714bac96f720f497)
2026-11-05 05:11:14 -08:00
Anees Iqbal 792822226e Take lavapipe out of LineTiesAreMetals: it leaves out the line lane's strip's first pixel
a5e1d20bd9 gave lavapipe the fact on the conformance case's evidence
(llvmpipe draws primitive-type-restart-indices' line through (3.5, 1.0)
as Metal does). The line lane on lavapipe says otherwise: at 3785e99d8e,
under --cfg m2v_cpu_icd on msi-laptop's lavapipe (llvmpipe, LLVM 23.1.1,
Mesa 26.2.4, m3-max-949), wide_lines_draw_metal_s_parallelograms and its
exact-answers twin fail at "LANE strip 1": the strip starts at (3.5, 1.0),
a vertex the diamonds of rows 0 and 1 share, and lavapipe leaves out row
0 column 3, which Metal covers; every other pixel of the map is Metal's.
With the fact the lane held lavapipe to exactness there, and it failed.

The fact's rows are now MoltenVK on the M3 Max alone, so lavapipe
announces device-line-ties at its width-1 line draws as NVIDIA does: a
notice lavapipe did not announce before, for a difference it drew
silently before. driver_facts' profile test no longer expects the fact
on the three lavapipe profiles; the fact's docs, the catalogue entry,
FAST-PATHS' known gap and the lane's docs say what lavapipe draws.

Verified: cargo fmt. The lavapipe rerun of the line lane is in the next
msi job.

(cherry picked from commit a13ef6b9c4aeb5bac7448bd1a16526352458169d)
2026-11-05 05:11:14 -08:00