100 Commits
Author SHA1 Message Date
Anees Iqbal 89fb420796 Runtime tests: the pending signal of the event-read cost test lies within the device's timeline limit
CI / test (macos-26) (push) Canceled after 0s
CI / test (ubuntu-26.04) (push) Canceled after 0s
a_value_the_host_sees_is_one_a_host_wait_confirmed signalled 2^40 over an event at 5. A device's
maxTimelineSemaphoreValueDifference may be as low as 2^31 - 1 (VUID-VkSubmitInfo2-semaphore-03883),
and AMDVLK 2025.Q2.1 on a Radeon 780M reports 4294967295: the submit broke that valid usage, the
validation layer reported it and the test failed there (job m3-max-76993, the rt suite under that
driver: 850 passed, 1 failed, 3 skipped). The signal is now 5 plus the device's limit, at most
2^40, which no progress value reaches and the limit allows, as the_largest_value_is_kept reads it.

Verified: see the jobs in the landing line (lavapipe, and the 780M under AMDVLK).
2026-11-27 06:27:24 -08:00
Anees Iqbal 0b0ac58eb0 Runtime tests: a whole copy in moves from undefined through each entry, a short one from home
What: tests::layouts::on_device::a_whole_copy_in_moves_from_undefined_through_each_entry_and_a_short_one_from_home.
On every device, under a Recording: a Shared RGBA8Unorm texture of two levels takes a blit's
copy_from_buffer into the whole of level 0, one short of level 1's edge, then replace_region of
the whole of level 0; the recorded old layout of the last barrier naming the image before each
copy in is UNDEFINED, home, UNDEFINED.

Why: b1's guard 1 (whole_copy_in's discards) asks TextureObject::away_into directly, so a revert
of only the two call sites (blit.rs copy_from_buffer, texture.rs record for a replace) with the
helper kept leaves it green; guard 2 shows the tear on the 780M only. This assertion reads the
barrier the call sites record, on any device, lavapipe included.

Verified: see the lane's report (lavapipe at this commit and with the two call sites reverted).
2026-11-27 06:05:09 -08:00
Anees Iqbal 719983b05a Runtime tests: Shared coherence's counts are held to the flush and invalidate calls made
What: the test-only command table tests::layouts::recorded (loaded at Device::new while a
Recording lives) now also takes vkMapMemory, vkFlushMappedMemoryRanges and
vkInvalidateMappedMemoryRanges: each call is passed to the driver and counted per device, with
the bytes of the ranges it names (a VK_WHOLE_SIZE range to the end of its memory's mapping as
vkMapMemory named it), in tests::layouts::coherence_calls. Every test in tests::coherence starts a
Recording, and each reading of a device's counters there (Seen::metrics) first asserts that
shared_flushes, shared_flushed_bytes, shared_invalidates and shared_invalidated_bytes equal those
calls and bytes since the device was made, so each per-point count the tests already assert is
of calls the device really made.

Why: the view tests counted only the runtime's own bookkeeping (Coherence::flush and settle
count after the call site, the time inside a call is two clock reads, and the view runs on memory
that is coherent in fact). With both Vulkan calls removed and the counters kept (scratch
188b2d0cee) they stayed green on the RX 550 (job m3-max-76941). No product line changes.

Verified: see the lane's report (the RX 550 at this commit and with the calls removed).
2026-11-27 06:05:03 -08:00
Anees Iqbal 18b0028af1 Runtime tests: each value a GPU signal raises is confirmed by one wait before the host sees it
What: tests::event_values::each_value_a_gpu_signal_raises_is_confirmed_by_one_wait_before_the_host_sees_it.
For three signals in turn (3, 9, 20), once the command buffer completed and the completion thread
took the value in, signaledValue reads the value and the test-only wait count
(Counters::event_reads) rose by exactly one since the signal was committed.

Why: the rule of 58158f96a9 (a value the guest sees that a GPU signal raised is gated by
vkWaitSemaphores, never by the counter read alone) had only its cost test, which the old code
also meets. This assertion fails where EventInner::reached returns the counter's value without
the wait.

Verified: see the lane's report (lavapipe green at this commit, red in a scratch control).
2026-11-27 05:44:12 -08:00
Anees Iqbal 5089a1570a Runtime: GPU times round a tick count's nanoseconds to the nearest, not down
Ticks::span cast its f64 nanoseconds to u64, which truncates, and so did
Calibration::at, the host time of a tick by the calibration. Ticks of a period
an f32 cannot state exactly come out a nanosecond short: 96 ticks of the Iris
Xe's 19.2 MHz clock, a period of 52.083332 ns as Vulkan states it, are 5000 ns,
and the cast gave 4999. Both now round to the nearest whole nanosecond, one
expression each, no branch; an end before the start still saturates at 0.
Every GPU span and placed time goes through these two: Calibration::place, the
completion thread's placement (complete.rs), the held-start gaps and
Metrics::runtime_command_buffer_gpu_nanos.

