Commit Graph
4448 Commits
Author SHA1 Message Date
Anees Iqbal 79fc9eec07 stage_in_user_key.m: what the M3 Max answered for both forms 2026-11-12 04:10:11 -08:00
Anees Iqbal 9081edca8e Keep the plugin list a refusal; compare the typed fixture's module words
The empty !gld.plugin_info list is what this Mac's (macOS 27) OpenGL front end writes, and its
modules then stop at other module-level shapes (an `OpenGL GLSL` language version beside
Metal's, repeated versions, contradictory compile options); the guests' modules, from macOS
26, reached the entries. So the module-level shapes stay refusals, and only the two entry
shapes the guests met change. The engine test compares FunctionArtifact::module.words.
2026-11-12 04:10:11 -08:00
Anees Iqbal 797a440edd A kernel stage-in attribute named by its user key, on the lane and on Metal
The runtime lane's stage_in_strides takes the owned fixture kernel_stage_in with each
stage-in attribute's location followed by its name (`attrib_N`), as Apple's OpenGL front end
writes a kernel's stage-in node, and requires the fixed-stride words its unnamed form
answers. The probe stage_in_user_key.m makes both forms' stage_in_fetch on Metal and prints
their words.
2026-11-12 04:10:11 -08:00
Anees Iqbal 663e15af9f Bump SEMANTICS_VERSION to 2043: OpenGL front end shapes the ABI now decodes
A kernel stage-in attribute's user key, a plain buffer's declared size differing from its
typed pointee, and an empty !gld.plugin_info list were refusals and now decode, so the
outputs of such modules change (kernel_read_through_constant.air.ll among the fixtures).
2026-11-12 04:10:11 -08:00
Anees Iqbal 71f820395a ABI: OpenGL front end shapes: a stage-in attribute's user key, a plain buffer's declared size, the empty plugin list
Apple's OpenGL front end (GL on Metal) writes AIR that Metal makes pipelines of and the
metadata ABI refused:

- A kernel's per-attribute air.stage_in node follows its location with the attribute's
  name as a user key (`attrib_0`), as AIR 2.2 does for a vertex input. A stage-in attribute
  binds by its location, so the key is read and dropped, as the vertex input's is. Before:
  UnknownKey with no key at the argument.
- A plain buffer's air.arg_type_size is its declared type's (`uchar`, 1) while the typed
  pointer parameter points at a float or uint. Metal makes the pipeline, as it does for the
  owned fixture kernel_read_through_constant's one `char` behind a pointer to its 160-byte
  struct. The declared size now governs a plain buffer with no struct layout (alignment still
  a power of two, air.buffer_size a multiple of the declared size); an argument buffer's
  (its element stride for memory), a threadgroup argument's and a struct layout's pointee
  still agree. Before: TypeSizeMismatch at air.arg_type_size.
- Every module it writes names an empty !gld.plugin_info list, which carries nothing; a
  non-empty one stays UnknownKey.

Found from AIR this Mac's OpenGL wrote for GLSL of our own (scratch, not committed).
Unit tests for each shape; the typed fixture now compiles to its opaque form's module.
2026-11-12 04:10:11 -08:00
Anees Iqbal 1e659e16e1 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 04:09:47 -08:00
Anees Iqbal 5238c0855a RUNTIME_VERSION 2106: minimumLinearTextureAlignment answers the pitch every usage keeps in place
The commits before this one. minimumLinearTextureAlignmentForPixelFormat: probed only a read texture's images, so
ANV on an Iris Xe answered 16 and a render target at that alignment fell to a shadow (its rows not on the device's
memory line, the renders check failed). The probe now tries ShaderRead, then RenderTarget, then ShaderWrite, and
answers the largest of their smallest in-place alignments, at least nonCoherentAtomSize (Metal's 16 stays where no
usage is ever in place). The linear_alignment record's VERSION goes 1 -> 2, so every driver probes once again. The
answer promises the probe's pitch (the row's bytes rounded up to it); a wider bytesPerRow is not promised in place.

Verified: ANV Iris Xe (ms01, m3-max-20463) answers 64 for 96 formats where it answered 16; 9/9 render targets at 64
in place, the old answer's RGBA8 one at offset 16 a shadow; 72/72 reads in place. lavapipe (m3-max-20437) 64,
9/9 + 72/72; RX 550 (m3-max-20451) 256/512/1024 by texel size, 9/9. tests::linear_alignment, capabilities, families
39/39 (m3-max-20424); lint three ways and rustdoc (m3-max-20468). The probe's first query: lavapipe 17.2 -> 43 ms,
RX 550 119 ms, Iris Xe 124 ms (debug), once per driver identity and record version.
2026-11-12 04:08:45 -08:00
Anees Iqbal 1725128528 Linear alignments: the answers and the probe's time measured with its three usages
The README named the M3 Max's MoltenVK at 16 and RADV at 256 from probes of reads alone. It now
names what the lane measured with reads, renders and writes at d91a18ca98: ANV on an Iris Xe and
lavapipe 64, RADV on a Radeon RX 550 256 (512 and 1024 for 8- and 16-byte texels), and 16 for the
formats no texture of over a buffer is ever in place. The module doc's probe time (17 to 23 ms,
reads alone) is now the first query's with the record absent, in the same debug lane test: 43 ms
on lavapipe (m3-max-20437; 17.2 ms with reads alone, m3-max-5986), 119 ms on the RX 550
(m3-max-20451), 124 ms on the Iris Xe (m3-max-20463); reading the record took 0.20, 0.53 and
0.69 ms.

