Commit Graph
438 Commits
Author SHA1 Message Date
Anees Iqbal 3d18018dad A raster order group on a color read takes no interlock where fetch is ordered between draws alone
On a device with neither rasterization-order color attachment access nor the pixel interlock, a
color input reads its input attachment ordered between draws by the runtime's barriers. A raster
order group on that input (fragment_fetch's fetch_ordered), or on a color output of an attachment
the function reads, asks for the order of that read, which is the read's own form there; it no
longer interlocks the function, so such a function is no longer refused RasterOrderGroups after the
fetch itself stopped being refused. Its overlapping fragments of one draw stay unordered,
PrecisionNote::UnorderedFetchWithinDraw, which the read records. A group on a buffer, texture or
imageblock member still needs the interlock. Devices with an ordered fetch form keep their path
(rog::declared is unchanged where fetch::fetch_unordered is false).

The conformance cases that fetch (fetch_ordered, srgb_fetch: one fullscreen triangle a draw, so
every byte still compares exactly) name unordered-fetch-within-draw among their notice allowances,
so a venue with neither form (RADV on the RX 550) replays them against the M3's recordings.

Tests: the compile test draws fetch_ordered on lavapipe's description without either ordered form
(input attachment, neither feature required, noted) and with the interlock (interlocked, as
before); engine_dead_reads' live dfr_output on vk12-floor now compiles without an interlock,
noted (before, refused RasterOrderGroups). Docs: API.md's fetch paragraph and catalogue entry,
rog.rs's module docs, the note's doc.
2026-11-11 04:01:36 -08:00
Anees Iqbal 22a96f62d4 Docs: framebuffer fetch between draws, its note, REFUSALS and the API signatures
docs/API.md's framebuffer-fetch paragraph says what a device with neither
ordered form does, and the degrade-notice catalogue gains
unordered-fetch-within-draw. docs/FAST-PATHS.md's device-gap table gains its
row. docs/REFUSALS.md regenerated (FramebufferFetch loses the
unsupported_features and family-row sites). api_signatures.tsv blessed: the
PrecisionNote and Degradation variants and WorkCounts::fetch_draw_barriers.

Verified: refusal_surface.py (0 without reach mark or basis), signatures.py
--bless (3 added).
2026-11-11 04:01:35 -08:00
Anees Iqbal b39d22516f Four runtime messages are said once per device and kind, each later one counted
What: metal2vulkan-heap-texture-refused (Info, a placement heap's texture not
made at an offset inside it), metal2vulkan-twin-decode-failed (Error, a decoded
twin's failed CPU decode), metal2vulkan-late-reservation (Warning, an ignored
late reserve_resource_ids call) and metal2vulkan-queue-limits-reached (Info,
each placement or queue-sharing read the queue limits changed, at device
creation, per queue made and per report) were said at every occurrence. They
now go through the degradations' once-per-device record: Announced keeps a
bit per kind of a closed vocabulary of messages that are no degradation
(degradation::Told), and Device::tell says a kind's first message on the device
(through its sink, else stderr) and counts each later one, without making its
text, in the kind's new WorkCounts field: heap_texture_refused_withheld,
twin_decode_failed_withheld, late_reservation_withheld,
queue_limits_reached_withheld. Device::inform_once is the informational form.
Every refusal and answer is as before; only the messages' rate changes.

Why: the owner's rule (11-11): a degradation, fallback or refusal message is
logged once per kind and device, later occurrences counted, never logged per
call. reims's sweep at ef7af82fe4 found these four firing per occurrence.

Tests: tests::told_once (each kind said once and its later one counted on
one device, said again on another; a second late reservation counted, not
said); tests::heap_refused_notice (the second refusal on a device counted, not
named; another device names its own first); tests::queue_limits_device (the
first case met is sent, every later one counted; a second read of the sharing
counts one more). api_signatures.tsv takes the four fields; the docs of the
four messages (texture.rs, resource_ids.rs, DeviceOptions::queue_limits, the
runtime README, docs/API.md) say the rate.

Verified: see the branch's report.
2026-11-11 02:45:22 -08:00
Anees Iqbal 3811e1c184 air.convert's rounding and .sat suffixes: the conversion the types name, as x86 Metal answers
The exact emulation of the directed roundings, the integer .sat clamp, float-to-int pre-rounding,
the RoundingModeRTE plan and PrecisionNote::NativeConversionRounding are removed; they stay in
history at 540011dd49. The parser accepts the suffix and the lowering is the plain conversion:
Metal's compilers disagree on the suffixes, and the owner's 11-07 rule takes the cheapest answer
inside the envelope where real Macs disagree.

Measured per form, 64 threads of the fixture's edge values, one kernel per intrinsic (probes
m3-max-14380 Radeon Pro 5300M and m3-max-14381 UHD Graphics 630, macOS 26.7.1; m3-max-14382 M3
Max, macOS 27.0.1):

  form                         M3 Max                 5300M            630            now
  float->int .rte              nearest even           truncates        no pipeline    truncates
  float->half .rtz/.rtp/.rtn   .rtz as named,         nearest even     as named       nearest even
                               no pipeline rtp/rtn
  float->int .sat              unsigned keeps a       8-bit not        no pipeline    clamps
                               negative's wrap, long  clamped, long
                               of inf is 0            clamped to int
  int->float/half any mode     .rte nearest even,     nearest even     nearest even   nearest even
                               no pipeline directed
  int->int .sat                no pipeline            wraps            wraps          wraps
  float->int .rtp/.rtn         no pipeline            truncates        no pipeline    truncates

The last three rows are no difference: every Mac that creates the pipeline answers the plain
conversion. OpenCL on all three GPUs (not Metal) answers the exact IEEE roundings. The M3's
compiler service exits (XPC_ERROR_CONNECTION_INTERRUPTED) on the forms it does not compile.

- metal2vulkan-air: Convert::parse takes `.<rte|rtz|rtp|rtn>` and then `.sat` (to an integer
  only), between numbers; the module doc carries the measurement. Test: every suffix parses to
  its plain form.
- Engine test: 24 forms with every rounding (and .sat to an integer) compile on lavapipe and on
  moltenvk-m3 without shaderInt64 to the plain conversion's module words and notes, and pass L3.
- Fixture: kernel_convert_rounding_apple_gpu now calls only the forms the M3 compiles and
  answers plainly, for a case qualified there.
- docs/API.md accepted differences: the table above.
- SEMANTICS_VERSION 2024 (development is at 2023); ARTIFACT_FORMAT_VERSION back to 500, with no
  codec change.

Verified: not yet run (dispatched next).
2026-11-11 02:42:04 -08:00
Anees Iqbal 2bc702f4b4 air.convert roundings: drop the double paths AIR cannot name; fix the tests' first run
air.convert names no double (the AIR element types stop at f32), so the directed double
narrowings, the double results and the 64-bit RTE width were unreachable: removed. The nearest-even
plan is now a flag for a float result, and narrow::rte_modes decides 32 bits and the widths the
device's independence ties to it. The engine test reads the interpreter's buffers directly, pins
the RTE widths of the venue profiles (lavapipe and RADV 32, ANV 16/32/64, MoltenVK and the floor
none) and the parse test names a float narrowing instead of a double one.

Verified: the first test job (m3-max-14044, homelab-ms01-1) failed on the double case in the parse
test and a compile error in the engine test; both fixed here, rerun next.
2026-11-11 02:41:51 -08:00
Anees Iqbal 9f4590f124 air.convert with a rounding suffix: parse it and lower each form
Apple's OpenCL compiler spells every convert_* it emits as an air.convert with a
rounding after the types (.rte, .rtz, .rtp, .rtn) and, to an integer, .sat after it
(convert_float4_rte(uchar4) is air.convert.f.v4f32.u.v4i8.rte, convert_int_sat(float)
is air.convert.s.i32.f.f32.rtz.sat; the forms are read from the OpenCL runtime library
the macOS 27.2 Metal toolchain ships). Convert::parse took exactly four tokens, so each
such name was an unknown intrinsic and the pipeline was refused.

- metal2vulkan-air: Convert gains `rounding: Option<ConvertRounding>` and `saturate`;
  a rounding is accepted between numbers only (no bool, no 8-bit float) and .sat only
  after one, to an integer. Static folding leaves the saturating and the directed forms
  alone.
- Lowering (lower/arith/rounding.rs):
  - float to integer: RoundEven / Ceil / Floor first (rte / rtp / rtn; rtz is the
    conversion's own truncation), then the saturating conversion every air.convert to an
    integer takes; the NaN test reads the operand itself. Denormal notes as rint / ceil /
    floor take them.
  - integer to integer: plain; .sat clamps to the range both types share (SClamp/SMax/SMin
    of the sign extension, masked, or UMin; pairs on the wide path).
  - integer to float and float to narrower float, nearest even: the plain conversion. Where
    it can round to f32/f64 the entry declares RoundingModeRTE for the width and the widths
    the device's independence ties to it (narrow::rte_modes); a device that cannot declare
    them records the new PrecisionNote::NativeConversionRounding.
  - toward zero or an infinity: no Vulkan conversion rounds so per instruction, so the
    result is computed exactly by integer arithmetic: the magnitude's dropped bits with an
    increment where the lane rounds away (f32, f64 from 64-bit, the wide path through its
    sticky 32-bit fold), f32 to half on the bits (normal, overflow, subnormal, inf, NaN),
    double to float by stepping the device's faithful conversion, double to half through
    the round-to-odd f32. A conversion that cannot round is the plain one.
- PrecisionNote::NativeConversionRounding (native-conversion-rounding): codec, runtime
  Degradation, comparison table (unbounded), fast_paths ledger class, docs/API.md.
- SEMANTICS_VERSION 2021, ARTIFACT_FORMAT_VERSION 501 (the codec gains the note);
  api_signatures and the air api_surface blessed.
- Fixture kernel_convert_rounding_modes (owned MSL, air-rename to 64 suffixed intrinsics).

Unverified at this commit: build and tests follow in potluck jobs.
2026-11-11 02:41:50 -08:00
Anees Iqbal 1032d39bd6 Pass log: a pass a frame repeats with other counts prints no line again
The pass log told its lines apart by their whole text, its draw-call and resident counts
included, so a pass a frame repeats with one draw more printed again and the 256-line bound
could fill before the pass that matters ran. A line is now keyed by the pass without those
counts; the line still prints them.

Verified: cargo fmt; tests::pass_log runs on potluck after this commit.
2026-11-11 01:49:25 -08:00
Anees Iqbal 5a21f6d3f3 METAL2VULKAN_LOG_PASSES: a default-off log of the render passes that name a watched texture
A diagnostic to find which pass draws the white at a widget's glass edges in the 27.0.1 guest:
the runtime sees every pass's attachments, which the consumer's own logs cannot name.

The switch's value is the textures to watch, a comma-separated list of FORMAT:WIDTHxHEIGHT
(the format as the notices print it or as Metal names it, `*` for any format or size). At the end
of each render encoder that renders into a watched texture, binds one to its fragment stage or
makes one resident, the device logs one line (id name metal2vulkan-passes, Info): the render area,
its Vulkan render pass instances and draw calls, each attachment (format, size, object ID, label,
whether it took its storage form, level, slice, load and store actions as the pass ends, its
stand-in and cause), the depth/stencil aspects' actions, the pipeline states its draws drew with,
the textures bound to the fragment stage at a draw, the watched resident textures with their
stages, and what it watched. A line the same as one printed before is not printed again; a process
prints at most 256. Off (unset, empty or 0, or a value it cannot read, said once on stderr), an
encoder notes nothing; no behaviour reads it.

- crates/metal2vulkan/src/env_vars.rs: the registry row and `log_passes()`, the raw value.
- crates/metal2vulkan-runtime/src/pass_log.rs: the filter, the notes, the line and its bound.
- render.rs: an encoder's notes, made where the log is on, noted at each draw call, logged at
  the pass's end once its store actions are settled.
- texture.rs: `Texture::took_storage_form`, which the line names.
- docs/API.md and the artifact test's list of the runtime's variables name it.

Verified: cargo fmt; the build, clippy and the tests run on potluck after this commit
(tests::pass_log: the filter's parse and refusals, an entry's match, the once-and-bound rule).
2026-11-11 01:49:25 -08:00
Anees Iqbal 7aefa49b7f A float write through an argument buffer notes the half-float and small-float NaN only where the heap can name such a texture
What: lower::texture::stored_where gave a heap element one clause of no test, so a
`float` texel's write through an argument buffer recorded DeviceNanEncoding (and,
off MetalHalfStorageWrites, DeviceColorConversion) unconditionally, whatever the
command made resident. It now gives the clause the family the caller asks about:
may_store_half the 16-bit float family (bind::heap::NAN_SIXTEEN), small_float_storage
the packed small float one (NAN_SMALL), tested on SpecKey::HeapNanFamilies, which
the runtime reads at each draw or dispatch, as a `half` write's heap note already
does (half_write_nans). SEMANTICS_VERSION 2021: the notes change under unchanged
keys on every profile without MetalHalfStorageNans.