Metal states GPUStartTime and GPUEndTime as host seconds (CFTimeInterval, "the
host time in seconds that GPU starts executing this command buffer") with no
precision promise, so the nearest nanosecond the ticks allow is ours to give.

Verified: the ported durations_count_ticks_of_the_period_across_a_wrap
(tests/times.rs, its answer of 5000 as the deleted runtime's test stated it)
was red at the tree before this commit on lavapipe, job m3-max-76896 (left
4999, right 5000; the other four ported tests green). Green after it:
lavapipe run follows.
2026-11-27 05:36:14 -08:00
Anees Iqbal 124b5026bc Runtime tests: port the GPU-time calibration placements the old runtime's deletion took
5d725aeec7 deleted the old runtime with its tests. Of its GPU-time tests
(tests/gpu_time.rs), these describe the new runtime's Calibration as they stood,
ported with their answers unchanged:

- a_pair_places_timestamps_on_the_hosts_clock_either_side_of_it, whole, as
  a_calibration_places_timestamps_on_the_hosts_clock_either_side_of_it
  (GpuClock::place, now Calibration::at);
- the calibrated case of a_span_is_placed_by_the_pair_or_ends_at_the_completion,
  as a_span_is_placed_by_the_calibration (Calibration::place); its uncalibrated
  cases do not port, since the floor requires calibrated timestamps;
- the 65 s-ahead case of a_pair_that_places_times_outside_the_life_is_set_aside
  (the Radeon 780M's after two MODE2 resets), as
  a_calibration_65_s_ahead_places_times_by_the_completion: the times end at the
  completion seen. Its drift and deviation allowance and its lower bound at the
  kernel start do not port: the new runtime bounds GPU times by the completion
  seen alone.

Calibration's two fields become pub(crate) so the tests can build one; nothing
else changes.

Verified: lavapipe and lint runs follow, reported with their jobs.
2026-11-27 05:36:14 -08:00
Anees Iqbal 9e046ed8d2 Runtime tests: port the GPU-time duration and host-clock tests the old runtime's deletion took
5d725aeec7 deleted the old runtime with its tests. Two of its GPU-time tests
(tests/gpu_time.rs) describe the new runtime's design as they stood and need
nothing new, so they come back unchanged in their answers:

- durations_count_ticks_of_the_period_across_a_wrap: the old GpuClock::duration,
  now Ticks::span (Ticks::new takes the period first, then the valid bits).
- the_host_time_rises: host_time, now u64 nanoseconds where it was f64.

Verified: baseline runs pending (the runtime's tree as it stands at
development's tip, with only these tests added).
2026-11-27 05:36:14 -08:00
Anees Iqbal 2b4219047e Probe opencl_operand_encodings: what the shape kernels compile to
The probe's notes gain what job m3-max-76861 measured for the kernels of the runtime's tests
opencl_shapes: a __local atomic_cmpxchg is air.atomic.local.cmpxchg.weak.i32 of orders 0 and 0
and scope 1 through an alloca of its expected value, as the __global one with scope 2; a read
through a sampler with integer coordinates converts them with air.convert and samples.
2026-11-27 05:27:15 -08:00
Anees Iqbal 4bb8fe19aa Runtime tests: OpenCL-mode constant samplers read through Metal's sampler words
A constant sampler_t had no test in the shape Apple's OpenCL compiler writes: an
air.sampler_states global of Metal's two sampler words, never OpenCL's bits (our kernel
ocl_sampler, the probe opencl_operand_encodings, M3 Max, job m3-max-76861). Two of them, each
of OpenCL bits unlike Metal's words: CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE |
CLK_FILTER_NEAREST (0x7bff0000088049), read with integer coordinates (air.convert to float,
then air.sample_texture_2d of access 0), and CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_REPEAT |
CLK_FILTER_LINEAR (0x7bff0000080a92), read with float ones. Each work-item reads a 4 by 2
RGBA8Unorm image through both: the first at a texel coordinate on each side of the image
answers the texel clamped to the edge, the second half-way between a texel and the next one
across, wrapping to the row's first, answers their mean. Each address mode, filter and
coordinate space answers differently from the others there, and every byte of the image is
even so each mean is a whole byte: the answers are computed here and compared exactly.

Test only, at development's product code. Its runs follow this commit.
2026-11-27 05:27:15 -08:00
Anees Iqbal fd637dbf59 Runtime tests: OpenCL-mode 1.2 atomics on __local and __global memory lose no update
OpenCL 1.2's atomic_add and atomic_cmpxchg had no test in the shape Apple's OpenCL compiler
writes: air.atomic.{local,global}.{add.s,cmpxchg.weak}.i32 in the AIR 2.9 form, order 0, scope
1 on __local and 2 on __global, mem_flags 0, volatile, the exchange through its expected
value's alloca with the old value read back from it (our kernel ocl_atomics, the probe
opencl_operand_encodings, M3 Max, job m3-max-76861). Over 16 work-groups of 128 work-items each
work-item adds its global id into a __local word and counts itself into another through a
compare-exchange loop from 0, storing the old value its exchange succeeded on as a ticket, then
does the same into two __global words. The answers are computed here and no lost update can
give them: each work-group's sum and count of 128, the total sum and the count of 2048, each
work-group's __local tickets every value below 128 once and the __global tickets every value
below 2048 once.

Test only, at development's product code. Its runs follow this commit.
2026-11-27 05:27:15 -08:00
Anees Iqbal 5a89af6d73 Runtime tests: an OpenCL-mode image write through an identity view stores the written texels
The OpenCL-mode image write had no device test since the swizzled-view write left the range
(229d9db40b). This one is in the shape Apple's OpenCL compiler writes for our own kernel
ocl_write (write_imagef on a write-only image: _Z12write_imagef14ocl_image2d_woDv2_iDv4_f
calling air.write_texture_2d of access 2; the probe opencl_operand_encodings, M3 Max, job
m3-max-76861): work-item i writes ((17, 81, 145, 209) + i) / 255 to texel (i & 3, i >> 2) of a
4 by 2 texture filled with 0xee, through two identity views, and the texture's bytes read back
are the written ones, computed here. The views: an RGBA8Unorm view of an RGBA8Unorm texture
made with the identity swizzle, whose OpenCL-mode writes the M3 Max stores as written (the
probe opencl_swizzled_images, job m3-max-16336), and an RGBA8Unorm view of an RGBA8Uint
texture, the texture Apple's OpenCL binds for a CL_RGBA, CL_UNORM_INT8 image (same job).

Test only, at development's product code. Its runs follow this commit.
2026-11-27 05:27:14 -08:00
Anees Iqbal f53639c3f7 Probe opencl_operand_encodings: the kernels of the OpenCL-mode shape tests
Three kernels of our own join the probe: ocl_write (write_imagef through a write-only image),
ocl_atomics (OpenCL 1.2's atomic_add and atomic_cmpxchg on __global and __local memory) and
ocl_sampler (two constant samplers whose OpenCL bits differ from Metal's sampler words). The
runtime's tests opencl_shapes write their modules after what Apple's OpenCL compiler makes of
them, which this probe prints and leaves in out/. The run follows this commit.
2026-11-27 05:27:14 -08:00
Anees Iqbal d922da7b73 Tests: OpenCL C's mem_fence fences at acq_rel, the order Apple's compiler writes
Apple's OpenCL compiler (Metal's OpenCL mode) writes mem_fence(flags) as
air.atomic.fence(flags, 4, 1): order 4, acq_rel, after its trunc, llvm.bitreverse.i2 and zext
of the flags; read_mem_fence takes order 2 and write_mem_fence order 3 (the probe
opencl_operand_encodings, M3 Max, job m3-max-76799; the module text read again in job
m3-max-76855). The test modules that stand for mem_fence wrote order 3, a release fence, which
puts a fence weaker than Apple's on the side that reads: opencl_kernels's FENCE,
opencl_barriers's _Z9mem_fencej and unbound_immediates's fence. Each now writes order 4, and the
canon test asserts the fence it binds is acq_rel. None of the three stands for write_mem_fence,
so none keeps order 3.

A test correction only: no product code changes. The before and after runs of the two device
tests on one card per vendor follow this commit.
2026-11-27 05:27:14 -08:00
Anees Iqbal 39b435e4b5 Probe opencl_operand_encodings: what Apple's OpenCL compiler writes for enum and flag operands
Run on the M3 Max under macOS 27.0.1 (job m3-max-76799), through Metal's
OpenCL mode (OpenCL.framework's program binary holds only the options
and the source): barrier passes cl_mem_fence_flags to air.wg.barrier
unconverted (1 local, 2 global, order 5, scope 1); mem_fence,
read_mem_fence and write_mem_fence convert them to Metal's mask through
llvm.bitreverse.i2 (orders 4, 2, 3, scope 1); the 1.2 atomics write
order 0, scope 2 or 1 and mem_flags 0; constant samplers become
air.sampler_states words in Metal's encoding; image accesses are
sample 0, read 1, write 2. The header records the words.
2026-11-27 05:27:14 -08:00
Anees Iqbal 7db2db953f Probe: which encoding OpenCL C's enum and flag operands reach AIR in
Our own OpenCL C kernels (barrier, mem_fence, read_mem_fence and
write_mem_fence of each cl_mem_fence_flags value, the 1.2 atomics on
__global and __local memory, constant samplers whose OpenCL bits differ
from Metal's sampler words, a sampler argument, a read without a
sampler, a write), each compiled through OpenCL.framework's program
binary and through Metal's OpenCL mode, the bitcode carved out and
disassembled so the operands can be read.

Not yet run.
2026-11-27 05:27:14 -08:00
Anees Iqbal 0d0d7e4526 Runtime docs: a view keeps the texture that owns its image; parentTexture is the consumer's answer
new_texture_view's doc said the view keeps this texture "as Metal's parentTexture". For a view
of a view that is loose: the runtime keeps the texture that owns the image (the first ancestor
with an image of its own), while Metal's parentTexture answers the texture the view was made
from, the intermediate view (M3 Max, job m3-max-76856). The runtime has no parentTexture
accessor; the consumer answers it to the guest, as Metal does. Doc only, no behaviour change.
2026-11-27 05:24:09 -08:00
Anees Iqbal 102f9c524e Probe swizzled_view_stores: record the usage path on the M3 Max (job m3-max-76856)
The header records what the usage path answered on the M3 Max, macOS 27.0.1: a view made
without a swizzle and one made with the identity passed answer the base's 0x17; a (Blue,
Green, Red, Alpha) view 0x11; every view of that view 0x11, made without a swizzle, with
the identity, with (Blue, Green, Red, Alpha) (combining to the identity) and with (Green,
Blue, Red, Alpha); a (Blue, Green, Red, Alpha) view of the plain view 0x11; the same with
MTL_DEBUG_LAYER=1. A view answers its parent's usage, less RenderTarget and ShaderWrite
where the swizzle passed is not the identity, and the swizzle passed, else its parent's.
The render and compute lines of the same run equal job m3-max-76829's.
2026-11-27 05:14:44 -08:00
Anees Iqbal 2bd05d0067 Runtime docs: a view reports its base's usage, what it may be used with
Texture::descriptor's doc comment and the README's swizzle paragraph (Known gaps of
textures) state that a view's descriptor reports its base texture's usage, which is what
the view may be used with, so a draw into a swizzled view and a kernel's write through it
run, where Metal's usage answers only ShaderRead and PixelFormatView of a base of those,
ShaderWrite and RenderTarget, for a view made with a swizzle other than the identity and
for every view of such a view.

Measured on the M3 Max, macOS 27.0.1, job m3-max-76856 (swizzled_view_stores.m): a base of
0x17; a view made without a swizzle and one made with the identity passed answer 0x17; a
(Blue, Green, Red, Alpha) view 0x11; views of that view made without a swizzle, with the
identity, with (Blue, Green, Red, Alpha) and with (Green, Blue, Red, Alpha) all 0x11; a
(Blue, Green, Red, Alpha) view of the plain view 0x11; the same with MTL_DEBUG_LAYER=1.
The consumer answers a guest's read of a view's usage from its own descriptor, so the
runtime's answer is its own contract; nothing in the runtime changes. Docs only;
refusal_surface.py --check and signatures.py --check pass.
2026-11-27 05:14:36 -08:00
Anees Iqbal 2456c27074 Probe swizzled_view_stores: the usage each view of a swizzled view reports
A usage path makes no draw or write: of an RGBA8Unorm Private base of ShaderRead |
ShaderWrite | RenderTarget | PixelFormatView it prints the usage, swizzle and parent of a
view made without a swizzle, one made with the identity swizzle passed, a (Blue, Green,
Red, Alpha) view, four views of that view (without a swizzle, with the identity, with
(Blue, Green, Red, Alpha), which combines to the identity, and with (Green, Blue, Red,
Alpha)), and a (Blue, Green, Red, Alpha) view of the plain view, then runs again in a
child under MTL_DEBUG_LAYER=1. Which views Metal reports without RenderTarget and
ShaderWrite is measured here rather than guessed.

Syntax-checked with xcrun clang -fsyntax-only; the M3 Max run follows.
2026-11-27 05:12:32 -08:00
Anees Iqbal 0bb092f8ff API docs: a kernel's write through a channel-permuting swizzled view is stored as written
Section 10's Kernels gains the accepted difference: the runtime stores a kernel's write
through a texture view whose swizzle permutes its format's channels as written, where the
M3 Max stores it through the swizzle (an RGBA8Unorm (Blue, Green, Red, Alpha) view's write
of (0x33, 0x66, 0xb3, 0xcc) leaves (0xb3, 0x66, 0x33, 0xcc); swizzled_view_stores.m, job
m3-max-76829) and Metal's validation refuses the write, the view reporting no ShaderWrite
usage. The OpenCL images paragraph said a write stores the value with the swizzle undone,
which is the M3's answer, not the runtime's; it now states the runtime's rule and points
to the entry.

Docs only; the rule is the runtime's README's ("A swizzle reaches a texture's sampled
element alone") and the lane's write test asserts it.
2026-11-27 05:11:10 -08:00
Anees Iqbal 441505998c Runtime tests: a write through a swizzled OpenCL image is stored as written
opencl_mode_writes_through_a_swizzled_image_store_the_value_as_written takes the write
test held on steelbrain/ocl-port-swizzle (e579f13a30) with its kernel and helpers, and
asserts the runtime's rule: a write-only image's write through a swizzled view stores
channel c from lane c (the runtime README's known gaps of textures, "A swizzle reaches a
texture's sampled element alone"). The M3 Max's answer is named in the module doc as the
difference: it stores the value with the swizzle undone (OpenCL probe, job m3-max-16336;
on rgba8/BGRA texel 0 [0x91, 0x51, 0x11, 0xd1] where the runtime stores [0x11, 0x51, 0x91,
0xd1]), as it does for a plain-Metal kernel's write (swizzled_view_stores.m, job
m3-max-76829), and Metal's validation refuses such a write, the view reporting no
ShaderWrite usage. The M3's write rule (write_rule) goes, since nothing asserts it now.

The held commit's runs showed the as-written bytes on lavapipe (job m3-max-76607), the
RX 7900 XTX (m3-max-76618), the 780M (m3-max-76619), the RTX 2080 (m3-max-76620) and the
RTX 5080 (m3-max-76614); this commit's own runs are in the lane's report.
2026-11-27 05:11:10 -08:00
Anees Iqbal dad45427b0 Probe swizzled_view_stores: record what it measured on the M3 Max (job m3-max-76829)
A swizzled view used as colour attachment 0 stores the clear and the draw as written in all three
cases; a plain Metal kernel's access::write through the view stores the colour permuted by the
swizzle (channel s[l] takes lane l). Metal gives every swizzled view usage 0x11 over a base of
0x17, and its validation layer ends both uses for the missing RenderTarget and ShaderWrite usage.
2026-11-27 05:11:10 -08:00
Anees Iqbal c159887669 Probe: what Metal stores through a swizzled view used as a colour attachment and written by a kernel
Our own shaders over three cases: an RG32Float texture over a Shared buffer (usage ShaderRead |
ShaderWrite | RenderTarget | PixelFormatView) viewed as RG32Float with the swizzle (Red, Green,
Zero, One), the same base viewed with (Green, Red, Zero, One), and a Private RGBA8Unorm viewed
with (Blue, Green, Red, Alpha). Each view is cleared and drawn as colour attachment 0 and,
separately, written by a plain Metal kernel (access::write); the base's bytes are read back and
every texel is sampled through the view. Each case and path runs again in a child process under
Metal's validation layer. Not yet run.
2026-11-27 05:11:10 -08:00
Anees Iqbal b120feee53 Runtime tests: the largest event value runs only where the device's timeline limit covers it
the_largest_value_is_kept signals u64::MAX on a fresh event, a jump of 2^64-1, which Vulkan
bounds by the device's maxTimelineSemaphoreValueDifference (VUID-VkSubmitInfo2-semaphore-03883).
A suite test must not make a submission outside valid usage on any device the floor admits, and
Vulkan lets that limit be as low as 2,147,483,647. So the test reads the limit
(VkPhysicalDeviceVulkan12Properties) and runs where it covers the jump, printing the limit;
elsewhere it prints "not run: the device's limit is N" and checks nothing.

At 5481c1b88b, before this condition, it was green on lavapipe (m3-max-76802), the RX 7900 XTX
(m3-max-76807), the Iris Xe (m3-max-76806), the RTX 2080 (m3-max-76808) and the RTX 5080 Laptop
(m3-max-76814), each reporting a limit of 2^64-1.
2026-11-27 05:00:43 -08:00
Anees Iqbal cd9ac9dbee Runtime README: an event value an encoded signal or wait carries past the device's timeline limit
The queues section's known gaps gain one line. The runtime puts Metal's event value on the
event's timeline semaphore as it is. Vulkan requires a signal's or wait's value to lie within
maxTimelineSemaphoreValueDifference of the semaphore's value and of every signal and wait pending
on it (VUID-VkSubmitInfo2-semaphore-03883, -03884), and lets a device report a limit as low as
2,147,483,647. On a device whose limit is below the jump, such a program is outside Vulkan's
valid usage. A host set_signaled_value never signals the semaphore, so it has no such limit
(event.rs's set_signaled_value).

The count behind the row: six recorded streams, largest jump an encoded signal or wait carried
178, none past the limit; the only values past it were host sets, which never reach the
semaphore. The lab cards the ported tests ran on (RX 7900 XTX, Iris Xe, RTX 2080, RTX 5080
Laptop) report 2^64-1.
2026-11-27 05:00:43 -08:00
Anees Iqbal 1f7b797e2e Runtime README: the host-seen event value is stated in the events contract
The sentence saying that an event's value the host sees, where a GPU signal raised it, is one a
host wait with a timeout of 0 confirmed states how events behave; it is not a gap. It moves from
"Known gaps" (the timestamp-pool bullet, restored to its text before the fix) to the `Event` and
`SharedEvent` bullet of "Queues, command buffers and events", in the present tense. No code
changes.

The record of the fix's cost (58158f96a9, with the doc commit 4ab995b621 on it): the harness's
two_queues row (`harness --runtime new --only two_queues`), before = d50eeb3522, after =
4ab995b621, 5 pairs alternated in one exclusive job per card, the arm order swapped each pair.
Times in us (b_done_p50 in ms: B committed to completed in the signalling part). spr is an arm's
max / min - 1.

RTX 2080, job m3-max-76839: every event key within 1%, base spreads at most 4.0%.
run       wait_p50 wait_p90 a_gap_p50 a_gap_p90  a_per_cb b_done_p50
before 1    19.840   20.192    41.376    42.336 20250.718    161.700
after  1    19.840   20.352    41.600    42.528 20263.368    161.800
after  2    19.872   20.128    41.312    42.176 20255.721    161.800
before 2    19.808   20.448    41.350    42.432 20251.343    161.800
before 3    19.872   20.480    41.120    42.144 20255.964    161.800
after  3    19.904   21.472    41.472    44.416 20255.081    161.800
after  4    20.000   20.416    41.344    43.040 20256.101    161.800
before 4    19.904   20.896    41.333    42.976 20258.708    161.800
before 5    19.904   20.992    41.440    43.776 20254.411    161.800
after  5    19.904   21.088    41.472    42.469 20252.510    161.800
before p50  19.872   20.480    41.350    42.432 20254.411    161.800
before spr    0.5%     4.0%      0.8%      3.9%      0.0%       0.1%
after p50   19.904   20.416    41.472    42.528 20255.721    161.800
after spr     0.8%     6.7%      0.7%      5.3%      0.1%       0.0%
after/before 1.002    0.997     1.003     1.002     1.000      1.000

Iris Xe (RPL-P), job m3-max-76844: every event key within 1%, base spreads at most 1.7%.
run       wait_p50 wait_p90 a_gap_p50 a_gap_p90  a_per_cb b_done_p50
before 1     9.012    9.167    38.803    46.503 22598.215    180.500
after  1     9.063    9.324    38.854    46.564 22597.641    180.500
after  2     9.220    9.636    38.959    46.826 22609.295    180.500
before 2     9.064    9.271    38.855    46.663 22597.349    180.500
before 3     9.115    9.272    38.855    46.353 22610.056    180.500
after  3     9.115    9.272    38.856    46.625 22642.170    180.600
after  4     9.114    9.271    38.803    46.498 22597.597    180.400
before 4     9.115    9.271    38.855    46.410 22625.471    180.500
before 5     9.167    9.323    38.804    46.567 22606.507    180.400
after  5     9.115    9.272    38.855    46.574 22618.163    180.500
before p50   9.115    9.271    38.855    46.503 22606.507    180.500
before spr    1.7%     1.7%      0.1%      0.7%      0.1%       0.1%
after p50    9.115    9.272    38.855    46.574 22609.295    180.500
after spr     1.7%     3.9%      0.4%      0.7%      0.2%       0.1%
after/before 1.000    1.000     1.000     1.002     1.000      1.000

RX 7900 XTX (RADV), job m3-max-76837: every event key within 1%, base spreads at most 4.5%.
run       wait_p50 wait_p90 a_gap_p50 a_gap_p90  a_per_cb b_done_p50
before 1    23.480   23.720   664.250   690.220 20664.500    165.100
after  1    23.560   23.800   665.520   685.240 20546.559    164.200
after  2    23.520   23.680   665.530   735.111 20645.568    165.000
before 2    23.520   23.680   663.780   697.990 20594.544    164.700
before 3    23.440   23.680   654.693   677.460 20495.322    164.300
after  3    23.480   23.680   665.810   670.200 20624.176    164.800
after  4    23.560   23.720   665.800   681.720 20659.588    165.100
before 4    23.560   23.720   661.400   688.170 20614.650    164.500
before 5    23.600   23.720   661.600   668.007 20625.205    164.700
after  5    23.520   23.720   665.078   697.190 20629.603    164.800
before p50  23.520   23.720   661.600   688.170 20614.650    164.700
before spr    0.7%     0.2%      1.5%      4.5%      0.8%       0.5%
after p50   23.520   23.720   665.530   685.240 20629.603    164.800
after spr     0.3%     0.5%      0.1%      9.7%      0.6%       0.5%
after/before 1.000    1.000     1.006     0.996     1.001      1.001

RTX 5080 Laptop, job m3-max-76834: VOID, its base arm spreads above 10% (41.4% on wait_p50,
41.8% on wait_a_gap_p50); its runs fall in two groups (8.3 to 9.1 us and 10.2 to 12.0 us on
wait_p50) in both arms.
run       wait_p50 wait_p90 a_gap_p50 a_gap_p90  a_per_cb b_done_p50
before 1    12.032   12.768    23.872    26.016 20877.065    160.800
after  1    10.176   12.448    22.576    25.984 21461.131    163.600
after  2    11.264   12.768    22.719    26.464 21465.165    163.700
before 2     8.960   12.512    18.272    25.984 21513.619    163.900
before 3     8.672   12.352    17.984    25.952 21537.336    163.900
after  3    11.232   12.416    22.130    25.184 21585.253    164.100
after  4     8.320   12.256    16.544    24.736 21603.339    164.000
before 4     8.512   12.480    16.832    24.736 21658.572    165.000
before 5     8.672   12.448    17.568    26.016 21687.321    165.000
after  5     9.088   12.640    19.136    26.272 21728.232    164.900
before p50   8.672   12.480    17.984    25.984 21537.336    163.900
before spr   41.4%     3.4%     41.8%      5.2%      3.9%       2.6%
after p50   10.176   12.448    22.130    25.984 21585.253    164.000
after spr    35.4%     4.2%     37.3%      7.0%      1.2%       0.8%
after/before 1.173    0.997     1.231     1.000     1.002      1.001

Columns: wait_p50 and wait_p90 are B's GPU start after the signaller's GPU end; a_gap_p50 and
a_gap_p90 are the harness's wait_a_gap keys (A's GPU idle before each of its command buffers);
a_per_cb is wait_a_per_cb.

At 4ab995b621: lint job m3-max-76840 green (fmt, signatures, api_surface, clippy in all three
configurations, Rustdoc -D warnings); the runtime suite on lavapipe under the validation layer,
jobs m3-max-76841 (394 passed) and m3-max-76842 (444 passed), none failed. This commit
changes the README alone; its check is fmt and Rustdoc -D warnings, run on it once made.
2026-11-27 04:57:51 -08:00
Anees Iqbal 4ab995b621 Runtime docs: a value seen on the host is gated by a host wait, never by the counter read
complete.rs's module doc now states the planner's one reading for the tree: a retirement, a host
read of bytes the GPU wrote, a value the guest sees that a GPU signal raised, and a free are gated
by vkWaitSemaphores (a timeout of 0 allowed), never by vkGetSemaphoreCounterValue alone; the
counter read may find which value to confirm. It rests on the Vulkan specification's Fences
section (7.3: waiting on a fence, by vkWaitForFences or by polling vkGetFenceStatus, defines an
execution dependency), the semaphores' overview (7.4: a dependency "between a queue operation
and the host") and the memory model's System-Synchronizes-With note ("signal operations
happening before host operations that wait on them"); Host Operations on Semaphores (7.4.4)
carries no such sentence. The Queue Operation section (3.2.1) gives what came before a signal a
wait has seen. VK_KHR_timeline_semaphore's issue 5 is no longer cited: it states no order.

The host-visibility paragraph (record::end's Reach::Host barrier, then host coherence or
crate::coherence) stays. run()'s comment on the completion loop's zero-timeout wait is unchanged.

Doc only. Verification: cargo fmt here; Rustdoc with -D warnings in the lane's lint job.
2026-11-27 04:47:23 -08:00
Anees Iqbal 58158f96a9 Runtime: an event's value the host sees is one a host wait confirmed
A value the guest sees that a GPU signal raised (SharedEvent::signaled_value,
wait_until_signaled_value, a listener's value, and the completion thread's observation that ends
an event's watch and may free its semaphore) came from vkGetSemaphoreCounterValue alone. Vulkan
states an execution dependency only for a host wait on a semaphore (the memory model's "signal
operations happening before host operations that wait on them"), and the completion of command
buffers already retires only on a vkWaitSemaphores; the planner's reading: a retirement, a host
read of bytes the GPU wrote, a value the guest sees that a GPU signal raised and a free are gated
by vkWaitSemaphores (a timeout of 0 allowed), never by the counter read alone.

EventInner::reached replaces the bare counter read at every site that gates: the counter read
finds the value, complete::reached_by_wait (timeout 0) confirms it, and the highest value
confirmed is kept. A value read at or below it asks for no wait, so a steady event pays one
counter read as before. Where the wait does not confirm the value read, a lower candidate (the
completion thread's next pending value, a host wait's own value) is waited for, and otherwise the
last value confirmed stands: on the completion thread the event stays watched and the round's GPU
wait blocks on its next pending value, so a "not yet" never spins.

Test-only counts (Counters::event_reads: reads, waits, not yet, not yet on the completion
thread, the completion thread's wake-ups) and a test, a_value_the_host_sees_is_one_a_host_wait_
confirmed: 1,000 reads of a steady value make at most one wait, and with a signal pending behind
the busy gate the completion thread does not return from its GPU wait for 200 ms. No public item
changes; signaled_value's doc and the runtime README's timestamps paragraph say it.

Verification: not run when committed; lavapipe, the cards and the harness's cost rows follow on
this branch.
2026-11-27 04:44:55 -08:00
Anees Iqbal d50eeb3522 Runtime docs: what a timeline value seen on the host means, at the completion thread
complete.rs's module doc now states the completion path's host side: a host wait
(vkWaitSemaphores) or a counter read (vkGetSemaphoreCounterValue) at or above the value a
submission signals means that signal operation has happened. It rests on the Vulkan
specification's Queue Operation section (3.2.1: a semaphore is signaled only once earlier queue
operations completed and their writes are available), Semaphore Signaling (7.4.1: a timeline
semaphore is signaled with respect to its counter value) and VK_KHR_timeline_semaphore's issue 5
(the payload query is one of the two documented host waits). It also says that Host Operations on
Semaphores (7.4.4) carries no execution-dependency sentence, unlike the fence wait, and that host
visibility comes from record::end's host-reaching barrier (Reach::Host), then host coherence or
the flush and invalidate of crate::coherence.

Doc only: no behaviour change, no version bump. Verification: cargo fmt here; Rustdoc with
-D warnings in the lane's lint job.
2026-11-27 04:33:07 -08:00
Anees Iqbal 5481c1b88b Runtime tests: an event keeps the largest value, from the deleted suite
The deleted runtime's the_largest_value_is_kept, on the public API: a signal of u64::MAX
reaches a shared event, which reads it; a second is left out; a host set of it changes nothing.
Metal's event values are uint64_t (MTLEvent.h, signaledValue).

The runtime puts Metal's value on the event's timeline semaphore as it is, and Vulkan bounds a
signal's distance from the semaphore's value by maxTimelineSemaphoreValueDifference
(VUID-VkSubmitInfo2-semaphore-03883; Vulkan's minimum is 2^31-1), so on a device whose limit is
below 2^64-1 the validation layer is expected to report this signal: a separate commit, held off
landing until its runs are read.

Verification: not run when committed; the lavapipe run and one card per vendor follow on this
branch.
2026-11-27 04:28:55 -08:00
Anees Iqbal 9d32e6bfbc Runtime tests: event values, handler orders and the commit's time, from the deleted suite
The runtime deleted with commit 5d725aeec7 took its event, completion and host-settable-wait
tests with it. Seven of its 38 tests describe what the new runtime still promises; this ports
them onto the public API (and EventState::pending where the old test read the pending signals),
keeping each one's observations and values:

- tests/event_values.rs: a signal not above what is known (a lower one on another queue, an
  equal one) is left out, the value 7 once the GPU runs (Metal's answer, measured); a shared
  event's host value reads at once below a pending GPU signal, lower and equal sets change
  nothing (measured), the semaphore is never signalled by the host, a wait the floor met goes
  unheld and one only the pending 7 meets completes after it; a host set above a pending signal
  stays the value once it lands; listeners run off the posting thread, on one thread, in the
  order posted.
- tests/completion_orders.rs: a command buffer that waited on the GPU for another queue's signal
  completes after it (the signaller Completed when the waiter's wait returns and in its handlers,
  the signaller's first handler first), over 50 rounds of each of 40 shapes; the orders within a
  command buffer, a queue and across queues, over 80 rounds; and no commit of 1,800 on one of four
  queues takes 50 ms or more less the thread's wait for a CPU.

Metal has no completion-seen handler: where a shape names one, it is a completed handler added
first. Device tests, under m2v_gpu and m2v_cpu_icd.

Verification: not run when committed; the lavapipe run and one card per vendor follow on this
branch.
2026-11-27 04:28:29 -08:00
Anees Iqbal 959a4ccbcd Runtime tests: OpenGL mode's rasterizing void vertex function is refused, a known gap
The GL-mode half of the old runtime's void-vertex test. Metal on an Apple M3 Max (macOS 27.0.1,
probe conformance/probes/opengl_mode.m) makes, under the private OpenGL mode, a rasterizing state
whose vertex function returns void: its draw runs the vertex function and rasterizes nothing.
The runtime refuses it in either mode, as the translator's link does (pipeline/link.rs,
check_stages: DescriptorError::RasterizedVoidVertex whatever the mode).

The consumer counted the refusal over 812 runtime boots, 221 with guest GL-renderer content and 160
with a browser 3D scene: 0, while 737 of those logs carry other runtime refusal lines. On that zero
the planner ruled the refusal a known gap rather than a build: the test asserts today's typed
refusal with the mode on, Metal's answer stays in its doc as the difference, and the runtime's
README lists it under Known gaps of render pipeline states, as a guest meets it. The refusal test
without the mode now shares the assertion through one helper.

Verified: the same refusal, "invalid descriptor: RasterizedVoidVertex" with the mode on, was what
the Metal-valued form of this test met on lavapipe (job m3-max-76678), the Iris Xe (m3-max-76684),
a Radeon 780M (m3-max-76687) and an RTX 2080 (m3-max-76688); this form reruns on lavapipe at the
branch tip, reported to main with its job.
2026-11-27 03:42:08 -08:00
Anees Iqbal c10d191b46 Runtime tests: a render state carries DevicePointSize where its vertex function writes a size
No runtime test asserted the point-size note on a render state: the old runtime's per-draw
notice test went with it, and the translator's CPU tests check the note on compiled artifacts
alone. The note is static, decided by the vertex function (a [[point_size]] output) and the
device (its pointSizeRange's whole-pixel bound below Metal's 511) in the translator's stage I/O
plan, never by a draw's primitive. The new device test asserts exactly that on every device of
the cfg's kind: the state of rt6_point carries it where the device's bound is below 511, the
state of rt6_full on no device.

Verified: to run on lavapipe at the branch tip (a CPU job), reported to main with its job.
2026-11-27 03:42:08 -08:00
Anees Iqbal 1a4310899a Runtime tests: OpenGL mode's depth output without a depth attachment, and the void vertex refusal
The old runtime's OpenGL-mode device tests went with it on 11-20 and were never ported, so the
private render state the guest's GL renderer sets on every pipeline lost its guard. This ports
them onto the new runtime's device-test helpers, with the M3 Max's answers as they stood (probe
conformance/probes/opengl_mode.m, macOS 27.0.1):

- opengl_mode_makes_a_depth_output_without_a_depth_attachment: with the mode, a fragment function
  writing depth without a depth attachment makes a state whose colors are those it draws with a
  depth attachment. The old test's other half, the refusal without the mode, is not ported: only
  the M3 Max's driver refuses it and no Metal document states it (MTLRenderPipeline.h, Apple's
  pages for depthAttachmentPixelFormat and makeRenderPipelineState(descriptor:), the MSL spec's
  depth output), so on the planner's ruling the runtime makes the state, recorded in
  docs/API.md's accepted differences.
- without_opengl_mode_a_rasterizing_void_vertex_function_is_refused: the refusal half of the old
  void-vertex test, as the translator's typed DescriptorError::RasterizedVoidVertex; Metal's text
  stays in the module doc, as the runtime's errors carry none.

The module doc names the nine deleted tests not ported and why: point_size_notices' per-draw
notice is gone (the note is the state's), and private_properties' eight tests test Apple's private
device properties, which the consumer answers and the runtime holds none of.

Verified: to run on lavapipe at the branch tip (a CPU job), reported to main with its job.
2026-11-27 03:42:08 -08:00
Anees Iqbal 229d9db40b Runtime tests: the swizzled-view write leaves; the refusals the port met are named
The runtime's README records, as a program meets it, that an OpenCL-mode kernel taking a
1D image cannot be made into a pipeline state: the four image tests of the port met that
refusal on lavapipe (job m3-max-76590). The swizzled read_write gap is there already
(Known gaps of textures, Gap::SwizzledReadWrite). The test files name the two refusals
with their error text: opencl_mode for the 1D images, opencl_swizzles for the swizzled
read_write image.

The swizzled-view write test (opencl_mode_writes_through_a_swizzled_image_undo_the_swizzle)
leaves this range with its kernel and helpers: the planner's ruling, from Apple's text,
applies the swizzle when reading or sampling, so the runtime's unswizzled write stands
unless a stream counts such a write. The test comes back, unchanged and red as it stands,
in the branch's next commit, which is left out of the landing until that count.
2026-11-27 03:35:20 -08:00
Anees Iqbal 3bb7f3f596 Runtime tests: the plain-pipeline barrier variants pass Metal's flags
In a plain pipeline air.wg.barrier's flags are Metal's mem_flags (mem_device 1,
mem_threadgroup 2), so the plain variants of 8f16b3e544 asked for device memory's order
over threadgroup data (1) and for threadgroup memory's over device data (2), for which
Metal promises no answer: their reds on the 780M (job m3-max-76619) and the RX 7900 XTX
(job m3-max-76618) say nothing of the runtime. The plain set now passes mem_threadgroup
alone over threadgroup data, mem_device alone over device data, and both over each. The
OpenCL-mode set keeps OpenCL's flags, and the fences keep theirs, which the wrapper's
llvm.bitreverse.i2 turns into Metal's.

Verified at 8f16b3e544, before this change: signatures, fmt, clippy in the three
configurations and rustdoc green (job m3-max-76615); the runtime suite on lavapipe 816 of
817 green, the one red the swizzled-view write (job m3-max-76621). This commit's run follows.
2026-11-27 03:35:20 -08:00
Anees Iqbal a472f5de92 Runtime tests: OpenCL barrier and fence variants whose data crosses waves
Neither deleted barrier test could see a barrier that fences the wrong memory: the
out-of-line barrier test passes both flags (3) and the threadgroup sum runs one wave a
threadgroup on RADV. Beside the tests as they stood, these variants run threadgroups of 128
threads (more than one wave on every device) in which thread t reads what thread t ^ 64
wrote, over four rounds as a tiled kernel's loop runs them, against an answer computed in
the test:

- a barrier of OpenCL's CLK_LOCAL_MEM_FENCE (1) alone over threadgroup memory,
  CLK_GLOBAL_MEM_FENCE (2) alone over device memory, and both (3) over each, passed on as
  Apple's OpenCL compiler passes it (`tail call fastcc void @_Z7barrierj(i32 noundef 1)`
  to an out-of-line wrapper of air.wg.barrier): in a plain pipeline through the two-operand
  air.wg.barrier (the out-of-line barrier test's form), and in a pipeline of OpenCL mode
  through it and through the three-operand form the work-item kernel's wrapper uses;
- a fence of the same flags in a plain pipeline, through the out-of-line fence test's
  llvm.bitreverse.i2 shape: the data crosses through the fence, barrier(0) and the fence
  again, since a fence orders only its own thread's accesses.

Verified: the lavapipe run follows.
2026-11-27 03:35:20 -08:00
Anees Iqbal 5a406c7ada Runtime tests: the OpenCL-mode tests the runtime cannot run leave, refused
Five of the ported tests meet a typed refusal on lavapipe (llvmpipe, LLVM 23.1.1, under the
validation layer, job m3-max-76590), so the runtime lacks the piece each needs and none can
run as it stood:

- opencl_mode_image_formats_read_the_third_hidden_buffer,
  opencl_mode_1d_images_read_their_2d_bindings_row_0,
  opencl_mode_1d_images_read_real_1d_textures and
  opencl_mode_1d_images_write_their_2d_bindings_row_0: each kernel has a 1D image, whose
  RuntimeFact::OpenClLineTexture the pipeline cannot take: "the translator made no pipeline
  of __entry_<name>: unsupported: IdentityDomains (state of a bound texture or sampler
  beyond its resource ID (OpenClLineTexture { slot: ... })); needs NotImplemented";
- opencl_mode_read_write_images_of_a_swizzled_view_read_and_write_as_metal: its dispatch
  is Gap::SwizzledReadWrite ("a read_write texture slot 0 bound to a swizzled texture is
  not built").

The old opencl_images file held only the four 1D-image tests, so it goes; the image, sampler
and dispatch helpers the swizzle tests use move into opencl_swizzles.

The other 13 tests stay as ported. 12 pass on lavapipe in that job. One is red there with
the M3 Max's answer, and stays red, unchanged:
opencl_mode_writes_through_a_swizzled_image_undo_the_swizzle stores rgba8/BGRA's texels
unswizzled ([17, 81, 145, 209, ...]) where the M3 Max undoes the swizzle
([145, 81, 17, 209, ...]).
2026-11-27 03:35:20 -08:00
Anees Iqbal 1c959e079c Runtime tests: port the old runtime's OpenCL-mode device tests
The old runtime's OpenCL-mode device tests went with it (5d725aeec7) and none was carried
to the runtime, so an OpenCL-mode regression had no device test to fail. This brings every
test of the old opencl_mode, opencl_images, opencl_swizzles, opencl_data and opencl_kernels
files into crates/metal2vulkan-runtime/src/tests, under the device cfgs, on every device of
the cfg's kind (each_device), with the module text and the oracle answers as they stood:

- the kernels are built with ComputePipelineDescriptor::open_cl_mode_enabled and bound as
  the replay player's OpenCL-mode play binds them: the first hidden buffer's four words by
  setBytes at index 0, the second and third as buffers at 1 and 2 (the third the image
  order and data type table), the kernel's own from 3;
- buffers are Shared buffers in blocks of their own, textures and sampler states are made
  at indices of the device's grants;
- vsh_round's NativeHalfConversion and NativeNanEncoding are read from the state's own
  precision notes (ComputePipelineState::precision_notes) where the old runtime heard its
  announcements; the NaN test's exemption for a device measured to move a NaN as Metal's
  (DriverDeviation::MetalNanMoves) has no counterpart in the translator now, which records
  the note for every module that encodes a half, so the test asserts the note.

Left out: the old opencl_mode test's lsum (a threadgroup sum through __local memory),
ported on its own branch, and the old runtime's pipeline creation log test and its child
(METAL2VULKAN_LOG_PIPELINES and METAL2VULKAN_DUMP_PIPELINES), which the runtime does not
have.

Verified: not yet run; the lavapipe run follows.
2026-11-27 03:35:19 -08:00
Anees Iqbal 9a6404e17a Runtime tests: the fence variant's doc names the seq_cst fence's refusal
The test's doc now names why its fences are MSL 4.1's release and acquire: a seq_cst
atomic_thread_fence, the one order before MSL 4.1, is refused on every device as Error::Translation
of Unsupported not implemented IdentityDomains, naming "a sequentially consistent fence", the known
gap the runtime's README records (seen on lavapipe in job m3-max-76649). Comment only.
2026-11-27 03:33:30 -08:00
Anees Iqbal 12d7291381 Runtime tests: the fence variant takes MSL 4.1's release and acquire fences
The fence variant's seq_cst atomic_thread_fence is a refusal the runtime records among its known
gaps (a sequentially consistent fence, which the translator orders through a status word the
identity domains do not reach): on lavapipe the state was refused, "the translator made no
pipeline of fence_threadgroup: unsupported: IdentityDomains (a sequentially consistent fence)",
job m3-max-76649. A seq_cst order is the only one atomic_thread_fence takes before MSL 4.1, so the
kernel is now MSL 4.1's form (AIR 2.9, air64_v29-apple-macosx27.0.0, Metal 4.1): a release fence
before the relaxed add and an acquire fence after the add that reads 255, Metal's documented
release and acquire fences (MSL 6.16.3) around the atomic, and the AIR 2.9 atomic's mem_flags
operand (0, as Apple's compiler passes for a relaxed explicit atomic). The other three variants
passed on lavapipe in that job.
2026-11-27 03:33:30 -08:00
Anees Iqbal a8d9e65d87 Runtime tests: Metal-mode barriers and a fence above one SIMD group, data crossing them
The runtime's device tests held threadgroup_barrier(mem_threadgroup) alone above one wave with
data crossing waves, and nothing else: no mem_device barrier whose data crosses a 64-wide wave
(row_barrier's 32-wide rows pair within one wave on a wave64 device), no barrier of both flags, and
no air.atomic.fence. Four tests beside the originals, which stay unchanged, each with its answer
computed in the test:

- every_device_reads_another_simd_groups_device_word_past_a_device_memory_barrier: the harness
  fixture's row_barrier (mem_device alone) in rows of 64 and 128, threadgroups of 128 and 256,
  so thread t reads what thread t ^ 64 (or t ^ 128) stored in the device buffer: 512 x 4,
  512 x 3 (ragged in y) and 200 x 4 (ragged in x) in 64 x 2, 512 x 4 in 128 x 2, 192 x 8 in 64 x 4.
- every_device_reads_another_simd_groups_device_words_across_a_float_arenas_barrier:
  float_arena_reader, FLOAT_ARENA whose last loop reads the device words the loop before its
  mem_device barrier stored (thread t reads threads 4t..4t+3 mod 256's) in place of the arena.
- every_device_orders_both_memories_across_simd_groups_through_one_barrier: both_flags, a loop of
  four over one barrier of mem_device | mem_threadgroup, thread t reading the threadgroup word of
  t ^ 64 and the device word of (t + 64) % 256, in 8 threadgroups of 256 and 4 of 1,024.
- every_device_gathers_every_simd_groups_word_past_a_fence_and_an_atomic_count: Metal's fence
  pattern (MSL 6.16.1, 6.16.3), the last of 256 threads to add to a relaxed atomic count, after a
  seq_cst air.atomic.fence of mem_device, fences again and copies every thread's word; at
  thread_scope_threadgroup and thread_scope_device, 16 threadgroups. No thread waits for another.

The kernels are LLVM text in the test, as FLOAT_ARENA and VOTE_WORD are; row_barrier is the
harness fixture's own.
2026-11-27 03:33:30 -08:00
Anees Iqbal a9bffc7749 Runtime tests: the OpenCL local-memory tests' module doc names the variants
The module doc now says what the file runs: lsum also at 256 threads a
group, and the tiled multiply also behind both fence flags and through
global tiles behind the global flag alone. Doc only.
2026-11-27 03:30:57 -08:00
Anees Iqbal 63ecd16bab Runtime tests: the global tiles' scratch is held by a named binding the compiler does not warn of
The scratch buffer of the global-tile multiply is held until the work
completes; its binding now begins with an underscore, so the build of
the runtime's tests carries no unused-variable warning (lavapipe build,
job m3-max-76603).
2026-11-27 03:30:57 -08:00
Anees Iqbal c39fca99c0 Runtime tests: OpenCL-mode barrier variants across waves and by each fence flag
Every test of a barrier now also runs at a threadgroup larger than one
wave and with each fence flag alone and both:
- lsum in 64 threadgroups of 256 threads (each group's sum reads
  __local words other waves wrote), against the CPU's sums
  (65536 g + 32640, exact in f32); the ported lsum stays as it stood.
- the tiled multiply behind barrier(CLK_LOCAL_MEM_FENCE |
  CLK_GLOBAL_MEM_FENCE), and with its tiles in the threadgroup's own
  part of a __global scratch buffer (buffer index 5) behind
  barrier(CLK_GLOBAL_MEM_FENCE) alone, so the data crossing waves goes
  through device memory; both compared exactly with the CPU's product.

Verification follows (lavapipe and RADV and NVIDIA cards).
2026-11-27 03:30:57 -08:00
Anees Iqbal 6afe3ef7ff Runtime tests: the tiled multiply's barrier is the two-operand form Apple's OpenCL compiler writes
The OpenCL-mode tiled multiply now calls barrier(CLK_LOCAL_MEM_FENCE)
as Apple's OpenCL compiler writes it (llvm-dis of a kernel it
compiled): `tail call fastcc void @_Z7barrierj(i32 noundef 1)`, the
wrapper passing OpenCL's flags on unchanged to the two-operand
air.wg.barrier (flags, threadgroup). CLK_LOCAL_MEM_FENCE is 1 in
OpenCL's encoding, which Metal's mem_flags read as mem_device. lsum
keeps the three-operand form the deleted test wrote, a second route
to the same flags. The bit-reversed variant goes: Apple's compiler
does not write barrier that way.

Verified: the two modules assemble with llvm-as (regenerated from the
test's strings); device runs follow.
2026-11-27 03:30:57 -08:00
Anees Iqbal 1801bbaa63 Runtime tests: OpenCL-mode kernels that share __local memory through barriers
Device tests of the runtime, on every device of the cfg's kind, of
kernels in the shape Apple's OpenCL compiler writes (an __entry_ wrapper
loading the values passed by value, the internal kernel, the work-item
functions and barrier as internal wrappers), bound as a pipeline of
OpenCL mode is bound: the global offset and dimension count by setBytes
at index 0, the kernel's buffers and values 3 past their indices, and
each __local argument's length by setThreadgroupMemoryLength at its own
index.

- lsum, ported from the deleted runtime's OpenCL-mode tests with its
  answers (2016, 6112, 10208, 14304): a threadgroup of 64 sums its
  inputs through __local memory and a barrier.
- Our own tiled matrix multiply: c = a b through two __local tiles of
  32 by 32 floats (4096 bytes each, threadgroup indices 0 and 1), in
  threadgroups of 32 by 4, each thread accumulating 8 rows, a barrier
  after each tile's load and another before the next, dispatched over
  160 by 3200 threads (whole threadgroups) 8 times in one command
  buffer, each into its own c of 25600 by 160, k = 128. The values are
  multiples of 1/64 below 4 in magnitude, so every product and partial
  sum is exact in f32 and c is compared with the CPU's exactly; each
  repeat prints how many elements differ and by how much. It runs with
  barrier passing OpenCL's flags on to air.wg.barrier unchanged (as the
  deleted tests wrote it) and with them reversed through
  llvm.bitreverse.i2 (as mem_fence's are).

The guard for wrong values of an OpenCL-mode tiled multiply on RADV.
Verified so far: the three modules assemble with llvm-as (regenerated
from the test's strings); device runs follow.
2026-11-27 03:30:57 -08:00
Anees Iqbal 5af18cd7a7 Translator tests: the barriers our own passes insert keep Metal's flags in OpenCL mode
The pass that reads an OpenCL-mode air.wg.barrier's flags as OpenCL's
(canon::opencl::barriers) runs in specialization, after the last SCCP
and before the post-check (canon/mod.rs, specialize_linked). Our
passes that write a barrier:
- canon::async_copy writes air.simdgroup.barrier(mem_threadgroup)
  (async_copy.rs, NAME at line 295). It runs before the pass, but the
  pass takes air.wg.barrier alone, so this barrier keeps Metal's flags.
- lower::simd::lockstep::insert writes air.wg.barrier and
  air.simdgroup.barrier with Metal's mask (lockstep.rs, at lines 1133
  to 1149). It runs from pipeline::compile's order_specialized
  (compile.rs, at line 2832), on the entry specialization returns, so
  after the pass.
- The partial-threadgroups variant's vote (lower/simd/workgroup.rs,
  at lines 549 and 552), the mesh and object barrier
  (lower/mesh/mod.rs, at line 1253), tile staging
  (lower/access/tile.rs, at line 1122) and cooperative imageblock
  staging (lower/texture/emit.rs, at line 3289) emit OpControlBarrier
  in lowering directly, with no air.wg.barrier call the pass could
  see.

The new test runs where a pass of ours does add barriers: the
lockstep pass under the resident-table domains, on the 780M's profile.
These are the barriers that broke the refusal test's control at
cb77b3f60d: two air.wg.barrier calls with mem_device and
mem_threadgroup (UniformMemory | WorkgroupMemory). The kernel holds
OpenCL barriers 1, 2 and 3, then stores to its __local slot again
right before reading it. In a threadgroup narrower than 32, two
threads of a simdgroup can share that slot, and no barrier orders the
pair, so the pass inserts one. In the ordered entry the program's
barriers read as OpenCL's (threadgroup, device, both), and every
inserted barrier's decoded flags are Metal's reading of its own
operand, threadgroup memory among them. Without the fix the first
assertion fails, as the program's 1 and 2 read as mem_device and
mem_threadgroup. If the pass ran after lockstep, the inserted
barriers' mem_threadgroup (2) would read as CLK_GLOBAL_MEM_FENCE, and
the second assertion would fail.
2026-11-27 03:28:58 -08:00
Anees Iqbal 578f8c9df5 Translator tests: an OpenCL-mode simdgroup barrier keeps Metal's flags
The OpenCL-mode reading of barrier flags (canon::opencl::barriers)
takes air.wg.barrier alone. Of the canonicalization passes that run
before it, only async_copy writes a barrier, and that barrier is
air.simdgroup.barrier with Metal's mem_threadgroup: its
simdgroup_barrier writes one name only, NAME = "air.simdgroup.barrier"
(async_copy.rs, at line 295). No canon pass writes air.wg.barrier, none
expands wait_group_events or async_work_group_copy, and the OpenCL
work-item, image and hidden-buffer rewrites write loads, arithmetic,
selects and texture calls. The lockstep pass writes air.wg.barrier
(lower/simd/lockstep.rs, at line 1149), but it is lowering's and runs
after specialization.

This test pins the half of that the pass decides: a kernel's
air.simdgroup.barrier(mem_threadgroup) orders threadgroup memory alone
(WorkgroupMemory) in OpenCL mode and without it, on the 780M's profile
under the runtime's policy. If the pass took simdgroup barriers, OpenCL
mode would read 2 as CLK_GLOBAL_MEM_FENCE and the test would see
UniformMemory.
2026-11-27 03:26:30 -08:00
Anees Iqbal e6f2606842 Translator tests: the OpenCL-mode barrier refusal test compiles under the runtime's policy
Its control (the same AIR without the mode orders texture memory) built
the 780M's device under the resident-table domains, where the lockstep
pass inserts two barriers of its own after the program's, so the module
held three barriers where the test asked for one (job m3-max-76626 on
the commit before). The runtime compiles under DevicePolicy::default(),
whose identity domains order no lockstep pair, as the other new test
already does; the refusal test now takes the 780M's profile from the
same devices.

At the commit before, job m3-max-76628 ran both new tests with that
commit's sources in canon and intrinsics reverted to its parent: the
flags test fails, CLK_LOCAL_MEM_FENCE lowering to UniformMemory (64)
and CLK_GLOBAL_MEM_FENCE to WorkgroupMemory (256) on the 780M HawkPoint
profile, and the refusal test fails as the flags-4 barrier compiles.
With them (job m3-max-76626) the flags test passes on every committed
profile under the runtime's policy.
2026-11-27 03:17:43 -08:00
Anees Iqbal cb77b3f60d Translator: an OpenCL-mode barrier's flags are OpenCL's cl_mem_fence_flags
OpenCL C's barrier(flags) takes cl_mem_fence_flags, which Apple's
cl_kernel.h (OpenCL.framework, "5.9.7 - Synchronization") defines as
CLK_LOCAL_MEM_FENCE = 1U << 0 and CLK_GLOBAL_MEM_FENCE = 1U << 1, and
Apple's OpenCL compiler passes them to air.wg.barrier unconverted (an
internal function passing its parameter on as the barrier's flags).
Metal's mem_flags read the same bits as mem_device (1) and
mem_threadgroup (2), and decode reads every barrier as Metal's, so in a
kernel linked for OpenCL mode barrier(CLK_LOCAL_MEM_FENCE) lowered to
OpControlBarrier(Workgroup, Workgroup, AcquireRelease | UniformMemory):
nothing ordered the __local tiles, and RADV reordered them (a tiled
multiply's outputs wrong on the RX 550, the RX 7900 XTX and the 780M).
CLK_GLOBAL_MEM_FENCE likewise ordered threadgroup memory and left device
memory unfenced.

Specialization now reads each air.wg.barrier's flags again as OpenCL's
in a kernel of OpenCL mode (canon::opencl::barriers, from the
SpecRequest::open_cl_mode fact), after the last SCCP, so an out-of-line
barrier has its own call site's flags: CLK_LOCAL_MEM_FENCE is
mem_threadgroup and CLK_GLOBAL_MEM_FENCE mem_device
(MemFlags::from_cl_mem_fence_flags). It rewrites the call's decoded
operation in the entry's body, which lowering, the lockstep analysis,
the partial-threadgroups variant and the strategy census all read. A
flag outside the two leaves the call an unknown intrinsic, which the
post-check refuses (Unsupported, UnknownIntrinsic, naming
air.wg.barrier), as one outside Metal's mem_flags is. Nothing keys on a
function name. Metal-mode kernels, air.simdgroup.barrier (the header
declares no work_group_barrier or sub_group_barrier) and
air.atomic.fence (mem_fence's flags, which Apple's compiler converts
itself through llvm.bitreverse.i2) keep Metal's reading.

SEMANTICS_VERSION 2308. canon::opencl's module doc, docs/API.md (OpenCL
mode) and docs/ARCHITECTURE.md say what the flags mean and on what that
rests. docs/REFUSALS.md regenerates unchanged: the refusal is the
existing UnknownIntrinsic site.

Tests (tests::engine_opencl_mode):
- an_opencl_mode_barrier_orders_the_memory_its_opencl_flags_name: a
  kernel of barriers 1, 2 and 3 by four routes (air.wg.barrier with the
  constant, the wrapper of two operands, of three, and a parameter each
  of three call sites binds), compiled as a pipeline on every committed
  profile under the runtime's policy: in OpenCL mode WorkgroupMemory
  alone, UniformMemory alone, both; without the mode UniformMemory,
  WorkgroupMemory, both.
- an_opencl_mode_barrier_of_a_flag_opencl_does_not_name_is_refused:
  flags 4, inline and through the wrapper, refused in OpenCL mode and
  ImageMemory without it.
A job at this tip runs them, and once more with this commit's sources
in canon and intrinsics reverted to its parent, where the first fails.
2026-11-27 03:14:48 -08:00
Anees Iqbal c984bed3a4 Replay tests: the OpenCL-mode play asserts the form the device gives its dispatch
The round's device legs run every rt_replay test on every card, so the
OpenCL-mode test also plays where the device binds a kernel's buffers
(the twelfth form). It now asks the device's own answer,
device.translator().profile().binds_kernel_buffers(), the query the
runtime makes the form from, and asserts one bound dispatch and no
address dispatch where it binds them, else one address dispatch and no
bound one; it prints the form as "REPLAY opencl-mode form ..." for the
round's log. play_then is split so a test can make the device first
(play_on) and ask it before the play.

Lavapipe takes the address form; the check job at this tip runs it.
2026-11-27 02:09:47 -08:00
Anees Iqbal 8ac09ba43e Replay compare-dumps: a differing buffer's line names its first word in each play
compare-dumps said which word of a buffer differed first outside every
cover, but not what either play held there, so telling a NaN from a
rounding step or a stale word meant reading both dumps by hand. A
Difference now carries that word in each play's dump (first_values,
little-endian; a short end's bytes with zeros above them, none past a
dump's end), and its line prints them after the word's index:
"the first word W (a 0x........, b 0x........)". The stream doc says so.

The three compare tests take the values in their expected lines and
Differences, and a new unit test compares three buffers whose second
word differs in b, ends 2 bytes into it, or ends before it.
2026-11-27 02:09:46 -08:00
Anees Iqbal 866a8dd2f2 Replay player: a compute pipeline state takes the stream's openClMode
The player refused a compute descriptor whose openClMode was true, so a
stream that makes an OpenCL-mode pipeline (a guest running OpenCL C on
Metal) stopped at its first one. The runtime's descriptor carries the
mode (open_cl_mode_enabled), and the translator links the kernel for it:
the three hidden buffers ahead of the kernel's own, its buffer indices 3
on, get_global_id with the dispatch's offset. The player now gives the
stream's value to the descriptor, off where absent, and the stream doc
says so.

The previous commit's test is its check on lavapipe: red before this
commit, green with it.
2026-11-27 02:09:46 -08:00
Anees Iqbal 84503c6e40 Replay tests: a compute state of OpenCL mode plays its kernel as OpenCL mode binds it
A device test of the player on the runtime: a stream makes a compute
pipeline state with openClMode true from our own kernel in the shape
Apple's OpenCL compiler writes (the translator's by-value kernel:
o[get_global_id(0)] = k + s.a), binds the first hidden buffer with a
global offset of 1 and one dimension, o at 3 and k and s by setBytes at 4
and 5, and dispatches three threads. o[1..4] must read 3.75 and o[0]
keep its -1, nothing skipped.

The player refuses openClMode true today, so this test fails at this
commit (the play stops at the pipeline state); the next commit gives the
key to the pipeline descriptor.
2026-11-27 02:09:46 -08:00
Anees Iqbal ceed1a2727 Runtime: rt's own copy into a texture over a buffer discards first, the evidence
No content change: the evidence for the form (a473ab8c92) and its layouts test (3df886d8f1,
418ff4c348).

rt's own copy tore 6 of 4,000 at R8Unorm 1920x1080 through rt before the form and 0 of 4,000
after (780M, RADV, validation layer not loaded); the recordings hold in-reach textures by
descriptor, whose copied form on the device files do not show.

The layouts test an_over_image_is_copied_in_from_undefined_and_back_from_home: red on lavapipe
at the commit before the form (job m3-max-76431), green with it (job m3-max-76432).

The arms, Radeon 780M (RADV PHOENIX, Mesa 26.2.6), through the runtime, validation layer not
loaded, 4,000 repeats an arm, every byte of a repeat unlike the last repeat's, read back whole:
- R8Unorm 1920x1080 ShaderRead|RenderTarget over a Shared buffer at a pitch of 2304 (cause
  Pitch), job m3-max-76446:
  - old form: refill 6 of 4,000 stale (repeats 418, 1367, 1484, 2674, 3318, 3807; 8 bytes each,
    every one the last repeat's), first use 0 of 4,000;
  - new form: refill 0 of 4,000, first use 0 of 4,000;
  - over_copies 4000, over_copies_pitch 4000, over_copy_bytes_shared 8294400000 in every arm.
- BGRA8Unorm 1024x1024 ShaderRead|RenderTarget at rows of 7680, offset 0, over a Shared buffer
  of 8,294,400 bytes, refill, job m3-max-76454: old form 0 of 4,000, new form 0 of 4,000;
  over_copies 4000, over_copies_pitch 4000 in each (the copied form ran).

The timed check, command-replay at 779fd31192 (old) and at 418ff4c348 (new), alternated in one
job (new, old, old, new), each play with a fresh shader cache; the sum of the frames' wall time
and GPU busy time per play. Deterministic counts (submissions, barriers, bytes copied, over-copy
bytes Shared, passes) equal in every play unless noted.
- Radeon 780M, glbench-780m-r2, job m3-max-76454 (exclusive): wall new 117.935 / 119.705 s,
  old 118.742 / 117.946 s, new +0.40% on the mean (the old pair 0.67% apart); GPU busy new
  16.998 / 17.022 s, old 17.061 / 17.040 s (-0.24%).
- RTX 5080 Laptop, gb-3090-r2 with --managed two-copy, job m3-max-76456 (exclusive): wall new
  85.560 / 86.018 s, old 84.570 / 83.330 s, new +2.19% (the old pair 1.48% apart); GPU busy new
  21.931 / 21.416 s, old 21.367 / 20.810 s (+2.77%). Both new plays slower than both old ones on
  both measures. Barriers 702306 / 702315 / 702312 / 702311: they move between plays of one
  build.
- Iris Xe (RPL-P, ANV), glbench-780m-r2, job m3-max-76477 (exclusive): wall new 131.978 /
  132.296 s, old 132.248 / 132.112 s, new -0.03% (the old pair 0.10% apart); GPU busy new
  32.386 / 32.392 s, old 32.380 / 32.364 s (+0.05%).

Values, one old and one new play with --check-presents, compared by compare-plays:
- Radeon 780M, glbench-780m-r2, job m3-max-76476: 15 frames checked in both, 0 differ; counts
  equal in 792 of 792 frames.
- RTX 5080 Laptop, gb-3090-r2, job m3-max-76470: 22 frames checked in both, 0 differ; counts
  equal in 1115 of 1115 frames.
- Iris Xe, glbench-780m-r2, job m3-max-76478: 15 frames checked in both, 0 differ; counts equal
  in 792 of 792 frames.

The branch's check, job m3-max-76451 at 418ff4c348: fmt, signatures, clippy (plain, m2v_gpu,
m2v_cpu_icd), Rustdoc, and the runtime's device suite on lavapipe with validation layer 1.4.363.0
(788 passed, 3 skipped).
2026-11-27 02:07:04 -08:00
Anees Iqbal 418ff4c348 rt tests: the over copy layouts test shows layouts by number, as ash's ImageLayout has no Debug here
The test at 3df886d8f1 did not compile on lavapipe (job m3-max-76429): ash::vk::ImageLayout
implements no Debug in this build. Its print and assertion messages now show each layout's
number (VkImageLayout).
2026-11-27 01:22:20 -08:00
Anees Iqbal a473ab8c92 Runtime: rt's own copy into a texture over a buffer's image of its own discards first
A texture over a buffer that the device's linear image does not hold lives in an optimal image of
the runtime's (the copied form, crate::over), refreshed by one vkCmdCopyBufferToImage of the
texture's whole level and slice. Its move to the transfer layout started from the image's home,
which keeps the image's earlier contents: the whole-refill shape that leaves a stale 4 x 2 cell on
a Radeon 780M under RADV (Mesa 26.2.6; 7 of 4,000 R8Unorm 1920 x 1080 refills in plain Vulkan).
The landed form (TextureObject::away_into) covered only the blit encoder's copies.

A copy into the image now moves it from the undefined layout, discarding what it held, as the
copy writes every texel of the image's one level, slice and aspect: texture::over_texel refuses
any texture over a buffer but a 2D one of one level, sample and slice of a colour format of one
texel an element (texture.rs over_texel, the unit's aspect COLOR), so the region always covers the
barrier's one aspect. A copy back keeps the move from home. The runtime README's gap sentence and
over.rs's module doc say so.

Verified: the layouts test an_over_image_is_copied_in_from_undefined_and_back_from_home, red at
the commit before, green here, on lavapipe (jobs in the next report).
2026-11-27 01:20:31 -08:00
Anees Iqbal 3df886d8f1 rt tests: a copy into a texture over a buffer in an image of its own names its move's old layout
A layouts test for rt's own copies between a texture over a Shared buffer and the image of its
own that the copied form keeps (crate::over): every copy of the buffer's bytes into the image is
to move the image from the undefined layout, as the copy writes its whole level and slice, and
every copy back from home. On this commit's form the copy in moves from home, so the test fails:
the red half of the over-copy discard.

The layouts recorder learns the discard's shape. A move of an image's first level from the
undefined layout after its move home was always counted as a second move home that drops the
image's bytes. It is now a discard, made good only when the image's next step is a copy from a
buffer into its whole first level (the recorder keeps each image's extent, as made), and counted
in Moves::discards; any other next step is still a step out of order. The landed whole copy in
(TextureObject::away_into) has the same shape.

Verified in the next job on lavapipe (red here by design).
2026-11-27 01:19:27 -08:00
Anees Iqbal 779fd31192 Runtime docs: the RADV partial-copy gap names where its cells lay and the other sizes measured
The known gap of a copy from a buffer into part of a texture on a Radeon 780M under RADV
(Mesa 26.2.6) now says where the stale 4 x 2 cells lay at 1920 x 1080, in its own numbers:
refilling rows 864 to 1079, rows 1026 to 1058 (through the runtime, job m3-max-76165, both
archives; the plain Vulkan repro, job m3-max-76256: rows 1042 to 1058). It adds the plain Vulkan
repro's other sizes, the bottom 216 rows refilled 4,000 times each (job m3-max-76256): at
1920 x 1088, 4 stale in rows 882 to 890; at 1024 x 1024, 3 in rows 818 to 826; at 2048 x 2048,
none.

The form's steady price, measured in the rung-1 timed check (copy_from_buffer of a whole
1920 x 1080 level, 16 a command buffer, its GPU span; replace_region of a whole Shared
texture, 16 a command buffer, its upload's GPU time; old form against new, alternated in one
job), which the form's commit, already made, does not carry:
- RTX 3090: every row within 0.3% (job m3-max-76188).
- Iris Xe: every row within its spread; the RGBA8 upload's p10, its noisiest row, 132.75 us
  against 132.78, 0.02% (job m3-max-76213, 4 pairs of 200 rounds).
- Radeon 780M (job m3-max-76214, 4 pairs of 200 rounds, mean of each pair's p10): R8 upload
  95.05 us against 96.55, +1.6% (about 1.5 us, slower in every pair); RGBA8 copy 216.9 against
  219.1, +1.0%, slower in every pair; RGBA8 upload +0.7%; R8 copy +0.2%. All within 3%.

README only.
2026-11-27 00:29:20 -08:00
Anees Iqbal bfbc89b585 Runtime tests: the whole refills' pattern steps by as_chunks_mut, as clippy asks
Clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd refused chunks_exact_mut with a constant
size in whole_copy_in.rs (check job m3-max-76207). The step is unchanged: each byte adds 37,
eight at a time, the remainder one at a time.
2026-11-26 23:59:13 -08:00
Anees Iqbal 064bb96450 Runtime docs: a partial copy from a buffer into a texture on RADV, a known gap
A copy from a buffer into part of a one-sample colour texture can leave one aligned 4 x 2 cell
of the texture's earlier contents on the Radeon 780M under RADV (Mesa 26.2.6), measured on
R8Unorm at 1920 x 1080 only: in proof job m3-max-76165, refills of the bottom band of 1920 x 216
tore 17 of 4000 through rt and 9 of 4000 in plain Vulkan on rt's create info; refills of
480 x 216 rectangles of a 4 x 5 grid in turn, 1 of 4000 through rt and 0 of 4000 plain, the
bottom band reached in 800 of them. A whole-level copy discards first and does not (0 of 4000
through rt). No recording form covers a partial copy: no layout of the copy and no barrier
stopped the whole-refill form (job m3-max-76144).
2026-11-26 23:59:13 -08:00
Anees Iqbal c364eddb37 Runtime tests: the whole refills advance their pattern eight bytes at a time
Each refill's bytes are the last's plus 37, added a word at a time, where the test computed each
byte from its column and row, which a debug build spends most of a refill on.
2026-11-26 23:59:13 -08:00
Anees Iqbal 842b359c61 Runtime tests: the whole copy-in's moves compared without Debug on ash's types
ash is built without its debug feature here, so the layouts and aspects are compared as values
and printed raw. The m2v_gpu build of ff0e8e78c1 failed on it (job m3-max-76191).
2026-11-26 23:59:13 -08:00
Anees Iqbal 7d86d8f128 Runtime: a copy from a buffer that writes a whole subresource moves it from undefined
A copy from a buffer into a texture whose region starts at the level's first texel and reaches
its edge on every axis (a 3D level's depth included; a compressed level's edge as place clamps
the region), of every aspect of the image, moves that level and layer to TRANSFER_DST_OPTIMAL
from VK_IMAGE_LAYOUT_UNDEFINED in place of its home layout. Only the old layout changes: the
barrier's range is the one level and layer the copy writes (all slices of a 3D level, which the
copy then writes whole), and its source scope stays ALL_COMMANDS, MEMORY_WRITE over every earlier
access of the image, so the copy is still ordered after every earlier read and write. A copy of
one aspect of a depth-stencil image, a region short of the level on any axis, and an image whose
bytes another reaches (in place over a buffer, a surface plane's, an import's) keep the old form.
A heap-placed texture takes the form as a texture of its own memory does. Copies between
textures are not touched.

Both upload entries share it: the blit encoder's copy from a buffer into a texture
(copyFromBuffer:...toTexture:, record_buffer_copies) and the staged upload of replaceRegion and
a Managed texture's writes (TextureInner::record), each through TextureInner::away_into.

Why it is right for Metal: a copy that writes the whole level and slice leaves none of the
earlier contents for a program to see, so discarding them first is unobservable. Why Vulkan
allows it, vkspec 1.4.366 line 9241: "The old layout must either be VK_IMAGE_LAYOUT_UNDEFINED,
or match the current layout of the image subresource range. If the old layout matches the
current layout of the image subresource range, the transition preserves the contents of that
range. If the old layout is VK_IMAGE_LAYOUT_UNDEFINED, the contents of that range may be
discarded." The range is the subresource the copy then writes whole. For a heap-placed texture,
line 32552: "If the first alias is not host-accessible, then the bytes affected are those
overlapped by the image subresources that were written": the copy writes those bytes in any
form, so the discard leaves nothing undefined that the copy's write would not.

Why: on the Radeon 780M (RADV PHOENIX, Mesa 26.2.6, kernel 7.3.3), a buffer-to-image copy that
refilled an R8 1920 x 1080 DCC-compressed image in place left one whole aligned 4x2 cell of the
previous contents in about 2 to 4 of 1000 refills, measured on R8 at 1920 x 1080; no layout of
the copy and no barrier stopped it (GENERAL 6 of 3000, no move between refills 11 of 3000, job
m3-max-76144), and the validation layer 1.4.363.0 with synchronization validation reported
nothing while it reported a hazard planted for it. A pure C repro of the calls (job
m3-max-76150, 4000 repeats an arm): the move from home 7 stale, from undefined 0,
RADV_DEBUG=nodcc 0, without COLOR_ATTACHMENT 0. Through ash in job m3-max-76165 (archives of
build m3-max-76163): the same image refilled with the move from undefined 0 of 4000, beside the
move from home 14 of 4000; through rt with this form, CONTROL, W2048 and H (the consumer's
shapes) 0 of 4000 each. Mesa's source was not read for this change.

whole_copy_in.rs holds the move's old layout for whole and short regions, levels past the
first, a 3D level's depth, one aspect of depth and stencil, and a texture over a buffer; and
1000 whole refills of an R8 1920 x 1080 render target through rt, each read back whole and
compared byte for byte.
2026-11-26 23:59:13 -08:00
Anees Iqbal 56a94f060d Runtime docs: a block's chunks name the Unix-only sparse_block without a link
Block::_chunks is on every target, but sparse_block is #[cfg(unix)], so a private-items rustdoc
for a Windows target could not resolve the intra-doc link (found by the Direct3D 11 hand-over
lane's rustdoc of x86_64-pc-windows-gnullvm at 57dcc7f826). The field's doc now names the
function as code, on Unix, and the comment is rewrapped to 100 columns. Docs only.

Checked by a private-items rustdoc of metal2vulkan-runtime with -D warnings for
x86_64-pc-windows-gnullvm, x86_64-pc-windows-msvc and the Linux host.
2026-11-26 23:21:13 -08:00
Anees Iqbal 57dcc7f826 Runtime: the plane's import extent check has a test with no device; the layer's silence is noted
The planner's two additions before landing.

The maxExtent refusal had only a Windows device test, and on the UHD 630 the import query answers
what the plain query does, so no card in the lab fails without the check. The check is now one
function, texture::plane_within (a plane of one 2D layer against the import query's answer, which
d3d11_plane_form calls), compiled for Windows and the tests, and
a_plane_past_its_import_s_max_extent_is_texture_size (no device, every leg) gives it an import
answer one texel narrower, then one shorter, than a 64x32 plane: each is Limit::TextureSize
carrying the import's extent; an answer of the plane's own extent passes. Replacing the check
with Ok fails it. Removing d3d11_plane_form's call is not caught on Linux, where that function
is not compiled; no card in the lab shows the import check firing on its own.

The Khronos validation layer does not track a Direct3D 11 import's layout: on the UHD 630, layer
1.4.363.0 reported neither the old form's first acquire from the general layout (job
m3-max-76170) nor the new form's from the undefined layout (job m3-max-76174). The Layout
paragraph of import_d3d11_surface and the first-use test's doc say so, so its silence is not read
as evidence.
2026-11-26 23:09:04 -08:00
Anees Iqbal 55f6c2760b Runtime tests: the part builder test's shape names its types, as clippy asks
Clippy under --cfg m2v_gpu at 9737a44d98 (job m3-max-76168) refused plane_parts' `shape` return
type as too complex (clippy::type_complexity, denied by -D warnings). The parts and the hand-overs
asked for are now named types. No test changes what it checks.
2026-11-26 23:04:24 -08:00
Anees Iqbal 9737a44d98 Runtime: a Direct3D 11 plane's first acquire names the undefined layout unless an access was reported
A plane's image is made undefined (VUID-VkImageCreateInfo-pNext-01443) and Vulkan takes it as
general only "when they are accessed in Vulkan after external access" (section 12.5.2). Every
acquire named the general layout as its old layout, so where rt used a plane before any
Direct3D 11 access (the consumer's transfer fill of a new target, or a guest command buffer that
writes the plane first), the acquire's old layout was neither the image's current layout nor
undefined, past section 12.5.1 ("the old layout value must either equal the current layout of the
image subresource (at the time the transition executes), or else be VK_IMAGE_LAYOUT_UNDEFINED").

Now a plane's first acquire recorded, in recording order on the submit thread, names the
undefined layout, unless the surface's external_writes_done was called before it; every later
acquire, and every release, names the general layout, as before. The plane's existing once-only
move-home flag (Image::homed) carries it: a Direct3D 11 plane, which no upload moves, is now made
with the flag clear and `first` undefined, its first acquire sets it as it moves the plane from
undefined, and external_writes_done sets it on the host for each plane of a Direct3D 11 surface,
with no GPU work. homing() never moves such a plane, so an upload that copies into one leaves its
move to the acquire ahead of it. VUID-VkImageMemoryBarrier-srcQueueFamilyIndex-12332 allows either
old layout, so the barrier is the same one with another old layout: no wait, copy, clear or
submission is added.

The consumer's precondition now includes external_writes_done after every Direct3D 11 access,
before the commit of the command buffers that use the plane: without it, the plane's first
acquire names the undefined layout, which need not preserve the contents (section 12.5.1), so the
device may discard what Direct3D 11 wrote. The Layout, Ownership and precondition paragraphs of
import_d3d11_surface, the d3d11 module's doc, external_writes_done's doc and the runtime README
say so.

The test commit's every_device_acquires_a_direct3d_11_plane_from_undefined_only_before_any_access
states this rule; its red run is of 74c3940054.
2026-11-26 23:02:17 -08:00
Anees Iqbal 74c3940054 Runtime: the Direct3D 11 tests and the sparse wait compile on Windows without warnings
Three fixes the Windows cross-build of 7c5df5a317 found (the gnullvm target under --cfg m2v_gpu,
job m3-max-76160):

- The maxExtent refusal test printed a vk::Extent3D and the first-use test compared and printed
  vk::ImageLayout values with Debug, which ash's types do not implement here: the extent prints
  as its three numbers, and the layouts compare and print as their raw values.
- Since the part builder returns the parts, the only change to them after it is the sparse bind's
  wait, made on Unix hosts alone, so `let mut parts` was an unused mut on Windows (a warning, an
  error under -D warnings). The owed wait is now read into one binding on every host, None where
  the host has no such import, and the mutation compiles everywhere.

No behaviour changes.
2026-11-26 22:59:32 -08:00
Anees Iqbal 7c5df5a317 Runtime tests: a Direct3D 11 plane's first acquire before any access names the undefined layout
A plane's image is made undefined (VUID-VkImageCreateInfo-pNext-01443), and Vulkan takes it as
general only "when they are accessed in Vulkan after external access" (section 12.5.2). Every
acquire of a plane names the general layout as its old layout, the first included, so where rt
uses a plane before any Direct3D 11 access (a transfer fill of a new target, or a command buffer
that writes the plane first), that acquire's old layout is neither the image's current layout nor
undefined (section 12.5.1: "the old layout value must either equal the current layout of the
image subresource (at the time the transition executes), or else be VK_IMAGE_LAYOUT_UNDEFINED").

This test states the rule and fails on this tree:
every_device_acquires_a_direct3d_11_plane_from_undefined_only_before_any_access (Windows, m2v_gpu).
rt writes picture 3 into a new surface's planes before any Direct3D 11 access: each plane's first
acquire must name the undefined layout, and the acquire of rt's next read, after Direct3D 11 read
picture 3 exactly, the general layout. On a surface Direct3D 11 drew first and the consumer
reported by external_writes_done, every acquire names the general layout, the first included, and
rt reads picture 1 exactly: the control, which passes here.

The acquires are read from Work::acquired, a record only the device tests compile: each plane
acquire's image and old layout as the hand-over records it, in recording order.
2026-11-26 22:57:39 -08:00
Anees Iqbal 1b3bd24aba Runtime: a Direct3D 11 plane past its import's maxExtent is Limit::TextureSize
A plane's extent was checked only against the image format query without the handle type
(plane_plan's prepare). VUID-VkImageCreateInfo-extent-02252 bounds an image's extent by
imageCreateMaxExtent, which for an image made with VkExternalMemoryImageCreateInfo is the query's
answer with VkPhysicalDeviceExternalImageFormatInfo naming the handle type: a device may make an
imported image smaller than a plain one, and a plane between the two would be created past the
limit.

The import query (d3d11::import_query) now answers the image's properties with the handle too, and
d3d11_plane_form checks the plane's extent against them once its usage and format list are
final: past it, Limit::TextureSize carries the import's maxExtent. The existing kind has the
same meaning (an extent past what the device makes of the image), so no new variant; its doc and
basis name the import's query, and docs/REFUSALS.md is regenerated (a second NoImport site, the
query failing at the final form, which the earlier checks make unreachable on a conforming
driver). The extent check itself is one function now (texture::size_within), the plain path's
included, unchanged there.

The Windows refusal test asks for a luma one texel wider than the import query's maxExtent and
expects TextureSize at that answer or the plain query's below it, printing both. On a device
whose two answers are equal the plain check refuses first, so that run does not show the import
check firing on its own.
2026-11-26 22:55:11 -08:00
Anees Iqbal 2d6ed58921 Runtime: each vkQueueSubmit2 part hands its own Direct3D 11 planes over
A group sent member by member is one vkQueueSubmit2 a part, each with a progress value of its own,
and each command buffer retires at its own part's value. The planes' hand-over was per group: one
acquire ahead of the first part and one release at the end of the last, taking the last part's
signals. A member ahead of the last that used a plane was then seen complete before that plane's
release had run, and the consumer's precondition (rt's command buffers that use a plane have
completed before Direct3D 11 accesses it) let Direct3D 11 take the plane while rt still owned it,
its release still queued (Vulkan 1.4, section 12.10.1: "Ensure the release operation has completed
using semaphores or fences"; 7.7.6: an ownership transfer may access all memory bound to the
subresource). Found by reading; whether any run met it, and whether it made a hang on any driver,
is not known.

Now a group records which planes each part's segments use, by the part the segment is in (the
leads before it), from what each segment keeps (Segment::planes), and the part builder hands each
plane-using part's planes over in that part: the acquire at its head, after the global barrier as
before, and the release at its end, taking that part's last signals, its progress value among
them, so it adds no submit info and no submission. The uploads' planes go with the first part. A
group sent as one part is unchanged: one acquire ahead of everything, one release after
everything. Each plane-using part of a group sent apart adds one acquire and one release command
buffer, with no wait, copy or submission added.

Metrics::d3d11_plane_submissions now counts vkQueueSubmit2 calls that hand planes over: a group
sent as one counts once, a group sent apart once for each of its calls that uses a plane. The new
Metrics::d3d11_plane_parts (no Metal counterpart) counts the calls among those that are parts of a
group sent member by member: the path's evidence. The Ownership paragraph (d3d11.rs), the runtime
README, Segment::planes, external_writes_done, release_surface_to_external and the metric docs
say per vkQueueSubmit2 where it was per submission. api_signatures.tsv blessed for the new field;
docs/REFUSALS.md unchanged by its regeneration.

The test commit's plane_parts tests (no device), red on that commit (job m3-max-76147), and its
Direct3D 11 apart test state this form; the apart test now asserts d3d11_plane_parts too.
2026-11-26 22:49:51 -08:00
Anees Iqbal dbd332e087 Runtime tests: each part of a group sent apart hands its own Direct3D 11 planes over
A group sent member by member is one vkQueueSubmit2 a part, each part signalling a progress value of
its own, and each command buffer retires at its own part's value. The Direct3D 11 planes' hand-over
is still per group: one acquire ahead of the first part and one release at the end of the last, so
a member ahead of the last that used a plane is seen complete before that plane's release has run,
and the consumer's precondition (rt's command buffers that use a plane have completed) lets
Direct3D 11 take the plane while rt still owns it (Vulkan 1.4, section 12.10.1: "Ensure the release
operation has completed"). Found by reading; whether any run met it is not known.

These tests state the per-part form and fail on this tree:

- plane_parts (no device, every leg): the part builder, now its own function (`submit::parts`)
  with the per-group placement unchanged, given a group of an upload and two leads and the planes
  each part uses. Each plane-using part must acquire at its head and release at its end, the
  release taking the part's signals and progress value; a part using no plane takes neither; the
  uploads' planes go with the part ahead of the first lead. The negative control, a group sent as
  one part, hands over once ahead of everything and once after, as today, and passes here.
- every_device_hands_direct3d_11_planes_over_in_each_part_of_a_group_sent_apart (Windows,
  m2v_gpu): behind a queue's busy work, a read of the planes and a second command buffer join one
  group; a run of 1 s seen before it goes (QueueInner::ran, the state retirements set) sends it
  member by member. Two reads must hand over twice each way and make two vkQueueSubmit2 calls; a
  read and a buffer copy once each way in two calls. Sent as one part (send_now), the two reads
  hand over once: the control.

The extraction moves no command buffer: the acquire still leads the uploads and the release still
takes the last part's last signals.
2026-11-26 22:46:01 -08:00
Anees Iqbal 0c494452b5 Runtime docs: the descriptor's cost line wrapped to the README's width
6ae4d7dbaf left one line of the AttachmentFormats bullet at 123 characters. The bullet's
last seven lines are wrapped again to 100; no word changes.

Verified: no line of the bullet passes 100 characters (python -I check); docs only.
2026-11-26 21:00:22 -08:00
Anees Iqbal 6ae4d7dbaf Runtime docs: what keeping a render state's descriptor costs its make
Every render state now keeps its descriptor (the state drawn without the colours past its
pass's last attachment is made of it), so every make copies it and every drop frees the copy.
The README's line said what a set and a draw cost and what the kept descriptor holds alive,
but not this. It now states it: a make of a content the device already holds takes about
13,500 user-space instructions on lavapipe against about 11,800 without the keep, once a
state and never a draw.

Verified: the figures are the lane's scratch count test, release, lavapipe (llvmpipe, LLVM
23.1.1), mean of 200 calls, 5 runs each: m3-max-75974 at the branch (13,494 to 13,506) and
m3-max-75975 at development 0ae823f5e7 (11,806); read from both jobs' logs. Docs only.
2026-11-26 20:59:54 -08:00
Anees Iqbal be98ac249c Conformance: the between case makes its targets over the array it fills, as clippy asks
clippy (needless_range_loop, -D warnings) refused the loop that indexed targets[at] by the
colour's index (job m3-max-75986, msi, plain configuration); the loop now walks the array
it fills. The calls and their order are unchanged, so the recording stands.

Verified: formatted; clippy in all three configurations runs next.
2026-11-26 20:53:40 -08:00
Anees Iqbal d5b2379d91 Conformance: the between case declares its interpolation notice, and its refusal is a ledger row
`conformance replay --cpu` of both unattached-colour cases on lavapipe (job m3-max-75983,
at 981d1c0d81) read:
- pass-pipeline-color-unattached: announced, every value equal to Metal's; the one
  difference is the native note native-nan-encoding, which the suite's native set holds.
- pass-pipeline-color-unattached-between: refused at case/drawn/pass:lacking
  (DrawKind::AttachmentFormats), as the form intends, and divergent at case/notices:
  our side announced device-interpolation, which the case declared nowhere.

The between case's fragment, cg_five, writes every colour from an interpolated varying,
so the case now declares device-interpolation (a notice declaration, which loosens no
value). known-gaps-rt.tsv gains the refused row, venue *: the refusal is the same on every
device (lacked_past answers None for that shape). docs/CONFORMANCE-COVERAGE.md is
regenerated: 191 case modules, 1339 recordings, both new modules every field compared.

Verified: the replay rerun and the conformance crate's tests follow in the next job.
2026-11-26 20:51:35 -08:00
Anees Iqbal 981d1c0d81 Runtime docs: a state drawn without the colours past its pass's last attachment, and its costs
README, Render encoders: a pipeline state that names colours past its pass's last colour
attachment, the rest of its formats and its sample count the pass's, is drawn as plain
Metal draws it (pass-pipeline-color-unattached, Apple M3 Max, macOS 27.0.1, job
m3-max-75903), through the state of its descriptor without those colours. The costs, each
from a run:
- the first such set and draw: about 3.3 ms once per state and pass shape on an RTX 5080
  Laptop card, from a proxy (a state of the same functions with colour 0 alone; jobs
  m3-max-75918 and m3-max-75925);
- each later such set: about 14,500 user-space instructions on lavapipe (job m3-max-75974,
  release, five runs, 14,510 to 14,517), where a set of a state that renders into its pass
  is 140;
- the descriptor each render state keeps: in states-only plays of two recorded replay
  streams on lavapipe it kept no library alive that was not alive without it (jobs
  m3-max-75968 and m3-max-75969: the bytes of released libraries still alive, at each
  change, equal at this tree and at its base, 29 and 140 changes).
The between shape stays refused (job m3-max-75934). The Gap::Draw list's "a pipeline state
whose formats are not the pass's attachments'" now excepts the shape drawn, and the
first-use list names that state's pipeline under first_use_unfinished_waits.

docs/REFUSALS.md is regenerated (refusal_surface.py): Gap::Draw gains its site in
render.rs (without_colors).
2026-11-26 20:48:06 -08:00
Anees Iqbal 08456a7859 Conformance: Metal's times for the two unattached-colour cases, kept in their recordings
`conformance times --runs 8 --write pass-pipeline-color-unattached
pass-pipeline-color-unattached-between`, built --release at d2d96151a8, on the Apple M3
Max, macOS 27.0.1 (26A434), job m3-max-75970 (the build: job m3-max-75963). Each
recording gained one time record (native Metal, 8 rounds) and nothing else: a comparison
of the JSON before and after shows `times` the one key added and every other key equal.
2026-11-26 20:42:24 -08:00
Anees Iqbal d2d96151a8 Conformance: the two unattached-colour cases hold Metal's recordings to their shapes
metals_recording_draws_colour_0_and_keeps_the_clear_elsewhere holds the recording of
pass-pipeline-color-unattached to the case's codes: colour 0 holds the fragment's codes in
the scissor's rows and the clear in the others, and the command buffer has no error.
metals_recording_writes_colour_1_into_colour_2 holds the recording of
pass-pipeline-color-unattached-between to what job m3-max-75934 showed: the lacking pass's
colour 0 equals the reference's, its colour 2 holds the reference's colour 1 in the drawn
rows (and differs from the reference's colour 2 there), and its clear elsewhere.

Verified: a Python reading of both committed recordings gives each assertion true; the
Rust tests run in the conformance suite's job that follows.
2026-11-26 20:39:35 -08:00
Anees Iqbal ea0bf79d34 Conformance: Metal's recording of pass-pipeline-color-unattached-between
Plain Metal on the Apple M3 Max, macOS 27.0.1 (26A434), job m3-max-75934: three runs,
one outcome, the command buffer complete with no error. Colour 0 of the pass that
leaves colour 1 unset equals the reference pass's at all 64 texels; its colour 2 holds,
at all 32 drawn texels, the reference's colour 1 bytes (RG16Float bits written into the
RGBA8Unorm attachment) and its clear elsewhere. The validated leg stops at the render
call: "For color attachment 1, the renderPipelineState pixelFormat must be
MTLPixelFormatInvalid, as no texture is set."

Verified: the recording is the file record mode wrote in that job, copied back
unchanged; the planes were compared texel by texel.
2026-11-26 20:25:20 -08:00
Anees Iqbal 80ecfdab4a Runtime: draw a state whose colours past the pass's last attachment the pass lacks
A pipeline state that names colours past its pass's last colour attachment, its
formats up to that attachment, its depth and stencil formats and its raster sample
count all the pass's, was refused at the draw as DrawKind::AttachmentFormats. Plain
Metal draws it (pass-pipeline-color-unattached, the Apple M3 Max, job m3-max-75903):
the attachments it has hold the fragment's values, and its validation alone stops it.

set_render_pipeline_state now binds, for such a pass, the state of the descriptor
without those colours (RenderPipelineState::without_colors): a content of its own in
the device's map of contents, lowered on the calling thread where the device holds
none, its fragment function storing those colours nowhere as for any descriptor that
leaves them unset, its samplers numbered at the state's indices, and its pipeline made
by its first draw (a first-use wait). That content renders into the pass under the
exact match draws already take, so no new attachment rule enters a pipeline's make. A
state that renders into its pass takes the same path as before: one renders_into and
the lend. Each state now keeps the descriptor it was made of.

A colour the state names before the pass's last colour attachment that the pass
leaves unset stays refused: plain Metal writes the next colour's value into the
attachment after it (pass-pipeline-color-unattached-between, job m3-max-75934). So do
another format, a depth or stencil format the pass lacks and another sample count.

Test: tests/unattached_colors.rs. Verified: formatted only; the device runs follow.
2026-11-26 20:25:14 -08:00
Anees Iqbal 65966f1c62 Conformance: a case whose pipeline names a colour between two its pass attaches
pass-pipeline-color-unattached-between: a pipeline of colour 0 BGRA8Unorm, colour 1
RG16Float and colour 2 RGBA8Unorm over the owned color_groups fixture (cg_cover,
cg_five), drawn twice in one command buffer: into a pass of all three colours, the
reference, and into a pass of colours 0 and 2 with colour 1's descriptor unset. It
reads both passes' colours 0 and 2, the reference's colour 1, and the command
buffer's status and error.

Why: the runtime's form for a pipeline colour its pass lacks covers a missing colour
between two present ones only if Metal draws that shape too; this case is Metal's
answer for it, taken next on the Apple M3 Max.

Verified: nothing yet (formatted only); the build and the record run follow.
2026-11-26 20:17:48 -08:00
Anees Iqbal e51bc82025 Conformance: Metal's recording of pass-pipeline-color-unattached
Plain Metal on the Apple M3 Max, macOS 27.0.1 (26A434), job m3-max-75903: three runs,
one outcome. Colour 0 holds the fragment's value at all 32 texels of the drawn rows
and the clear at the other 32; the command buffer completes with no error. The
validated leg (MTL_DEBUG_LAYER=1, nslog) stops at the render call: "For color
attachment 1, the renderPipelineState pixelFormat must be MTLPixelFormatInvalid, as no
texture is set."

Verified: the recording is the file record mode wrote in that job, copied back
unchanged (potluck cp), and every texel was checked against the case's codes.
2026-11-26 20:17:48 -08:00
Anees Iqbal 1a2fb91628 Conformance: a case whose pipeline names a colour its pass does not attach
pass-pipeline-color-unattached: a pipeline of colour 0 BGRA8Unorm and colour 1
RG16Float over the owned rt6_pair fixture (rt6_pair_two writes both), drawn in a
pass that attaches colour 0 alone and leaves colour 1's descriptor unset. The case
reads colour 0's level 0, the command buffer's status and its error.

Why: the runtime refuses such a draw as DrawKind::AttachmentFormats (renders_into
asks equal colour counts), and Metal's answer for the shape is not in the tree.
The case is that answer's carrier; its recording is taken next on the Apple M3 Max.

Verified: nothing yet (formatted only); the build and the record run follow.
2026-11-26 19:52:01 -08:00
Anees Iqbal 0ae823f5e7 Runtime comments: coherence's module doc says a texture over a Shared buffer counts as its whole buffer
coherence.rs's list of what a command buffer may write named each texture over a Shared buffer
in an image of its own, and a texture over one as a command names it, without saying which bytes
they count for. As in the runtime README's clause (a129f2cb7f), the code counts the whole buffer
the texture lies over: TextureObject::shared_range (texture.rs:5780) is its named buffer's
BufferObject::shared_range (buffer.rs:654). Comment only; no behaviour change.

Verified: fmt --check and rustdoc -D warnings in the job that follows.
2026-11-26 19:04:14 -08:00
Anees Iqbal a129f2cb7f Runtime docs: a texture over a Shared buffer is settled as the whole buffer it lies over
The runtime README's list of what a command buffer may write, which its completion flushes and
invalidates, names every texture over a Shared buffer in an image of its own (and a pass's
attachments, a binding, a use_resource write, a copy's destination, which may be such a texture)
but did not say which bytes such a texture's settle covers. The code settles the whole buffer the
texture lies over: TextureObject::shared_range (crates/metal2vulkan-runtime/src/texture.rs:5780)
is its named buffer's BufferObject::shared_range (buffer.rs:654, the buffer's whole span), and
coherence::Ranges::of (coherence.rs:212) adds that range to what is written for a texture in an
image of its own. The list now says so, in one clause. Docs only; nothing narrowed.

Verified: fmt --check and rustdoc -D warnings in the job that follows.
2026-11-26 19:03:45 -08:00
Anees Iqbal afd4373cdb Tests: the event test's completion counts the flush of the segment after its wait
On the RTX 5080 (b5080 entry in job m3-max-75853) the event test's completion read
[2, 128, 1, 64, 0, 64, 64, 0, 0]: the command buffer's segment after its wait for the host's value
is a submission of its own, which flushes the buffer again at the submission's point (64 bytes),
then the completion settles it at the retirement's (64). The test asserted no flush at the
submission's point there. It now asserts both flushes and their points; the doc comment says so.

Verified: cargo fmt only; the 5080 run follows.
2026-11-26 18:48:55 -08:00
Anees Iqbal e129303c42 Tests: the point-counting test makes the calls the runtime makes at each point
The first run (lavapipe, job m3-max-75846) settled at the submission's point too, which the
runtime never does, so the identity calls() asserts (the invalidated bytes are the retirements',
the events' and at most the staging's) failed there: [1, 128, 1, 128, 0, 128, 0, 0, 0]. The test
now flushes at the submission's point, settles at the retirement's and the event's, and does both
at the staging point, as the product's sites do.

Verified: cargo fmt only; the lavapipe job follows.
2026-11-26 18:48:55 -08:00
Anees Iqbal 5cd3228dbc Runtime: Shared coherence's flushed bytes by point, and the host time inside its calls
What: six public Metrics fields, after shared_coherence_failures.
- shared_reach_flushed_bytes, shared_retire_flushed_bytes, shared_event_flushed_bytes and
  shared_staging_flushed_bytes: each flush's bytes once more, by the point that made it
  (coherence::Point: the flush before a submission; the settle as a command buffer retires; the
  settle before a GPU-raised shared event value is seen; the runtime's own host accesses:
  replace_region, upload_region, get_bytes and the zero source). A settle's flush counts at its
  settle's point.
- shared_flush_nanos and shared_invalidate_nanos: host_time() read at each
  vkFlushMappedMemoryRanges and vkInvalidateMappedMemoryRanges call and at its return (a settle
  times its two calls apart), one Relaxed add each. The zero source's flush, made outside
  Coherence, is timed the same way.

The identity: reach + retire + event + staging == shared_flushed_bytes, and
retire + event <= shared_invalidated_bytes <= retire + event + staging (the excess is get_bytes's
settles), for a read made while no call is under way and for the difference of two such reads.
A device whose Shared type is host-coherent holds no Coherence, reads no clock for these and
keeps all six at 0.

Why: issue 182's Meteor Lake session averages 67 MB a frame of flushed and settled bytes, and its
counters cannot say which point carries them, nor how long the driver's calls take. Counting and
timing only: no site narrowed, no form, switch or device check.

Tests (crates/metal2vulkan-runtime/src/tests/coherence.rs): calls() returns the four points with
the five totals and asserts the identity on every delta it reads; each site under the forced view
asserts its bytes at its own point (a fill, a blit, replace_region, get_bytes, a GPU-signalled
event seen, the texture-over-buffer, use_resource, use_heap, function-table, upload and
written-only sites through one_submission); a device with no coherence state counts nothing and
no time over its life; where calls ran the time fields are not 0. A new device test,
a_coherence_state_counts_each_call_at_its_point_and_times_it, makes a coherence state of its own
over the viewed Shared type, so it runs on lavapipe too, where the floor refuses the view: a
flush and a settle at each point count there alone.

Docs: the Metrics fields' comments, coherence.rs's module doc, the runtime README's Shared memory's
coherence and its known gap; api_signatures.tsv blessed (six field lines). refusal_surface.py
--check passes unchanged.

Verified: cargo fmt only when committed; the build and device jobs follow.
2026-11-26 18:48:55 -08:00
Anees Iqbal 0ae2000a78 Runtime tests: the copy-in span test asserts the ordering its doc states, on the GPU's counter
every_device_leaves_a_copy_in_out_of_the_gpu_span_it_goes_ahead_of says "a start written
before the copy-in ends puts the upload inside it". It checked that with a bar on span
lengths, the command buffer's span times 4 under its copy-in's, and that bar measured the
card's load.

In the forced two-copy view it was red in three of three Intel suite runs:
- the Iris Xe in round 1b908464ea-1126-1752 (m3-max-75798): copy-in 12,017 us, span
  34,975 us;
- the UHD 630 on Windows in the same round (m3-max-75776): copy-in 29,668 us, span
  142,758 us;
- the Iris Xe again, from a stamp-printing probe build of the whole suite (m3-max-75836).

Two printed runs on the Iris show the start after the copy-in's end both times:
- alone (m3-max-75815), it passed: the command buffer started 53 ticks (2.8 us) after
  its copy-in's end, and its span was 3 us against an 8.2 ms copy-in;
- inside the whole suite (m3-max-75836), it failed: the starts came 53 and 58 ticks
  (2.8 and 3.0 us) after the copy-ins' ends, while the spans stretched to 37 and 50 ms.
The 52.083 ns ticks come from the probe branch steelbrain/irisspan-probe, which never lands.

This is neither an adjustment nor a skip. The cause is shown in those two runs, and the
test now asserts the claim its own doc states:
- The device keeps one test-only record of each pair of timestamps the completion thread
  reads, a Metal command buffer's or the runtime's own, in retirement order, in raw ticks
  (Core::stamped, times::Stamped). It replaces tick_spans, which held only Metal command
  buffers' durations. The calibration test reads its durations from the same record.
- The test clears the record before did_modify_range. It then asserts that the record
  holds the copy-in's pair and then the command buffer's, both read, and that the command
  buffer's start tick is at or after the copy-in's end tick (starts_after, on Ticks::nanos,
  across the counter's wrap). The span-length bar is gone.
- "Both read" replaces "the copy-in's span > 0", which contradicted a gap the runtime
  README's known gaps already state: on Mesa's Apple-GPU driver, an upload or a copy-in's
  span is 0. Equal stamps pass the ordering.
- Ticks::nanos becomes crate-visible for the comparison. Product behaviour is unchanged:
  every new item is under cfg(test).

The negative control is a_start_before_the_copy_in_s_end_fails_the_ordering. It is a unit
check of the comparison, since no device writes the start early: a start 1 tick before the
end fails, and a start after it, at it, or past the counter's wrap holds.
2026-11-26 18:33:08 -08:00
Anees Iqbal cc89c80bdc Validation observations: drop the Metal rows recorded under older oracle ABIs
3934 of the 6297 committed Metal rows were recorded under an ORACLE_ABI older than the
current metal-literal-resources-v49 (v18 to v48). All of them are in environments no
reference names: apple-m2-macos26.5.2, apple-m3-max-macos26.5.2, apple-m3-max-macos26.7,
local-metal and local-metal-m2. c3-references.json's one reference is the primary,
apple-m3-max-macos27.0.1. No such row matches a case's dependency, so none compares
anything. Each one also made its case's Metal state stale in corpus-status: the index's
state is stale while any row is. That flag stood on 2184 of the 2363 cases, so it could not
show a case whose current row had gone stale. The 26.7 rows went stale at 4def63989b
(2026-11-03, ORACLE_ABI v49); the older ones went stale earlier. Every one predates
fc9c99916d.

Each case keeps its one v49 row in the primary: 2359 qualified and 4 reference gaps.
Texts that named the dropped environments now name the primary, after checking that the
answers are the same there:
- the rationales of three cases (shard_023 lines 26 and 27, shard_052 line 43). Their
  26.7 and 27.0.1 rows have the same output and input digests, and a rationale is not
  part of a case's identity;
- the notes of the four reviewed reference gaps in cutover/c3-reviewed.json. Their 27.0.1
  rows record the same GPUFamily10 reference gap.

Search for readers of a non-primary Metal environment:
`git grep -n -E 'apple-m3-max-macos26\.7|apple-m3-max-macos26\.5\.2|apple-m2-macos26\.5\.2|local-metal'`
outside corpus/observations, at 467e7441ef. Zero readers. The hits left are prose:
- c3/reference.rs:223 (an example of the id's format) and c3/reference/tests.rs:12 (the
  naming function's test);
- comments that state where a measurement was made: lower/sampler/footprint.rs:6 and its
  tests.rs:3, whose eight cases' 26.7 and 27.0.1 rows are equal; and
  tests/engine_simd_past_n.rs:148, a probe's readings with no committed row. They stay as
  written, so the translator's source fingerprint does not move for a comment.

No version bump is owed. The index clears and reloads every Metal row on each sync
(index.rs:603-608), and no versioned cache keys on them.

Verified on the same row deletion (job m3-max-75793 on the Intel ARL laptop node, at the
first form of this change, a0d54d649c):
- corpus-index and corpus-index --check rc=0 before and after;
- corpus-status over every case: 2184 metal=stale and 2 current before; 0 stale after
  (12 current and 4 reference_gap listed, for their engine slots);
- public case qualification on lavapipe rc=0: 20 cases metal=current with vulkan=current,
  and 1 with metal=current and vulkan=stale (a committed Vulkan row, unchanged here);
- the validation suite 1312 of 1312.
Read from the committed files (python -I): 2363 rows kept, 3934 dropped, 64 shard files.
Each of the 42 committed Vulkan rows matches a kept v49 row on the case, the input digest
and the output digest.
2026-11-26 18:05:45 -08:00
Anees Iqbal 467e7441ef Runtime docs: what with_present_queue's closure may wait for, by its reason
The contract said `f` "waits for no work of the runtime's". By its words that forbids a
vkQueueWaitIdle on the presenting queue, which a consumer runs under the lock where its
device has no present fences, and which Vulkan requires to run with the queue externally
synchronized. It now says what holds. `f` waits for nothing that needs a thread of the
runtime's or the lock it holds. A wait for work already submitted ends. Where the family
has one queue, the wait holds every submission of the runtime for its length.

The reason a wait for submitted work ends (files read at 0c0aab0df9): no batch the runtime
submits waits on a signal that only a later submission gives.
- Search: `git grep -n -E 'wait_semaphore_infos|wait_semaphores\(|p_wait_semaphores|queue_bind_sparse|queue_submit2?\('`
  over crates/metal2vulkan-runtime/src, tests excluded. Its submission hits: submit.rs:2803
  and :2824, and import.rs:335. The other hits are host-side semaphore waits.
- A submission's only semaphore waits are its first segment's wait for a sparse bind
  (submit.rs:2783-2791, `Sparse::owed`). That bind's signal was submitted earlier, by
  vkQueueBindSparse under the same runtime-queue lock (import.rs:308-341), before `owed`
  is set.
- A bind sparse waits on nothing.
- Segments stage signals only (submit.rs:2278-2311, `stage`).
- encodeWaitForEvent submits no semaphore wait: the submit thread holds the segment until
  the event's value is reached (command.rs:557-563).
- The runtime makes no present and no acquire call: zero hits for queue_present and
  acquire_next_image outside the tests.

Docs only, outside pin 1b908464ea.
2026-11-26 18:02:57 -08:00
Anees Iqbal 0c0aab0df9 Runtime docs: what Metal showed for a handler's wait, in two refusals
Refusal::InScheduledHandler and Refusal::WaitOnOwnThread said Metal runs
handlers on a thread of their own, with no quote or run behind it. They now
say only what the conformance probe cross_queue_handler_waits measured on
Metal (Apple M3 Max, macOS 27.0.1, 10 runs a case): a handler waiting for
another queue's completed handler holds neither queue back (its wait ended
7.6 to 9.3 ms after it began), and a scheduled handler waiting for a
completed handler of its own queue never ends (the 5 s bound in every run,
both handlers on one thread), so one queue's handlers run one at a time.
What rt does is unchanged and was already stated.

Verified: refusal_surface.py regenerates docs/REFUSALS.md with no change and
--check passes. Docs only; lands after the pin tip is fixed (planner).
2026-11-26 17:49:37 -08:00
Anees Iqbal 1b908464ea Authored-compile table: add the fifteen float and half function-constant cases
The census's --bless-additions at 031c37d674 adds 15 new cases, all compiled on the
table's 9 profiles. It removes no case, adds no profile and changes no existing cell
(changed_cells=0, regressions=0, failed=0). The artifacts_at line takes the product's
new fingerprint.

Verified: job m3-max-75761 on the Apple M3 Max. 2363 cases, 21267 cells,
18973 compiled and 2294 refused, 61 s wall, and the parent's peak RSS was 102 MiB.
2026-11-26 17:48:10 -08:00
Anees Iqbal 031c37d674 Golden tables: bless the float and half function-constant fixtures at semantics 2307
The bless at 520c0d3108 adds the cells and printouts of the fixtures fc_float_gate and
fc_half_gate: 90 new golden cells (6 subjects on 15 profiles), 0 gone, 0 under a changed
fixture source or profile, and no existing cell moved. The semantics line goes from 2305
to 2307. It also adds the two engine printouts, fc_float_gate.txt and fc_half_gate.txt.

Verified: job m3-max-75756 on the Apple M3 Max. The golden check before the bless failed
only on those 90 new cells. The inventory check passed (15 of 15, macOS, .air.ll rows
included). bless_engine_inventory, bless_golden_hashes and bless_engine_goldens each
returned 0 (llvm-as from llvm@21).
2026-11-26 17:43:53 -08:00
Anees Iqbal 520c0d3108 Runtime docs: what a device's last drop and a completed wait wait for
Device: a last handle dropped on the consumer's thread tears the device down
in that drop, and so waits, with no deadline, for every scheduled and
completed handler of a command buffer still to retire, every listener whose
value is reached before the threads end, and every BlockMappings hook or
import release the block-maker thread runs: one that waits for a lock the
dropping thread holds never lets the drop return (halt with no deadline,
device.rs's Drop for Shared).

CommandBuffer::wait_until_completed: elsewhere than the completion thread it
waits for the command buffer's completed handlers to return, as Metal's
does: on the Apple M3 Max (macOS 27.0.1, job m3-max-75735), a thread that
held a lock across the commit and waitUntilCompleted, with the command
buffer's completed handler taking that lock, did not return within 10 s; the
same program without the handler's lock ended in 15 to 69 ms. Those handlers
run on the device's one completion thread with every queue's, so a handler
or listener of any queue that runs first and waits for a lock the waiting
thread holds never lets the call return.

add_completed_handler names the one completion thread for all queues.
add_scheduled_handler says what the runtime does in place of a claim with
no quote or run behind it ("Metal runs a scheduled handler on a thread of
its own"): the calls it refuses are refused because the handler runs on the
submit thread they would wait for; and, the device having one submit
thread, every queue's later submissions wait while a scheduled handler runs
(it said its own queue's), as submit.rs's pass runs the handlers before the
submission it closed and before any later group.

Docs only; rustdoc -D warnings and the refusal surface check in the lane
report.
2026-11-26 17:35:22 -08:00
Anees Iqbal 1b008bfd6e Runtime tests: a new arena block's map hook leaves another thread's arena dispatch free
every_device_takes_a_new_arena_block_off_the_arena_s_lock opens each device
with a BlockMappings hook. Thread A dispatches a kernel of 36 KiB of private
memory a thread over 8 threadgroups under a 64 MiB arena budget: its new
32 MiB block passes the pool's 16 MiB allocations, so the take makes an
allocation on thread A and the hook's map runs there. The hook, armed by
thread A for its first map of a Private allocation of at least 32 MiB,
signals that it is inside and waits up to 10 s for thread B's dispatch of
the same kernel over one threadgroup, which takes an arena block too, to
return. With the arena's lock held across the take, B waits for the lock
and the hook waits out its 10 s, which the test fails on (bounded, no hang);
off the lock B returns first. Both command buffers then complete with the
CPU's answers.
2026-11-26 17:35:22 -08:00
Anees Iqbal 243657ef33 Runtime: the arena's block take runs off the arena's lock
arena::take held the device's arena lock across Core::take_memory. A take
that no free range fits makes an allocation on the dispatching thread and
runs the consumer's BlockMappings::map there, so the hook ran under the
arena's lock: another thread's dispatch whose kernel keeps an arena waited
for that lock, and a hook that waited for such a thread never returned.

Now the lock is taken once to read the device's last block (the fast path
is unchanged: one lock and the Weak's upgrade, nothing added where a block
fits) and once more, after the take, to store the new block's Weak. Two
dispatches that miss at once each take their own block and keep it, held by
its command buffer until it retires; the device keeps the longer as its
last. The arena stays within its bound: each block is its own dispatch's,
at most the budget or one workgroup's slots where those pass it, and a race
adds one such block for each dispatch that missed, never a longer one. A
block read under the lock and found too short is dropped off the lock.

BlockMappings::map and ::unmap now say "never under the pool's or the
arena's lock", and that a hook never waits for a lock a thread inside a
runtime call holds. Callers checked for map (memory.rs Pool::map): Pool::own
from Pool::take, reached through Core::take_memory by Device::take_block
(no lock), places.rs texture places (blocks lock dropped first), the
visible function table (no lock), arena::take (fixed here), the indirect
template (templates guard ends with its if-let) and indirect command
buffers (no lock); ahead() on the block-maker thread (pool lock dropped
first) and stock() in Device::new (no lock). For unmap: Pool::map's late
unmap (after its drop), free_idle on the block-maker thread (pool lock
dropped first), unmap_all from halt (quiesce and the last drop's teardown,
the threads lock released first) and free_all at the core's drop (&mut,
no lock). "No runtime lock" is not claimed: a device's last drop, which
runs unmap_all, can happen wherever a handle drops, and those sites are not
all audited.

Verified by the device test of the next commit on lavapipe, and by the same
test over the unfixed take as a negative control (jobs in the lane report).
2026-11-26 17:35:22 -08:00