Commit Graph
711 Commits
Author SHA1 Message Date
Anees Iqbal e2491fe2b7 Read a rasterizing state's void-vertex answer from its compile, not a question
2f44dda930's render creations asked whether the vertex function returns a
value on every creation, so each plain creation counted one more linked-use
question, one more specialized stage entry and one more shared one than its
cost record (159 cases over bounds in the whole-set replay, all those counts).

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

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

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

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

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

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

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

Not yet verified: the tests and clippy follow.

(cherry picked from commit 3b174b367547b6f6187671d84f01797f9fe8f8ea)
2026-11-07 14:01:21 -08:00
Anees Iqbal 2fff78740e Record that a sparse slice past the texture's costs its other levels and tail what it costs inside
UnitGrid::clipped_region charges a mapping update whose slice is past
the texture's own what the same region inside the texture costs: the
region clipped to the level's tiles, a page per tile, the slice's whole
tail at firstMipmapInTail, and nothing inside the tail past it. That
was measured on level 0 alone, and mapping.rs called every other level
and the tail unmeasured.

sparse_slice_past_levels_usedsize.m (landed with rows2's fixes) ran on
the M3 Max (macOS 27.0.1, job m3-max-4446): eighteen shapes, each in its
own process and run twice. It used the direct selector, the indirect one
and the direct one through a view, over a 2-slice 256x256 nine-level
R32Float texture. Every reading is the rule's, and so is every
control's on an in-bounds slice:
- a tile of level 1 or of level 2 costs one page;
- 8x8 tiles on a level holding 2x2 cost four;
- a tile of level 3, the first tail level, costs the slice's tail (one
  page here);
- level 5, inside the tail, costs nothing;
- an unmap gives the page back.
The three forms and the two runs read alike. No behavior changes.

- tests::sparse gains the readings row by row, each with its control.
- mapping.rs states the rule as measured on those levels and the tail.
- The probe's header records what it read.
- FAST-PATHS's known gap said the runtime counts none of these pages.
  It counts the pages Metal's heap counts (sparse/bind.rs charges them
  through SparseState::charged), as docs/API.md's accepted difference
  already said, so the known gap now says the same.

(cherry picked from commit c4a47fc17d634f750b9c62b6489c95d3d4d5d966)
2026-11-07 14:00:19 -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 669d756fd7 Make a texture buffer over a surface's plane at an offset or pitch off 16
What. Buffer::new_texture_with_iosurface_plane makes a TextureBuffer
over a plane of a surface with planes whose offset or bytesPerRow is
off 16 bytes, where it answered NotImplemented(SurfacePlaneShape). Its
texels are placed from the plane's CPU layout (placed.cpu) and go
through into_texture_buffer as a buffer's texture buffer does: its CPU
calls at the plane's offset, its functions from the offset rounded down
to 16. A BC texture off 16 stays refused. SurfacePlaneShape's doc, the
module's Beyond the plane's rows, BufferRefusal::PlaneShape and
FAST-PATHS.md's known gap say so.

Why. Metal makes it, in one place a path. On the M3 Max under macOS
27.0.1 (probes/surface_texture_envelope.m's bgraat8.texbuf.64,
bgraat8.texbuf.128 and bgrarow264.texbuf.128, job m3-max-4776) its
kernels read texel i from the offset rounded down to 16 plus i texels,
and getBytes and replaceRegion from the offset, at a 264-byte pitch as
at 256: the layout a texture buffer over a buffer already has in the
runtime. What Metal lays out in one place stays in place.

Tests: tests::surface_shapes::textures_over_surfaces_take_the_bytes_metal_does
gains the three probe shapes over a plane at offset 8 and at 264 bytes a
row; a kernel's reads are checked against the rows from the offset
rounded down to 16 (gpu_rows_of), the CPU's from the offset. linear_plan's
a_surface_plane_s_other_shapes_follow_the_probe places offsets 36, 8 and
pitch 264 (CPU offset kept, GPU offset rounded down); its refused row
for an off-16 texture buffer goes.