Why: with lavapipe's MetalSmallFloatNans row, runtime_lane::half_storage_writes::
every_nan_a_kernel_writes_to_a_small_float_texture_is_metal_s_where_measured failed
on lavapipe (gem10, Mesa 26.2.6, LLVM 23.1.4) in its argument-buffer form alone:
every one of 98,298 NaN fields was Metal's, yet the dispatch, whose only resident
texture is RG11B10Float, announced device-nan-encoding for the half-float family
the heap might have held. The same over-note as the reported one, through the
argument buffer's float write.

Test that fails without it: tests::engine_handles::a_heap_texel_write_is_the_devices_write
now requires a float texel's DeviceNanEncoding to hold only under HeapNanFamilies
clauses of NAN_SIXTEEN (profile without MetalHalfStorageNans) and NAN_SMALL (without
MetalSmallFloatNans); and the lane above on lavapipe.
2026-11-11 01:30:36 -08:00
Anees Iqbal 08ff006256 lavapipe stores small-float NaNs as Metal does: its MetalSmallFloatNans row, and the lanes that gate it
What: driver_facts::DEVIATIONS gains MetalSmallFloatNans for MESA_LLVMPIPE (every
CPU). A half or float texel's write that may reach an RG11B10Float storage image
on lavapipe then records no DeviceNanEncoding for it and requires
VkProperty::MetalSmallFloatNans, as on MoltenVK's Apple9 identity. Two lane tests
measure the deviation on every venue and gate it where a driver is listed:
half_storage_writes::every_nan_a_kernel_writes_to_a_small_float_texture_is_metal_s_where_measured
(32,766 float NaNs: every top-13 payload pattern, low bits clear and set, both
signs; write, read_write, texture buffer and argument buffer forms) and
half_write_nans::every_half_nan_written_to_a_small_float_texture_is_metal_s_where_measured
(all 2,046 half NaNs; write, read_write, held). Each requires every NaN field
Metal's canonical one and no device-nan-encoding where the profile takes the
deviation, and device-nan-encoding where any field differs elsewhere. half_write_nans'
stored() takes its texels. The existing half_write_nans lane's measured branch
no longer requires native-nan-encoding absent where the device's widening is
unmeasured (no MetalNanMoves): that note is the kernel making's, for its widening of
the half whatever texture it writes, and a 32-bit float store shows it.

Why: lavapipe announced device-nan-encoding on every RG11B10Float half write of
runtime_lane::half_write_nans (write, read_write and held) with 0 of 25 lanes
differing from Metal's (msi, Mesa 26.2.4, LLVM 23.1.1, at 7d7085f9d0), and the
conformance case half-write-nans-rg11b10f differed only in its notices. The note
fires because the profile lacked the deviation, not because the store differs:
llvmpipe packs a small float in its shader code and writes every NaN as the
field's quiet NaN with its sign dropped, which is Metal's. RADV and NVIDIA keep
payload bits, so they stay unlisted. No SEMANTICS_VERSION bump: the deviation is
an enabled property the profile fingerprint hashes, so lavapipe's keys change
(golden_hashes' lavapipe cells re-key; re-blessed on development).

Test that fails without it: device::tests::driver_facts::
the_profile_takes_the_deviations_its_driver_is_measured_with now expects
MetalSmallFloatNans on lavapipe, gate-lavapipe and gate-lavapipe-x86_64.
Verified: the lavapipe, PHOENIX and M3 runs in the branch's report.
2026-11-11 01:30:29 -08:00
Anees Iqbal 04bf17db16 Fence each optnone call only helper invocations may make before a storage write with an identity simdgroup shuffle
What: on a driver whose compiler loses a simdgroup's texture writes after an `optnone` call that
only its helper invocations make (DriverWorkaround::DiscardDropsSimdgroupStores: MoltenVK on an
Apple GPU), a call the helper guard cannot keep the helpers away from exactly (an arm with a
derivative or subgroup operation, a loop the helpers repeat alone) and that no tangled
instruction reading its result follows was left as it was, with
PrecisionNote::HelperBranchDropsSimdgroupStores recorded. Now spirv::helper_branches fences each
such call: an OpGroupNonUniformShuffle of its result at SubgroupLocalInvocationId (a
MulExtended's structure member by member, put together again) follows it, and every use reads
the shuffled value. Each invocation, a helper too, reads its own lane, so no answer changes and
no lane reads another's; the shuffle is the simdgroup operation after the call, reading what it
computes, that the M4 probe found keeps the writes. The fences are placed once every analysis of
the module has run (compile.rs, before the verifier): those analyses would read a shuffle as a
move between lanes.
- guard_for returns the Fences beside Guarded (Guarded::fences counts them); plan lists every
  bare call (Facts::bare, which any_bare was) and no longer stops at the first function with one.
- The census names the fences `fragment.helper-fence`; the runtime's pipeline creation log
  prints `helper-fence <stage>`.
- The note stays where no shuffle can follow: no fragment-stage subgroup shuffle on the profile,
  or a 64-bit or bool lane, or an 8- or 16-bit one without shaderSubgroupExtendedTypes.

Why: the weather widget's glass edges in the 27.0.1 guest on the M3 draw white 8x4-pixel blocks
along the primitive's edges (solid strips in some boots, a comb in others, at every pin since 30),
and the guest's run announces helper-branch-drops-simdgroup-stores for a fragment function.

Tests: engine_fragment's helper guard tests (rch_helper_branch_loop and rch_helper_tangle's
`before` and `unread` functions fenced, census and shuffles counted, no note, L3), a new test that
the note stays with the fragment shuffle taken out of the profile, and the runtime lane
helper_tangle, which now requires the fence and no lost write where the fragment stage shuffles.
SEMANTICS_VERSION 2021.

Verified: cargo fmt; the build, the touched tests and the M3 lane follow.
2026-11-11 01:12:17 -08:00
Anees Iqbal 131be007fa A half write through an argument buffer notes its NaN only where the heap can name a family the device stores its own way
What: a `half` texel's write to a heap element recorded `PrecisionNote::DeviceNanEncoding`
unconditionally ("a heap element may be any format"), so on MoltenVK on the M3 Max a write
through an argument buffer into an RGBA32Float or RG11B10Float texture announced the note
though the store is Metal's there (0 of 25 lanes differ, job 13458's lanes128.log). A new key,
`SpecKey::HeapNanFamilies(Stage)`, gives from the command's heap members the families whose
texels may hold a NaN a `half` write stores (`lower::texture::nan_family`, the same classes
the slot path tests of a bound format: 1 a 16-bit float format, 2 a 32-bit one, 4 a packed
small float one, 8 a float format of none of those; normalized, sRGB, extended-range,
integer and stencil formats none). `half_write_nans` now records the heap write's note under
one clause per family whose deviation the profile lacks (`MetalHalfTexelWrites`,
`MetalNanMoves`, `MetalSmallFloatNans`) and the no-family bit, requiring the property of each
family it takes, as a slot's write does.

Measured, before the change (`runtime_lane::half_write_nans`, argument-buffer writes):
- M3 Max, MoltenVK (job 13458): 16-bit float formats 15 of 25 lanes differ (signalling NaNs
  stored 0x7e00); 32-bit float and RG11B10Float 0 differ. The note now holds there only where
  the heap can name a 16-bit float texture (or one of no family).
- lavapipe (job 13553): 16-bit 8 differ, 32-bit 15 differ, RG11B10Float 0 differ. lavapipe
  takes none of the three deviations, so its note keeps every family's clause.

Runtime: `degrade_bound_values` reads the clause at each draw or dispatch (generic; no
runtime code changed). The lane `half_write_nans` now holds argument-buffer writes to the
measured rule as it holds slot writes: on a device with the family's property, 0 lanes differ
and nothing is announced.

Public API: `SpecKey` gains `HeapNanFamilies(Stage)` (a `#[non_exhaustive]` enum; no
consumer breaks); api_signatures.tsv blessed.

Tests: heap::a_heap_half_write_s_nan_note_follows_the_families_its_command_can_name (the
clauses and required properties on every committed profile with a heap; plan values 1/2/4/0
for R16Float, RGBA32Float, RG11B10Float, RGBA8Unorm and R32Uint residents and the note held
under them).

SEMANTICS_VERSION 2019, ARTIFACT_FORMAT_VERSION 500 (a SpecKey tag; both renumbered at
landing).

(cherry picked from commit 8f6f24055459c9143f3473da8ab60e6532b30676)
2026-11-10 06:13:23 -08:00
Anees Iqbal 199f9a99a2 A half sample of a 32-bit float texel records no half-texel note where the device's half is Metal's
What: half_texels' clause for a sample of a 32-bit float texel (Bound & BicubicTexels::LINEAR,
'Metal rounds toward zero, saturating') is no longer added on a profile that takes
DriverDeviation::MetalHalfConversion; the module then requires VkProperty::MetalHalfConversion
(TexturePlan::storage_properties), as half_texel_nans' NaN clauses do since 782da3582b. Elsewhere
the clause stays. The unmeasured-class and 16-bit normalized clauses are unchanged.