Verified: cargo fmt; docs only.
2026-11-12 04:08:33 -08:00
Anees Iqbal 56dbf31db5 Render targets at the answer: try the probe's pitch alone
The lavapipe lane (m3-max-20419) failed a_render_target_at_the_answered_alignment_is_in_place
at RGBA8Unorm 16x5, offset 64, rows 128 apart: a shadow at the answer of 64. The probe tries a
row's bytes rounded up to the alignment as the pitch, so the answer promises that pitch, not
one an alignment wider; the test now makes its render targets at the probe's pitch alone, and
its doc says a wider one is not promised. The tight case passed in the same run.

Verified: cargo fmt. The lane rerun follows.
2026-11-12 04:08:33 -08:00
Anees Iqbal 2edb063c6a tests::linear_alignment: skip a profile that states no nonCoherentAtomSize
roadmap-2022, a requirements profile, states none; the rule's sweep over
the committed profiles now reads the 18 that state their line and
checks that many do. Job m3-max-20418 failed on it.
2026-11-12 04:08:33 -08:00
Anees Iqbal 3e5293679e minimumLinearTextureAlignment: every usage's pitch, at least the device's line
The answer was, per format, the smallest power of two from 16 at which
a ShaderRead texture of every probed width took its in-place image. Two
things it did not cover:

- A texture that renders or that a shader writes takes the same
  in-place image with those usages, whose linear layout the driver may
  pitch otherwise. The probe now tries reading, reading and rendering,
  and reading and a shader's writes (USAGES), and answers the largest of
  the usages that ever lie in place (a usage the format's linear images
  cannot take has none).