Verified (same tree content on the previous base, replay-27 9a1a8abf1d):
lavapipe on homelab-gem10-1 (m3-max-4868): runtime lane 174/174 with
surface_shapes passing; negative control, the runtime's sources at the
base with these tests: surface_shapes fails.
Re-checked on this base by the
branch's check job.

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

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

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

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

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

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

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

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

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

(cherry picked from commit 5ad2ed0b865ff4027488c398a09fc53c0a80ab2f)
2026-11-07 12:44:45 -08:00
Anees Iqbal 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 d33079bd05 Read a shadowed attachment through a snapshot after a barrier, not a split
A texture over host pages that renders is always a shadow (in_place.rs:
ShadowCause::RenderTarget), the consumer's guest's IOSurface framebuffer
among them, and Texture::snapshot_color took only an image of its own or a
linear image over the bytes. So every draw that read such a target at its own
pixels after a barrier over the render targets split the render pass
instance, on every device: a keep of the whole shadow for the merge, a copy
of every texel from the bytes into the copy the reader reads, and a store and
load of the attachment, at each read (the guest's selfread probe on the Iris
Xe: 30 splits, 31 whole copies in and 30 keeps a frame, 98 ms).

The shadow is the image the pass renders, so the snapshot path serves it as
it serves an image of its own:

- the shadow image takes the feedback loop usage where that costs it nothing
  (Device::if_free, as with_free_usage gives an image of its own), counted as
  WorkCounts::feedback_loop_shadow_images;
- Texture::snapshot_color takes Storage::Shadow's image;
- RenderCommandEncoder::over_bytes (the snapshot at any area) takes a texture
  that renders its bytes through a shadow too (Texture::renders_bytes), as
  the split's copy there reads the bytes into the reader's copy after a keep
  and a merge.

Every other check of render/snapshot.rs stands; the reads are the snapshot's,
exact as for an image of its own. The pass's shadow plan is unchanged: the
attachment is copied in before the instance and merged back as the encoder
ends, as before, without the keeps and copies of the splits.

Tests: runtime_lane::snapshot_reads::a_surfaces_readers_take_the_snapshot_at_any_area
now expects a snapshot for each reader of a surface over host pages wherever
the device takes the path and the image the pass renders took the usage (the
shadow's, or a linear alias's), its bytes unchanged. The self_reads lane
prints the images made with the usage. The WorkCounts field is in the
api_signatures table and host_ab's list; the FAST-PATHS row on attachment
reads names shadows.

