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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit 37a50861dd4e105619690a520a290c30bd3208d5)
2026-11-05 18:59:20 -08:00
Anees Iqbal c305c66a7f Give mesh pipelines Metal's descriptor limits, state queries and refusals
The mesh descriptor gains Metal's fields, with Metal's defaults:
max_total_threads_per_{object,mesh}_threadgroup, max_total_threadgroups_per_mesh_grid,
the two threadgroup-size-is-multiple-of-width flags, payload_memory_length,
max_vertex_amplification_count (1) and required_threads_per_{object,mesh}_threadgroup. The
descriptor key reads every one.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit a13ef6b9c4aeb5bac7448bd1a16526352458169d)
2026-11-05 05:11:14 -08:00
Anees Iqbal d9e3324d4e Announce device-line-ties where a driver breaks a width-1 line's diamond-vertex tie unmeasured
line_widths' wide_lines_draw_metal_s_parallelograms (and its exact-answers
twin) failed on the RTX 5080 Laptop GPU at "LANE strip 1": the
three-vertex strip at width 1, drawn in Bresenham's mode, put its
diagonal a row higher than Metal's (row 9 columns 3-4 where Metal draws
row 9 column 3 and row 10 columns 4-5, and so on, its last pixel at row
14 left out). The diagonal runs through vertices two pixels' diamonds
share; Metal covers the lower pixel, and Vulkan's diamond is open, so
the tie is the driver's with no Vulkan control over it. FAST-PATHS'
known gap "One line texel at a diamond vertex on the RTX 5080" already
said so for the conformance case primitive-type-restart-indices, but
the runtime announced nothing: a near-equivalent drawn silently.

- DriverFact::LineTiesAreMetals (appended): the driver's width-1 lines,
  as the runtime draws them, cover Metal's pixel at such a tie. Rows:
  MoltenVK on the M3 Max (APPLE9; its lines are Metal's own, the lane's
  maps pass there) and lavapipe (the conformance case: no texel differs
  on llvmpipe, LLVM 23.1.1, Mesa 26.2.4). Every other driver is
  unmeasured, so NVIDIA, RADV and ANV announce.
- Degradation::DeviceLineTies ("device-line-ties", precision): announced
  by line_route at each draw the device's lines draw at width 1 (a
  plain-width draw of lines or edges, or the nearest width where that
  is 1) on a driver without the fact. Its catalogue entry in docs/API.md,
  FAST-PATHS' known gap (now "announced"), and the conformance suite's
  NATIVE_NOTES (the device's own answer) take it.
- The lane announces it per draw, leaves such a case unchecked as it
  does the other announced routes, and holds it to the fact: never
  announced where the driver has it, announced in some case where it
  does not. degrade_notices lists LINE_TIES as its site.
- driver_facts' profile test now expects the fact on the three lavapipe
  profiles and moltenvk-m3.

Note sets: MoltenVK on the M3 Max and lavapipe take the fact, so neither
announces anything new. api_signatures.tsv gains the three items
(blessed); docs/REFUSALS.md regenerates unchanged. Not covered (left as
it was): a pipeline whose multisample state keeps Bresenham's mode off
(alpha to coverage, alpha to one, sample shading) draws the device's
default mode, which the fact does not measure. The runtime's notice and
line_width.rs are runtime pin inputs, so RUNTIME_VERSION and the pin are
the orchestrator's to move.

Verified: cargo fmt; scripts/api-signatures --check after --bless;
refusal_surface.py. Build, clippy, the unit tests and the 5080 and M3
lane runs are pending (the lane fixes batch).

(cherry picked from commit 75bb1413eacbf5ef3e1a3abed7ec97eff4b1c42d)
2026-11-05 05:11:13 -08:00
Anees Iqbal 639e505b11 State NVIDIA's BC decode bound as the RTX 5080 measures it: 4/255 for BC1 to BC3, 7.4/255 for BC4 and BC5
compressed_decode's bc1_to_bc5_texels_read_the_device_s_decode failed on
the RTX 5080 Laptop GPU (identically at d19da8bfce and 961b1ff319: the
lane's blocks are seeded) with channels past compressed-texel-decode's
stated bound. Its BCDECODE lines, per channel:

  BC2RGBASRGB  codes [2, 4, 2, 0]            18 past the note
  BC3RGBA      [2.0, 4.0, 2.0, 6.0]/255       7 past
  BC3RGBASRGB  codes [2, 4, 2, 0], alpha 6    12 past
  BC4RUnorm    7.327/255                      6 past
  BC5RGSnorm   16.329/255 (0.064035)          4 past

The others are within it (BC1RGBA [1, 3, 2, 0]/255, BC4RSnorm 0.0595,
BC5RGUnorm [7.163, 5.593]/255). The decode is the device's own (rule 1),
announced; the bound understated it: a BC1 to BC3 channel (the 6-bit
green) up to 4/255 where it said 3/255, a BC4 or BC5 channel up to
7.4/255 (signed 0.065) where it said 7.3/255 (signed 0.064).

The notice's cost (degradation.rs), docs/API.md's catalogue entry,
docs/FAST-PATHS.md's row and the two DriverFact docs now state the 5080's
measured bounds for NVIDIA, lavapipe's 3/255 kept apart, and the lane's
noted_bound copies them (4/255, 7.4/255, signed 0.065), so a run past them
still fails. No decode, note condition or announcement changes.

degradation.rs and driver_facts.rs are runtime pin inputs: the
runtime-sources pin needs its re-hash.

Verified: cargo fmt. The 5080 rerun is pending (the lane fixes batch).
(cherry picked from commit 164575080bf6132dc621a7e542af6a6f133c3a3f)
2026-11-05 05:11:13 -08:00
Anees Iqbal 751135f389 State a gathered 32-bit float denormal, flushed to a zero, in device-texel-conversion's bound
runtime_lane::half_read_nans::half_float_reads_hand_back_metals_nans on the RTX 5080 Laptop GPU
(NVIDIA 615.71.09, at 961b1ff319): with the gathered NaNs taken (eb9a8db1ac), 24 lanes still
differed, every one a gathered 32-bit float denormal (0x00000001, 0x80000001 in R32Float,
RG32Float and RGBA32Float) handed back as a zero of its sign, where Metal hands back the texel's
bits; the device's reads and samples of the same texels hand them back as stored. The gather is
the device's texture unit's, which DeviceTexelConversion records off Apple GPUs; its bound named
the gathered NaN, not the denormal. An under-stated bound.

What: DeviceTexelConversion's bound (pipeline/artifact.rs) and docs/API.md's catalogue state a
32-bit float texel's denormal in a gather as flushed to a zero of its sign; the lane takes such a
lane for Metal's where the device's texture unit is not Metal's. The note's condition is
unchanged, so no translation, note set or classification moves.

Verified: the 24 differing lanes of the 5080's run are each a flushed gathered denormal (the lane's
HALF-READ-DIFFERS lines); the lane reruns in the next proof run.

(cherry picked from commit ec73c51148a57302b1c6cc8f421c4b02692036e5)
2026-11-05 05:10:59 -08:00
Anees Iqbal c6901502d2 Prove max_buffer_length's heap bound in the lane: a buffer one byte past it is nil, one of it is made
The lane's a_buffer_past_max_buffer_length_is_nil prints the device's
max_buffer_length (MAX-BUFFER-LENGTH) and refuses a Shared and a Private
buffer one byte longer as Nil(new_buffer, BufferLength), as plain Metal
answers nil past maxBufferLength. The ignored
a_buffer_of_max_buffer_length_is_made_where_the_heap_bounds_it makes a
Private buffer of exactly max_buffer_length where the heap bound is below the
compile layer's answer (the RTX 5080 Laptop GPU's) and refuses one byte more;
it takes three quarters of the device's memory, so it runs only by name.

docs/API.md's accepted differences name the proxy: the largest DEVICE_LOCAL
heap stands for Metal's recommendedMaxWorkingSetSize, which Vulkan does not
report.