- The device's check of images in place measures lines of
  nonCoherentAtomSize bytes (in_place::RowEnds), and on the Iris Xe its
  renders and writes of texels that share a line with bytes beside them
  fail (the line holding a row's last texels is written back whole). ANV
  answered 16 against a 64-byte line, so a guest that laid a render
  target out at 16 put its texels in a line with bytes before them: a
  shadow. The answer is now at least nonCoherentAtomSize, "the size and
  alignment in bytes that bounds concurrent access to host-mapped device
  memory" (vkspec, Limits) (placed_answer). At it, a texture whose rows'
  bytes fill whole lines shares none with other bytes. Rows whose bytes
  are no multiple of the line keep their padding in their last line at
  any alignment, so on ANV those stay shadows for renders and writes
  whatever the answer; the docs say so.

Metal's 16 stays where the device imports no host pages, for a format
no usage brings in place, and where a probe failed. The record's VERSION
goes to 2, so no answer of the old probe is read again. Expected answers
(the venues' read answers with the line): ANV 16 -> 64, lavapipe 64,
RADV 256, MoltenVK 16 (its line is 16).

Tests: tests::linear_alignment's the_answer_is_the_usages_largest_and_
at_least_the_line (the rule over every committed profile's line, ANV's
16 before and 64 after); the lane's render-target test (previous commit)
gains the same texture at Metal's 16, a shadow wherever the check failed
such renders.
2026-11-12 04:08:33 -08:00
Anees Iqbal 6e5a5594e8 Lane: a render target at the answered linear alignment is in place
A RenderTarget texture of RGBA8Unorm, RGBA16Float and RGBA32Float over
a no-copy buffer, at an offset of the format's
minimumLinearTextureAlignmentForPixelFormat answer and rows whose bytes
are a multiple of it (tight, or the answer apart past them), must share
no line of the device's memory (in_place_check_line, nonCoherentAtomSize)
with bytes beside its texels, and must be in place wherever the device's
check passed renders of such textures over pointer-imported pages; a
blit out of it reads the caller's texels.

The answer must be at least the device's line for that. On ANV the
answer is 16 and the line 64, so this test fails there until the answer
takes the line (the next commit). over_pages takes the texture's usage.
2026-11-12 04:08:32 -08:00
Anees Iqbal 7f3412bf64 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 03:58:04 -08:00
Anees Iqbal a4466edfa6 RUNTIME_VERSION 2105: heap textures over host pages in the device's image, padded rows in place, reordered views of the image
The commits before this one (their own bumps to 2101-2103 were taken by other landings and are left out). Three
behaviour changes, each a shadow or copy that was a first option where the device has an in-place form:
- A texture Metal tiles in a Shared heap over host pages lies in the device's own image over the pages first; Metal's
  tiled byte layout is kept only as the fallback. Apple documents a heap texture's byte layout as private, and the
  consumer's guest code never reads or writes those bytes directly. The host-allocation linear image's requirements
  go through the requirements cache (counted), so making such textures every frame makes no extra VkImage.
- A texture over a buffer whose GPU bytes only the runtime's ordered commands write (a Private buffer, a Managed
  buffer's device copy) and whose rows are padded lies in place in route 1 (LINEAR, PREINITIALIZED, kept GENERAL)
  where the driver's rowPitch equals the buffer's pitch: Vulkan 7.1.1 (a transition from the current layout
  preserves the range) and 12.11 (host-accessible aliases are consistent). Not render targets. New counters:
  kept_padding_aliases; managed_ranges_modified / managed_bytes_modified, managed_resources_synchronized /
  managed_bytes_synchronized. New runtime query Device::linear_texture_bytes_per_row: the driver's own linear pitch.
- RGBA8Unorm, BGRA8Unorm and their sRGB twins, when they render, list their channel-order sibling and its twin in
  VkImageFormatListCreateInfo, so a pass renders into a BGRA8 view of an RGBA8 texture made without PixelFormatView
  (the view Apple documents as allowed) on the image itself, with no shadow; a linear image never loses a feature to
  the sibling formats (linear_keeping).

Measured (release, medians): the reordered view's clear, 3090 60.0 -> 17.8 us, RX 550 620.6 -> 228.8 us
(shadowed-texture-view notices 1 -> 0); the plain clear and copy unchanged within spread on both (3090 17.4/42.1 ->
18.3/44.1, RX 550 230.1/393.9 -> 229.0/392.2), so listing the siblings shows no measurable compression cost there.
Tests: kept_padding 3/3 and the view, sample and resource_ids lanes 71/71 on the 3090 (m3-max-20450); heap_layouts
counts tiled 1 -> 0 per shape with texels through every API path; lavapipe green (m3-max-20281, 20429); build and
gpucfg clippy (m3-max-20414).
2026-11-12 03:57:06 -08:00
Anees Iqbal f26ed9a694 Tests: the Shared contrast's shadow copies in for a kernel's read; reordered views within 1
kept_padding's Shared contrast read and wrote the shadowed texture with blits, which go to the
buffer's bytes, so the shadow never copied in (m3-max-20318, 20380 on the 3090). A kernel
(invert_texels) now reads it: the copy in is counted and the kernel reads row 7 as the CPU wrote it.

view_attachments' BGRA8Unorm view check allowed no difference; the 3090 stored 0x7f where Metal
stored 0x80, a unorm tie the device rounds its own way. It takes the slack of 1 the file's other
unorm checks take.
2026-11-12 03:56:51 -08:00
Anees Iqbal 944d3f11a9 image_plan: linear_keeping clears MUTABLE_FORMAT by difference
The crate's ImageCreateFlags has no remove (E0599 in m3-max-20332, the
gem10 build of 66b5cad4bb); difference is its form.

Verified: not yet built; the next gem10 build builds it.
2026-11-12 03:56:51 -08:00
Anees Iqbal 72a86e45f3 kept_padding: the Shared contrast counts the copy in before a blit that writes a row
On the RTX 3090 (m3-max-20318) the Managed test's in-place half passed
and its Shared contrast failed: the blit that reads the shadowed
texture into a buffer reads a texture over a buffer from the buffer's
bytes, so no shadow texel was copied in. The contrast now writes row 20
into the Shared texture by a blit, which writes its shadow after taking
its texels in (as blit_cover.rs's partial copy), and reads rows 7 and 20
back. The Managed texture's same blit is asserted to copy no shadow
texel in.

Verified: not yet run.
2026-11-12 03:56:51 -08:00
Anees Iqbal 47ccb574ba image_plan: a render target's sibling formats never cost its linear image
231a2cd061 lists a render target's channel-order sibling's formats
(BGRA8Unorm and BGRA8Unorm_sRGB of an RGBA8Unorm texture) in its plan.
The same plan is the linear image's of every texture over a buffer's or
host pages (route 1, the host-allocation image, Between::Kept), whose
check (linear_lack) asks every listed format's linear tiling for the
features the usages need. Where the sibling's linear tiling lacks one
(a color attachment, say) and the texture's own formats hold them, the
listing would have turned such a texture, a guest surface among them,
from the image over its bytes into a shadow.

linear_keeping returns the plan without the formats only the sibling
added where that plan's linear image lacks nothing and the listed one's
does: the linear routes keep their image, and the sibling's views of
that texture stay apart, as before 231a2cd061. Expected, not measured:
the committed profiles' linear tables give B8G8R8A8 and R8G8B8A8 the
same features, so nothing is left out there; the test prints any
profile where it is.

Test: image_plan::render_targets_take_their_channel_order_sibling_s_views
now asserts, where a sibling's views are not taken though the device
renders them directly, that the plan's linear image lacks nothing.

Verified: not yet built.
2026-11-12 03:56:51 -08:00
Anees Iqbal cdcd787fb8 A render target's channel-order sibling views are views of its image
A pass rendering into a BGRA8Unorm or BGRA8Unorm_sRGB view of an
RGBA8Unorm texture made without PixelFormatView usage (and the same for
BGRA8Unorm and the sRGB twins) rendered through a shadow image of the
view's format, copied in before the pass and back after it
(shadowed-texture-view, about 50-95 us a command buffer at 64x64): the
texture's image was mutable only for its sRGB twin's formats, so Vulkan
made no view of it in the sibling's format.

Basis, documented on both sides:
- Vulkan: VkImageFormatListCreateInfo (core 1.2), pViewFormats
  "specifying all formats which can be used when creating views of this
  image", with MUTABLE_FORMAT; the formats are of one class.
- Metal: MTLTextureUsage.pixelFormatView, "Don't set this option if your
  texture view only converts between linear space and sRGB. For example,
  if your texture uses the rgba8Unorm pixel format and your texture view
  uses bgra8Unorm_srgb." Plain Metal makes the BGRA8Unorm view too and
  renders through it (its API validation stops it; view_attachments).

Change (image_plan.rs): a color texture of those four formats with
RenderTarget usage lists, besides its sRGB twin's views, the views of
its sibling and the sibling's twin (reordered_views, reordered_formats),
in the single-sample and the multisample plan; a word attachment's view
is left out as for the twin. A texture that renders nothing lists none:
its sibling views already read the image through a swizzle. The view's
other uses then view the image too (takes_views_of).

Compression: expected, not measured. Mesa's sources suggest RADV before
GFX11 keeps no DCC for a list whose formats' channel orders differ, ANV
keeps CCS_E for formats of the same channel bits, RADV GFX11+ keeps DCC
for any list; NVIDIA documents nothing. The A/B lane
view_attachments::reordered_view_render_costs (the parent commit)
measures it per driver.

Tests: image_plan::render_targets_take_their_channel_order_sibling_s_views
(every committed profile: the sibling and its twin taken where the
device renders them directly, none for a texture that only reads, none
for RGBA16Float); runtime_lane::view_attachments::
a_render_target_s_reordered_views_render_in_place (draws through both
views, Metal's bytes, no shadowed-texture-view).
Docs: the ShadowedTextureView notice (degradation.rs, API.md), the
FAST-PATHS view bullet, view_shadow.rs.

Verified: not yet built.
2026-11-12 03:56:51 -08:00
Anees Iqbal 99d83d06f4 view_attachments: what a render target and its reordered view's pass cost the GPU
An ignored measurement, run by name: a 2048x2048 RGBA8Unorm Private
render target made without PixelFormatView usage, timed for a pass that
clears it and stores, a blit into another such texture, and a pass that
clears its BGRA8Unorm view, each its own command buffer (medians and
fastest of 40 after 8), with the notices printed (shadowed-texture-view
when the view's pass renders through a shadow).

It is the A/B for listing the channel-order sibling's formats in such a
texture's image (the next change): the first two numbers show whether
the driver keeps its compression with the longer list, the third what
the view's pass costs as a shadow against in place.

Verified: not yet built.
2026-11-12 03:56:51 -08:00
Anees Iqbal afff0e6cfe kept_padding: the Managed test's words by as_chunks
clippy's chunks_exact_to_as_chunks denied the constant-size
chunks_exact in the Managed test's host words (m3-max-20244's clippy
leg). The words are the same.

Verified: m3-max-20244 (lavapipe on msi, at 602a8bcc3e) ran the runtime
filter (248 passed, the three kept_padding tests among them), the
validation filter (332 passed, the heap_layouts lane among them) and
api_signatures/api_surface (15 passed); only this lint failed.
2026-11-12 03:56:51 -08:00
Anees Iqbal 946ee6e0b6 Device::linear_texture_bytes_per_row: the driver's own linear pitch for a 2D texture
A texture over a buffer whose rows hold bytes between them is the
device's linear image in place (route 1, and Between::Kept for a buffer
only the device's ordered commands write) only at the pitch the driver
itself reports for that image (vkGetImageSubresourceLayout's rowPitch);
the alias checks it exactly. A caller laying out rows had no way to ask
for that pitch: minimum_linear_texture_alignment_for_pixel_format
answers the alignment of images over host pages (16 where the device
imports none), and a pitch rounded up to it can miss the driver's.

The new query (a runtime extension, no Metal counterpart) plans the
image as the texture's making does (declared_plan), makes the plan's
linear image unbound, reads its rowPitch, and releases it. It answers
None where the texture is not one 2D level, layer and sample, or where
the device has no linear image of the plan.

Test (kept_padding.rs): at the answered pitch the texture over a
Private buffer is in place; at each other padded pitch it is a shadow.
Docs: the runtime README beside the alignment query, HOWTO beside the
kept-padding sentence; api_signatures.tsv.

Verified: not yet built; the lavapipe job and one GPU run follow.
2026-11-12 03:56:50 -08:00
Anees Iqbal 3918e6de0b requirements: Query derives no Debug
vk::ImageTiling has no Debug, so the derive on Query, the requirement
cache's key for host linear images and tilings, failed to compile
(E0277 on the lavapipe build of m3-max-20214). Nothing prints a Query.

Verified: not yet built; the next lavapipe job builds it.
2026-11-12 03:56:50 -08:00
Anees Iqbal 42e11abcd4 Textures over buffers only the device's ordered commands write hold their rows' padding in place
What: a texture that renders nothing over a buffer of the runtime's own memory whose rows lie
with the buffer's bytes between them is now the device's linear image, made PREINITIALIZED, at
the buffer's pitch, where only the device's commands, in the runtime's order, write those bytes:
a Private buffer, and a Managed buffer's own on a device without unified memory (a two-copy
no-copy buffer's device copy, or one with its own host copy), not one whose VkBuffer was handed
out or whose memory is exportable (Buffer::gpu_bytes_ordered). linear_plan::holding answers what
an image may hold besides the texels (Between::{Nothing, Unobserved, Kept}); Kept takes route 1
alone: the linear image whose rowPitch the driver reports equal to the buffer's
(vkGetImageSubresourceLayout, aliases with within_padding). No DRM_FORMAT_MOD_LINEAR image at
Metal's pitch, no image over exportable memory or in exportable blocks, as each is made
UNDEFINED. A render target stays a shadow. Counted: WorkCounts::kept_padding_aliases.

Also two pairs of counts of what the program asks of a two-copy Managed buffer, beside the bytes
the runtime copies: managed_ranges_modified and managed_bytes_modified (did_modify_range),
managed_resources_synchronized and managed_bytes_synchronized (synchronize_resource), to compare
with managed_bytes_copied_in and managed_bytes_copied_out.

Why: the RTX 2080 guest census (reims's v302 run) made 230 textures over Managed buffers, 200 of
them RGBA8 ShaderRead|ShaderWrite at 3884, 4208 and 2448 texels a row with rows rounded up to
256 bytes, every one a shadow for its padded rows ("its rows lie N bytes apart"): 2.52 G shadow
texels first copied in, 1.26 G kept, 1.26 G words examined by merges back. Owner's rule:
in place where possible, a shadow only where impossible. Main approved the route and its
conditions.

Basis (Vulkan 1.4, docs/API.md's shadowed-texture entry): 7.1.1 Image Layout Transitions, "Image
layout transitions may perform read and write accesses on all memory bound to the image
subresource range ... If the old layout matches the current layout of the image subresource
range, the transition preserves the contents of that range": the image's one transition is its
first move, PREINITIALIZED to GENERAL, out of the layout it is in, ordered after and before every
write of those bytes, as only the device's ordered commands write them. 12.11 Memory Aliasing:
"Buffers, linear tensors, and linear image subresources are considered host-accessible
subresources when they are in any of these layouts: VK_IMAGE_LAYOUT_PREINITIALIZED,
VK_IMAGE_LAYOUT_GENERAL ... If two aliases are both host-accessible, then they interpret the
contents of the memory in consistent ways, and data written to one alias can be read by the other
alias." VkSubresourceLayout's "size includes any extra memory that is required based on
rowPitch" puts the padding inside the range. A kernel's writes may change the padding as on the
x86 Macs (in_place::Padding::Free); a render pass's load and store "may read and write back" it,
so render targets keep the shadow.

Verified: not built yet. tests::kept_padding (a Private buffer at 416, 448 and 512 bytes a row,
the buffer read back whole after the image's first move; a Managed two-copy texture changed in
one row through did_modify_range, then a blit-written row synchronized out, every byte between
rows as given, against a Shared buffer's shadow), tests::linear_plan's holding cases and
tests::texture_placement run on lavapipe next, then one RTX 3090 run.
2026-11-12 03:56:50 -08:00
Anees Iqbal e1ba565ea3 Tests: a plain texture in a heap over host pages lies in the device's image over the pages, else in Metal's tiles
What: runtime_lane::heap_layouts follows the route e3b1cd42d1 gives a texture Metal keeps
uncompressed in a heap over host pages. The plain-shape test (renamed
a_host_heap_s_plain_texture_lies_in_place_or_in_metal_s_tiles) branches on the texture's count:
in place (counted untiled, the first announced heap-texture-untiled-layout with its ID, made with
no zeros) its texels round-trip through replaceRegion and getBytes, a blit in and out and a
buffer's fill over its bytes, and a blit into it writes no byte of the heap outside its answered
size; tiled, every assertion of Metal's tiles stands. It prints how many shapes lay each way: the
proof that the tiled count over host pages goes from one per shape to none where the device's
image serves. The made-again, beside-dispatches and two-ways tests check Metal's bytes only for a
tiled texture; the merge-scratch test skips, saying so, for one in place; the block rows count an
untiled row (in place, or decoded) beside a tiled one.

Verified: not run yet; the lavapipe run of the heap lanes follows.
2026-11-12 03:56:50 -08:00
Anees Iqbal 3689e5c9d6 Heaps over host pages: keep the linear image's requirements for host allocations as the plan's others
What: host_image_requirements (the linear image made for host allocations that a texture in a
heap over host pages lies in) now takes the answer kept for its plan on a device that enables
maintenance4, as planned_requirements does, and counts its limits query and its image
(WorkCounts::requirement_limits_asked, requirement_images_made). RequirementAnswers is keyed by
plan and a Query (a tiling for the device's own memory, or the host-allocation linear image).

Why: the commit before this one has every plain texture in a heap over host pages try that image
first, so each making (a window server makes its heap textures each frame) made and destroyed a
VkImage and asked the device's limits, uncounted, where the tiled route asked nothing after the
first. Vulkan fixes the answer by the creation parameters (Resource Memory Association: size by
the create info and its pNext chain, memoryTypeBits by tiling and handleTypes, alignment under
maintenance4), and an image whose handle type the limits take without DEDICATED_ONLY requires no
dedicated allocation ("requiresDedicatedAllocation will otherwise be VK_FALSE").

Verified: not built yet; runtime_lane::heap_layouts' made-again test checks the counts on the
lavapipe run that follows.
2026-11-12 03:56:50 -08:00
Anees Iqbal 9d184d13ec Heaps over host pages: a texture Metal tiles lies in the device's image over the pages first
In a heap over the caller's host pages (new_heap_with_bytes_no_copy), a single-sample texture
whose bytes Metal lays out in its tiles now takes the image bound to the pages wherever one
serves: its linear image made for host allocations, or over dma-buf pages the driver's
DRM_FORMAT_MOD_LINEAR image, in the driver's rows with no copy, announced
heap-texture-untiled-layout (Untiled::LINEAR). The shadow of Metal's tiles (AliasRoute::Tiled)
is the fallback where no such image serves, and stays the route of a copied heap.

The bytes in guest pages are now the device's layout, not Metal's tiles. Basis: Apple documents
a texture's layout in a heap's bytes as private to Metal, and the consumer confirms that no guest
code of theirs reads or writes a heap texture's bytes in guest pages (replaceRegion and getBytes
go through a staging blit; no buffer aliases a heap texture), so the copies in and out of the
tiles shadow bought nothing it could see (the owner's rule: shadows are a fallback, never a
first option). dma_buf_heap_plan now answers why its image does not serve instead of taking the
shadow itself, so a texture Metal tiles over dma-buf pages falls back to the tiles shadow before
the rows one.

Docs: host_heap_plan, AliasRoute::Tiled, the dma_buf module, the heap-texture-untiled-layout
declaration and catalogue entry, and the FAST-PATHS known-gap entry on heap textures in the
driver's layout.

Verified: cargo fmt only; builds and tests run as potluck jobs after this commit.
2026-11-12 03:56:49 -08:00
Anees Iqbal ee52d7e483 Tests: a layer pass's own shadow stands and its backdrop read copies its rectangle alone
The compositor-shaped probe now asserts what lavapipe measured (m3-max-20039, LAYER-STANDING):
from the second command buffer on, the Private plane's shadow is skipped by its standing (1024
texels), and the only texels copied in are the attached read's rectangle a pixel wider each way
(108), whose shadow holds part of the truth and so never stands (Missed::Partial).

Verified: m3-max-20039 printed these counts at d22a0902e5 on lavapipe; the assertions run in the
next job.
2026-11-12 03:56:49 -08:00
Anees Iqbal 658e8b4976 Tests: a compositor's layer pass over a Private plane, command buffer after command buffer
A probe of the standing of a shadowed texture over a Private surface plane that a pass loads,
draws into and reads at its own pixels (a backdrop), as a window compositor's layer passes do:
it prints each command buffer's copies in (LAYER-STANDING) and checks the bytes each pass
leaves.

Verified: cargo fmt only; the run is a potluck job after this commit.
2026-11-12 03:56:49 -08:00
Anees Iqbal 230c34472e Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 03:45:55 -08:00
Anees Iqbal b5c0db3294 attached_levels: name the slot parts alias SlotParts
The exit-guard scan (tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions)
finds the types that keep the device's functions by name, and device/mod.rs's visible `Parts`
keeps them: the private `type Parts<'a>` of render/attached_levels.rs, which holds `&Device`
and keeps no copy of the functions, read as one by name at its three by-value parameters.
Renamed, the module keeps nothing the scan lists.
2026-11-12 03:44:56 -08:00
Anees Iqbal 250438e30e Candidate rows: the argument-buffer sparse-sample cases on the RADV 780M
The two authored cases over tail_argument_sparse_samples (99b72141..., the sample's value where
resident; c8f6a438..., resident() states every texel resident) ran as Vulkan candidates on the
amd-780m-radv venue (AMD Radeon 780M Graphics, RADV PHOENIX, Mesa 26.2.6-arch3.1), stated and
robustness-off legs, against the M3 Max's Metal rows (apple-m3-max-macos27.0.1). All four runs
report Match, with candidate output hashes ebc81c32... and 67c145ea..., the Metal rows' own.

Lavapipe on that node is Mesa 26.2.6 with LLVM 23.1.4, not the venue's Ubuntu 26.0.8 identity, so
the venue check rejected those runs and no lavapipe row is recorded here; CI's Ubuntu lavapipe
qualification covers them.

Verified: potluck m3-max-20423 (homelab-um790-xtx-1, MESA_VK_DEVICE_SELECT=1002:15bf!, radeon
ICD only).
2026-11-12 03:43:53 -08:00
Anees Iqbal d714059dd0 Metal observations of the two heap-texture sparse-sample cases on the M3
corpus-metal qualified both on apple-m3-max-macos27.0.1 (job m3-max-20396, three runs each):
99b72141ffee (the value where resident) output_sha256 ebc81c32735a, and c8f6a438d16d (the residency
read) output_sha256 67c145ea102f, each the SHA-256 of the 2x2 rgba16_float pixels the rationale
states: Metal samples the argument buffer's texture that is not sparse as resident, its texels
exact.
2026-11-12 03:43:53 -08:00
Anees Iqbal 6d9649716b Authored cases over tail_argument_sparse_samples: a heap texture's sparse sample, resident
Two fragment cases over the owned fixture, each a 2x2 rgba16_float argument-buffer texture of
distinct exact texels sampled at its texel centres through the fixture's constexpr sampler (linear
min, mag and mip filters, repeat, anisotropy 10), compared exactly:
- sparse-sample-of-an-argument-buffer-texture-returns-its-value-where-resident
  (argument_sparse_fragment, case 99b72141ffee): the value where resident(), else the
  min_lod_clamp fallback;
- sparse-sample-of-an-argument-buffer-texture-states-it-resident
  (argument_sparse_residency_fragment, case c8f6a438d16d): the value's first two channels and
  0.25 where resident, 0.75 where not.

Installed by corpus-case-check (job m3-max-20388). Qualification on the M3 and the candidates
follow.
2026-11-12 03:43:53 -08:00
Anees Iqbal eef34650ba Re-bless the engine inventory and the golden tables for the argument-buffer sparse-sample fixture
Blessed on development at 7f6c002dce (potluck m3-max-20398, macOS: xcrun metal-as, llvm@21 printouts) after SEMANTICS_VERSION 2042 landed engine/tail_argument_sparse_samples without its cells. Only additions: its golden hashes on every committed profile, its engine-inventory rows and its air_input printout; no existing cell moved.
2026-11-12 03:41:45 -08:00
Anees Iqbal 0096578d8f Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 03:39:26 -08:00
Anees Iqbal 543be65531 RUNTIME_VERSION 2104: maxThreadgroupMemoryLength is the presented Mac class's, up to the device's limit
The commits before this one. The runtime answered maxThreadgroupMemoryLength as min(maxComputeSharedMemorySize,
32 KiB), an Apple GPU's bound, for every Mac class; a real AMD Radeon Pro 5300M and Intel UHD 630 answer 65536
(reims's oracle Q9), the M3 32768. It now answers min(maxComputeSharedMemorySize, the presented Mac class's
bound): 32 KiB for AppleSilicon (unchanged), 64 KiB for IntelOrAmd (MacClass::max_threadgroup_memory_length).
Direct dispatches already took up to the device's limit; the indirect host step clamps to this answer.

Verified: RX 550 (RADV POLARIS12, m3-max-20392) answers 65536 where reims's rsprobe read 32768 at pin 48, and a
kernel wrote and read back all 16384 words of a 65536-byte threadgroup argument, 0 wrong; lavapipe (m3-max-20356)
answers its own 32768, 8192 words, 0 wrong; tests::capabilities and tests::families 37/37 (m3-max-20355); lint three
ways and rustdoc (m3-max-20358, 20359).
2026-11-12 03:38:13 -08:00
Anees Iqbal 13a8232d8c docs/API.md: maxThreadgroupMemoryLength among the presented Mac's answers
The Mac-class section lists what a device presenting a Mac with an Intel
or AMD GPU answers as that Mac; it now names the threadgroup memory
bound (65536 bytes, where an Apple silicon Mac's is 32768) that the
previous commit made the runtime's answer. Docs only.
2026-11-12 03:38:01 -08:00
Anees Iqbal ef9bc65fb7 maxThreadgroupMemoryLength: the presented Mac's answer, 64 KiB on an Intel or AMD Mac
The runtime answered maxThreadgroupMemoryLength as the compile layer's
min(maxComputeSharedMemorySize, an Apple GPU's 32 KiB) on every device,
whatever the Mac class it presents. A Mac with an Intel or AMD GPU
answers 65536 (the consumer's oracle probes: an AMD Radeon Pro 5300M and
an Intel UHD 630, macOS 26.7.1; the M3 Max answers 32768), so a guest
presenting an AMD Mac on an RX 550 (RADV, 64 KiB of shared memory) read
32768 where a real one reads 65536, and took lower paths for it.

The answer is now the device's maxComputeSharedMemorySize up to the
presented class's own (MacClass::max_threadgroup_memory_length, private):
32 KiB for AppleSilicon, unchanged, and 64 KiB for IntelOrAmd. A direct
dispatch already took threadgroup memory up to the device's own limit
(bind::plan::compute), and the indirect host step clamps to this answer,
so every length answered runs. The GPU replay registers flat variants
only, which read no lengths.

The other three queries the consumer reported low (function pointers,
dynamic libraries, rasterization rate maps) are yes in the runtime on a
RADV device; the consumer's lane answers them no. A unit test pins that
on the RADV profile, and the device test checks it where it runs.

Tests:
- tests::capabilities: threadgroup_memory_is_the_presented_mac_class_s
  (per profile and declared class: RADV 65536 as an AMD Mac and 32768 as
  Apple silicon; MoltenVK M3 32768 either way; never past the device's
  limit). The test devices now take their profile's vendorID, so the
  MoltenVK profile presents Apple silicon as its device does. The pinned
  venue answers move: RADV 65536, ANV and NVIDIA 49152.
- tests::families: a_radv_device_answers_function_pointers_libraries_
  and_rate_maps.
- tests::threadgroup_memory_device (m2v_gpu, m2v_cpu_icd): a kernel
  writes and reads back every word of exactly the answered length.
- runtime_lane::capabilities follows the new answer.
2026-11-12 03:38:01 -08:00
Anees Iqbal 7f6c002dce Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 03:37:02 -08:00
Anees Iqbal 1435c6f658 SEMANTICS_VERSION 2042: a heap element's observed residency is resident (the commits before this one)
The commits before this one bumped SEMANTICS_VERSION 2040 -> 2041, the value development already took for the
private-array reach fix, so this one is 2042 (ARTIFACT_FORMAT_VERSION 504 for the new RuntimeFact::HeapResidency).
lower::texture::residency refused the observed status word of a texture read through an argument buffer
(sparse_sample then resident()), so a public forward-rendering sample's fragment shader, whose material textures
sit in an argument buffer, was refused as Lowering(Texture) NotImplemented on every GPU. Such a word is now 0 (Metal's
answer for a texture that is not sparse) and the stage states RuntimeFact::HeapResidency; the planner refuses a
sparse texture its handle tables reach (Unsupported ArgumentBufferTextures, a known gap in FAST-PATHS). A texture-
or sampler-family refusal of an air.* call now names the intrinsic in Unsupported.symbol.

Verified: our fixture engine/tail_argument_sparse_samples FALLBACK before (m3-max-20327), translated with spirv-val
PASS after (m3-max-20349); nextest heap|mechanism|fast_paths|api|refusal|codec 174/174 incl.
tests::engine_heap_residency; the sample's own AIR read in place on the M3 translates on amd-780m-radv and
moltenvk-m3 (m3-max-20381, nothing kept). Golden table and inventory re-bless on development follow.
2026-11-12 03:35:55 -08:00
Anees Iqbal bd427d30ca Name the air.* intrinsic in a texture or sampler family refusal that names nothing
One family refuses many operations alike: Lowering(Texture), NotImplemented, has some 30 sites,
and a refusal's location (a block and an instruction of the canonicalized function) does not say
which operation a consumer's log met. lower::select now names the call's declaration
(Unsupported::naming, diagnostics only, as route_air and the ray tracing family already do) where
a texture or sampler family selection of an air.* call refuses it without a symbol. Feature,
needs and location are unchanged, so no golden cell moves.

Why: a consumer's GL-on-Metal pipeline is refused Lowering(Texture) at block 68 instruction 748
of a function whose AIR stays on the guest; the next log names the operation.
2026-11-12 03:35:36 -08:00
Anees Iqbal 236340a171 A heap texture's observed residency is resident; a sparse member under it is refused at plan
A function that observes the residency of a read, sample or gather of a texture it reaches
through an argument buffer (sparse_sample, then sparse_color::resident()) was refused at
pipeline creation: lower::texture::residency answered Lowering(Texture), NotImplemented, for a
heap element's status word. A forward renderer that streams its material textures compiles
exactly that, so its pipeline never made and it drew nothing.

Metal reports a texture that is not sparse resident everywhere, which is the word 0 the module
already builds for a heap element's access (emit::with_word). So residency() now answers a heap
element's observed residency with no residency form, the word 0, and the stage states the new
RuntimeFact::HeapResidency { stage } (PlanTimeCheck). The planner (bind::heap::HeapPlanner::new)
refuses a sparse texture (TextureFacts::sparse) that such a stage's handle tables reach,
Unsupported { ArgumentBufferTextures, NotImplemented }: answering one would need the member's
tile map or sparse image per handle-table entry, which is not built. docs/FAST-PATHS.md records
it as a known gap; a slot's sparse texture stays answered (RuntimeFact::SparseTexture).

SEMANTICS_VERSION 2041 (refusals become modules); ARTIFACT_FORMAT_VERSION 504 (a RuntimeFact
variant). docs/REFUSALS.md and the API surface table regenerated.

Test: tests::engine_heap_residency over the new tail_argument_sparse_samples fixture: both
fragments compile behind its vertex function on every committed profile with what they use
(moltenvk-m3, lavapipe and amd-780m-radv named), state the fact and pass L3; their plan holds
a texture that is not sparse and refuses a sparse one. Before the change the base CLI refused
argument_sparse_fragment with Lowering(Texture), NotImplemented, at block 0 instruction 2, the
sparse sample (job m3-max-20327, gem10).
2026-11-12 03:35:36 -08:00
Anees Iqbal 9b1e6b09ec Fixture: a fragment's sparse sample of an argument buffer's texture, its residency observed
tail_argument_sparse_samples: a material {texture2d<half> t; uint min_mip;} in constant buffer 0;
argument_sparse_fragment samples t through a constexpr sampler (linear min, mag and mip filters,
repeat, anisotropy 10) with sparse_sample, returns the value where resident() holds and else the
sample clamped by min_lod_clamp(min_mip); argument_sparse_residency_fragment states the residency
it read beside the value's first two channels; argument_sparse_vertex draws a triangle over the
target with uv its normalized position. The front end merges the two samples' {half4, i8} results
in a phi and tests (status & 1) == 0, the shape a forward renderer that streams its materials
compiles.

Compiled by scripts/regen-air-fixtures (metal 32023.922, SDK 27.2).
2026-11-12 03:35:35 -08:00
Anees Iqbal f7f9a72263 Re-bless the engine inventory and the golden tables for the private-reach fixtures
Blessed on development at ee9f6df70c (potluck m3-max-20335, macOS: xcrun metal-as, llvm@21 printouts) after SEMANTICS_VERSION 2041 landed the private_reach_tiles and private_reach_functions fixtures without their cells. Only additions: their golden hashes on every committed profile (57 cells), their engine-inventory rows and their air_input printouts; no existing cell moved. The merged check m3-max-20300 failed exactly these two tests (golden_hashes_match_the_table, engine_fixtures_match_their_golden_printout).
2026-11-12 03:24:19 -08:00
Anees Iqbal ee9f6df70c SEMANTICS_VERSION 2041: a private array of nested arrays is allocated only as far as its proven indices reach
The commits before this one (their own bump to 2040 met development's NaN-LOD bump to 2040, so this one is 2041).
A kernel's private accumulator, alloca [32 x [32 x [4 x [4 x [4 x float]]]]] (256 KiB), was counted and emitted at
its declared size, so a compute pipeline with that shape was refused as PrivateMemory (FunctionStorageBytesPerThread
264264 > 98304 on RADV) where an AMD Mac compiles it; the guest's convolution kernels (Core ML, Vision, MPSGraph full
convolutions) abort on every AMD host. New canon pass (crates/metal2vulkan-air/src/canon/reach.rs), after unrolling:
a count-1 private array of nested arrays narrows to the reach of its indices only where every index is proven (a
constant, a function-constant value, or the counter of a loop whose trip count is decided, through PHI joins and
integer ops that cannot wrap) and every use is an element access or GEP of its own type; anything unbounded,
escaping, read whole or past a level keeps the declared type.

Verified: Metal on the M3 (m3-max-20190, the conformance probe private_array_reach.m) and the RX 7900 XTX (RADV,
m3-max-20285, under the validation layer): our tile kernel's pipeline is made and its 4x128 words equal the M3's; the
kernel with a buffer-bound loop keeps its declared size and is refused as before. canon unit tests (narrowing by
counters and by a function constant; dynamic index, past-level, ptrtoint and whole load keep the type) and the engine
tests: metal2vulkan-air + engine 592/592 (m3-max-20191).
2026-11-12 03:09:57 -08:00
Anees Iqbal 664b7617d7 The tile fixtures' lane and engine tests; SEMANTICS_VERSION 2040
The runtime lane's private_reach makes private_reach_tiles (tile sizes 2 and 4, linking postfix)
on the device the cfg selects and compares its words with what the probe private_array_reach.m
printed on the M3 Max under macOS 27.0.1, and checks private_reach_rows, whose loop a buffer word
bounds, is refused needing its 256 KiB, as the M3 refused it ("Compute function exceeds available
stack space"). The engine test compiles the same fixtures on the RX 7900 XTX's profile: 128 bytes
a thread with no note, and the rows kernel refused needing 262144 of 98304.

SEMANTICS_VERSION 2040: a private array of nested arrays that bounded indices reach in part is
now emitted and counted at its reach, so refusals and modules change under unchanged keys.
The canon module docs and ARCHITECTURE name the pass.
2026-11-12 03:09:30 -08:00
Anees Iqbal 4677b9e1bc The tile fixtures' companions and the Metal probe of the same kernels
scripts/regen-air-fixtures compiled private_reach_tiles and
private_reach_functions (Xcode 27.2's Metal toolchain); conformance's probe
private_array_reach.m runs the same source on Metal. The canon test's builder
is renamed so it no longer shadows the shared kernel() helper.
2026-11-12 03:09:30 -08:00
Anees Iqbal 630870cbdc Reach: an access at an address's offset 0 reaches element 0 below; owned tile fixtures
An access whose type is the type at offset 0 of the type its address names
(trailing zero indices left out) reaches element 0 of the levels it passes
down and the levels below those whole; before, such an access kept the
array's declared size.

The owned MSL private_reach_tiles (a kernel written for its largest tile:
float acc[32][32][4][4][4], tile loops of function constants 0 and 1, each
sum handed to a linked visible function) and private_reach_functions (that
function). Companions follow from scripts/regen-air-fixtures.
2026-11-12 03:09:30 -08:00
Anees Iqbal 503546f49e Test a kernel's private array that bounded indices reach in part
engine_private_memory: the kernel 'reached' declares float a[64][64][16]
(256 KiB) and reaches a[0..2][0..4][3] and a[gid & 1][3][3]; it compiles at
128 bytes a thread with no note on the RTX 5080 (32 KiB) and on the floor of
a device not measured, and read at a[gid][3][3] it keeps 256 KiB and is
refused on both. reach also bounds 'and' by one bounded operand and 'urem' by
its divisor.
2026-11-12 03:09:30 -08:00