(cherry picked from commit 60b9a69d393a097f8658af8bcb5a8d6ef3576441)
2026-11-07 12:33:49 -08:00
Anees Iqbal 8de3a6023b Regenerate REFUSALS.md and the API signatures for RasterizedVoidVertex and open_gl_mode_enabled
(cherry picked from commit a479dc65fc8840b739a35c2e94b15dc4cdf81afa)
2026-11-07 12:12:33 -08:00
Anees Iqbal 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 5e4e9bc60c Make a byval argument's copy at its call, so the inliner takes the call
A byval(T) parameter is the callee's own copy of the T its argument
points to, made at the call. Apple's OpenCL compiler passes a struct
kernel argument so: __entry_st copies the value from its constant buffer
into an alloca and calls st with that pointer byval. The inliner refused
every byval call (DirectCall), so a struct passed by value did not
compile (msi job m3-max-4674: the engine's by-value reflection test).

canon::byval::explicit now runs before pointer erasure: each call that
passes a thread-memory argument byval gets an alloca T and an
llvm.memcpy of T's bytes from the argument just before the call, passes
the copy as a plain pointer, and the attribute leaves the call and every
function's parameters. An argument outside thread memory, or a T
without a size, leaves the module as it was, and the call stays
refused, typed.

Tests: a byval argument is copied at its call and inlined; one outside
thread memory stays DirectCall at the call, naming the callee.

(cherry picked from commit 85844bd545602fa1bc14cb410e6e0b89b3a8c696)
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 6a31655071 Guest RAM on a listed device: no making or copy waits for a long chunk's import
On a device where each listed import costs every submission (RADV with a dma-buf source), a
guest RAM's chunks are a few long dma-bufs (2.7 GiB on the Radeon 780M and RX 7900 XTX), and
the first object over a chunk not imported imported it on its own thread: 660 to 692 ms, at
the first object over each chunk and again at a released chunk's next use. A copy over such a
chunk (copy_from_host_ram, copy_to_host_ram) did the same on the encoding thread.

Now the chunk's import is off the caller's path:
- On a listed device the device's thread (listed_chunks, in place of release_idle) imports each
  chunk an object or copy asked for (ChunkSlot::asked, RamOnDevice::next_asked), and still
  releases idle chunks. The object, and every object over the chunk until the import is done,
  is bound in an import of its own run alone (RamOnDevice::run_alone), as on a device that
  imports ahead; those after lie in the chunk.
- A buffer's (not a heap's) run import is releasable as a no-copy buffer's own import is
  (host_residency.rs, AgainFrom::RamRun): released while idle, its address never handed out,
  and at its next blit bound in the chunk's import where that is made and lays the bytes as the
  run's did, else in its run's own import again; never the chunk's import nor a wait for one.
  This holds on every device whose objects take run imports.
- A copy over a chunk not imported imports each of its ranges of that chunk alone (ranges less
  than 2 MiB apart joined, at most copy::MOST_ALONE = 16), held by its command buffer, while the
  device's thread imports the chunk (RamOnDevice::for_copy); more ranges than that, or where an
  object's run would not be imported alone, the chunk as before.

Tests: the listed device test now checks the first object's run import, the thread's import of
the asked chunk, the holders in the chunk, the runs' release while idle and the rebind in the
chunk at the next blit, the chunks' release, and a copy over a released chunk taking its run
alone. The AHEAD copy window test expects the copy past the window to import its page alone.
Unit tests: next_asked's choice, alone_ranges' joins.

Docs: host_ram.rs, host_residency.rs, host_ram/copy.rs module docs, use_host_ram,
HostMemory::with_runs, WorkCounts::run_imports_live, FAST-PATHS.md, HOWTO.md.
(cherry picked from commit f80468eb4afac1e30f14fd99e1af06b67622a1a1)
2026-11-07 11:10:07 -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 96482aadbf Re-derive the conformance coverage document for argb8-targets-destination-alpha's rows
6d7223a048 replaced the case's refused row with a lavapipe texel row and did
not re-derive the document. Verified: scripts/conformance-coverage/coverage.py
writes this; the ledger holds 3295 rows.
2026-11-07 10:41:21 -08:00
Anees Iqbal 48ba1d9856 Guest RAM on a device that pays per listed import: few long chunks, none ahead, idle ones released
Where the device imports dma-bufs, the RAM has a source and the device's held imports add to the
cost of every submission (RADV), each listed import costs every submission: an 8 GiB RAM as 128
dma-bufs of 64 MiB raised a submission's median from 14 us to 60-88 us on the 780M (probe
submit_per_ram_dma_buf, job 3904), as 3 of 2730 MiB to 16 us.