Verified: not yet built (potluck build queued).
(cherry picked from commit 77fc830057352d11837826a8bb181ebb9a6bac5b)
2026-11-05 05:10:58 -08:00
Anees Iqbal 12497a0aad State a gathered 32-bit float NaN in device-texel-conversion's bound
half_read_nans failed on the RTX 5080 Laptop GPU (NVIDIA 615.71.09): a gather of R32Float,
RG32Float and RGBA32Float hands back 0x7fffffff for every NaN texel (64 lanes each), where Metal
hands back the stored words; the same texels read and sampled come back as stored. The gather
records PrecisionNote::DeviceTexelConversion off Apple's GPUs, whose bound said every class but a
half-float or small-float NaN is Metal's value.

What: the bound (the note's rustdoc and API.md's catalogue) states a 32-bit float texel's NaN in a
gather as the device's encoding, with the 5080's answer; half_read_nans takes a gathered 32-bit
float NaN for Metal's where the device's texture unit is not Metal's, as it takes a half-float
texel's NaN. No note is recorded differently, so no version moves.

Verified: compile and the 5080 and M3 runs follow in the lane proof run.
(cherry picked from commit 8e537ae9c2c3ad814c0973841b2454fa15d66120)
2026-11-05 05:10:58 -08:00
Anees Iqbal fc79fdd4e9 Announce every NVIDIA RTX 5080 Laptop clear and plain fill off a whole code: its clears take either nearest code
runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear (vkCmdClearColorImage of 762
colours into each of 70 formats) on the RTX 5080 Laptop GPU at 0b556ddfd6: 352 fills stored 382
normalized channels a code from Metal's, each one of the two codes nearest the scaled value,
unannounced where the value was not near a midpoint. Vulkan allows it ("returns one of the two
unsigned binary integer values with exactly b bits which are closest to the floating-point value
r. Implementations should round to nearest"). The 8- and 16-bit unorm and snorm channels went
toward zero (R16Unorm's 0.001, 65.535 codes, stored 65; R8Snorm's -0.5 stored -63), packed and
10-bit channels and an sRGB format's alpha at times to the code above the nearest. An under-note.

What:
- DriverFact::ColorClearTakesEitherCode, on the RTX 5080 Laptop GPU (NVIDIA), with its
  measurement in its doc.
- clear_value::rounds_apart takes the fact: on such a driver a normalized channel's clear is in
  question wherever its scaled value is off a whole code, not only near a midpoint; the clear and
  the plain colour fill (blit_fill, fill_value, render_pass) announce device-color-conversion then.
- docs/API.md's catalogue entry for the clear conversion names the fact.
- Tests: driver_facts' table test; a fill_value unit test of the rule on the measured cases with
  and without the fact; api_signatures for the new variant.

Verified: in the lane proof runs on the 5080 and the M3 (counts in the series' last commit). The
M3's and lavapipe's facts are unchanged, so their notices are.

(cherry picked from commit f2da9346bb51ed034f0d5f8bf076c8d55c57f277)
2026-11-05 05:10:38 -08:00
Anees Iqbal f1def3dffe Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
Re-applies 384734851d (reverted in the stack by 5dbf6f3be3) on top of the previous commit, which
merges a heap half read's class arms as the texel's half bits.

What: narrow::round_texel rounds through round_measured, so in QuantizeForm::Converted the
conversion pair's narrowing is recorded as measured. On a profile that takes
DriverDeviation::MetalHalfConversion (MoltenVK on the Apple M3 Max's macOS 27 identity) a texel's
half rounding records no PrecisionNote::NativeHalfConversion, and the module requires
VkProperty::MetalHalfConversion instead: a texel the module decodes itself
(extended_range::decode), a merge of texels (a heap read's phi of its fetched texel and its decode
routine's) and an image instruction's. The note stays for roundings by narrow::round: half
operations and functions computed in float, filter sums, packs and the rest. Other profiles never
read the measured set, so they are unchanged by construction, and round_measured emits the same
pair, so the SPIR-V is unchanged. SEMANTICS_VERSION 1967: recorded notes change on moltenvk-m3.

Why: reims-vgpu's strict Mac tests die on native-half-conversion at a kernel that reads an
argument buffer's texture as half (their ycbcr_probe.metal read_held, over BGRA8Unorm). Every heap
half read carries the decode routine of the seven extended-range/padded/bfloat forms, and its
merge, so it recorded the note whatever the texture. MetalHalfConversion measured the device's
conversion as Metal's half(float) for loaded and computed floats; where Metal's half texel is not
the nearest even half of the texel's value, the access's own note states it: HalfTexelConversion
(outright for a heap element, by the bound class at a slot) or DevicePackConversion (a decoded
texel). The stack 28 gate's cross-class lane failure that reverted it came from the heap read's
merge of widened halves, not from a rounding: an integer texel's bits read as half go through no
rounding, and the previous commit merges them as integers, so they keep their bits without a note.

Kept from 384734851d: the core tests heap_half_texels_round_by_the_measured_conversion and
decoded_half_texels_round_by_the_measured_conversion, the M3 lane
heap_extended_reads::heap_half_reads_of_every_code_round_their_float (half_conversions::half_of
made pub(super) for it), and the docs: the PrecisionNote, DriverDeviation and VkProperty rustdoc,
API.md's native-half-conversion exemption, the driver-facts record (which now also says the
argument buffer's cross-class half read rounds nothing and names its lane), narrow's docs.
runtime-sources.sha256 moves for the doc edits in driver_facts.rs and requirements.rs, which change
no behaviour of a run.

Verified: pending in this commit; the next jobs run the core and M3 lane checks on it.
(cherry picked from commit 1757bd7866aa87c4e38ab83f0b4c4d83e68c75bb)
2026-11-05 04:28:29 -08:00
Anees Iqbal 5dbf6f3be3 Revert counting a texel's half rounding as measured on MetalHalfConversion profiles
This reverts the stack's pick of 384734851d ("Count a texel's half rounding as the measured
conversion on MetalHalfConversion profiles"); SEMANTICS_VERSION goes to 1965, since the recorded
notes change back.

The stack 28 gate's M3 lane run failed
runtime_lane::cross_class_reads::argument_buffer_cross_class_reads_are_the_native_words: an
argument buffer's half read of an integer texture (R8Sint, RGBA8Sint, RG16Sint, RGBA16Sint,
RGBA32Sint, RGBA16Uint, RGBA32Uint; 66 of 2170 lanes) answers the device's quiet NaN 0x7e00 where
the slot's read of the same texel keeps its bits (0xfff5 and the like). The heap read rounds its
texel through float, and that rounding's narrowing no longer recorded NativeHalfConversion on
moltenvk-m3, so the stage carried no note that leaves a half NaN's bits to the device (the notes
were SetPastLayoutSupport, DeviceNanEncoding and HalfTexelConversion). The commit's measurement
covered the extended-range forms' codes, not an integer texel's bits read as half. Until a fix
keeps those bits or notes them, the note stays as it was before the change.

The doc conflict in driver_facts.rs (a later pick's measurement paragraph for the reverted rule)
takes the text from before the change.

Verified: not yet; the gate reruns the core suite and the M3 lanes on this tree.
2026-11-05 02:46:28 -08:00
Anees Iqbal bc1d0ab837 Say in render-pass-split's trigger that a read of the clear alone takes a cleared copy instead
The declaration in degradation.rs and docs/API.md's catalogue entry both said a draw that reads a
color attachment's texture after a memory barrier splits the pass. A read of the clear alone
before any draw of the pass now reads its copy cleared to the clear in the pass's one instance
where the copy can be (WorkCounts::attachment_read_clears), so both name that exception.

Docs only; unverified beyond cargo fmt.

(cherry picked from commit 1bcf89e89571bc7f65694c10ea34bdde6c3af6b0)
2026-11-05 02:08:33 -08:00
Anees Iqbal de64560175 Name the pass-start read's cleared copy in the API guide's accepted difference
docs/API.md: a draw that reads the clear after a render-target barrier before
any draw of its pass reads its copy cleared to the clear in the pass's first
instance where the copy can be so (WorkCounts::attachment_read_clears), else an
instance after one of the clear alone.

Unverified: documentation of 4259b7f41c, whose runs are pending.
(cherry picked from commit cc9312dcc9a97d5c663efbfea3f0f25374581249)
2026-11-05 02:08:33 -08:00
Anees Iqbal 749daae1d9 Say a texture's image of any storage mode may overflow past device-local memory
Every texture's image is placed in Private memory (image_plan.rs), so a
Shared or Managed texture's image overflows as a Private one does; the
notice's declaration, the catalogue entry, the runtime README and the
lane's site note now say so.

Verified: nothing (docs and comments only).
(cherry picked from commit ec5b5a70fdea000eb9a7d5ab84e5aaad02fffed4)
2026-11-05 02:08:31 -08:00
Anees Iqbal 8ccb2934c9 Place resources past a full device-local heap in system memory
Placement refused a resource once device-local memory was full: memory.rs
gives the Private class only DEVICE_LOCAL types, every texture's image is
Private, and a Managed buffer's own bytes on a device without unified memory
are Private, so place() returned OutOfMemory(Device). On the RTX 5080, 96 of
5090 1-MiB Managed GPU copies were refused at about 5 GB held, where Metal
on a 4 GiB Radeon Pro 5300M made, used and read back 12 GiB of Managed
buffers, six 1 GiB Private buffers and a 17 GB Private heap.

- memory.rs: overflow_candidates, the types a Private or Memoryless
  resource overflows into where none of its own has room (allowed,
  allocatable, neither device-local nor lazily allocated; those the host
  does not map first). place() tries them after the class's own types;
  such a placement is marked (Placement::overflowed) and counted
  (Memory::overflows, WorkCounts::device_memory_overflows). Metal's own
  refusals (max_buffer_length, texture limits) stay where they are.
- Driver paging first: VK_EXT_pageable_device_local_memory with
  VK_EXT_memory_priority, enabled where the device lists both and has
  pageableDeviceLocalMemory (enables.rs, create.rs); the spec lets such a
  driver page memory out rather than fail an allocation. Every allocation
  keeps the default priority.
- Degradation::DeviceMemoryOverflow (performance), announced once for a
  program's buffer or heap (degrade_system_memory, which now names the
  storage mode) and texture (Texture::overflowed) that overflowed.
- Tests: tests::memory::device_local_classes_overflow_into_system_memory,
  tests::device::pageable_device_local_memory_is_enabled_where_the_device_has_it,
  and the device test tests::device_memory_overflow (a GPU hazard, under
  m2v_gpu_hazards on a GPU, in the shape of 7b57d9a87a; check-cfg added),
  which fills device-local memory where it can overflow and makes, uses
  and reads back Private buffers, a Private heap with a buffer and a
  texture, Private textures and Managed buffers past it. The lane names
  the kind's site as the runtime's test (degrade_notices OVERFLOWED).
- Docs: API.md (runtime-own extensions, catalogue entry), runtime README
  memory model.

Verified: nothing yet (cargo fmt only); builds and runs follow as potluck
jobs.

(cherry picked from commit 586f2d0b5c6708016d9a255c0934f9727569125c)
2026-11-05 02:08:30 -08:00
Anees Iqbal 504d01b759 Present the Mac class the consumer declares, by default its GPU's, as the fresh-texture key
The fresh-texture key (DeviceProperties::lossless_compression) was
has_unified_memory. That is wrong for every integrated GPU that is not
Apple's. The consumer's oracle shows an Intel UHD 630 Mac reports unified
memory and reads zero or a released texture's texels from a new Private
texture, as the AMD 5300M does, and never Apple's pattern. The owner's
choice (option B): the consumer declares the Mac class the device presents,
and the default follows the GPU family.

What:
- MacClass { AppleSilicon, IntelOrAmd } (public, capabilities.rs), with
  MacClass::of_vendor: an Apple GPU (vendorID 0x106b, MoltenVK on Apple
  silicon) is AppleSilicon, every other GPU IntelOrAmd.
- DeviceOptions::mac_class and RawDevice::mac_class (Option, None by default:
  the GPU's class) feed presents_lossless_compression, still the one place
  the key is decided. lossless_compression is class == AppleSilicon. The
  options' equality and Debug list the field.
- A new Private texture under IntelOrAmd on a GPU that is not Apple's holds
  what its memory held, as before (private_textures_unfilled). On an Apple
  GPU, whose own image of such a texture is compressed and reads Apple's
  pattern, it is filled with zeros as it is made, which is what such a Mac
  reads where its memory held nothing. Counted by the new
  WorkCounts::private_textures_zero_filled. The pattern path now runs only
  where the device presents compression.
- AppleSilicon keeps the runtime's pattern and zeros on any GPU. The device's
  own contents are not Metal's pattern on the M3: in the negative control
  (m3-max-88) leaving Private textures unfilled failed 16 of the 28 lanes.
  No PrecisionNote: the fill is capability (the declared Mac's contract),
  not arithmetic. An Apple-class pattern that no clear or copy writes
  exactly still announces fresh-pattern-zeroed.
- Defaults change only where unified memory and GPU family disagree: Intel
  and AMD integrated GPUs and lavapipe now present no compression (their new
  Private textures are unfilled). The M3 (Apple) and the discrete GPUs
  answer as before.
- Docs: docs/API.md (the accepted difference and the fresh-pattern-zeroed
  entry), the runtime README, the degradation declaration, the work-count
  docs. api_signatures blessed. REFUSALS.md regenerated with no change. No
  FAST-PATHS row: no speed-for-accuracy choice.

Tests:
- tests::capabilities::lossless_compression_is_the_presented_mac_class
  (no device): every vendor kind (Apple, Intel, AMD integrated and
  discrete, NVIDIA, Mesa CPU) under no declaration and both declarations.
- tests::mac_class (device, both settings):
  the_default_class_is_the_gpu_s and
  a_declared_class_other_than_the_gpu_s_is_presented. Each reads a new
  Private RGBA8Unorm target and checks the counters: AppleSilicon reads
  Metal's magenta pattern; IntelOrAmd on an Apple GPU reads zero
  (zero_filled +1); IntelOrAmd elsewhere is unfilled (+1).

Verified: cargo fmt --all. Build, clippy and tests run as potluck jobs
after this commit (results in the next commit or report).

(cherry picked from commit f3d6f24ca447fbcadc8df56e63e598cbc92e09b7)
2026-11-05 02:08:30 -08:00
Anees Iqbal 9fe1b0175f Key the compressed shape's clear route in the extended-range and bfloat clear checks
A clear takes Metal's straight route only where nan_clear::keeps_nan_sign holds (render.rs),
which the fresh-texture key now makes false on a device that presents a Mac keeping no texture
compressed: there a 16 x 16 plain target is not compressed, so it clears through half, as
Metal's uncompressed targets do (expected, not measured on such a Mac). Three checks still
expected the straight route there and failed on the RTX 5080 Laptop at fd34a10316:

- conformance xr-clear-routes-{bgra10xr,bgra10xr-srgb,bgr10xr,bgr10xr-srgb}: divergent at
  case/plain-16/texels/0..3 alone (15 sites), unlisted, in the replay of job m3-max-120; the
  baseline replay at 0b556ddfd6 (job m3-max-141) held none of them (its other 908 unlisted gap
  sites are the same in both runs). ClearRoutes now declares
  replay::without_compression("plain-16").
- validation runtime_lane::extended_range_targets::clears_take_metal_s_route (15 clears
  differ, all the 16 x 16 draws-false shape) and runtime_lane::bfloat_targets::
  bfloat_clears_take_metal_s_route (11, all that shape), suite job m3-max-124: each now expects
  ClearRoute::Straight for that shape only where DeviceProperties::lossless_compression holds,
  else ThroughHalf.

docs/API.md's accepted difference says the clear route too, and keeps_nan_sign's doc says it
decides the route.

Verified on the M3 Max, no device: nextest metal2vulkan-conformance 1011/1011; cargo clippy -D
warnings on validation and conformance with --cfg m2v_gpu (all targets, all features);
docs/CONFORMANCE-COVERAGE.md re-derives unchanged. UNVERIFIED: none of the three has run with
this commit on the 5080 or the M3.

(cherry picked from commit 1c042263e5fee942b79fbd30042c2dc9f222b61b)
2026-11-05 02:08:30 -08:00
Anees Iqbal 64bea51c0c Put the fresh-texture key behind one presented fact, and give every lane and case its arm
The key that decides whether the Mac a device presents keeps textures losslessly compressed is
now one public fact, DeviceProperties::lossless_compression, decided in one private function,
capabilities.rs presents_lossless_compression. Today it is has_unified_memory, as the approved
proposal said; the owner's open question (unified memory, a consumer-declared Mac class, or a
family split) changes that one function. Everything that differs because Apple silicon
compresses reads only that field: Device::metal_compresses_textures() (a new Private texture's
fill, compressed_blit::compressed(), nan_clear::keeps_nan_sign), the validation lanes
(fresh_contents::unfilled, patterns_of) and the conformance venue (Venue::lossless_compression;
the Metal side answers supportsFamily(MTLGPUFamily::Apple1)).

This finishes what the parked commit before it listed as open:

- docs/API.md: a new accepted-differences group, "The Mac a device presents", whose entry
  (slug a-device-that-presents-a-mac-without-texture-compression-answers-as-that-mac) gives
  reims's measured AMD 5300M and Intel UHD 630 rows for fresh Private contents and marks the
  blit encodings, fills and NaN clear sign as expected, and states the Intel-iGPU limit. The
  fresh-pattern-zeroed catalogue entry and its rustdoc say the key; so does the runtime README's
  "New resources" bullet.
- Conformance: Justification::WithoutUnifiedMemory became WithoutCompression (and
  Unjustified::VenueCompresses, Offered::lossless_compression, replay::without_compression /
  WITHOUT_COMPRESSION). The fresh family's Private rows declare it at their fresh site; the
  compressed-blits-* rows of the BGRA10_XR formats (the only ones whose canonical encoding the
  runtime writes) declare it at the seven sites a blit reaches through the compressed texture.
  The fresh test now asserts the new shape (renamed
  a_row_loosens_the_notices_site_and_a_private_texture_s_fresh_site); the compressed-blits test
  asserts the venue declarations site by site.
- Lane arms on an unfilled device: fresh_costs (the counter moves by count x runs per Private
  shape; no readback), fresh_writes (patterns_of in both controls and the scratch test; the
  forced single-sample note only where the device fills), parallel_encodes (no expected
  pattern), depth_denormals (no draw/store check of unwritten texels, no sign, no zeroed note),
  compressed_blits (the notes and the Canonical rewrite only where the device compresses).
  degrade_notices needs none (FRESH_PATTERNS is only its catalogue list); the tile-store lanes
  (rotated_textures, snorm_tile_store, padded_loads, extended_range_blends) read draw notes,
  which are not keyed.
- api_signatures.tsv blessed for DeviceProperties.lossless_compression and
  WorkCounts.private_textures_unfilled. docs/CONFORMANCE-COVERAGE.md regenerated (the Metal leg
  now calls supportsFamily:, and WithoutCompression is a justification it names).

No RUNTIME_VERSION or runtime-sources pin change here: left to the orchestrator.

Verified on the M3 Max, no device: cargo clippy -D warnings over the runtime, validation and
conformance (all targets, all features) plain and with --cfg m2v_gpu; nextest
metal2vulkan-conformance 1011/1011, metal2vulkan-runtime 1234/1234 (2 skipped),
metal2vulkan api_signatures + api_surface 15/15; the refusal-surface and metal-coverage checks
pass. UNVERIFIED: no device run yet (the lanes, the nan_signs test and the conformance replays,
on the M3 and the 5080), and no negative control yet.

(cherry picked from commit fd34a1031602645e87e4cb192d1044790f79a88f)
2026-11-05 02:08:29 -08:00
Anees Iqbal 61e6e1f9ac Announce device-pack-conversion where a heap set holds a texture by its raw texels
A heap holds a texture of a form ExtendedRange::HEAP_READ names
(BGR10_XR, BGRA10_XR, R10Unorm_X6, RG10Unorm_X12 and the bfloat
formats) by its raw texels alone, its raw view in the unsigned integer
class. A function's float read, sample or gather of it through an
argument buffer decodes the raw texels itself, by the device's
arithmetic, within the bounds PrecisionNote::DevicePackConversion
states. That is the same conversion a slot's read records statically,
but nothing announced it for a heap read: the stage cannot know which
textures an argument buffer names, and recording the note on every heap
float read would announce it for argument buffers that never hold such
a texture.

Scope it through the run-time mechanism a decoded twin already uses.
heap_sets now notes, per set, the textures whose raw view a set's
unsigned integer array holds (SetEntry.raws, detected in texture_info
by the class and bind::heap_raw_form). It announces
Degradation::DevicePackConversion, naming the texture ("BGRA10XR
texture at resource ID n"), at the first command that binds a set
holding one, and once (degrade_once) as one is placed in a set a
pending command buffer may read through. This matches TwinRead's
twin_read and twin_placed. A command whose sets hold no such texture
announces nothing. A command that binds a set holding one announces it
whether or not its function reads that texture, because the runtime
does not see which textures an argument buffer names. The twin
bookkeeping shares the new noted and pending_read helpers.

The runtime's DevicePackConversion doc, docs/API.md's
device-pack-conversion entry and heap_sets' module docs say so.

New lane test
runtime_lane::heap_extended_reads::a_heap_set_holding_a_raw_texture_announces_its_decode.
It dispatches a heap float-read kernel with only an RGBA8Unorm texture
live (no device-pack-conversion announced), then with a BGRA10XR
texture made (the notice names that texture's resource ID). It prints
the stage's own notes beside the notices.

No RUNTIME_VERSION bump (not asked for on this branch).

Verification: the branch's next CPU job (clippy, runtime suites) and
GPU job (the heap_extended_reads lane on MoltenVK on the M3).

(cherry picked from commit f5c2127ebee39d3fcf221e1930e287d26c7f9e68)
2026-11-05 02:08:28 -08:00
Anees Iqbal 75228b052b Record no device-nan-encoding for a color output that only ever returns NaN-free constants
A fragment function's color output to a half-float attachment recorded
PrecisionNote::DeviceNanEncoding wherever the device's conversion stores
a NaN otherwise than Metal, even when every value the function returns
there is a constant with no NaN lane, which stores no NaN. Texture
writes already skip the note for such a constant texel
(texture::holds_no_nan); color outputs now apply the same structural
rule. stage_io::returns_no_nan follows each `ret` of the function to the
output's member (through insertvalue chains and aggregate constants),
and color_write::plan, called from the output-variable path and from
the storage-form path, leaves the note out when every return holds such
a constant. Any computed, undef, argument or partly unknown member
keeps the note.

Per-site audit of the device-nan-encoding notes on MoltenVK on the M3
(the reims strict Mac tests), with the translator CLI over each site's
stages:
- (a) undefined tests x3 (xr_constant_fragment and the other
  constant-colour fragments): their outputs are NaN-free constants, so
  the note was wrong there. Fixed here.
- (c) encode_render x2 (sweep_fragment, sweep_half_fragment): computed
  outputs that sweep through NaN values. The device stores its own NaN
  encoding, so the note stays.
- (c) rgbx x3 (rgbx_write_half, store_half, read_write_half, and the
  NaN clears and half NaN writes): deliberate NaN texel writes. The
  note stays.
- (c) slice_write_repro x1 (slice_write, slice_write_l0): computed
  texel writes. The note stays.

New public fixture ncw_constant_colors (our own MSL, compiled by
scripts/regen-air-fixtures). It covers a half and a float constant
colour, a constant NaN colour, a computed colour, and a two-member
struct whose member 0 is a constant and member 1 computed. The new test
engine_link::constant_colors_without_a_nan_record_no_nan_encoding
checks, on the lavapipe and moltenvk-m3 profiles, that the note is
recorded exactly for the NaN constant, the computed colour and the
pair's computed member, and that each stage links and validates.

docs/API.md's device-nan-encoding entry states the rule. SEMANTICS_VERSION
goes to 1963 because the recorded notes change. The golden tables
need the new fixture's rows, re-blessed on development.

Verification: the new test and the touched suites run in the branch's
next CPU job.

(cherry picked from commit 2d436ebc2963f1aac1854b850ff1808e654c61f3)
2026-11-05 02:08:28 -08:00
Anees Iqbal 6eb2a66d6e Gather a two-plane YCbCr texture's planes in place
A function that samples a YCBCR8_420_2P or YCBCR10_420_2P texture and also
gathers it (a probe asking each lane for a sample or a gather of red or
blue) lost the in-place form for the whole slot: `in_place_sample` built no
gather, so the gather set `in_place.blocked`, the slot bound the converted
image, and on MoltenVK its linear samples went through Metal's sampler of
RGBA16F-like texels: `ycbcr-filter-not-exact` (Half/FloatSampleFilter), and
through a pixel sampler `pixel-sampler-scaling`. Those notes killed three
of a consumer's strict Mac tests.

What: the in-place form now builds a 2D gather of a component without
comparison, constant offset or none, through a constexpr sampler (either
filter: a gather follows none) or a runtime one. The gather is the
extended-range emulation's `gathered` over `Decode::InPlace` taps: the four
taps of the linear footprint, each the texel Metal reads there (the border
texel past a border axis), in Vulkan's order, a runtime sampler's word
mapped as a 4:2:0 texture addresses. A gathered slot stays off the device's
own Y'CbCr conversion (`device: false`):
VUID-RuntimeSpirv-OpTypeSampledImage-12206 admits only samples through it.
No Quad routine for a gather. SEMANTICS_VERSION 1962 (facts and modules of
gathered slots change).

Tests (engine_ycbcr_in_place): every gather of each component of random
8- and 10-bit planes under three conversions, constexpr and runtime
samplers, float and half, on the lavapipe and moltenvk-m3 profiles, equals
Metal's model taps on the interpreter; a gather states the in-place fact
with `device: false`; a function that samples and gathers through one
runtime sampler notes FloatSampleFilter/HalfSampleFilter on its image
compile and states the fact, and its in-place compile builds both forms and
notes neither those nor PixelSamplerScaling. Device evidence against
Metal's rows follows with the fixture and conformance cases.

Docs: API.md and FAST-PATHS (in-place reads and the planes-image row),
RuntimeFact::YCbCrInPlace, InPlaceReads, the runtime README.
(cherry picked from commit b95b95a355f9a8ff4c1bfacbf329a728c4896db9)
2026-11-05 02:08:27 -08:00
Anees Iqbal 2e2c1ec056 Leave fneg, fabs, floor and ceil unnoted where the M3's Metal keeps their denormals
MoltenVK on the Apple M3 Max runs a SPIR-V `OpFNegate`, `FAbs`, `Floor` and
`Ceil` through Metal's own compiler, which keeps a denormal operand of
negation and absolute value and reads it as the zero of its sign in floor
and ceil, as plain Metal does. The translator noted `DeviceDenormals` on
every such operation, so a strict consumer died on a kernel that negates a
float though the answer is Metal's.

What: a new APPLE9-only `DriverDeviation::MetalUnaryDenormals` (and its
`VkProperty`) on the moltenvk-m3 profile. A function whose float negation,
fabs, floor or ceil the deviation covers records no `DeviceDenormals` for
them and requires the property instead; fabs keeps its Metal-own exemption
on every other profile, and trunc, round, rint, fract, sign and the rest
stay noted (the lane does not check them). `ARTIFACT_FORMAT_VERSION` 486
(the property's tag), `SEMANTICS_VERSION` 1961 (notes and requirements
change).

Evidence: the committed MoltenVK M3 observations of the four denormal
cases (nan_denormals, nan_denormals_fast, dfl, dfl_fast) hash equal to
Metal's on the same M3. The float_denormals gate lane now checks probe rows
-a, 0-a, -(a*b), fabs(a), floor and ceil where the deviation is taken, and
asserts the module requires the property exactly then; the
arith unit test covers each op under each fast and unary setting. Device
runs follow on the GPU job for this stack.

Docs: FAST-PATHS row on device denormals, API.md degrade catalogue,
driver_facts' measurement paragraph, api_signatures.tsv; refusal surface
and signatures checks pass.

(cherry picked from commit f3f65903a395b46b3a8001c4259bb1e4bb7bc203)
2026-11-05 02:08:27 -08:00
Anees Iqbal a139f39c89 Note a texel centre's denormal only under an address mode that parts texel -1 from texel 0
What: a nearest pixel-coordinate sample at its texel's centre, floor(x) + 0.5, records
DeviceDenormals for that floor: Metal's sampler reads a negative subnormal x as texel -1, where a
floor that flushes it (MoltenVK's) makes texel 0. Clamp to edge, mirror clamp to edge and mirrored
repeat read texel -1 as texel 0, so the note now holds only where the s or t mode is repeat, clamp
to zero or clamp to the border:
- a constexpr sampler decides it from its (mapped) s and t modes at compile (centre_parts);
- a runtime sampler slot's clauses add, per axis, a test of the bound sampler's word that the
  axis's mode is none of the three. The word is read through a new note-only key,
  SpecKey::BoundSamplerWord(slot): no constant declares it and no pipeline's key carries it, so
  the mode adds no VkPipeline variant (the alternative, the ADDRESS bits in SamplerState's fields,
  would split every runtime pixel sampler slot's pipelines by mode on every device). The plan
  records its value beside the pushed specialized values (slots::record_noted, given by
  BindingPlan::specialized_value), SpecClause::tests_bound_values counts it, and the runtime's
  degrade_bound_values announces such a clause at each draw or dispatch, as it does for a pushed
  format class. The runtime's notice reads "under the formats and samplers it binds".
- NoteOn::BoundSampler is the lowering's name for the key.

Why: reims-vgpu's strict Mac tests died on device-denormals from a nearest clamp-to-edge pixel
sampler, under which the device's texel is Metal's.

Tests: tests::engine_sample_coordinates::a_texel_centre_notes_denormals_only_where_its_mode_
parts_texel_minus_one (constexpr array samples per mode on every committed profile; the runtime
slot's clauses evaluated over every s/t mode pair, and never under a normalized state);
cache::tests::the_version_485_member_round_trips;
runtime_lane::pixel_samplers::a_texel_centre_s_denormals_wait_for_a_mode_that_parts_texel_minus_one
(device: nothing at making, nor under clamp to edge and mirror clamp to edge, once under clamp to
zero). Conformance: four cases pixel-samplers-subnormal-{edge,zero,border,mirror}, the RGBA8Unorm
texture through a nearest filter at sixteen coordinates of subnormals, zeros and -2^-126 on each
axis, recorded on Metal in a following commit.

Versions: ARTIFACT_FORMAT_VERSION 485 (the SpecKey variant), SEMANTICS_VERSION 1960 (the clauses).
api_signatures gains the variant. Docs: API.md and FAST-PATHS.md (device-denormals), the
DeviceDenormals, SpecKey, SpecClause and plan rustdoc.

(cherry picked from commit 624008697abfab1dbb3039a926902373b84e1268)
2026-11-05 02:08:27 -08:00
Anees Iqbal 6e63f015b5 Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
What: narrow::round_texel rounds through round_measured, so in QuantizeForm::Converted the
conversion pair's narrowing is recorded as measured. On a profile that takes
DriverDeviation::MetalHalfConversion (MoltenVK on the Apple M3 Max's macOS 27 identity) a texel's
half rounding no longer records PrecisionNote::NativeHalfConversion. That covers a texel the module
decodes itself (extended_range::decode) and a merge of texels (a heap read's phi of its fetched
texel and its decode routine's), as well as an image instruction's. The module requires
VkProperty::MetalHalfConversion instead. The note stays for roundings by narrow::round: half
operations and functions computed in float, filter sums, packs and the rest. Other profiles never
read the measured set, so they are unchanged by construction. The SPIR-V is unchanged too:
round_measured emits the same pair.

Why: reims-vgpu's strict Mac tests die on native-half-conversion at a kernel that reads an
argument buffer's texture as half (their ycbcr_probe.metal read_held). Every heap half read
carries the decode routine of the seven extended-range/padded/bfloat forms, and its merge, so it
recorded the note even for a BGRA8Unorm texture. The note states that the device's conversion may
differ from Metal's half(float), and MetalHalfConversion measured that conversion as Metal's
half(float) for loaded and computed floats. Where Metal's half texel is not the nearest even half
of the texel's value, the access's own note states it: HalfTexelConversion (outright for a heap
element, by the bound class at a slot) or DevicePackConversion (a decoded texel).

Verified:
- New core tests heap_half_texels_round_by_the_measured_conversion (heap half read, nearest sample
  and gather on moltenvk-m3: no note and the property with the deviation, the note without it,
  HalfTexelConversion kept; a linear sample's filter sum keeps the note on both) and
  decoded_half_texels_round_by_the_measured_conversion (a slot's half read of each extended-range
  form: the same, DevicePackConversion kept). Both fail with round_texel's old rounding and pass
  with the change; half_conversions_are_metals_where_measured still passes.
- Notes of every public fixture subject on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before
  and after (a temporary dump over the golden-hash subjects, 2,915 per profile): 7 change, all on
  moltenvk-m3, each losing NativeHalfConversion alone and keeping HalfTexelConversion
  (a8r_buffer_read_half, hlf_half_buffer, selected_member_texture and
  kernel_texture_variant_leftovers, the .ll and .air.ll forms).
- reims's ycbcr_probe read_held on moltenvk-m3 through the CLI: [DeviceNanEncoding,
  HalfTexelConversion, NativeHalfConversion] before.
- Pending: the M3 lane heap_half_reads_of_every_code_round_their_float (new) and the lanes that
  read the note (alpha_in_red now requires a8r_buffer_read_half to be Metal's there).

Docs: the PrecisionNote, DriverDeviation and VkProperty rustdoc, API.md's native-half-conversion
exemption, the driver-facts record, narrow's docs.

(cherry picked from commit 384734851de7b2f1a3106355a6c941080f097be4)
2026-11-05 02:08:27 -08:00
Anees Iqbal 493178c82e Keep a draw's heap part while what it is made of holds
A replayed page's host step costs about 400 ns per replayed draw per
resident texture (reims: 14 s a frame). Each draw works its heap part
out again for every texture its encoder made resident, though the
residency did not change and the command rebinds only a buffer:
- the handle tables, at every heap member (bind::heap::member_id,
  table_bytes);
- where the heap writes go (heap_elements, member_id again);
- each heap entry's view check (bound_view, view_reading,
  binding_view, Image::view);
- for every member, a neutral image descriptor in each heap image
  array whose class it does not fit (neutral_view, border_texel,
  BicubicTexels::with_border). heap_sets::bind then dropped every one
  of those.

Now:
- The translator splits the heap part from the rest of a draw's
  commands:
  - BindingPlan::instantiate_draw_apart_into writes every command but
    the heap tables;
  - heap_tables_into writes the heap tables alone (handle tables,
    sampler tables, function-table directories);
  - heap_slots names the texture slots they read besides the used
    resources.
  instantiate_draw_into is unchanged. A consumer breaks nowhere: all
  three are additions. docs/API.md says when the tables may be kept.
- The runtime keeps each draw's heap part in its encoder's LiveBind
  (render/heap_part.rs): the heap tables, where the heap writes go
  (Arc<HeapElements>), and the writes past the heap's entries
  (binding::PastHeap). The first draw that checks every entry's view
  lists those writes, and meets no notice the device announces at each
  occurrence (EachWatch) while it does.
- What a part is made of:
  - the plan, by address;
  - the variant's heap capacity;
  - the residency's generation;
  - the argument samplers: the count of sampler-ID slot changes they
    were listed at, else compared state by state;
  - the function tables, compared;
  - what the plan's heap slots bind, compared;
  - the heap placement and the token order.
- Parts are kept for the last 8 plans, so pipeline states drawn in
  turn and the plans a draw's primitive type picks each keep their
  own. They go as the encoder ends.
- Builds with debug assertions check every kept part against one
  worked out whole, and every listing of writes past the heap against
  one listed again.
- bind_into writes no heap image element at all, whatever the plan
  reads: the device's heap set holds each one. One predicate,
  heap_sets::holds_element, now says this for bind_into and
  heap_sets::bind.
- WorkCounts::draw_heap_parts_made counts the parts worked out. The
  replayed-frames lanes print it, and the resident uses' walk counters.

Builds with debug assertions check a kept listing against the writes
listed again in place, allocating nothing.

Measured, release, the replayed textured page
(runtime_lane::replayed_textured, 3 frames, interleaved with the
commit before over two rounds):
- Apple M3 Max, MoltenVK 1.4.2:
  - host_step_ms 10363-10491 a frame before, 1489-1621 after;
  - test time 31.7-32.5 s before, 5.1-5.3 s after;
  - pixels e3306dc52a1c9e86 in both;
  - peak RSS 306-317 MiB in both.
- RTX 5080 Laptop (b5080 entry resident-x-heap-part-004402, kind t):
  - host_step_ms 8800-8931 before, 1309-1359 after;
  - pixels 8e977e2bb4582473 in both.
- After, in both: draw_heap_parts_made 2 a frame (the point draws'
  plan and the other draws'). resident_uses_made stays 10,009,006 a
  frame; the next commit addresses it.

The 5080 binaries came from build-only commits. Their release code
equals this tree's but for the Deferred Send and Sync below this
commit and the lane's extra counter print.

Verified:
- On the M3 (potluck), clippy, plain and --cfg m2v_gpu, all targets,
  of the translator, the runtime and the validation crate; Rustdoc
  -D warnings; scripts/api-docs.
- The translator's heap, binder, instantiate and api tests, 143 of
  143. Among them, graphics tests check that instantiate_draw_apart_into
  plus heap_tables_into equals instantiate_draw_into wherever the
  latter succeeds.
- The runtime's suite, debug, --cfg m2v_gpu, hazard filter: 1626 of
  1627. The one failure, exit_guard's
  only_the_listed_modules_keep_the_device_s_functions, fails on the
  base too: a547d0ce33's command_buffer Parts shares a name with the
  device's Parts.
- The validation lanes over residency, draws and notices, debug,
  --cfg m2v_gpu, hazard filter: 246 of 247. The one failure is
  runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_
  within_their_bounds: 21.50 allocations a draw on the M3 against
  DRAW_ALLOCATIONS_DEBUG, 20. Whether that comes from this change or
  from its base is not yet measured. The release bound
  (DRAW_ALLOCATIONS) was not run.
- Negative control: with the kept part never kept, the new test fails
  at draw 1 (heap_parts 1, expected 0).

(cherry picked from commit 12f8301c62ffbbc149c04792007895649b8fe9ed)
2026-11-05 02:08:26 -08:00
Anees Iqbal 5b451a6508 Hold a commit's refused recording of a write-resident ICB's records for the host step
A commit that recorded an execution from the CPU's records and found a record it refuses failed
there, though a route met after the commit may still write those records before the work runs:
another queue's command buffer that the work waits for through a shared event, encoded and
committed after this commit. Metal runs what that route wrote (the new probe
crates/metal2vulkan-conformance/probes/icb_cross_queue_writes.m, M3 Max, macOS 27.0.1, validation
off: `written` completes both command buffers with the kernel's green triangle; `unwritten`
completes too, drawing the CPU's mismatched-format command as garbage). Dying there where Metal
runs breaks the owner's rule 2.

Now, where the commit's recording of a render pass's executions, or of a compute execution, is
refused and the command buffer made one of the executed buffers resident for writing
(Residency::writable_indirect_command_buffers), the segment is held for its host step
(Prepared::held sets Segment::host), prepared as a step's: settled variants and made-ahead
pipelines, its footprint bound. The step waits for the work before it, records from the records
as they stand then, and fails the command buffer at that batch's submission only where they are
still refused. A refusal of another buffer's records, and every valid recording, keep the
commit-time path. Counted: WorkCounts::commit_refusals_held (api_signatures row).

The lane test write_routes::a_refused_command_another_queue_writes_again_runs_what_it_wrote runs
the probe's `written` shape: both command buffers complete, the centre is green, and the counter
moved once. docs/API.md states the held refusal.

Verified: clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and
validation crates; api_signatures/api_surface 15/15. The lane test is not run on a device yet.

(cherry picked from commit 83a1365119f1563ce45f97941a335ea119bc9efc)
2026-11-05 02:08:23 -08:00
Anees Iqbal cee5c7eeb3 Name a draw's read behind a barrier as the cause in the render-pass-split notice
What: a split made so a draw reads a color attachment's texture after a memory barrier
(`Split::AttachedRead`, the pass-start barrier's split among them) is now counted for the
split's degrade notice (`SplitCauses::attached_reads`), whose reason says so: "draws that read
a color attachment's texture after a memory barrier read what its load actions and the draws
before the barrier stored, in a Vulkan render pass instance after theirs, ending N of them".
The `RenderPassSplit` declaration and docs/API.md's catalogue entry list the cause.

Why: such a split counted neither as a barrier split (`self.barrier` is false for a
render-target barrier before any draw, and for one between draws, which records in the
instance) nor as any other cause, so the notice fell to its last reason, "its draws keep
different attachments out of their subpass", which describes no part of this pass. The
conformance replays of the pass-start barrier family showed the split announced on every
barrier row (Apple M3 Max, lavapipe).

How verified: builds (conformance binary, debug). The lane assertion added to
`a_draw_after_a_barrier_at_the_pass_start_reads_the_clear` (the split's reason, and a notice
exactly where a pass split) is NOT yet run; the runtime-sources pin is not re-hashed (the
coordinator's).

(cherry picked from commit 30b797c61b27d4dbe34386c36a27837bb3ed8ead)
2026-11-04 21:54:21 -08:00
Anees Iqbal 34bafa410d Record the pass-start barrier family on the M3 Max (unverified on our side)
WORK IN PROGRESS, parked: recorded on Metal, not yet replayed on the runtime.

pass_start_reads.rs adds 13 conformance cases (pass-start-barrier-*), each a pass that clears a
BGRA8Unorm target and draws a read of it (owned fixture psb_reads):
- 32x32 private and over-a-buffer targets, each with: the barrier then a read at own pixels; the
  barrier then a pixel-coordinate sample; the read and the sample with no barrier; a solid draw,
  the barrier, then the read.
- display-masked-read: a 1728x1216 private target holding an earlier DontCare pass's leftovers
  (61x55, 45x45), cleared, the barrier, a read at own pixels through a 453x100 scissor beside an
  A8Unorm mask over a buffer at texture 3.
- new-texture-chain: two new 896x576 private textures, each cleared, the barrier, a read at own
  pixels through 841x521 (the second beside the first at texture 3), then a target over a buffer,
  loaded, the barrier, and a read of the second over it.
- new-texture-tile: a new 448x576 texture cleared, the barrier, a read over all of it.
Texels are recorded as runs of equal texels (fresh_contents::texel_runs, now pub(super)). Rows
with a barrier accept, beside the M3 Max's recorded answer, the Mac2 answer the case states, by
docs/API.md's accepted difference a-barrier-over-the-render-targets-orders-what-it-names-as-a-
mac2-gpu-s-does (the sentence naming these cases is added to it here). tests.rs bills the 13
cases' cost records to the next whole-set run (AFTER_THE_LAST_RUN).

Verified:
- conformance record on the M3 Max (macOS 27, 3 runs, one outcome each): every row's read
  draws the texels from before its pass, the barrier or not; Metal's validated leg stops the
  barrier ("scope (0x4) cannot contain MTLBarrierScopeRenderTargets on this device; afterStages
  (0x2) can not contain ... MTLRenderStageFragment on this device").
- cases::pass_start_reads unit tests pass (plain target), including
  metal_reads_the_texels_from_before_the_pass_on_the_small_rows against these recordings.
- clippy -p metal2vulkan-conformance --all-targets --all-features -D warnings.

Unverified / owed:
- conformance replay of these cases on the runtime (M3 MoltenVK, 5080, lavapipe): whether each
  barrier row matches the stated Mac2 answer exactly, and which notices each venue announces
  (shared-in-system-memory is declared; shadowed-texture or dont-care-stand-in may be needed).
- times::every_case_carries_its_timing fails until `conformance times --write` runs over these
  13 cases on the M3.
- docs/CONFORMANCE-COVERAGE.md not regenerated.
- new-texture-chain's recording is 1.46 MB of pretty-printed JSON (three 896x576 sites of 1042
  runs each); consider dropping the first texture's site.

(cherry picked from commit 724afbf80b78c14a8824dfb96203df3813fba9aa)
2026-11-04 21:54:20 -08:00
Anees Iqbal 60d3c512a6 Announce copied-host-pages for a buffer that lies in a live copy
What: a no-copy buffer or rebind that lies in the live copy of the same
bytes (`Device::degrade_copied_shared`) announces `copied-host-pages`, its
detail saying it lies in that copy and whether the copy drops the GPU's
writes. docs/API.md says so.

Why: such a buffer makes no copy of its own, but the GPU uses a copy for
it all the same (`Buffer::host_backing` answers `Copied`); before the join
each one was a copy and was announced. A consumer that asks for the kind at
each occurrence (`DeviceOptions::announce_each`) hears it per buffer as
before.

Verified: cargo check of the runtime (all features); the lane runs follow
on the M3.

(cherry picked from commit a4a75f118381a9f049157b1da063ba2fa4c9bff5)
2026-11-04 21:54:20 -08:00
Anees Iqbal 6c4b409fb0 Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an
admitted import failed) now joins its memory and is placed as an import is
(`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later
no-copy buffer over exactly the same first byte and length, of either
storage mode, finds it (`HostAliases::import`: an import of its class,
else the live copy), lies in it through `Device::buffer_in_import`, is
named to it (`copied_as`) and joins its key, with the gate not asked. A
rebind onto such bytes lies in the copy too where its textures were
planned at the copy's offset (its first byte) and no image in place rides
on it; an import keeps the old `!moved` rule. A heap's own copy is placed
but joins nothing; a buffer whose writes are dropped keeps its read-only
view. New counter `WorkCounts::copied_host_buffers_shared`.

Why: two copies of one memory agreed only through the pages (merge back
at the writer's completion, copy in at the reader's commit). reims-vgpu
measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface,
each over its own refused no-copy buffer: a blit write then a blit read in
one command buffer, and a reader committed first on a second queue waiting
on the writer's event, both read all 16384 bytes stale, where Metal and
the runtime in place read the write. The consumer also made a full copy of
the surface per texture per present.

The remaining GPU-to-GPU gap, between a copy and another copy or import of
overlapping but different bytes, is recorded in copied.rs, docs/API.md,
docs/HOWTO.md and docs/FAST-PATHS.md's known gaps.

Verified: cargo check of the runtime with tests; the lane in the next
commit, run on the M3 (see its message).

(cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa)
2026-11-04 21:54:19 -08:00
Anees Iqbal 3797c098eb Order a pass's clear before a draw that reads it after a barrier at the pass's start
A pass that clears a color and begins with a memory barrier over the render targets (after the
fragment stage, before it) and then samples that color's texture in a draw read the texels from
before the pass. Mac2 GPUs read the clear there (an Intel UHD 630 after the barrier, an AMD
Radeon Pro 5300M with or without it). The draw reads the texture's copy, taken ahead of the pass's
load actions (render/shadows.rs), and a barrier split the pass only where a draw of the current
instance came before it, so a barrier at the pass's start split nothing.

Such a barrier now orders the pass's load actions (`loads_ordered`): the scope form with the render
targets, or the resource form over an attachment's texture, after the fragment stage and before a
stage at or before it, recorded before any draw of the pass. A draw after it that samples the
texture of a color the pass clears (`Texture::cleared_in`) takes the existing after-barrier path:
it records into an instance after the pass's first, which runs the clear and draws nothing
(`next_instance` keeps the first instead of replacing it), so the copy before it holds the clear;
or, where the device has them, it reads through snapshots inside the first instance. The split is
counted as the after-barrier read's (`attachment_read_splits`, `instance_splits_attached_read`)
and reloads stand-ins over a buffer's bytes as one after a barrier does. A pass with such a
barrier but no such draw records as without it.

docs/API.md section 10 gets the accepted difference this ordering is: Apple GPUs do not support
the render-target scope, and the M3 Max reads the texels from before the pass after it.

The owned fixture psb_reads (regen-air-fixtures) holds the functions the lane and the coming
conformance cases draw with: a read and a pixel-coordinate sample of texture 0 at the fragment's
own pixel, channels reordered so a read is told from a skipped draw, and two-texture reads.

Verified on the M3 Max (MoltenVK, debug, --cfg m2v_gpu), runtime_lane::attachment_reads:
- a_draw_after_a_barrier_at_the_pass_start_reads_the_clear: both targets (own image, over a
  buffer), psb_read and psb_sample, the scope alone, with the textures and the resource form:
  the clear inside the scissor, one split each (attachment_read_splits 1, instance splits 1,
  2 instances begun), own-pixel copies of 308 texels (the 20x12 scissor and a pixel round).
- a_draw_after_a_clear_with_no_barrier_reads_the_texels_from_before_the_pass: no split.
- a_barrier_at_the_pass_start_costs_nothing_without_a_read_of_a_cleared_color: a loaded target
  read after the barrier, and a cleared one with a draw reading another texture: no split, as
  many instances begun and copies taken as with no barrier.
Negative control: the same tests on the tree without the runtime change fail at pixel (4, 4),
reading [0, 64, 0, 255] (the texel from before the pass, reordered) where the clear's
[120, 200, 40, 255] is due.

(cherry picked from commit 923095effcd188a93ee5134ecc4dad3fab21b3fe)
2026-11-04 18:50:30 -08:00
Anees Iqbal b2df1add01 Bind a storage view of a whole buffer from its space's start, so draws that move only an offset keep their set 0
What: `bind::instantiate::planned_range` gives a descriptor-form slot read
through a storage view of its `Whole` window the range from the start of
the bound buffer's space to its padded end, whatever the bind offset, and
the bind offset as its `SlotBindOffset` residual. `bind_buffers` (every
draw's and dispatch's instantiation) and `rebind_slots`
(`rebind_draw_slots_into`) take it. Every other slot keeps
`descriptor_range`'s range: uniform views (whose `RangeAtBindOffset`
specialization reads a range from the bind offset), bounded windows, and a
storage view whose range from 0 would pass the view's
`maxStorageBufferRange` (`PlannedBuffer::max_range`) or 2^32 bytes (a
32-bit residual and offset), or whose bind offset lies at or past the
padded end. The tessellation factor and index bindings keep it too.

Why: `EncoderCore::set_zero_of` was 14.3% (draws.10k) and 8.8% (WS-like)
of the encoding thread's samples: every draw allocated, wrote and bound a
set 0 of its own. A `device T *` slot's range started at the bind offset
aligned down, so each new offset wrote another descriptor and neither
`LastSetZero` nor `SetCache` could match.

Vulkan: the descriptor's offset is the space's start (256-aligned, as a
bind at offset 0 has it today) and its range ends where today's ends (the
padded end), so offset + range, and a dynamic binding's effective offset +
range (VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979), are what they
were. dynamic_writes moves that same start into the dynamic offset for
every bind offset. The range is explicit, never VK_WHOLE_SIZE (06715 does
not apply). Hazard ranges are untouched: they come from the plan's use
ranges from the bind offset (`binding::bytes_use`).

Behaviour: a Metal offset m from the bind offset reads byte residual + m of
the range, the same byte as before for every access inside the window. An
access that reaches back before the bind offset (a negative index, the
32-bit offset wrapping) and lands in the buffer's space now reads and
writes the buffer's bytes there, as Metal's does; before, it lay outside
the descriptor range unless it stayed within the alignment's residue. On
a device with robustBufferAccess (or under in-shader containment against
the view's size) accesses are bounded by the larger range [space start,
padded end) instead of [bind offset aligned down, padded end): such an
access before the bind offset is in range and reaches the buffer's bytes
where it was a robust out-of-bounds access (a zero, a value from within
the buffer, or a dropped write). Accesses past the end are bounded as
before.

SEMANTICS_VERSION 1957 -> 1958: instantiated descriptor ranges and
residuals change. golden_hashes_match_the_table passed unchanged here (it
hashes compiled modules, which this does not change); the re-bless on
development decides.

Tests: planned_range's unit tests (the range from 0 and the residual at
every 4-byte offset for base alignments 16, 64 and 256, and a 2^32-byte
buffer at its last word; each fallback equal to descriptor_range's
answer). A device test, set_zero_at_offsets: 9 draws of colored_vertex
moving only two device buffers' offsets reuse 8 sets and bind 1, and draw
what 9 draws of buffers of their own draw (0 reused, 9 bound).
dynamic_multi_variable's moved-offset dispatches now reuse their
predecessor's set (7 of 8) and still answer Metal's values from each
dispatch's own offset. docs/API.md states the range.

Verified: the translator suite, 3324 of 3324 (plain). On the M3 Max
(MoltenVK 1.4.2), debug, --cfg m2v_gpu, under maclock and memcap: 96 of 96
runtime tests (fix 1's set plus set_zero_at_offsets,
dynamic_multi_variable, uniform_bind_offsets, binding_view, range,
rebind_descriptor_slip, rebind_behind_a_wait, depth_ranges, attributes),
and 220 of 220 validation lanes under the validation layer (fix 1's set
plus stage_in_regions, stage_in_strides, padded_loads, escaped_slots,
absent_reads, chosen_pointers, dispatch_*, read_through_views,
guarded_effects, index_fetches, first_vertex, vertex_strides, host_bytes,
pointer_uploads, commands_recorded, runtime_lane::tests, among them
renders::public_render_cases_match_metal and
tests::stage_in_region_cases_match_metal). Negative control:
planned_range forced to fall back fails set_zero_at_offsets ((0, 9)
against (8, 1)) and both dynamic_multi_variable moved-offset tests
((0, 0) against (7, 0)). clippy plain and with --cfg m2v_gpu clean.

Per draw on the encoding thread, release with thin LTO, 3 interleaved
rounds against the parent build, medians:
  draws.10k  11201.7 ->  9212.4 instructions (-17.8%), 616-661 -> 485-495 ns
  WS-like    23121.1 -> 21752.5 instructions (-5.9%)
One round's counts: draws.10k 0 -> 29880 sets reused, 30000 -> 120
vkCmdBindDescriptorSets, 6 -> 60000 vkCmdPushConstants (the residuals;
both stages' writes are pushed where either changes); WS-like 0 -> 3744
sets found in the command buffer's cache, binds unchanged at 4000.

(cherry picked from commit b875660ecbad7dd6f9dfa9f976ef1c2b32bded1e)
(cherry picked from commit b09293e9c22d80e4ae4c505b00ba0e07e6a8165c)
2026-11-04 18:50:27 -08:00