Why: on MoltenVK over the M3 Max a half sample of RGBX32Float through a runtime sampler (the
consumer's rgbx_sample_half) announced half-texel-conversion ('where it binds texture 0 bound as
RGBX32Float') while every value was Metal's. The deviation's measurement covers the half result
of a read, sample and gather of every float word of RGBA32Float (half-texel-nans-rgba32f,
m3-max-13447: every value Metal's), and RGBX32Float is held in that twin.

Test: runtime_lane::rgbx_textures::rgbx_half_samples_are_metals (the previous commit): nearest and
linear runtime samplers, edge and border, shared and private, RGBX32Float and RGBA32Float; on a
profile of MetalSampler and MetalHalfConversion no half-texel-conversion may be announced.
Docs: the note's rustdoc and API.md's catalogue entry. SEMANTICS_VERSION 2019.

Verified: the M3 run of the control and of this commit follows.
(cherry picked from commit bb5662fd6d9bb512bc8d185c85a5d7098b1f2d9d)
2026-11-10 05:50:50 -08:00
Anees Iqbal 83e5e06789 DescriptorError::ColorAttachment carries Metal's answer: nil with an NSError, or the process ends
A layer that answers as Metal does needs to know, per refused pipeline, whether Metal returns nil
with an NSError or its descriptor validation asserts and ends the process. ColorAttachment now
carries `metal: MetalAnswer` (NilWithError | EndsProcess), set at each of its 17 sites from plain
Metal's answer on an Apple M3 Max under macOS 27.0.1 (probes/color_attachment_answers.m, no
MTL_DEBUG_LAYER, job m3-max-13738):

- EndsProcess (SIGABRT, "Render Pipeline Descriptor Validation"): blending on a bfloat attachment,
  with a function, a fetching function or none ("... MTLPixelFormatRGBA16Bfloat for this render
  target is not blendable."); alpha to coverage over an integer attachment 0, rasterizing or not
  ("... alphaToCoverageEnabled requires a float/unorm pixel format ..."). The link's doc said the
  second was unmeasured with rasterization off; it is measured now.
- NilWithError (code 3, domain AGXMetalG15X_M1): an output of another numeric class (half4, float4
  and int4 into RGBA8Uint; uint4 into RGBA8Unorm and RGBA8Sint; a fetching uint4 of RGBA8Unorm);
  a color input of another class (uint4 of RGBA8Unorm, BGR10_XR, A8Unorm); fewer output components
  than channels (with and without fetch); a blend of the second source without the second output,
  or without the first (with and without fetch); a color input without an attachment; a tile
  function's imageblock member without a format ("Invalid pixel format for render target 1").
- A `Compiled` tile function compiled under another format than the descriptor's has no Metal
  counterpart (Metal compiles the function for its pipeline) and answers EndsProcess, the answer
  of an unmeasured case; under no format it answers Metal's NilWithError.

Public API: the new `error::MetalAnswer` and the changed variant are in api_signatures.tsv and the
api_surface table. Refusals are not serialized in any cache, and translation output is unchanged,
so neither ARTIFACT_FORMAT_VERSION nor SEMANTICS_VERSION moves. docs/REFUSALS.md regenerates
unchanged (descriptor errors are not in it). docs/API.md states the two answers.

Tests: each existing test of a ColorAttachment refusal now names its answer (bfloat blends,
alpha to coverage, a tile function compiled for other formats: EndsProcess; output class and
components, the second source, unattached inputs, unformatted tile members: NilWithError), and a
new unit test holds the storage form's class refusal to NilWithError for reads and writes.

(cherry picked from commit cd17476e5a4ae2b9fbf8118453ad089691adaba2)
2026-11-10 05:40:38 -08:00
Anees Iqbal f0b1976e58 Queue sharing: a command buffer whose VkQueue waits on the GPU for another's work counts that wait in its long mark
The Adaptive long mark read a command buffer's own GPU timestamps alone. A batch that waits on the
GPU for another VkQueue's work (an MTLEvent's signal pending there, the tracker's wait for another
VkQueue's writes, new resources' first work there) writes its start timestamp only once that wait
is met, so a queue of short command buffers, each waiting for another queue's 30 ms one, never went
long: it kept sharing its VkQueue, and every command buffer the queues sharing it committed behind
each wait waited for the other queue's whole long command buffer.

Now submit_batch notes, at the first batch whose VkQueue it hands such a wait (an event wait whose
signal is pending on another VkQueue or is the caller's, EventTimeline::waits_across; a tracker or
first-work wait on another VkQueue), the host time its submission was called (Times::waited_across).
place_gpu_times marks the queue long also where more than LONG_HEAD ran from then to the command
buffer's GPU end, placed in the host's time. A command buffer with no such wait is timed as before,
by its own timestamps, so the host-view false marks the module docs describe stay out.

The device test a_compositor_beside_a_queue_waiting_on_the_gpu_for_long_work_keeps_its_latency now
also asserts that the waiting queue goes long (WorkCounts::queues_gone_long >= 2). The QueueSharing
notice's cost, docs/API.md's catalogue entry and the FAST-PATHS row name the wait.

Verified: cargo fmt; unit test a_wait_crosses_queues_where_its_signal_is_pending_on_another; the
build, clippy and the 5080 device run are dispatched.

(cherry picked from commit 6391625634472fb158b6477dfad36340956ae2dd)
2026-11-10 05:16:05 -08:00
Anees Iqbal ff45556bcc An argument buffer's sample filter note holds only where its heap can name a filtered raw texture
What: a heap sample the function emulates (`sampler::heap_raw`) recorded
`PrecisionNote::BicubicFilterArithmetic` whatever the command's heap held: unconditionally
through a constexpr linear sampler, and under the bound sampler's word through a runtime
slot. A command whose heap holds no raw texture samples through the device's own sampler,
and a bfloat form's sample reads the nearest texel, so neither filters by the device's
arithmetic. `SpecKey::HeapRawTextures`' value now carries two bits, which the plan gives
from the command's heap members (`slots::heap_raw`): `heap_raw::HELD` (1, a raw-held
texture: the decode's `DevicePackConversion`, unchanged) and `heap_raw::FILTERED` (2, a
raw-held texture of a form the function filters: not a bfloat one). The filter note's
clauses each test `FILTERED` (beside the bound word's test through a runtime slot).

Runtime: `degrade_bound_values` reads the clause at each draw or dispatch, so a command
whose heap holds only RGBA8Unorm or RGBA16Bfloat textures no longer announces
bicubic-filter-arithmetic for a linear heap sample; one holding a BGRA10XR texture still
does. No runtime code changed (the path is generic).

Tests: heap::a_heap_sample_s_filter_note_follows_the_raw_texture_and_the_bound_sampler_word
(artifact clauses on every committed profile), heap::a_heap_sample_s_filter_note_holds_where_its_command_can_name_a_filtered_raw_texture
(plan values 3/1/0 and the notes bound under them), the decode-note plan test's values
(3 for BGRA10XR, 1 for RGBA16Bfloat), engine_sampler's argument-buffer stage check, and the
lane heap_extended_reads::a_heap_sample_s_filter_note_is_announced_where_its_command_can_name_a_filtered_raw_texture.
Docs: SpecKey::HeapRawTextures, the note's rustdoc, API.md.

SEMANTICS_VERSION 2018 (renumbered at landing).

(cherry picked from commit dbc8a2781ef6170f797d5b7a7a83b46264c5e4e2)
2026-11-10 04:45:12 -08:00
Anees Iqbal 445d410eda An extended-range sample's filter note through a runtime sampler follows the bound word
What: a sample of an extended-range or padded texture that the module filters itself
(`sampler::extended`, through the slot's variant, and `sampler::heap_raw`, through an
argument buffer's raw element) recorded `PrecisionNote::BicubicFilterArithmetic`
unconditionally through a runtime sampler slot. It is now specialized on the word of the
sampler bound at that slot (`NoteOn::BoundSampler`, `SpecKey::BoundSamplerWord`), with the
two tests `linear::filtering_word` gives, as the YCbCr filter note does: a linear
minification or magnification filter, anisotropy or a cubic filter (any of those bits), or
a linear mip filter. The level blend of a word-stated mip filter holds on the linear mip
test alone. A constexpr sampler keeps its rule (linear: unconditional; nearest: none).

Runtime: the clauses test a bound value, so `Device::degrade_bound_values` reads them at
each draw or dispatch of the variant (no runtime code changes: the path is generic, and
`slots::record_noted` already records the word for a noted key). A nearest runtime sampler
over such a texture no longer announces bicubic-filter-arithmetic; a filtering one still
does.

Why: a nearest sample is the decoded texel at Metal's position (no filter arithmetic), yet
it announced the note, so the conformance suite's nearest cases
(`rgb10a2-srgb-samples-nearest-*`, the eight `xr-two-plane-samples-*-n*-*`) declared it.

Tests: engine_extended_range::samples::a_runtime_sampler_s_filter_note_holds_only_where_the_bound_word_filters
(every form, half and float, runtime / constexpr linear / constexpr nearest, on lavapipe,
moltenvk-m3 and the RTX 5080 profile: clauses hold for linear, linear min, linear mag,
linear mip, anisotropic and cubic words, not for nearest or nearest-mip ones; bfloat forms
record none) and heap::a_heap_sample_s_filter_note_follows_the_bound_sampler_word. The
rgb10a2_srgb lane now checks its nearest samples announce no filter note. The conformance
allowances of the rgb10a2 sRGB and two-plane sample cases name the note for the linear
cases only. Docs: the note's rustdoc and API.md's catalogue entry.

SEMANTICS_VERSION 2016: an artifact's notes change.

(cherry picked from commit fd5212bee216b823ba18d3c5ba5e5a74a4b12073)
2026-11-10 03:17:33 -08:00
Anees Iqbal 6be4be9791 Keep the predicted plain half arm in a key's general form: a creation makes one pipeline, not two
What: on a device that samples through Metal's own texture unit (MoltenVK), a texture slot a
function converts to `half` declares SpecKey::PlainHalfTexels and SpecKey::UnmeasuredTexels.
The general form (render/residual.rs) zeroed both, so a state's creation made its predicted
key's general form (the class routine's arm, PlainHalfTexels 0) and handed the predicted key
itself (the plain arm, 1, as an unbound slot takes) to the pool right after. Every draw of a
plain class takes the predicted key, so the general form served a draw only while the
predicted key was still being made; the conformance cases render-then-sample-magnified-nearest
and -linear made it and no draw took it (cost.rs named it an open bug). PlainHalfTexels is no
longer a constant of the general form: a key keeps the plain arm its binding gives it. The
predicted key is now its own general form, and the creation makes that one pipeline.

What still takes a general form: a draw binding a class whose `half` conversion is not
measured (BC4 to BC7, the linear ASTC formats) keys UnmeasuredTexels 1, which no instruction
reads; its general form is the predicted key, made at creation, so it draws at once and runs
its own key's instructions while its own is made on the pool, as before. A draw binding a
YCbCr field on the grid 8192 (PlainHalfTexels 0) makes its own key at its draw, as any key the
creation did not predict; on a device whose memory is the host's such a slot reads its planes
in place in a variant of its own (VariantKey::ycbcr_in_place), which no creation predicts
either.

Tests: tests::general_form now expects the plain arm kept ([1,1,1,5,3] -> [0,1,0,5,3], an
unmeasured plain class's key -> the predicted key, a YCbCr class keeps the routine's arm); the
made_at_creation lane expects one making at creation on every device (it expected two on
Metal-sampler devices) and the unmeasured-class draw to take the predicted key as its general
form; ycbcr_textures' and runtime_lane's comments follow. Docs: residual.rs, predicted.rs,
WorkCounts::residual_form_draws, API.md's general-form bullet, and cost.rs's open-bug
paragraph (the recordings read 3 made until the rows' next measurement; WASTED_BY_CLASS's
draws ceiling can then drop by 2).

Verified on the M3 Max (MoltenVK 1.4.2), the same diff at 3e0db77c6f over 6f7bb169d2:
- conformance cost --runs 8 --show, each case, in order and alone (jobs m3-max-13511,
  13518): render-then-sample-magnified-nearest and -linear read creation_pipelines_made 2,
  creation_render_pipelines_made 2, variant_pipelines_made 2 (the record holds 3 of each),
  creation_pipelines_drawn 2 (the record's 2): the pipeline no draw took is gone, every
  pipeline made is drawn.
- conformance replay, the whole set (70 s): exit 0, "the 391 row(s) above are exactly the
  open gaps known-gaps.tsv expects on this venue": no case's answers moved.
- 77 touched tests under --cfg m2v_gpu passed: made_at_creation, ycbcr_textures' creation-made
  slot, pipeline_creation's pool draws, draw_work, general_form, uniform_bind_offsets,
  draw_again, draw_shape_notices.

(cherry picked from commit 56ddedfc3498c9376384a3ad4b57e7607d78594a)
2026-11-10 03:07:56 -08:00
Anees Iqbal 782da3582b A half read of a 32-bit or small float texel records no NaN note where the device's half is Metal's
On MoltenVK on the M3 Max (m3-max-13447, default policy) half-texel-nans-r32f, -rgba32f,
-rg11b10f and -rgb9e5f answered every value as Metal does and still announced
device-nan-encoding; runtime_lane::half_texel_nans read 0 differing half lanes. The profile takes
DriverDeviation::MetalHalfConversion, whose measurement covers the half result of a read, sample
and gather of every float word of RGBA32Float (NaNs among them) and 16,384 random words each of
RG11B10Float and RGB9E5Float.

half_texel_nans now records DeviceNanEncoding on such a profile only where the bound class is a
half-float one (packed field 0) or of no family, and requires VkProperty::MetalHalfConversion;
elsewhere it keeps the one clause of TexelFormat::NAN_FREE. The 16-bit float formats keep the
note: no deviation records their NaN payloads as measured.

Test: engine_texture's half-read test checks both forms per committed profile (clauses, formats
that hold, the property) and that a profile of the deviation ran. Docs: the note's rustdoc,
API.md's exemptions, the storage_properties doc. Under the branch's SEMANTICS_VERSION (2015).

(cherry picked from commit b03555f8c9f05e382f744593cfaa01f2dc3bbb20)
2026-11-10 02:59:43 -08:00
Anees Iqbal 85b896a7e1 Mesh pipelines: a required object size answers as Metal's first compile, as the mesh stage's does
Metal's answers here depend on what its compiler compiled before, which it keeps across processes
keyed on the function's AIR. With the probe's salt now in the AIR (d49370d732), an M3 Max under
macOS 27.0.1 answered, twice over, each sequence one fresh salt (m3-max-13430):

- required-object-32-max-64: refused on a first compile ("Kernel specified max total threads per
  threadgroup (32) must match compute pipeline specified max total threads per threadgroup (64)"),
  refused again, and again after required-object-32x2 or plain; made only after
  required-object-64-max-64. required-mesh-32-max-64 the same, made only after
  required-mesh-64-max-64. The object stage was made here because an earlier compile let it be.
- A required size gives its stage its threads on a first compile: required-object-32x2 answers an
  object maximum of 64 (we answered 1024), required-mesh-16x2 a mesh maximum of 32, and a
  required 32 beside a function's [[max_total_threads_per_threadgroup(64)]] 32 in either stage.

So the object stage now refuses a required size of other threads than its maximum
(MaxThreadsDiffer { stage: Object }), as the mesh stage already did, and each stage's thread
limit is the least of the descriptor's maximum, the function's, the required size's threads and
1024. RUNTIME behaviour: new_mesh_render_pipeline_state refuses an object maximum beside a
required object size of other threads, and maxTotalThreadsPer{Object,Mesh}Threadgroup answer a
required size's threads. The translator's mesh answers change, under the branch's
SEMANTICS_VERSION bump (2015).

Tests: engine_mesh's refusal test adds the object cases (32 and 16x2 under 64) and makes 64
under 64; its answers test checks a required size alone in each stage and below a function's
maximum; the runtime lane's mesh test does the same on a device. docs/API.md's accepted
difference, the error's and the getters' docs and the probe's measurements say the first-compile
rule and what later compiles answer.

(cherry picked from commit 3b05b274aec46c172fd0a38276c5ca45a1ade4ca)
2026-11-10 02:59:31 -08:00
Anees Iqbal 5bb3d04838 A float ldexp records no NativeNanEncoding: its lowering answers Metal's NaN itself
The 11-02 carve-out run flagged ldexp as possibly over-noted. A float
ldexp is lowered on the bits (math::ldexp_bits): an infinity or a NaN
operand is selected as the result bit for bit, which is Metal's answer
(NanAnswer::Operand: ldexp returns a NaN operand itself). No NaN of the
device's reaches the result on any device, yet float_call left the
answer to the device and recorded NativeNanEncoding everywhere,
MoltenVK included.

FloatFn::metal_nans now includes ldexp on float lanes, so the call
leaves no NaN answer and records no NaN note. A half ldexp multiplies by
2^k, so its NaN is still the device's product's where Metal answers the
canonical half NaN, and stays noted where the device does not answer
that. PrecisionNote::NativeNanEncoding's docs and docs/API.md's
catalogue say so.

Verified: lower::arith::tests::float_ldexp_answers_metals_nan_itself
(fails without the metal_nans change: call.nan is Some(Operand) and
NativeNanEncoding is recorded). SEMANTICS_VERSION 2014: a module
calling float ldexp records one note fewer.

(cherry picked from commit c4b748c1e63cee2a32400145a3665387a8ca72cf)
2026-11-10 02:59:23 -08:00
Anees Iqbal af1dd85b66 Blend-source notes state their bound and the device compiler's regrouping; padded rows on the 5080 and the Iris Xe
ExtendedRangeBlendSource and ExtendedRangeFloatBlendSource (their docs, the API
catalogue entries and the FAST-PATHS device-gap row) now say what the suite
measured: the device's compiler may contract and regroup the in-shader blend
(MoltenVK on the M3 Max and NVIDIA's driver on the RTX 5080 compute
S·F + D·(1 - F) as D + F·(S - D)); a stored channel lands within two codes of
Metal's on a linear format and within six near zero on an sRGB twin; and where
the compiler regroups a padded format's blend, an infinite second source stores
an end code where Metal's sum is NaN, stored as 0. The FAST-PATHS row names the
padded formats, which it lacked, and no longer says 'not measured'.

known-gaps.tsv: the 168 extended-range rows (xr-blend, xr-gamut, xr-gradient,
xr-masked) whose Open item was the blend notes' documentation are closed (Open:
nothing, the recorded bound covering the difference); every one is within the
bound (survey of the rows' largest differences). The padded-blend rows are
regenerated for five venues: the M3 Max, RADV PHOENIX and llvmpipe as before,
and the RTX 5080 (b5080 entry xrblend2-padded-replay-5080) and the Iris Xe
(job m3-max-13386), 17 each. The 5080's second-source cases differ by the whole
code range as the M3's do, and its counts are exactly a model of
D + a·(S - D) over an unnarrowed float destination (971 on R10Unorm_X6, 1850 on
RG10Unorm_X12); the Iris's are exactly the sum as written over the half
destination (844, 1607), as RADV's; llvmpipe's the sum as written over a float
destination (962, 1831). No venue's largest difference exceeds the M3's, the
780M's or llvmpipe's.

engine_padded_blends: a fetch of a padded attachment makes the whole pipeline
on every committed profile that orders fetch (storage form or input
attachment) and names the device gap elsewhere; a bfloat fetch stays
NotImplemented(Format), the negative control. Not yet run.

(cherry picked from commit c923b6d49c36c8354f375f6dababfd5f81f1ffbc)
(cherry picked from commit e3a2b226d7f5938811d1d251172088baf05c15cb)
(cherry picked from commit 85a2473cc6ea6a2c9165e2614d1e87ca77c1627e)
2026-11-10 02:59:18 -08:00
Anees Iqbal 880b03cb2b Blend into a padded attachment over unclamped operands; padded tiles announced
Measured on the M3 Max under macOS 27.0.1 (probes/padded_and_bfloat_blends.m,
targets without Metal's optimized layout, whose blits moved every texel):
- Metal clamps nothing before a blend into a padded attachment (R10Unorm_X6,
  RG10Unorm_X12, their sRGB twins, RGB10A2Unorm_sRGB): sources, second
  sources and blend colors past both ends of [0, 1], alpha among them, blend
  as they are. With the operands unclamped, the stored codes of 18 blend states
  under fast and safe math, half and float outputs, match the f32 model within
  one code for the linear forms (16-bit safe-math half outputs exactly in half
  arithmetic), apart from NaN and infinity results; clamped to [0, 1], up to
  1023 codes off in 30-50% of channels.
- A padded attachment's tile holds half through the pass: a premultiplied blend
  of (0, 0, 0, 0.5) over a clear of 0.33371 stored code 171 (the half's), not
  170 (code 341's), and over an unblended draw of values in [-0.5, 1.5] it
  matched the unclamped half in every channel (65,536 texels of R10Unorm_X6,
  131,072 channels of RG10Unorm_X12).

So blend::extended_ranges is None for a padded form (native() clamps nothing),
source_range drops its padded arm, and the model test clamps no padded lane:
every_blend_is_the_devices_arithmetic's random sources past the range fail it
with the clamp. The runtime's extended-range-blends-stored-codes now covers
padded colors (render.rs extended_colors), and ExtendedRange::clear_read_back
answers a padded form's clear by its codes' values (c / 1023, the sRGB twins'
transfer, RG10Unorm_X12_sRGB linear), so a blend over a clear between two codes
is announced as for the extended-range forms. Docs: the blend-source notes, the
stored-codes kind and its catalogue entry, ExtendedRangeColor.

(cherry picked from commit 5750641750642bdb7800da8e9618f98919d2cc9f)
2026-11-10 01:35:19 -08:00
Anees Iqbal ac0ffe1c25 Probe measurements and the API guide for reads dead after specialization
dead_ordered_and_unattached_reads.m records what it measured on the M3
Max under macOS 27.0.1 (potluck job m3-max-13241): dfr_color,
dfr_buffer and dfr_output are made and drawn, dead and live, every texel
the closed form's, with the debug layer silent; dfr_lacks has no state,
dead and live ('Shaders reads from a color attachment whose pixel format
is MTLPixelFormatInvalid'). Its header names the tests and the lane that
read it.

docs/API.md's color-group refusal list now names a raster order group on
a color output or on a parameter the function uses; one on a parameter
it never uses orders nothing and is not refused.

(cherry picked from commit 93aaa9c6685770db04032b710ec7b36950b56f89)
2026-11-10 00:55:27 -08:00
Anees Iqbal e51d85e18d API guide: a color input of another group is refused only where it is read
docs/API.md's color groups paragraph lists what each group's draw would
read from another group as the pipeline's limit refusal; a
[[color(n)]] input of another group is that only where the specialized
function reads it, as pipeline::compile::color_group::entry now decides.

(cherry picked from commit 1df7b9589dc6bda472d3faaa14bf432677647658)
2026-11-10 00:11:07 -08:00
Anees Iqbal c42e63e64b Record DevicePackConversion where a heap read decodes a raw-held texture
A float or half read, sample or gather through an argument buffer that
decodes a texture the heap holds by its raw texels alone (BGR10_XR,
BGRA10_XR, R10Unorm_X6, RG10Unorm_X12 and the bfloat formats; the
heap_raw routine) converts by the device's arithmetic, as a slot's decode
of the same texel does, but recorded no PrecisionNote: a reader of the
module alone saw no near-equivalent, against AGENTS.md's "allowed only
when the artifact records it".

The decode is planned in one place now, texture::heap_raw::plan, which
both the read (select_read_as) and the emulated sample or gather
(heap_raw_sample) call. It records DevicePackConversion as a specialized
note with one clause on a new bound-value key, SpecKey::HeapRawTextures
(stage): a texture the stage's handles can name is held raw. The binding
plan gives the key from the command's heap members (resident or bound
textures, as for HeapYCbCrTextures), so the note is in the module's
notes, holds under precision_notes_bound exactly where the command can
name such a texture, and the runtime announces it at that draw or
dispatch (degrade_bound_values) and never at the pipeline's making. A
stage that records the note outright for another conversion keeps it
outright. Heap accesses that reach no such texture (queries, integer
reads, storage reads, samples the function does not emulate) record
nothing.

NoteOn::HeapTextures is renamed HeapYCbCr beside the new HeapRaw.
bind::heap::raw_held is pub(crate) for the plan. The heap set's own
announcement naming the texture (heap_sets::RawRead) stays.

SEMANTICS_VERSION 2008 (heap-reading modules gain the note);
ARTIFACT_FORMAT_VERSION 498 (a SpecKey variant). api_signatures blessed;
REFUSALS.md regenerated (unchanged). docs/API.md's catalogue and the
runtime's Degradation docs say where the note is recorded and announced.

Tests: heap_decodes_record_the_device_pack_conversion now also asserts
the one HeapRawTextures clause; the new
a_heap_decode_s_note_holds_where_its_command_can_name_a_raw_texture checks
the plan's key and the bound note on every committed profile; the lane
a_heap_decode_s_stage_note_is_announced_where_its_command_can_name_a_raw_texture
checks the runtime's announcement under announce_each.

(cherry picked from commit 1ab403b671f18773a10c8572ffbe0a73b56f5bbc)
2026-11-09 23:54:15 -08:00
Anees Iqbal dbad32bb7b Docs: visibility venues, Metal's subnormal sample coordinates, a shared event's queue rule
Three corrections, each checked against the tree:

- runtime/src/visibility.rs said Metal's visibility-result behaviour was
  measured on an M4, which is not one of our venues. The conformance
  suite's visibility cases record Metal's answers on an Apple M3 Max with
  macOS 27.0.1 (recordings/visibility-*.json); the doc now names that venue.
  The 5300M and UHD 630 answers it cites beside it are unchanged.

- docs/FAST-PATHS.md's DeviceSampling row (and docs/API.md's device-sampling
  entry) said Metal reads any subnormal coordinate as the zero of its sign
  before addressing. That holds for a normalized coordinate (measured on the
  M3 Max on R32Float, PrecisionNote::DeviceSampling's documentation); a
  negative subnormal pixel coordinate addresses texel -1, as the M3 Max's
  recording of pixel-samplers-subnormal-border answers (the border at
  -2^-149, -2^-140 and -2^-127, known-gaps.tsv). Both now say so, and the 27
  known-gaps.tsv rows that quoted the old reading quote the new one.

- SharedEvent::reserve_vk_signal's Safety text lacked the same-VkQueue rule
  that Event::reserve_vk_signal states. A shared event's command-buffer waits
  are held on the host (event_timeline.rs: a settable timeline never hands
  a wait to Vulkan), but a command buffer that signals the event after the
  reservation waits on its VkQueue for the reserved index before its own
  signal (EventTimeline::signal's `after`, the order wait in
  command_buffer/submit.rs), so the caller's signalling submission must not
  go behind it on one VkQueue, and a texture copy on the first VkQueue behind
  it waits for the signal too. The rule is now stated, scoped to those
  signalling command buffers.

Verified: rustdoc and the runtime's degradation_catalogue test over the
edited text; no behaviour changes.

(cherry picked from commit 12bac3fafd3d3e66dc0b88d01231dd30e2694ffb)
2026-11-09 23:49:33 -08:00
Anees Iqbal ab10b3cbcf Runtime: say what a decoded twin's CPU decode makes replace_region wait for
The cpu-block-decode notice said the call waits for the decode where a
command buffer that may read the texture is submitted and not yet complete,
or the texture is untracked. The call has waited for no GPU work since the
decode moved to the device's decode thread (texture/twin_decode.rs): it waits
only for room, while 256 MiB of written blocks wait for the thread (a 4:2:2
carrier's partial-row write also reads its rows back first), and the
scheduler holds the first command buffer that may read the texture, every
command buffer where the texture is untracked.

The declaration's rustdoc, its announced cost and docs/API.md's catalogue
entry now say that. A test ties the stated bound to the queue's QUEUED_BYTES
(made pub(crate) for it), so the text follows the constant.

Verified: tests::degradation::the_cpu_block_decode_cost_states_the_calls_
only_wait and tests::degradation_catalogue (the catalogue states the cost).

(cherry picked from commit f128722f1b2197f52833080eca738fd498cf6ce5)
2026-11-09 23:49:33 -08:00
Anees Iqbal b1625c535c Translator: note a mesh function's point size only where it outputs points
A mesh function that writes a vertex's point size recorded
PrecisionNote::DevicePointSize whatever primitive its mesh outputs. The
rasterizer reads a vertex's size for points alone, so a line or triangle
mesh's size draws nothing on any device, and the runtime already announces
the note only at draws that rasterize points (7715a47be3). The note is now
recorded only where the mesh type's topology (air.mesh_type_info) is points,
a structural test, so the artifact carries no note its draws can never meet.

Apple's compiler refuses [[point_size]] in a triangle mesh's vertex, so the
case arises only for AIR not compiled from MSL. The test derives the
triangle mesh from the owned fixture's point mesh (mesh_outputs_points) by
its topology word alone.

SEMANTICS_VERSION 2008: an artifact's precision notes change. docs/API.md's
catalogue entry and the note's rustdoc say which mesh functions record it.

Verified: engine_mesh::a_mesh_point_size_is_noted_only_where_the_mesh_
outputs_points on every committed mesh profile with the largest point set
below Metal's: the point mesh is noted, the triangle mesh is not, both store
the size; the test fails with the topology check reverted.

(cherry picked from commit adc0435c64495e2f3a3355becf055941fc529fc3)
2026-11-09 23:49:33 -08:00
Anees Iqbal 25401533b9 Docs: a fast-math NaN constant beside a run value stores the NaN; the fold's wording
API.md, section 10, Function constants: an fadd, fsub, fmul or fdiv under
nnan whose operand is a function constant bound to a NaN is poison in the
AIR. The translation answers the NaN operand unchanged, as it does without
fast math, where that NaN is Metal's answer. On the M3 Max, Metal drops a
kernel's store of it.

Measured in job m3-max-12877 with case 2d9a7e3091e1f9d9..., which is the
fixture sfold_fast_poison in a scratch corpus:
- Metal on apple-m3-max-macos27.0.1 left every poison row's float and
  half store at the 0xCD fill, and wrote the run-value row.
- MoltenVK with the folds wrote the NaN operand unchanged in every poison
  row (ffc12345, 7f800321, fd21).
- MoltenVK with the base translator dropped the float rows, and wrote ff21
  and 0 in the half rows.
The case is not committed: the corpus compares exactly.

ARCHITECTURE.md: the canon row now says a NaN operand is as it is beside a
value the run computes, and quieted where every operand is a constant.

(cherry picked from commit cddef968a3a8a971341fafcc5469e141fb97b434)
2026-11-09 20:44:24 -08:00
Anees Iqbal b83d35f35a Clear reach: a pass without a draw call clears before itself where its own clear would overreach
On MoltenVK, a pass's own Clear load in a pass without a draw call reaches
the whole attachment. Where the reach is the render area itself (an
uncompressed attachment whose render area ends on 32x32 tiles, now that only
a compressed one is cleared whole), the pass's own clear was used and reached
the whole 128x128 texture over a 64x64 area: lane fresh_clear_reach on the M3
Max (MoltenVK), 3 of 150 cases, BGRA8Unorm, RGBA16Float and RG16Float.

ReachClears now clears such a stored attachment before the pass by a render
pass of its own and the pass loads it (own_clear_overreaches: no draw call,
an attachment larger than the render area), color and depth/stencil alike.
The pass's render area stays Metal's, so a DontCare or Load attachment beside
it keeps its texels.

Docs: MacClass and docs/API.md cite arm64metal's tileclear2 jobs: the M3's
answer (m3-max-12716, 12735) and the x86 Macs' disagreement (5300M whole,
UHD 630 from the area to the whole texture: m3-max-12736, 12737), where the
runtime keeps the whole level, the 5300M's answer.

(cherry picked from commit ea34c273885ff00633c3afe983fdb3a7a398dd03)
2026-11-09 19:20:24 -08:00
Anees Iqbal 44e51b5081 Docs: how far a Clear reaches without a draw call, by the Mac class
MacClass and docs/API.md's accepted differences (the Mac a device presents)
state the answer: on a device presenting an Apple silicon Mac, a Clear load in
a pass of one layer without a draw call clears a compressed texture's whole
level and slice and any other texture's render area rounded up to 32x32
tiles; on one presenting a Mac with an Intel or AMD GPU, the whole level and
slice whatever the texture, unmeasured there and kept as it was. The lane's
clear_reach docs name the compressed textures their whole-level cases use.

Docs only; no behaviour change.

(cherry picked from commit 5591cc4b71a9458fef7a3773ed99d1bf0eeb1dcd)
2026-11-09 19:20:24 -08:00
Anees Iqbal 73545f6afc Page blocks only where the fresh pages' verdicts give textures what plain blocks do
A texture over a buffer in a block of the runtime's own pages takes the route
over fresh pages: its image is made for host allocations and starts UNDEFINED,
so it lies in place only where the in-place check's verdicts of fresh pages
pass, where over a plain block's buffer the device's linear image starts
PREINITIALIZED and needs none. So the program's buffers now lie in such blocks
only where those verdicts give every access and row ends a texture over a plain
block's buffer takes in place (by the pooled class's verdicts) the same, as
the blocks allocated exportable already do: fd_blocks_take is now blocks_take
of a pages class (FdBlocks or Fresh), its enum BlocksTake, and
Device::page_blocks_taken asks it for Fresh, starting no check. Pending
verdicts leave the buffers in plain blocks.

The memory lock is no longer held while the verdicts are read as a buffer is
made.

Docs: memory.rs's module docs, device/carry.rs, the runtime README, docs/API.md
and the recovery notice's cost name the condition.

Verification: the suite follows.
(cherry picked from commit 8c50d54d9871bce0e80865ac4916e7da0c192a8a)
2026-11-09 09:51:54 -08:00
Anees Iqbal 3d0ece2f7a Page blocks: kept() asks the page buffers' address types before it borrows the families; docs
kept() asked address_types for Holds::PageBuffers while a Sharing borrowed
the families, which the borrow checker refused (job 11930). The query now runs
before that borrow.

Docs: memory.rs's module docs get "Buffers in the runtime's own pages";
device/carry.rs, Buffer::carry, the runtime README and docs/API.md's recovery
cost say a recovery carries the Shared and Managed (unified memory) buffers in
blocks of the runtime's own pages, and leaves those in memory the device
allocated.

Verification: the build follows.
(cherry picked from commit e5df53c305b27909f4cca460a4910c12861d20aa)
2026-11-09 09:51:53 -08:00
Anees Iqbal 2ef8af3abe A pass-start read takes the copy cleared by MoltenVK's clear command, which is Metal's clear
What: on MoltenVK (DriverFact::ColorClearIsMetals) a draw that samples a colour its pass clears,
after a memory barrier at the pass's start, split the pass again (attachment_read_splits, a
second render pass instance, the render-pass-split notice) instead of reading a copy of the
attachment cleared to the clear before the pass (attachment_read_clears). Texture::cleared_copy
refused a clear whose device-color-conversion note the load operation withholds
(ColorTarget::withheld_clear), because the copy is cleared by vkCmdClearColorImage and only
the load operation was measured to store Metal's texel there. Since 876cfd1402 every clear of
a normalized channel off a whole code is in question (the spec's rule), so the pass-start
clears of the lanes and the conformance cases became withheld on MoltenVK and split.

The driver's clear command is measured to store Metal's texel too, so the fact now covers it:
- Texture::cleared_copy takes a withheld clear (no note owed: the clear command's texel is the
  load operation's, Metal's).
- A memoryless attachment's backing cleared after the first instance, and an attachment the
  first instance leaves out cleared before the pass by the clear command (cleared_ahead), owe no
  note either; the same clear by a render pass of the attachment alone, or as sample planes,
  still announces it.
- DriverFact::ColorClearIsMetals, ColorTarget::withheld_clear, texture/attached_reads.rs and
  docs/API.md's device-color-conversion entry say so.
Elsewhere withheld_clear is None (the note is announced as the pass is laid out), so nothing
changes on other drivers.

Why, measured on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2):
- The cause, by a probe of each condition of cleared_copy over 22,482 runs of
  attachment_reads::a_draw_after_a_barrier_at_the_pass_start_reads_the_clear on development at
  1571c220d7: every run failed the same way, (cleared copies, splits, begun) = (0, 1, 2), with
  withheld_clear Some([200, 40, 120, 160] / 255) the only condition that refused (not load, not
  timing).
- The clear command: each of the 71 colour clears Metal was measured with
  (renders.rs COLOR_CLEARS: ties of 8-, 10- and 16-bit unorm and snorm channels, sRGB, packed
  16-bit, half and small floats, shared exponents, NaNs) by a plain fill of a whole 1x1 texture,
  which is vkCmdClearColorImage of the load operation's clear value (blit_fill.rs): 71 of 71
  Metal's bytes, and equal to the load operation's 71.
  runtime_lane::renders::clears_are_the_device_s_conversion_of_the_clear_value now checks this
  on a driver with the fact.

Ran on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2) at this change over 693fd3f96d, under --cfg
m2v_gpu: the whole validation suite, 3398 of 3400 passed (attachment_reads and renders among
them); the two failures are the runtime-sources pin, which the landing sets, and
degrade_notices::a_creation_s_notices_and_messages_reach_the_sink_on_the_asking_thread at
device creation (creation_heard_checked), before any pass is recorded. conformance cost --check
over the whole set: no gated count and no ceiling moved (the pass-start-barrier cases read the
cleared copy again, as recorded); conformance replay of the 14 pass-start-barrier cases: rc 0,
each difference an accepted one. On this base only driver_facts.rs merged (beside
ClearedDepthAtStandardPositions); the other five files are unchanged since 693fd3f96d.

RUNTIME: the runtime's pass-start reads on MoltenVK change (a cleared copy instead of a split).
(cherry picked from commit 25063af705d28d07b7332cc1b35a5cf1beedc6bb)
2026-11-09 07:53:32 -08:00
Anees Iqbal 15923d88c0 Docs: a recovery carries no-copy buffers and uses of guest RAM
The DeviceRecovered cost text (and docs/API.md's catalogue entry, which states
it), the runtime README's recovery section, new_buffer_with_bytes_no_copy, and
the contracts of the import gate, the run resolver and the dma-buf source now
say the following. A recovery carries a device's uses of guest RAM and its
no-copy buffers. Each buffer is made again over the same pages. The caller's
callbacks are asked again on the thread that recovers, before the new device
serves, so they must make no call on the device. The deallocator runs at the
buffer's release once no VkDevice's import of its pages is left (the
keep-alive's contract says the same). Detached no-copy buffers and a no-copy
heap's buffers stay refused. HostRamUse's doc says the use goes on.

(cherry picked from commit 58ba0931b857a9dcf9a6124138c81fc31a259552)
2026-11-09 06:01:13 -08:00
Anees Iqbal 33675e87f1 Carry tests, and docs for what a recovery carries and leaves refused
New device tests (tests/device_recovery_carry.rs, under the CPU-ICD and GPU
cfgs):

- One recovery carries a Private buffer (same address, zero after) and a
  buffer in fresh pages. The fresh-page buffer keeps its contents pointer and
  bytes, and the host's writes through that pointer after the recovery reach
  the GPU's copy. It also carries a shared event: its value, its listener's
  notification and a GPU signal after the recovery.
- A pooled Shared buffer stays refused, and the notice counts it. It keeps the
  lost VkDevice, which then holds no empty block and less memory than before
  the loss. Dropping it takes the line back to one live VkDevice.
- Seven recoveries with a carried buffer and event in use between them end
  with one live VkDevice, and eight made.

The device_recovery helpers are shared with the new file.

Docs: RuntimeGap::MadeBeforeRecovery, the DeviceRecovered catalogue entry and
its consequence (runtime and API.md), the runtime README's lost-device
section, line.rs's module and recover_for_test docs, in_place.rs, the
validation lane's docs and the refusal surface's reach mark now say what is
carried and what stays refused. REFUSALS.md is regenerated in the next commit.

Not yet built.

(cherry picked from commit 68d68cdfbdbbac979e5097a8ad286416450790bf)
2026-11-09 04:26:04 -08:00
Anees Iqbal 2cbe8ce595 Volume resolves: NVIDIA's leaves plane 1 unwritten, so it resolves through the scratch copied into the planes too
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09)
runtime_lane::view_attachments::a_resolve_writes_the_volume_plane_it_names failed at base and tip
alike, 3/3 each (t3d_resolve_plane1: byte 64 is 0x11, Metal's 0x33). Its VOLUME-RESOLVE lines and a
probe of resolve orders (scratch branch, never merged) show a 4x multisampled RGBA8Unorm attachment
resolved into the 2D view of a 4x4x4 or 4x4x8 volume that begins at depth plane 1 writes no plane:
the volume keeps every byte it had. Into the views at planes 0, 2 and 3 it writes that plane alone,
in every order tried (1023, 3210, 0123) and three times over into plane 1. A draw into plane 1
through the same kind of view writes it (a_volume_s_plane_is_an_attachment passes), and the
validation layer reports nothing, so the usage is the valid one RADV's defect row already cites.

Fix, the RADV fix's shape (c1a825d748): RuntimeDriverDefect::VolumeResolveFirstPlane gains an
NVIDIA_PROPRIETARY row, every NVIDIA GPU until a probe finds one clean. Its meaning is stated for
both drivers: the resolve is written where the view begins only at the image's first plane (RADV
writes plane 0 whatever plane the view begins at; NVIDIA's writes no plane from plane 1). There a
color resolve into a 3D texture's planes past its first, or into more than one, goes into the
scratch image of the pass's layers that is copied into the planes after the pass, announced as
resolve-scratch with the defect named. The variant, the table's doc, the resolve module's docs, the
notice's reason and docs/API.md's catalogue entry say so.

Tests: tests::driver_defects lists the defect for every committed NVIDIA profile (the RTX 5080
Laptop GPU's and the others'), so it fails without the row.

Verified: cargo fmt. The lane on the 5080 at this commit and at its base follows through potluck.
(cherry picked from commit 93795eaaa29dba62257ca9b4c569394e23c269da)
2026-11-09 04:15:29 -08:00
Anees Iqbal 876cfd1402 Colour clears and fills take either code on every device but where a measured row says Metal's
The orchestrator's decision: Vulkan lets a clear of a normalized channel store either of the two
codes closest to its scaled value ("returns one of the two ... closest ... Implementations should
round to nearest"), so every device takes that rule, not only the three devices measured to take
the farther code (DriverFact::ColorClearTakesEitherCode's rows: NVIDIA's on the RTX 5080 Laptop
GPU, ANV on the Iris Xe of RPL-P, RADV on the Radeon RX 550). The one exception stays the measured
DriverFact::ColorClearIsMetals row: MoltenVK on the Apple9 GPUs, whose load operation of an
attachment the render area covers clears as Metal's.

Runtime: clear_value::rounds_apart and fill_value::device_apart lose their `either` argument; a
normalized channel's clear or plain fill is in question wherever its scaled `float` is off a whole
code (the rule the three rows took), which subsumes the old margin of 1/1024 around a midpoint
(and the packed 16-bit formats' wider one). render_pass.rs and blit_fill.rs read no fact for it;
the load operation's exception under ColorClearIsMetals is unchanged. The fresh pattern of a
signed normalized format (code -1) is written by copies of its bytes, not a clear: no `float`
scales onto it (-1/127 is -0.99999999627 codes), so its clear is in question under the rule
(texture/heap_tiled.rs fresh_pattern; the fresh-pattern test allows its 1-byte texel).

Translator: DriverFact::ColorClearTakesEitherCode, its three rows and AMD_RX_550 (only they used
it) are removed; the facts table test and api_signatures.tsv follow. ColorClearIsMetals' doc
and PrecisionNote::DeviceColorConversion's state the spec's rule.

Validation: buffer_texture_blits' IOSurface planes expect the clear's notice on every device but
where the load operation clears as Metal's (degrade_notices::clear_in_question, the former
tie_cleared, now stated for any value off a whole code). color_fills prints how many plain fills
announced device-color-conversion (COLOR-FILLS-ANNOUNCED).

Docs: docs/API.md's device-color-conversion entry is the spec's statement plus the measured
devices and the one exception.

Verified: cargo fmt. Runs follow through potluck.
(cherry picked from commit 9a844f5c5f5ce1499664f77eceb66fccf2dfd9f7)
2026-11-09 03:47:40 -08:00
Anees Iqbal 7ed49fd04d RADV fuses float arithmetic into a half conversion: the pipeline records NativeHalfConversion
On the Radeon 780M (RADV PHOENIX) runtime_lane::half_conversions failed its product kernel:
2.6822087e-7 * 1.0000001 answered half 0x0005 where Metal's half of the float product is
0x0004, with notes only [NativeNanEncoding] (radvruns job 11026, 2 of 2 runs). The module
rounds under the float controls (QuantizeForm::Controlled), which make the conversion Metal's,
so it recorded no conversion note. RADV_DEBUG=shaders on the 780M (job 11121) shows why: ACO
compiles the product's OpFMul and the narrowing, both decorated NoContraction, as one
v_fma_mixlo_f16 v2, v1, v0, neg(0), rounding the exact product to half once where Metal rounds
the float product; the sum kernel's narrowing is one v_fma_mixlo_f16 1.0, a, b too.

That is the device's own rounding (rule 1), so the fix is the note, not Metal's bits:

- DriverWorkaround::HalfConversionFusedWithArithmetic, keyed on RADV on every GPU (the others
  unmeasured), as NVIDIA's HalfConversionPairFolded is keyed on its driver.
- narrow::rounds_arithmetic: whether a module rounds to half, through a conversion pair, the
  result of an f32 OpFAdd, OpFSub, OpFMul, OpFmaKHR or GLSL Fma.
- compile_kept records PrecisionNote::NativeHalfConversion where the module takes the
  controlled conversion, the profile carries the workaround and rounds_arithmetic holds. The
  controlled form itself stays: a loaded float's conversion is exact there and records nothing.
- Tests: radv_carries_the_fused_half_conversion (every committed RADV profile carries it, no
  other does, and RADV keeps the controlled form) and
  a_controlled_rounding_of_arithmetic_is_noted_where_the_driver_fuses_it (a float sum, product
  and fused multiply-add rounded to half record the note on every RADV profile and not on ANV;
  a loaded float narrowed alone records it on neither). Both fail with compile.rs and derive.rs
  at the base.
- The note's doc, the API guide's catalogue entry, HOWTO, the narrow module doc, the lane's doc
  and the signature table name the new variant.

(cherry picked from commit 799d39233c4e0ae2a18a716e794db8f67405ff00)
2026-11-09 03:12:03 -08:00
Anees Iqbal 6ee9db2b60 METAL2VULKAN_PENDING_AUDIT: a default-off audit of command buffers freed or reused while pending
A GPU hang on Iris (ANV) left a compute dispatch reading an interface
descriptor that another pass's viewport state had overwritten: the hung
command buffer's dynamic state went back to ANV's pool (a reset or begin)
while its request still ran. The path that freed it is not known yet. This
adds a diagnostic that finds it where it happens, against the GPU's own
timelines rather than what the host saw of them.

What it checks, where it is on (DeviceOptions::pending_audit, or
METAL2VULKAN_PENDING_AUDIT set, read at device creation):
- every vkBeginCommandBuffer made through the device's functions (Vk's
  begin_command_buffer, in both the full and the exit guard's tables), a
  primary begun ahead in a spare pool among them;
- each vkResetCommandPool of a spare pool, and each pool given back to the
  spares, for every command buffer the pool made;
- each submission of a command buffer submitted before and not begun for
  simultaneous use (ANV rewrites a chainable primary's tail at each
  submission).
What carries a command buffer: a batch's submission (direct or held in the
scheduler's group) to its queue's timeline value; the device's own and the
staging queue's submissions to their timelines; a secondary through each
primary that executes it (Vk's cmd_execute_commands notes it, a begin of
the primary forgets it). A failed submission is withdrawn. Each check reads
the carrying timelines with vkGetSemaphoreCounterValue; a value not reached
is a finding, logged (id name metal2vulkan-pending-audit, Info) with the
thread, command buffer, timeline, counter and value, and a backtrace for the
first 8. Off, each site tests an Option; on, it changes no work.

Tests: tests::pending_audit (the ledger: timelines, latest value per
timeline, one read per timeline per check, secondaries through primaries,
withdrawal, unreadable timelines, simultaneous use), and the device test
tests::pending_audit_device: a command buffer held on the GPU by a wait for
a reserved event signal has its pool given back early (a cfg(test) hook);
the audit finds it once and says it; after the host signal, the next command
buffer's pool reset, the primary begun ahead and its taking are checked and
nothing more is found. env_vars.rs registers the variable with its cost;
docs/API.md and api_signatures.tsv carry the option.

Verification: pending (potluck jobs on lavapipe and Iris).
(cherry picked from commit 2c524391e70921596add39688daf761cbc20662f)
2026-11-09 01:09:02 -08:00
Anees Iqbal f36d32dfd3 No-copy memory whose pointer the device refuses and whose source fails is a copy, as with no source
On RADV a no-copy buffer or heap over shared memory (a memfd mapping) made with no dma-buf
source is a copy of the pages since 3f69d1af77, but one made with a source that fails was
still refused (Unsupported, HostMemory): source_failure kept the dma-bufs' refusal unless the
pointer's refusal was the runtime's unpinnable one, and the caller marked it not the device's.
Metal makes a no-copy buffer over any page, and rule 2 lets only what Metal refuses or what
cannot run fail; the pages are readable, so the copy runs.

buffer_over_host_memory now carries whether the device was asked the pointer: where it refused
it (not_importable) and no dma-buf of the pages served either (the source failed, or the device
refused its dma-bufs, refused()), the outcome is the device's refusal, as with no source: a copy,
announced and counted as copied_host_buffers_device_refused. Unchanged: the unpinnable path
(copied as Failed), misuse (chunks that break the source's contract stay Invalid, DmaBuf), a lost
device, memory imported only as dma-bufs and windows the import alignment does not cover (no
pointer asked: still refused, as without a source), and rebinds (refused without a working
source, as before).

Docs: CopiedFor and CopiedBecause::DeviceRefused, the copied-host-pages detail and catalogue
entry (degradation.rs, docs/API.md), WorkCounts::copied_host_buffers_device_refused, copied.rs,
dma_buf.rs's refusals, HostMemory::with_dma_buf, imports_shared_host_pointers, the runtime
README and HOWTO section 6 and Copied host buffers.

Tests: copied_device's shared-memory test makes a second buffer, with a source that fails, over
pages of its own: on a device that refuses shared memory's pointer a copy counted as the
device's refusal, the source called once; elsewhere the pointer's import, no source called. The
runtime lane dma_buf_imports (renamed shared_memory_without_a_working_source_is_a_copy_and_
misuse_refused) expects the failing source's copy on RADV, over a view of its own.

Verified: cargo fmt only; the 780M runs (with a negative control on the base's
buffer_descriptor.rs) are dispatched next.

(cherry picked from commit a30909d44aec64136e29f57b5a5dacca8568d3bc)
2026-11-09 00:34:52 -08:00
Anees Iqbal 853e9205d9 word_samples_msaa: RADV's RGB9E5Float blend checked as the device's blend of halves
The 780M lane's red (19 answers, all RGB9E5Float blends at 2 and 4 samples on RADV PHOENIX,
Mesa 26.2.6) is the device's own blend arithmetic: RADV hands its blend an RGB9E5Float source
whose channels and alpha are halves rounded toward zero (a value past 65504 as 65504), where
Metal blends the floats. Vulkan asks a blend for no more precision and range than the
attachment's, which a half meets. Rule 1: the device's native blend is the only form, so no
path computes Metal's bits; the blend already records and announces device-color-conversion
(ChannelWrite::Device for a blend of factors other than one and zero).

The model, run offline over the lane's inputs (the probe's generator) and Metal's table:
- Metal's words are the f32 blend over Metal's stored samples, truncated to the format
  (32/32, 64/64);
- RADV's 11 failing sample words are the blend of halves rounded toward zero over Metal's
  stored samples, truncated, in 10 of 11. The eleventh (4 samples, pixel 7 sample 3) blends
  over a sample RADV's fill stored a code from Metal's;
- Metal's RGB9E5Float resolve is the crate-owned resolve's rule (f32 mean, nearest half,
  mantissas rounded half up) in 64/64 pixels. RADV's 8 failing blend resolves are that rule
  over the model's samples in 7 of 8.

The lane now, where the device is RADV and holds RGB9E5Float in its own format:
- checks each blended sample against that blend's word over the device's own stored sample,
  within a code (half_blend);
- checks the blend's resolve within a code of Metal's resolve of the device's samples
  (shared_exponent_resolve);
- prints how many of the samples' model words are not Metal's;
- requires device-color-conversion to be announced.
Elsewhere it keeps Metal's bound.

The note's declaration, API.md's entry and the comparison table's doc record the measured
size: 30 of 96 blended samples not Metal's, up to 33 units of the larger value's last
mantissa bit where the source passes 65504, and 7 where the half's alpha weighs a destination
far larger than the source.

Verified so far: the offline model above. The lane on PHOENIX is pending.

(cherry picked from commit 0fb6dcf07456cf7531021bb70fbe7eea64dadbb0)
2026-11-09 00:17:24 -08:00
Anees Iqbal 8bd103fc8e Record RADV's extrapolated perspective reads at a sample or offset as the device's answer
On the Radeon 780M (RADV, Mesa 26.2.6) runtime_lane::pull_model_interpolation read 1700
values off Metal's, up to about 1.0 in lane 3. The lowered pm_offset is straight-line code (a
uniform offset, its move and clamp, InterpolateAtOffset per input), so no control flow is at
fault. Every miss is a perspective input's read at a sample or an offset; the no-perspective
inputs' same reads were Metal's. A model with the lane's own geometry gives the driver's form:
the pixel center's value extrapolated along the quad's coarse derivatives,
f(center) + (f(tr) - f(tl)) * dx + (f(bl) - f(tl)) * dy. It reproduced all 52 one-sample offset
misses within 0.004 and all 1061 four-sample sample and sample_id misses within 0.005, where the
fine-derivative form was up to 0.98 off. Metal's value plus that form's error (first-order less
exact) matched each of RADV's within 0.2 of the lane's device bound.

Vulkan states no precision for interpolation, so under rule 1 the device's interpolation is the
answer: no form computes it otherwise. The fix records it.
- DriverWorkaround::PerspectiveReadsExtrapolated, a measured row keyed on RADV
  (driver_facts::DEFECTS, no vendor), as InterpolationNeedsTheWholeQuad is.
- PrecisionNote::ExtrapolatedInterpolation (extrapolated-interpolation). stage_io::plan records
  it structurally: an interpolant with the perspective qualifier read at a sample or an offset,
  or a perspective sample-qualified varying a looping function reads at each pass's sample
  (InterpolateAtSample), on a profile with that fact. A no-perspective read, the pixel-center
  form (offset 0), a center or centroid read and an absent interpolant record nothing.
- The pull-model lane: on such a device each perspective lane read at a sample or an offset is
  held to the device bound of Metal's value plus the extrapolation's error, computed from the
  lane's geometry (extrapolation_error), and the pipelines that read so, and those alone, must
  record the note.
- The engine tests over every committed profile assert the note where the RADV profile reads a
  perspective interpolant at a sample or offset, and nowhere else: pm_linear, a new fixture
  function reading the no-perspective interpolant alone at a sample and an offset, must not
  record it. The coverage-loop test asserts it for the looped perspective varyings on RADV.
- docs/API.md's device-interpolation entry and docs/FAST-PATHS.md's row no longer cover RADV's
  sample and offset reads with the 1.5e-4 figure. The new entry and row state the form and the
  measured size.
- SEMANTICS_VERSION 2000 (the RADV profile's pull-model and looping modules gain a note),
  ARTIFACT_FORMAT_VERSION 497 (the codec gains the note), api_signatures blessed. The refusal
  surface regenerated with no change.

The fixture's AIR companions for pm_linear come in the next commit, from the regen script on the
M3. The golden tables and the air_input snapshot are re-blessed on development.

(cherry picked from commit f4eb92a9bc4c099f9020fde2c2da40580514ec20)
2026-11-09 00:16:01 -08:00
Anees Iqbal f11ad530fe blit fill: a multisampled 32-bit float depth's samples clamp into [0, 1] where the device's do
On Iris Xe (ANV, RPL-P), which lacks VK_EXT_depth_range_unrestricted, the sample_fills case
d32-wide-4 fills a 4-sample Depth32Float texture with 33221100 77665544 bbaa9988 ffeeddcc and
reads back 33221100 3f800000 00000000 00000000. A multisampled fill writes each sample's bits
into an R32_UINT scratch image and copies it into the depth image (maintenance8's colour-to-depth
vkCmdCopyImage on ANV), and Vulkan writes undefined values there for a depth outside [0, 1]: ANV
stores the NaN as 0. restricted-depth-upload, announced once per device on an earlier case,
promises a clamp, a NaN 1.0, that no step made. replace_region and the buffer-copy route clamp
before the copy (depth_clamp.rs); the multisampled fill did not.

sample_fill now clamps each sample's depth word on the CPU (bind::clamped_depth) where the
texture clamps depth uploads, announces restricted-depth-upload for the fill, and counts it in
WorkCounts::depth_uploads_clamped, as replace_region does. A device with the extension writes
the bits as before. The docs of depth_clamp.rs, the counter, the degradation and docs/API.md's
entry name the fill.

The lane: the probe recorded d32-wide-4's digest (9c5b7be066d1c9fc) alone. depth_lines rebuilds
a byte-filled Depth32Float case's lines from the fill rule; the_recorded_lines_are_the_probes
holds the rebuild to that digest and to the recorded d32-4 and d32-2 lines. A Depth32Float case
on a device that announced restricted-depth-upload passes where it holds Metal's lines with every
word through clamped_depth, the fill counted (SAMPLE-FILLS-CLAMPED). Expected on Iris:
33221100 3f800000 00000000 3f800000. The metal.txt fixture, and so the conformance recordings'
input digest, is unchanged.

Verified offline: the rebuilt d32-wide-4 and d32-4 lines hash to the probe's 9c5b7be066d1c9fc
and 2098b9445cd43b96. Device runs (Iris, lavapipe, M3) are reported with the tip.

(cherry picked from commit b3f0f2ba7e176fa1972cb89982f6404375ffd169)
2026-11-08 22:48:29 -08:00
Anees Iqbal c1a825d748 Volume resolves: RADV writes a 3D image's first plane, so resolve through a scratch copied into the planes
On a Radeon 780M (RADV, Phoenix) a 4x multisampled RGBA8Unorm attachment resolved into depth plane
3 of a 4x4x4 volume, through the 2D view of the plane that resolve::destination attaches, wrote
plane 0 instead (the volume's first byte held the resolve; view_attachments, three runs at each of
two commits, ownpixel's job). Drawing into the same kind of view writes its plane there, and the
usage is valid: a 2D view of a 3D image made 2D_ARRAY_COMPATIBLE "can be used as a framebuffer
attachment that refers only to the specified range of slices" (VkImageSubresourceRange), and of a
resolve attachment Vulkan refuses only a 3D view (VUID-VkRenderingAttachmentInfo-resolveImageView-
12471). MoltenVK on the M3 Max writes each named plane (a_resolve_writes_the_volume_plane_it_names).

RuntimeDriverDefect::VolumeResolveFirstPlane names it, on every RADV GPU until a probe finds one
clean (driver_defects.rs, the table's rule). There a color resolve into a 3D texture's planes past
its first, or into more than one, goes into a scratch image of the pass's layers (Destination::
attach), whose layers ResolveCopies copies into the planes after the pass: one region whose depth is
the layers, from the resolve's first plane (VUID-VkCopyImageInfo2-srcImage-01791, dstImage-04444).
The scratch's copy into a 3D texture was not built before (render_pass::not_2d refused it); it is
now, but for a level reaching past the attachment, whose clear would be of the planes alone, which
stays NotImplemented(Render). Announced as resolve-scratch, its reason naming the defect; the
catalogue and the variant's docs say so. The device's own resolve still averages: the copy moves
its result unchanged.

Tests: tests::driver_defects lists the defect for every committed RADV profile;
runtime_lane::view_attachments::a_resolve_writes_the_volume_plane_it_names fails without the
change on the 780M (to be run with the runtime before it and after, on the 780M and the XTX).
docs/REFUSALS.md regenerated: unchanged.

(cherry picked from commit dcffee430897a499f47155664a8549a248b8a8ad)
(cherry picked from commit 707ef3439b2ca3c5f81f967a1322470da47c0d77)
2026-11-08 22:48:23 -08:00
Anees Iqbal de5a77cc06 Wide lines: no device's own lines are taken as Metal's parallelogram
RADV fails wide_lines_draw_metal_s_parallelograms and its exact-answers twin at the lane's
"scattered lines width 2.5, fragments" map, 628 pixels where Metal's has 622: on the Radeon RX
7900 XTX (homelab-gem10-1, m3-max-10724) and on the 780M (homelab-um870-1, its only GPU,
m3-max-10773), at this branch's base and at development alike. The runtime took RADV's lines as
Metal's there, unannounced: RADV is the one driver of the committed profiles stating non-strict
parallelogram lines (strictLines unset, nonStrictWideLinesUseParallelogram set), and 2.5 lies on
its 1/8 granularity above 1, so the route was the device's lines under both policies.

Cause, measured: a probe on the XTX (m3-max-10800, a scratch branch, never merged) drew each of
the 48 scattered lines alone and printed its pixels. 21 of them lie a row or a column off Metal's
parallelogram at an end: one more past the first vertex, one fewer before the last. A model of
Metal's rule (endpoints on the 1/256 subpixel grid, the parallelogram whose minor-axis edges are
w' long through them, the ends not extended, pixel centres by the top-left rule) reproduces
Metal's map pixel for pixel; the XTX's ends fit no constant shift of it. Vulkan leaves where a
non-strict wide line's ends fall to the implementation, and no driver is measured to place them
as Metal does.

Change: the device route has no exact form any more (render/line_width.rs route). Every draw the
device's own lines take is announced device-wide-lines, the notice naming "parallelograms, whose
ends and endpoints' snap the driver places as it draws them" where the width is on the grid above
1, and under WideLinePolicy::Exact (exact_answers) the band draws it wherever the device has
tessellationShader. On RADV, widths above 1 on the 1/8 grid move from silent device lines to
announced device lines under the default, and to the band under exact answers. No other profile
changes route: lavapipe and NVIDIA (strict) and ANV (not stated as parallelograms) were announced
already.

Tests: the runtime's route table reads A or B where it read E for the three RADV profiles (Cell::
Exact removed). The validation lane drops LineFacts::draws_as_metal, and asserts per case that
the draws of the device's own lines announce device-wide-lines one for one, which fails without
this change on RADV (width 2.5 drawn by the device's lines with no notice); the edges test
asserts the notice at each device-line draw.

Docs: render/line_width.rs's module docs, DeviceWideLines' rustdoc and docs/API.md's entry and
policy text, WideLinePolicy's and DevicePolicy::wide_lines' docs, the runtime README's route table
(its "exactly Metal's" row folded into the announced one), docs/FAST-PATHS.md's row (no device's
lines are taken as Metal's; the cost adds a row or a column at an end), docs/RUNTIME-PORTING.md's
SetLineWidth row. The announced cost string is unchanged.

Notices: one device-wide-lines per device (once per kind, unless announce_each names it) on a
RADV run that draws wide lines only at widths above 1 on the 1/8 grid, where it announced
nothing; a run that already drew a width below 1 or off the grid announced it already.

Needs the runtime-sources pin and a RUNTIME_VERSION (the orchestrator's numbers).

Verified: cargo fmt. The XTX, 780M, lavapipe and M3 runs follow through potluck.
(cherry picked from commit be88ae03f199d5a485abcc546d0d52b181290e7b)
2026-11-08 22:45:29 -08:00
Anees Iqbal aef1b019f4 Lines at the nearest width go on the device's granularity grid, never 0
With the refused band's lines through pixel centres (the commit before), RADV on gem10's RX 7900 XTX (NAVI31; the 780M, PHOENIX, on um870 reads the same, job 10773)
drew nothing at round 0 of a_refused_band_draws_at_the_nearest_width (m3-max-10559), where Metal
draws 23 pixels (its probe's 'horizontal y=16.5 x 4.5 to 27.5 width 0'). The nearest route
handed the driver w' = 1/16 for Metal's width 0, clamped into lineWidthRange [0, 8] alone. RADV's
lineWidthGranularity is 1/8 from 0, so 1/16 is a tie between 0 and 1/8, and Vulkan lets the
driver take either ("the nearest supported width"): a line of width 0 covers no pixel centre.
ANV's grid is 1/128, which holds 1/16, so ANV draws it as it is.

The nearest width is now on the device's grid: clamped into the range, then the nearer step of
lineWidthGranularity from the range's bottom (a tie the wider), and never 0 where the range starts
at 0 (render/line_width.rs drawn_width). So RADV draws Metal's width 0 at 1/8, and ANV still at
1/16. The runtime's route test and the validation lane's LineFacts::nearest mirror the rule; the
module docs, the runtime README's table, docs/API.md's lines-at-nearest-width entry and the
kind's rustdoc say it. The announced cost is unchanged.

Needs the runtime-sources pin and a RUNTIME_VERSION (the orchestrator's number).

Verified: cargo fmt. RADV, lavapipe, the M3 and the Iris lanes follow through potluck.

(cherry picked from commit c20de3da6e, message corrected: the run it cites (m3-max-10559) took the XTX, its MESA_VK_DEVICE_SELECT lacking the "!")
2026-11-08 22:17:31 -08:00
Anees Iqbal 5ed5e47ae5 DriverFact::ColorClearTakesEitherCode on RADV on the Radeon RX 550 (Polaris 12), as measured
runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear failed on the RX 550 (um790,
RADV POLARIS12, Mesa 26.2.6, job m3-max-10655 at 90c9936538): 186 plain fills differed from
Metal's past what they announce, 93 colour fills of 11 formats, each in a texel of a level and in
a whole 1 x 1 slice: RGB10A2Unorm and BGR10A2Unorm 24 each, RGBA8Snorm 9, RGBX8Snorm 7,
RGBA8Unorm, BGRA8Unorm and ARGB8Unorm 6 each, RGBX8Unorm 5, RG8Snorm 3, RG8Unorm 2, A8Unorm 1.
Every differing channel stored the code below the nearest, a code from Metal's, off the
midpoint: 8-bit scaled values 0.50 to 0.58 past their lower code (RG8Unorm's 0.515986, 131.58
codes, stored 131 where Metal stores 132), 10-bit ones 0.51 to 0.87 past (0.549235, 561.87 codes,
stored 561). None was announced: the runtime announces a clear off a midpoint only on a driver
that takes either code (clear_value::rounds_apart).

The cause: the device's clear cuts the colour to a half toward zero, then rounds to the code.
That model gives every one of the 270 channels of those 93 fills (offline, from the job's
lines), and the same lane's R16Float clears store the half cut toward zero (0.001 as 0x1418,
Metal's 0x1419), RG16Float and RG11B10Float alike, already announced there. A half's cut is under
half a 10-bit code, so the stored code is one of the two nearest: Vulkan's "one of the two ...
closest" allows it, the device's native conversion. The row records it as the 5080's and ANV's
do, keyed to RADV, AMD's vendorID and the RX 550's deviceID (0x699f, AMD_RX_550), so the runtime
announces device-color-conversion for a clear or plain fill of a normalized channel anywhere off
a whole code there.

The fact's doc gives the measurement; docs/API.md's clear entry names RADV on the RX 550. No
committed profile is of the RX 550, so no profile's facts move.

Verified: the model offline over the 10655 lines. The RX 550 color_fills lane and the suites
follow through potluck.

(cherry picked from commit e3455e70e245184ce96777a64e4a166c73400625)
2026-11-08 21:42:16 -08:00
Anees Iqbal f0628b75eb The levels each texture slot reads, and the attached-read slots counted by them
The translator states, for each texture slot of a stage, the levels of its bound view its
reads reach (`StageModule::level_reads`, `spirv::requirements::level_reads`): whether some
read may reach any level, the highest constant level a fetch, size query or gather names
(through the fetch lowering's `UMin(c, levels - 1)` containment too), and its samples by
sampler, with the highest constant explicit level of detail and whether one is computed.
`SampledLevels::level` answers the highest level such samples reach through a bound
sampler (`SamplerLevels::of` a `vk::SamplerDesc`: its LOD clamps, bias and mip mode), and
`LevelReads::highest_level` the slot's.

The runtime counts, at each draw that takes every step and reads through copies, every slot
whose sampled binding presents a texture an attachment of the instance renders
(`WorkCounts::attached_read_slots`), split by how its reads meet the lowest attached level:
one level, the first level attached, any level, reaching it, or below it. The samplers are
those the draw binds (the bind's own descriptor for a runtime sampler, the layout's
immutable sampler for a constexpr one). No draw binds or copies otherwise: this names the
shape of the usage shadow the attached reads of mipmapped textures take, ahead of serving
the "below" slots through a view of fewer levels.

SEMANTICS_VERSION 1998 and ARTIFACT_FORMAT_VERSION 495: the artifacts carry the new fact.
api_surface and api_signatures name the new public types and fields.

Verified: cargo fmt only so far; the build, clippy and tests run as potluck jobs next.
(cherry picked from commit 89855203ad1b8b9b3695f313b3cdb34688993840)
2026-11-08 21:15:12 -08:00