There (Plan::listed) a chunk is as long as one dma-buf of the source holds
(HostRam::with_largest_dma_buf, new: udmabuf's size_limit_mb) and maxMemoryAllocationSize,
maxBufferSize and maxStorageBufferRange take, in whole 64 MiB (listed_chunk_bytes). No thread
imports ahead and no run is imported alone; the device's thread instead releases a chunk only its
slot holds once it stayed so for its window (2 s, doubled per release up to 64 s, as a no-copy
buffer's idle import), counted by the new WorkCounts::host_ram_chunks_released.

Tests: listed_chunk_bytes and long chunk_spans unit tests; a device test
(where_each_listed_import_costs_a_submission_...) of one long chunk, none ahead, kept while held,
released once idle and imported again; the probe submit_per_ram_chunk (8 GiB memfd RAM, an
object over each 64 MiB). Docs: host_ram.rs, with_runs, HOWTO section 6, FAST-PATHS idle-release
row, api_signatures.

Not built yet: the next commits fix forward what the build finds.

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

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

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

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

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

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

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

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

(cherry picked from commit 9a22813ff057ffd81cce438c7a49652798f67bf7)
2026-11-07 10:04:13 -08:00
Anees Iqbal 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 d2f766e88e Fold only the integer bit operations in SCCP
Folding llvm.umin and the other two-operand integer intrinsics over constants made seven
engine_arith tests fail (job m3-max-4310). Their kernels take an opaque integer as
llvm.umin(C, -1), so a NaN or denormal pattern reaches the device without float arithmetic.
OpenCL C's mem_fence needs only llvm.bitreverse. SCCP now folds ctpop, bitreverse and bswap,
and leaves the rest to run where they did, so no module outside the OpenCL shapes changes.

(cherry picked from commit 94d75b4fad376c3138a467893adaa42dedf65a75)
2026-11-07 09:53:31 -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 e2aa48a1dd Bless the API signatures for RuntimeFact::RotatedInputBlend and regenerate the refusal surface for rows2's sites
The argb8 commits (413c737777, 75e73605c7) add the RuntimeFact variant
RotatedInputBlend and move a Format refusal's sites; neither generated file
was refreshed on the branch. Verified: signatures.py --check passes after
the bless; refusal_surface.py regenerates with this change only.
2026-11-07 09:38:35 -08:00
Anees Iqbal 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 b5fa3a8067 Bless the API signatures and re-derive the coverage doc on the rebased tree
On development c0d0511d68 plus this branch, the signature bless rewrites one
record, metal2vulkan-runtime::commands! (macro-template), whose committed text
no longer matched the macro. The coverage doc is regenerated from the merged
case set and ledger.

Verified: m3-max-4172 on homelab-ms01-1 at f7a9747f90 ran
`scripts/api-signatures/signatures.py --bless` (one signature changed),
`scripts/conformance-coverage/coverage.py`, and
`scripts/refusal-surface/refusal_surface.py` (REFUSALS.md unchanged), then
clippy in all three configurations and rustdoc, all clean.

(cherry picked from commit 7644dfd59580037247e8236f5ed4a8f84bbcf282)
2026-11-07 09:37:29 -08:00
Anees Iqbal 1fcaa5aa58 Read an executed indirect command's unstrided buffer at stride 2^32-1, as Metal does
An executed indirect command's kernel or vertex buffer set without an
attribute stride (the plain setter, or the stride form at
MTLAttributeStrideStatic), on an indirect command buffer that supports
dynamic attribute strides, under a layout of
MTLBufferLayoutStrideDynamic, was refused
NotImplemented(RuntimeGap::IndirectCommandUnstridedBuffer): plain Metal
reads it at the record's 32-bit stride word, 2^32-1 (measured on an M3
Max under macOS 27.0.1 with markers at bytes 2^32-1 and 2^32 of a buffer
past 4 GiB, compute and render alike; the stride form at 0xFFFFFFFF read
the same), which the 32-bit fetch could not place. The pulled fetch now
places a displacement past 32 bits (its reach check, a80982a04b), so both
executions bind such a buffer at stride u32::MAX
(indirect_execute::unstrided_stride), and without dynamic-stride support
at stride 0 as before. The RuntimeGap variant, its decision function and
the render side's reads_vertex_stride go; so does the validation
checker's rule that authored executions bind such buffers with the
stride form (check_replayed_strides), whose only reason was the gap.

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

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

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

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

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

(cherry picked from commit 8b4a0783997511a3ffcda495f3887749da56ca4a)
2026-11-07 09:37:10 -08:00
Anees Iqbal 4df5d48abe Ledger: drop the 8 RADV rows that rows3's two fixes settled
rows3 (e1ff50ac33) made two product fixes:
- GPU writes into read-only no-copy memory are now dropped off macOS.
- pass-sequence-color-actions' DontCare attachments are kept under the
  exact policy the replay runs.
The RADV rows for both families recorded the old answers, and the whole
RADV replays at development c418a1f55b read every one of the 8 as stale
("no longer diverges ... and the known-gaps ledger still lists it"), on
the Radeon 780M (m3-max-4236) and on the RX 7900 XTX (m3-max-4237) alike:
- host-page-writes-kernel-store-read-only and
  host-page-writes-visibility-read-only, each at
  case/bytes-in-a-later-command-buffer-bytes and
  case/bytes-the-cpu-reads-bytes;
- pass-sequence-color-actions at its four MTLStoreActionDontCare cells.
No venue's row is left for either family. docs/CONFORMANCE-COVERAGE.md
re-derived. Besides these, each replay held one unlisted line,
pass-bytes-srgb-decode-all-bytes, which amdperf owns.

(cherry picked from commit 0017a2c76ddad7a214127e4b700e5740fe3b6917)
2026-11-07 09:32:23 -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 9ab152f477 Ledger: RADV's remaining families, 295 rule-1 rows (275 RADV, 20 NAVI31)
The rest of the RADV ledger round: every line the whole RADV replays
read as unlisted, on the RX 7900 XTX (m3-max-4102, 306 lines) and the
Radeon 780M (m3-max-4108, 281 lines, each identical to an XTX line),
except the 10 lines the case declarations of b5c45c23cf settle and
pass-bytes-srgb-decode-all-bytes' one line, which amdperf owns.

Each row names the native note the RADV run announced for its case at
that site (the case block's "the device's native notes this case
announced" line, or a case-declared notice that fired), and states the
device's own answer with RADV's first differing element and largest
difference:
- 275 rows read "RADV": the 780M holds each of them with the same
  answer, so a RADV row holds on both of the consumer's AMD GPUs.
- 20 rows read "NAVI31": ycbcr-gathers-* and ycbcr-minify-band-*,
  where the XTX's memory is not the host's and the slot binds a
  converted image. The 780M, which reads the planes in place, does not
  diverge there.

Families with a text of their own:
- sampler-r-address-modes and sampler-border-colours: one lane, r the
  negative smallest subnormal, which Metal reads as layer 0 and the
  device reads below it.
- sampler-axis-mode-triples: the device's weight in whole 1/256 steps.
- denormal-word-fetches: the device's nearest samples flush a denormal
  and its gathers keep it.
- BC1 to BC3 sRGB: the sRGB decode moves, since the 780M's block decode
  is measured to be Metal's. BC4 and BC5: the device's decode.
- a2c-*: the device's coverage at alpha 0.5 is samples 0 and 2, and its
  resolve rounds a tie down, as device-rounded-resolve records for RADV.
- texture-fills, nearest-sample-positions, sample-positions-default-*,
  math-frexp-ilogb-half, the pass-bytes tanh and encode sites, and
  blend-interaction-format-*.
The other rows take another venue's venue-neutral text, after the first
differing element and the largest difference were substituted and the
text was read against RADV's answer.

docs/CONFORMANCE-COVERAGE.md re-derived (scripts/conformance-coverage).
Proof: the whole RADV replay on both GPUs at this branch's tip.

(cherry picked from commit 2e0f7f2baf5f72200580b2092005e49645eca4be)
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 8d8db05c06 Record what a bit-24 no-copy buffer's dropping copy costs off macOS
On the RTX 5080 Laptop GPU, commit to completion, median of 300 (the
scratch example rows3_cost, b5080 entry rows3-t2 in batch m3-max-3848):
beside a live 16 MiB copy whose pages carry no log, a 256-byte fill into
a writable 16 MiB no-copy buffer took 1.5 ms (49 us beside a 64 KiB
copy), and the same fill into the copy 2.6 ms; into a 64 KiB copy 53 us.
Before the page-at-a-time restore (rows3-t1, same batch) the fill into
the 16 MiB copy took 13.1 ms. The known gap in docs/FAST-PATHS.md now
says so; one code span there is rewrapped onto one line.

(cherry picked from commit 3c595e52ada9f9088a86e8077ab6a536c43c204f)
2026-11-07 09:05:41 -08:00
Anees Iqbal 75137702ab Record what a DontCare colour's kept texels cost
Family A's change came in be0b42bc67/568dd0d59b (a DontCare colour of a
texture's own image keeps its texels through a pooled backing) and
18b42a54bc/e3b68145f3 (drop the pass-sequence-color-actions rows). Their
subjects say WIP and they have no body, so this is their body:

What: kept_bytes::settle now also renders a colour attachment of a
texture's own image stored DontCare (not memoryless, resolving nothing,
not over a buffer) through a backing its queue keeps for the
attachment's shape (attachment_stand_in::pooled_backing, which now takes
whether it copies, Cause::KeptTexels), into which a Load copies the
texels first; the backing is stored DONT_CARE and nothing is copied back.
Not where the pass hands the store to a driver whose DONT_CARE is
Metal's own (MoltenVK), nor the viewed/executes/taken passes, nor where
a format makes no stand-in. No dont-care-store is announced for it, as
the texture keeps Metal's answer; WorkCounts::kept_texels_passes counts
each such pass.

Why: Metal's documentation leaves a DontCare store's contents open ("You
need to assume that GPU discarded the texture's contents"); what the M3
Max leaves, measured by pass-sequence-color-actions over eight runs, is
the attachment's texels from before the pass. Vulkan's DONT_CARE leaves
them undefined, and llvmpipe and the RTX 5080 left the pass's clear and
draw (8 ledger rows). STORE_OP_NONE does not keep the texels of a pass
that writes, so no store op alone matches; the backing does at the cost
below.

Verified:
- lavapipe: pass-sequence-color-actions every plane equal to Metal's
  (m3-max-3621, m3-max-3768, m3-max-3807 at the rebased tip); the whole
  lavapipe set matches the ledger exactly (3768: 1156 rows; 3807: 1137);
  the touched lane tests pass under m2v_cpu_icd (48 at the tip, 3807),
  among them dont_care_stores'
  a_dont_care_color_keeps_its_earlier_texels_on_every_driver, which
  counts kept_texels_passes.
- MoltenVK on the M3 Max: the case announced, its planes exact
  (m3-max-3743, m3-max-3822); 46 lane tests pass under m2v_gpu.
- Negative control (keeps_texels forced false, steelbrain/rows3-negctl,
  m3-max-3729): the 4 llvmpipe rows come back.
- Costs (this commit, docs/FAST-PATHS.md): the scratch example
  rows3_cost on the RTX 5080 (b5080 t entries rows3-t1, rows3-t2, batch
  m3-max-3848) and lavapipe (m3-max-3765, m3-max-3782).

(cherry picked from commit b0197dcf1103f2794723a2cf520f20d698a7b2fd)
2026-11-07 09:05:41 -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 f085d298cb Regenerate REFUSALS.md for kept_bytes::settle's second Render site
kept_bytes::settle now matches NotImplemented(Render) from the pooled
backing of a DontCare colour (it keeps the pass in place there), which the
refusal surface reads as a second site of gap::Render. Regenerated with
python3 scripts/refusal-surface/refusal_surface.py; no refusal changed.

(cherry picked from commit 8ca3ed766dc2d022ace03a294694d78b03faf7a9)
2026-11-07 09:05:40 -08:00
Anees Iqbal 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 c0d0511d68 Ledger: RADV's half-output-blends, pixel-downscales, half NaN, pixel-samplers and vertex-format families, 201 rule-1 rows
From the same whole RADV replay (m3-max-4016 at 7470a49e6d). Each
family's notes are announced for its cases on RADV (the case's own
native-note line, or every declaration fired: none of these cases is
among those whose declarations did not all fire, save the MoltenVK-only
set-past-layout one), and each row states RADV's own answer:

- half-output-blends (63): the device's fixed-function blend where
  Metal's compiler folds blend and conversion under fast math, under
  half-output-fast-math-blend; the rows say whether a site is within
  that note's bound is not established, as llvmpipe's do.
- pixel-downscales (42): a normalized downscale differs by 0.031 of a
  code at most, inside device-sampling's RADV bound (0.548); a pixel
  sampler's by up to 0.876, inside pixel-sampler-scaling's 2/255; the
  digest sites point at the head and tail rows.
- half-texel-nans, half-read-nans, half-write-nans (38): each a NaN
  whose sign and payload are the device's, under native-nan-encoding
  and the case's announced conversion note, with RADV's first
  differing element.
- pixel-samplers (38): digests of the device's own sampler and
  conversion; the subnormal arg and slot sites hold the digest
  MoltenVK and lavapipe answer, the device's floor of a negative
  subnormal, under device-denormals.
- vertex-format (20): a narrow float attribute's NaN widened with its
  payload, under device-nan-encoding; a float read as half keeps the
  NaN's sign, under native-nan-encoding.

All are scoped to RADV. CONFORMANCE-COVERAGE.md re-derived.

(cherry picked from commit 8e309cbacd31cdf61ecc74bbad8876225ae7a299)
2026-11-07 08:37:49 -08:00
Anees Iqbal ff6d387aa7 Ledger: RADV's extended-swizzles family, 193 rule-1 rows
The whole RADV replay (RX 7900 XTX, RADV NAVI31, Mesa 26.2.6; potluck
job m3-max-4016 at 7470a49e6d) read 704 lines not in known-gaps.tsv;
193 of them are the extended-swizzles family (extended-range,
padded 10-bit, packed 16-bit, bfloat and sRGB-twin formats under
every swizzle and op). Each is a site the case's M3 Max, NVIDIA and
llvmpipe rows already hold, and each is the same answer:

- 124 sites read exactly the count and largest difference another
  venue's row holds, and 15 more (the sRGB twins' gathers and reads)
  differ from it only in the largest word difference (91309 here
  against 91311-91315), the same one-step code; their row texts state
  the module's own decode and encode arithmetic and the device's
  conversions, venue-neutral, under device-pack-conversion, which
  every one of these cases announced on RADV, so they are reused as
  they stand;
- 20 extended-range linear samples (sl) blend their taps by the
  device's FMix, under bicubic-filter-arithmetic, which these cases
  declare and which fired on RADV (none of them is among the cases
  whose declarations did not all fire); each row now names RADV's
  own first mismatch and how far apart it is in value;
- 14 bfloat NaN sites keep the NaN's sign and payload where Metal
  answers 0x7fc00000 (RADV's first: ours 0xFFEF0000), under
  device-pack-conversion;
- 20 packed 16-bit linear samples are the device's own filter and
  widening, under device-sampling and device-texel-conversion
  (announced); each row names RADV's first differing element and
  that device-sampling's RADV bound (0.548 of a code) is measured on
  unpacked formats only.

All are scoped to RADV. CONFORMANCE-COVERAGE.md re-derived.

(cherry picked from commit b255f138531068fea5f2d4edc2be7f2084d24c09)
2026-11-07 08:37:37 -08:00