Commit Graph
9750 Commits
Author SHA1 Message Date
Anees Iqbal ca370da605 Replay: the stand-in for the other API is Linux's and macOS's; the validation crate's clippy for Windows passes
The validation crate builds for x86_64-pc-windows-gnullvm (with llvm-mingw for the bundled
SQLite, as win-cross.sh builds command-replay for the Windows play), and its clippy there (job
m3-max-78094 at abf7b8f873, plain and under --cfg m2v_gpu) reported the stand-in: its writes wait
under the crate's bounded fence waits (gpu::wait::vulkan), which the crate keeps to Linux and macOS,
and its empty extension list for an NT handle did not type-check. Rather than a Windows form of the
fence wait, the stand-in is Linux's and macOS's alone: its import is fd-only, and on any other host
StandIn::new says why it is absent, so each landing is counted unwritten with that reason and the
play goes on (the S1 ruling's handling of a stand-in that cannot be made). The NT-handle import,
which no build compiled, is gone, and so is the device test's Windows arm: the test, under the
layer through candidate::validated, is Linux's and macOS's. A plane's rows are the caller's tuple.

The same clippy reported lib-test code that predates the exported surfaces and never compiled for
Windows: build_support_tests.rs hex-encoded through crate::hash (not on Windows; now sha2's own
lower-hex), and gpu/wait.rs's tests of the fence and Metal waits' own endings, which Windows lacks
(now gated as those variants are).

docs/REPLAY-STREAM.md section 10 says the stand-in is Linux's and macOS's and what Windows counts.
2026-12-02 05:39:49 -08:00
Anees Iqbal b111f209ec Replay: the stand-in's device keeps its loader word as the candidate's context does; a doc line no longer starts a list
Clippy of the validation crate (job m3-max-78070, aeb43cd8b7, default and m2v_cpu_icd configs)
refused the stand-in's direct vkGetDeviceQueue, vkAllocateCommandBuffers and vkDestroyDevice: the
crate's clippy.toml keeps those loader-served calls behind the loader word a driver may write over
while reporting a message (candidate/platform/loader_word.rs). The stand-in now records its device's
word as vkCreateDevice returns it and puts it back before each such call on Linux and macOS, with
the crate's #[expect(clippy::disallowed_methods)] at those sites as VulkanContext has; LoaderWord is
re-exported to the crate for it. A redundant deref and a doc line that began with "+ " (a list
item to rustdoc's markdown) are fixed.
2026-12-02 05:39:49 -08:00
Anees Iqbal edc657331a Replay: the exported-surface device test plays under the validation layer; the format doc's exported-surface records
The device test of the exported-surface snippet ran with the layer on the loader's path but not
enabled: the validation crate's replay tests make their instance with no layer. Each of its plays
now runs under the Khronos validation layer as the candidate runs do (candidate::validated, made
reachable from the replay tests): the device must list the layer as an active tool, and any
message the layer logs fails the test, the stand-in's device's included, since it lives on the
runtime's instance.

docs/REPLAY-STREAM.md: section 4 points at the records, section 7 gives them (m2v.newExportedSurface,
m2v.surfacePlane, m2v.exportSurface, m2v.surfaceWritesDone, release), and section 10 says what the
player does at each, the stand-in for the other API, what a player cannot reproduce, the runtime's
hand-overs with its Metrics docs as the contract, the hand-over and exported-surfaces report lines
and counters, --video-handle's override, and `command-replay snippet video-surfaces`.

Verified before this commit (job m3-max-78051, f58ff0a2b3, lavapipe on msi, layer on the path
but not enabled): dma-buf in place and opaque-fd in the copy form each play 3 frames that agree
with the contract (acquires 2, releases 3 in frame 0 and 2 after) and 6 checks that match.
2026-12-02 05:39:49 -08:00
Anees Iqbal 02325796bc Replay: the exported-surface records, played through the runtime's surface call with a stand-in for the other API
The player plays m2v.newExportedSurface, m2v.surfacePlane, m2v.exportSurface and
m2v.surfaceWritesDone (the snippet's records) through Device::new_exported_surface,
Surface::planes, Surface::wait_until_ready and Surface::external_writes_done. Where the
stream was recorded a decoder wrote each picture; on replay a Vulkan device of the
player's own, on the runtime's instance and physical device, imports the surface's
handle, copies the picture's packed rows into its memory at the play's layout (or fills
it with the landing's number where the stream holds no bytes), releases it to the
handle's queue family and waits on its own fence. An import or write the stand-in cannot
make is counted on the exported-surfaces line and the play goes on.

The backend also counts what the runtime's hand-overs follow from, per frame: commits
whose command buffers name a texture in an exported surface, the makings a submission
carried, the pictures landed, and CPU calls on such textures (frames with those are not
judged). The report's hand-over line compares each frame's external_acquires and
external_releases with the runtime's Metrics contract at this commit: one acquire per
such submission, one release per such submission plus one per submission carrying a
making.

Unverified at this commit: the lavapipe run follows.
2026-12-02 05:39:49 -08:00
Anees Iqbal e4c206f759 Validation tests: an exported surface's snippet, its hand-overs per picture as the runtime's contract says
What: snippets::video_surfaces writes a synthetic stream of our own: one exported surface of a
64x36 8-bit 4:2:0 picture's two planes (m2v.newExportedSurface, m2v.surfacePlane, a view of the
luma plane, m2v.exportSurface), then three pictures of our own bytes (m2v.surfaceWritesDone), each
in a frame of its own: two submission parts (m2v.split) read the planes back into Shared buffers,
a third command buffer uses none of the surface, and m2v.check compares the read-backs with our
bytes. The device test plays it for each handle the host has and asserts that every frame's
external acquires and releases agree with the report's hand-over line (the runtime's documented
contract), that every check matches, and that nothing is skipped; a handle the device does not
export is counted and passed over.

Why: no recorded stream carries the exported-surface hand-over the consumer's video uses; this
test fails until the player plays the record family (it refuses m2v.newExportedSurface now).

Verified: not yet run; its first run is the red one, before the player change.
2026-12-02 05:39:48 -08:00
Anees Iqbal 6ae68f6eab Runtime tests: an acquire from the general layout moves an image over another API's memory home
The layouts recorder's moves() took an image's move home to be a barrier of its first level from
the undefined or the preinitialized layout, so a texture over a dma-buf in place, whose move home
is its acquire from the foreign queue family from the general layout (Vulkan's section 12.10.1:
that acquire's layout is the image's true initial layout), would have been noted as a step before
its move home, as would a Direct3D 11 plane's first acquire. No test read moves() for either.

The recorder now keeps the memory allocated from another API's handle (VkImportMemoryFdInfoKHR,
VkImportMemoryWin32HandleInfoKHR, through vkAllocateMemory) and the images made with external
memory info that vkBindImageMemory binds to it. For such an image alone, an acquire of its first
level from the external or foreign queue family from the general layout is its move home where
it has not moved home, and a use after. For every other image a first move from the general
layout stays a step before its move home. An exported surface's dma-buf planes are bound to the
runtime's own imports of its export, which the record does not tell from another API's; the
module doc says so.

Tests: a device-free test of the step a barrier is (an acquire over another API's memory, over
the runtime's, at another level, a release, a plain barrier, from undefined) and of take() (the
first acquire a move home, the second a use, a plain barrier first out of order); and import_overs'
dma-buf layouts test reads moves() and asserts no step out of order.

Also: forget() gets its own doc line, and barriers()'s doc is back above barriers().
2026-12-02 05:39:48 -08:00
Anees Iqbal 28a4ee50a8 Runtime README: a dma-buf texture's first acquire names the general layout by convention, not by a sentence
The planner's ruling on d789ca7aa5. The first acquire of a texture in place over a dma-buf's import
names the general layout as its old one, though the runtime has released nothing yet and the
image was made undefined. For a Direct3D 11 plane that layout stands on section 12.10.1 with
Table 17 (External Image Implied Layouts). Table 17 lists no dma-buf handle type, and section
12.10.1 leaves layouts to the other API, so no sentence names the dma-buf's layout there: the
first acquire's old layout is general by the same convention as the later ones. Imported blocks
says so, and Known gaps of memory blocks lists it. The undefined layout there would discard the
bytes, so the code stays.

Docs only.
2026-12-02 05:39:48 -08:00
Anees Iqbal 5ae5d0a169 Runtime tests: the external-image check compares its layout with assert!, ImageLayout having no Debug
no_external_preinitialized used assert_eq! on a vk::ImageLayout, which this build of ash gives no
Debug, so the runtime's lib tests did not compile at 49583b80c0 (lavapipe jobs m3-max-77905 and
m3-max-77906 stopped at E0277). The check now compares with assert! and prints the layout's
number, as the message already did.
2026-12-02 05:39:48 -08:00
Anees Iqbal e61d47452f Runtime README: a write to an imported dma-buf through another mapping is a host write
The planner's ruling on the aliased-write row. Imported blocks' coherence paragraph says that rt
takes a write to an imported dma-buf's pages, made through another mapping of the same pages, as a
host write to that memory, and that rt imports a dma-buf only into a host-visible, host-coherent
type on a device whose Shared type is host-coherent, refusing otherwise
(Limit::ImportCoherence, Limit::ImportType), so no flush or invalidate is owed (import.rs at
lines 420, 431, 439, 444, 530 and 696, read by main). Known gaps of memory blocks records that
Vulkan defines host access only through its own mapping and host-pointer imports, so the order of
such a write rests on the pages being the same and the type host-coherent, measured on the
Radeon 780M (RADV), not on a sentence of the spec.

Docs only.
2026-12-02 05:39:48 -08:00
Anees Iqbal 6fe011608a Runtime: a texture over a dma-buf in place is acquired from the general layout, never preinitialized
A texture over a buffer in a dma-buf's import, in place, is a linear image made with the import's
handle, so undefined (VUID-VkImageCreateInfo-pNext-01443). Its move home is the acquire of the
image and the buffer's range under it from the foreign queue family, and that acquire's old layout
is the image's true initial layout (section 12.10.1). It named the preinitialized layout: the
Source::Over in-place arm of Device::new_texture set first to PREINITIALIZED for every image in
place, the dma-buf's included, and Image::homing's foreign acquire named it.

The planner's ruling: no image with external memory info is named in the preinitialized layout,
and the acquire names the layout the memory was released in. The arm now sets first to
PREINITIALIZED only for an image of the runtime's own memory (made preinitialized, Laid::Own); the
dma-buf's image keeps first undefined, and homing's foreign acquire names the general layout
(first.old_layout(home)), the layout of the runtime's own hand-overs, in which a linear image and
the buffer are host-accessible aliases that read the bytes alike (section 12.11). copy_layout,
which took a preinitialized first to mean an image in place, also takes an image with a foreign
acquire as one, so a copy keeps it in the general layout. writes_whole already excluded it.

After this, no product code names the preinitialized layout for an image made with external
memory info: the remaining PREINITIALIZED sites are the in-place arm for the runtime's own memory
(texture.rs:1718), the probe image of linear_layout (texture.rs:2556, never bound) and
image_create's None-handle arm (texture.rs:3421); the handle arm makes undefined.

README: Imported blocks and Buffer::new_texture name the general layout as the acquire's old one.

Pinned by the previous commit's test (import_overs:
every_device_names_a_texture_over_a_dma_buf_in_no_preinitialized_layout), red before this commit
and green after on lavapipe (llvmpipe); jobs reported with the series.
2026-12-02 05:39:48 -08:00
Anees Iqbal 30b21e5ffb Runtime tests: no command names an image made with external memory info in the preinitialized layout
The layouts recorder keeps each image made with VkExternalMemoryImageCreateInfo in its chain, with
the layout it was made in. no_external_preinitialized checks every such image of a device: made
undefined (VUID-VkImageCreateInfo-pNext-01443), and named in the preinitialized layout by no
command. An acquire's old layout is such an image's true initial layout (section 12.10.1), and
Vulkan names the preinitialized layout only as one an image is made in and, under memory
aliasing, as the old layout of a move after host writes through an alias (section 12.11).

Two tests use it, each under a recording:
- import_overs: a texture over a dma-buf's buffer, read by a blit; exact against the CPU's bytes,
  and in place exactly one external image named.
- surface: every row the device exports, on the 1080p picture: read after external_writes_done,
  then written by a blit; every plane in place named.

At this commit the dma-buf test fails where the texture takes the form in place: the image's move
home is the acquire from the foreign queue family from the preinitialized layout
(texture.rs, the Source::Over in-place arm sets first to PREINITIALIZED for the dma-buf's image
too; Image::homing's foreign acquire names it). The next commit fixes it.
2026-12-02 05:39:48 -08:00
Anees Iqbal d562f130a6 Runtime: a making's wait for the work lock is a home lock wait; the ready-order test reads the semaphore
Work::create, which an exported block's or surface's make calls to owe its making to the next
submission's upload, waits for the submit side's work lock as a texture's move home does. It now
times that wait as Part::HomeLock, so Metrics::home_lock_waits counts it again; the hand-over change
moved the surface make's upload entry into Work::create and left the wait untimed, and
make_parts' every_device_times_an_exported_surfaces_make_by_part expects one home lock wait per
make. The counter's doc names the exported make.

every_device_completes_a_surface_s_making_before_its_ready_wait_returns read the device's
completed progress (Done::completed), which the completion thread raises after the progress
semaphore does; the ready wait returns on the semaphore. The test now reads the semaphore's own
value (vkGetSemaphoreCounterValue), which the ready wait's return orders after.

Failing before: both tests on lavapipe (llvmpipe), runtime suite job m3-max-77883 at 6559c48acd.
2026-12-02 05:39:48 -08:00
Anees Iqbal 4ea93af18c Runtime tests: a picture loop's hand-overs, counted per picture
every_device_counts_a_picture_loop_s_hand_overs runs, for each row the device exports on the
1080p picture, 8 decode pictures (the other device writes, external_writes_done, rt reads through
the planes) and 8 encode pictures (rt writes the planes by a blit, the other device reads through
the handle) after one warm-up of each, each read exact, and prints each picture's barriers,
runtime command buffers, submissions, acquires and releases counted around rt's calls alone. It
is the before-and-after measure of the hand-over: the same loop at 21d219b089, with the release
call the consumer's encode path made there, runs on a scratch branch; no lab recording carries
decoded pictures (main, 12-02). Printed only.

Verified on lavapipe with the before run; reported with the lane's tip.
2026-12-02 05:39:48 -08:00
Anees Iqbal 2113de81cb Runtime: the hand-over's private docs name Image::making and Upload::hand_over
6559c48acd renamed Image::made to Image::making and folded Upload::make_handed into
Upload::hand_over, and four private doc links still named the old items: the private-items
rustdoc of the runtime failed on them (job m3-max-77880, the Linux node's privdoc step; its
public rustdoc, gpu clippy and the validation crate's clippy passed there).

Verified by the next privdoc run, reported with the lane's tip.
2026-12-02 05:39:48 -08:00
Anees Iqbal d0a424060a Runtime: each submission that uses memory another API shares hands it over; the release calls are gone
A consumer's video path showed green frames. Its paths call external_writes_done before each
picture and a release only in their encode fills, so every acquire of an exported block or surface
after the first had no release of the runtime's to match (VUID-vkQueueSubmit2-commandBuffer-03879),
and whether memory another API wrote was acquired, or discarded, depended on the order the
consumer's calls arrived in. f6fe21431c's test shows it: no submission released the surface.

Now one form serves every kind of memory another API shares, the form Direct3D 11 planes already
took (crate::handed): each vkQueueSubmit2 part whose command buffers or uploads use an exported
block, an exported surface's planes in place or its buffer, or a Direct3D 11 plane acquires all of
it from the other API's queue family in one barrier, in a runtime command buffer at the part's head
after a global barrier, and releases it in one barrier in another at the part's end, which takes
the part's last signals. Per such part: 3 barriers and 2 runtime command buffers; no submission,
VkSubmitInfo2 or semaphore wait is added. The uploads' copies into textures over a buffer in an
exported block go with the first part, which hands that block over too.

Exported memory is the runtime's until its making (Work::create): an exported block's buffer is
released, and an exported surface's planes in place move out of the undefined layout and are
released in the same barrier, in a runtime command buffer at the head of the submission that takes
the make's upload, ahead of any acquire. The upload owes the making by weak reference, so a surface
or block dropped first owes nothing and holds nothing. The making's submission is the ready point:
Surface::wait_until_ready waits for it in both forms (the copy form's is its block's), and the new
Block::wait_until_ready is its twin (Metal counterpart none; refuses a block that is not exported;
has the submission go at once, so it returns with no command buffer committed). One barrier at the
making, nothing per frame beyond the per-part hand-over.

external_writes_done keeps only its host-side mark: on a block (and a copy-form surface) the
textures over it take its bytes again; in place and on a Direct3D 11 import it records nothing.
Surface::buffer records nothing at its make. A block that is not exported is still refused.

Deleted, with no replacement: BlitCommandEncoder::release_to_external and
BlitCommandEncoder::release_surface_to_external, and Building::release_command, which only they
used. Consumer uses (the consumer's checkout, searched for main): release_to_external at
vaapi/fill.rs:599 and nvidia/encode/fill.rs:289, each followed by EndEncoding, commit and the
consumer's CPU wait; its wrapper trait method BlitEncoder::release_to_external
(core/platform/blit.rs:395, a cfg(unix) no-op default) and the RtPlatform impl
(rt_platform/blit.rs:992-999); doc mentions at rt_platform/export.rs:33, vaapi/fill.rs:30 and
nvidia/encode/fill.rs:18. release_surface_to_external: zero uses. The consumer drops them all in
the pin that takes this commit.

The guard the planner asked for: a plane's image in place takes its tiling from InPlaceTiling
alone, whose values are LINEAR and the DRM_FORMAT_MOD_LINEAR modifier, never OPTIMAL; the
device-free test no_plane_in_place_takes_the_optimal_tiling pins it. The order test
every_device_completes_a_surface_s_making_before_its_ready_wait_returns checks that each plane
owes its move at the make and none once the wait returns, with the device's completed progress at
or past the ready point. The export, surface and Direct3D 11 tests now count one acquire and one
release per submission and one release at the making, with no release call.

The runtime README states the contract (The hand-over contract): nothing another API writes may
be handed memory of ours before that memory's ready point; the other API's next write must not
begin before the submissions that used the memory have completed; who waits by kind and what a
reader gets where no write landed; no optimal image in memory another API writes in place
(section 12.11), the Direct3D 11 import being the documented case (section 12.10.1, Table 17).
Its known gaps carry the planner's line on host-pointer memory. docs/REFUSALS.md is regenerated
and the signature table blessed (one added, two removed).

Checked before this commit: clippy of the runtime, all targets, plain and under --cfg
m2v_cpu_icd, on this commit's code less its doc changes (job m3-max-77874). The device runs at
this commit (lavapipe, the Radeon 780M, the UHD 630) follow and are reported with the lane's tip.
The dma-buf import half is not built.
2026-12-02 05:39:47 -08:00
Anees Iqbal 6557e60115 Runtime tests: a picture the other API writes after rt's read is read with no release call between
The consumer's video paths (VA-API into a dma-buf surface, NVIDIA's decode into an opaque one)
call Surface::external_writes_done before each picture and release_surface_to_external only in
their encode fills, so every acquire after a surface's first has no release of rt's to match
(VUID-vkQueueSubmit2-commandBuffer-03879: "there must exist a previously submitted Queue Family
Ownership Transfer Release Operation ... with parameters matching the acquire operation").

The new test makes each row's surface (the VA-API dma-buf, the NVIDIA opaque handle, the copy form)
at 1080p, waits for its ready point, and has the second device write picture 1, then the
consumer's call and rt's read; then picture 2 the same way, with no release call between. Each read
must be its picture's exactly, the validation layer silent, and each read's submission must count
one acquire and one release of the surface's memory (Metrics::external_acquires,
Metrics::external_releases). At this commit no submission releases the surface, so it fails there.
2026-12-02 05:39:47 -08:00
Anees Iqbal a57f18224c Runtime: a serial dispatch that writes after a read through an address outside every resource takes a barrier
A serial compute encoder recorded no barrier between a dispatch that reads through an address
outside its resources and a later dispatch that writes a resource through its slot or a
use_resource declaration, so on Vulkan the write could overlap the read and the read see its
bytes. Metal runs a serial encoder's dispatches in dispatched order (MTLCommandBuffer.h:
"Command encoder dispatches are executed in dispatched order"), and the README held that such a
pipeline conflicts with any write. The hazard sets marked nothing for the read
(Hazards::mark_wild_read set touched alone), and Building::dispatch_hazards tested an unbound
read against earlier writes and an unbound write against any earlier access, never a write
against an earlier unbound read.

Now Hazards keeps read_wild since the last barrier, set by mark_wild_read and cleared with the
sets, and a dispatch any of whose accesses writes conflicts with it, counted in
Metrics::dispatch_unbound_barriers (its doc says so). The flag covers any resource: what an
address read reaches is whatever the guest made resident, residency sets included, which the
runtime does not see, the breadth the rule already takes for an unbound read after any write.
The README's serial-encoder sentence and use_heap's doc say the read orders before later writes.
No public change; no new form. The barrier is the one an unbound access already takes.

Verified: not run yet; the lavapipe run of every_device_orders_a_write_after_an_unbound_read,
the runtime suite and clippy follow.
2026-12-02 05:39:47 -08:00
Anees Iqbal 58305fb9cd Runtime tests: a serial dispatch that writes after a read through an address outside every resource takes a barrier
A serial compute encoder records no barrier between a dispatch that reads through an address
outside its resources and a later dispatch that writes a resource through its slot or a
use_resource declaration: the read marks nothing in the hazard sets (Hazards::mark_wild_read sets
touched alone), and the unbound test in Building::dispatch_hazards looks at earlier writes for an
unbound read and at any earlier access for an unbound write, never at an earlier unbound read for
a write. Metal runs a serial encoder's dispatches in dispatched order (MTLCommandBuffer.h), so the
read sees the bytes from before the write; on Vulkan the two may overlap.

every_device_orders_a_write_after_an_unbound_read: the wild step kernel (reads_unbound) over y,
then step over x, in one serial encoder; it asserts one barrier in the unbound source and two
barriers with the segment's end. It fails before the fix (no source, one barrier).

Verified: not run yet; the lavapipe run follows.
2026-12-02 05:39:47 -08:00
Anees Iqbal d8735b75f0 Golden tables: bless at semantics 2310 for the high-word carry and the dominating slot base
The golden hash table was last blessed at semantics 2307 (031c37d674). Two translator commits
since then change emitted SPIR-V and bump SEMANTICS_VERSION to 2310: 2a42256955 carries biased
buffer offsets into the high address word, and e2e76d8879 makes a slot's direct base and address
once where they dominate. golden_hashes_match_the_table therefore reports a bless due, not a
missing bump.

What moved, read from the table's diff: 2310 of 3600 rows, every one hash to hash. No refusal
class changed, no fixture source hash changed, and no row was added or removed. That is 19275
cells: 10086 in .ll fixtures, the count the Linux run reports, and 9189 in .air.ll fixtures,
which only a macOS run computes. Every changed row's fixture source holds a device or constant
buffer pointer, which is the path both commits change. The 137 rows whose fixture has none did
not move.

The table is the only file changed. Every other test in the same core run passed, and the
public cases ran at 7adf1d6603 with new_mismatch 0 on lavapipe, the Iris and the 780M.

Blessed on the M3 at 7adf1d6603 (job m3-max-78055: inventory, golden and printouts all exit 0;
only golden_hashes.tsv changed).
2026-12-02 04:13:30 -08:00
Anees Iqbal 7adf1d6603 Runtime: a command marks its Managed-over writes and takes their copies back in its own segment, after its command buffer begins
A command encoded right after encodeSignalEvent marked what it did to textures over a Managed
buffer's device copy (managed_reach, wrote_managed, wrote_texture_managed) in the segment the
signal ends, before ordered_command split the recording there. That segment goes in a submission
of its own ahead of the command's, so on a device with two copies a write's copy in was taken
before the write ran and never after it (a fill of the buffer, then every later reader of the
texture read the bytes from before the fill), and a texture write's copy back was made before the
write. And managed_reach took the copy back owed by a write earlier in the command buffer before
managed_backs began the command buffer, so a begin that failed dropped it for good.

Building::open_segment makes the current segment the command's (a new one past a signal) and
begins its command buffer, with what is owed left owed. The blit copies, fill, mipmap chain and
synchronize, and the dispatch, call it before their first mark; a render pass's begin marks its
attachments after its ordered_command instead, so whether it opens its command buffer, which
spares its first barrier, is read as before. No public change and no new form.
2026-12-02 03:20:20 -08:00
Anees Iqbal 6bc41c8b94 Runtime tests: the two Managed-over tests print and check the copies over the device copy
The fill-after-a-signal test prints the bytes R's submission copied between the texture and the
Managed buffer's device copy (over_copy_bytes less those over Private and over Shared memory), and
the failed-begin test the bytes the copy encoded again copied back in its own commands. Where the
texture is owed by its buffer's entry (two copies), each must be non-zero: the evidence that the
two-copy form ran, not only that the bytes match.

Unverified at this commit: the failing run follows on lavapipe.
2026-12-02 03:20:20 -08:00
Anees Iqbal 1bc769f58a Runtime tests: a Managed buffer's write after an event signal, and a copy whose begin fails, keep the copies a texture over it owes
Two device tests over a texture over a Managed buffer in an image of its own, in both forms:

- A fill of the buffer encoded right after encodeSignalEvent reaches a later reader of the
  texture. Today the fill's marks (managed_reach, wrote_managed) land in the signalling segment,
  whose submission goes first: the copy in it owes is taken before the fill runs, and none after.
- A blit copy of the buffer whose command buffer cannot begin fails before it takes the copy back
  a write of the texture owes. Today managed_reach takes it, managed_backs fails at the begin, and
  the same copy encoded again reads the buffer without the texture's write.

A test-only seam, Core::fail_begins, fails the next begins of a command buffer's recording
(Building::begin) as vkBeginCommandBuffer out of host memory, before the driver is called.

Both are expected to fail in the two-copy form until the fix that follows. Unverified at this
commit: the failing run is being dispatched on lavapipe.
2026-12-02 03:20:20 -08:00
Anees Iqbal 01ed021d53 Translator tests: a direct access's instruction bounds are PR 22's carry form's measured cost
engine_access_size::a_device_access_of_whole_words_is_one_access held a direct access to the old
form's cost: a 64-bit add of the slot's base and the zero-extended biased offset. PR 22 replaced
that add with an OpIAddCarry on the low word and a carry into the high word, because AMD's Windows
driver folded the biased offset's 2^31 into a sign-extended 64-bit immediate and read 4 GiB below
the buffer. The structural pass (e2e76d8879) made the base and the slot's address once per slot;
the per-access remainder is the carry. The bounds move to the measured cost, never rounded up:

  float4 load at a uint offset    16 -> 19
  float4 store at a uint offset   16 -> 19
  float4 load at a float4 offset  16 -> 18
  pointer chase                   24 -> 22  (the pass took it below the old form)

The loss, as measured:
- On a device that takes compute buffers by address (lavapipe, a states-only play of 25,942
  states, refused 0 in both forms; m3-max-77799, a b a b): SPIR-V +7.0% (largest entry +6.2%),
  driver compile +5.1% (same-arm spread 1.1% and 2.6%), translation +0.7%, pipeline-make time
  +1.6%, play wall +0.8%.
- One translation by the compile worker's counting allocator (corpus-pipeline --compile-only,
  lavapipe; m3-max-77820, m3-max-77825): the corpus's largest row by allocator peak, 184,135,107
  bytes in both forms (PR 22 does not reach it); its largest by SPIR-V output, 62,572 -> 62,894
  words and 2,905,472 -> 2,921,373 bytes (+0.5%), 11 ms in both.
- Runtime GPU time of the frames (a b a b, one job per card): XTX +0.09% (m3-max-77764). RTX 3090 (gem10, in a
  Thunderbolt enclosure): m3-max-77854 not resolved, its arms at unequal clocks (one b play 81
  samples at P8 210 MHz against 50 and 51, wall 144.4 s against 133.7-137.9 s); m3-max-77895, both
  pairs counted (P8 samples 109/109 and 108/103), +1.90% and -2.72%, means -0.44%: inside. The
  +0.21% at 2f5f35ca47 on that card was before it moved hosts and is not a before-run. Iris Xe: no loss shown, 3% not resolved by this measure there (pair spread 7.8% and
  11.3%).

The carry form is unverified in the lab on the driver it fixes: no lab device runs AMD's Windows
driver; only the contributor's run (RX 6950 XT and an integrated Radeon, driver 26.11.2, offsets 0
and 256) covers it. A cheaper form for constant offsets was not taken for that reason; the cost is
a no-lane row that reopens on a venue running that driver or a pipeline-make cost of 5% or more on
a real device that takes buffers by address.

Verified: the measured values are m3-max-77757's size table at e2e76d8879 (no translator change
since); this commit's test runs in the merge check next.
2026-12-02 03:19:08 -08:00
Anees Iqbal 21d219b089 Runtime tests: every acquire of a Direct3D 11 plane read ahead of external_writes_done names the general layout
every_device_reads_what_direct3d_11_drew_through_a_commit_ahead_of_external_writes_done (d68f165aae)
now asserts what it printed: every acquire of a plane, the first included, names the general
layout as its old layout (Work::acquired). Its byte checks stay.

Why the structural check: no wrong picture was reproduced. On the UHD 630 the read committed ahead
of the call matched picture 1 at 3072 of 3072 bytes at d68f165aae, the old code, whose acquires'
old layouts were [undefined, undefined, general, general] (job m3-max-77834); at cd5d7df2f0 the
same read matched 3072 of 3072 with [general, general, general, general] (job m3-max-77839). That
driver kept the bytes through an acquire from the undefined layout, which Vulkan does not promise
(section 12.5.1: "implying that the contents of the image subresource need not be preserved"), so
the bytes cannot fail there and the old layouts are the failing proof. cd5d7df2f0 stays as the
spec's form (sections 12.5.2, 12.10.1, Table 17).

How it is verified: one job on the UHD 630 runs tests::d3d11 from two Windows cross-builds, the
old code with this assertion (expected to fail on [0, 0, 1, 1]) and this commit (expected to
pass); its job is reported with the lane's tip.
2026-12-02 02:41:12 -08:00
Anees Iqbal cd5d7df2f0 Runtime: every acquire of a Direct3D 11 plane names the general layout, the first included
A consumer's video path showed green frames. A plane's first acquire named the undefined layout
unless Surface::external_writes_done had been called before the first commit that used it, and a
transition from the undefined layout need not keep the bytes (section 12.5.1: "implying that the
contents of the image subresource need not be preserved"). What 9737a44d98 and its test 7c5df5a317
left open: whether that first acquire discards depended on the order the commit and the call
arrived in. The consumer's decode order today is fence wait, external_writes_done, then the
session's signal, so the hole is reached by a guest command buffer that reads a new cache's planes
without waiting on the session, committed between the draw's completion and the call.

Now Image::handed names the general layout as the old layout of every acquire, the first included,
and of every release. A Direct3D 11 plane is made owing no move (its homed flag set), so no upload
moves it, as before 9737a44d98. Surface::external_writes_done records nothing and changes nothing
for a Direct3D 11 surface; Image::external_access, which it called, is gone. No barrier, command
buffer, submission or wait is added or removed: the acquire is the same barrier with another old
layout.

The spec's form for this handle type. Section 12.5.2: "When images created with external memory
handle types listed in the external image implied layouts table are accessed outside of Vulkan,
they must be in the layout specified in the table, and can be assumed to be in that layout when
they are accessed in Vulkan after external access", and Table 17 gives
VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT the layout VK_IMAGE_LAYOUT_GENERAL. The conflict
9737a44d98 met (a plane rt uses before any Direct3D 11 access, whose image is made undefined) is
answered by section 12.10.1's note on an image bound to memory another API owns: "Such an image is
not usable until it acquires ownership of its memory from the existing owner. Therefore, the layout
specified as part of this transition will be the true initial layout of the image. The undefined
layout specified when creating it is a placeholder to simplify valid usage requirements."
Direct3D 11 made the texture, so it is that owner, and VUID-VkImageMemoryBarrier-
srcQueueFamilyIndex-12332 allows the general layout for any acquire of such an image from
VK_QUEUE_FAMILY_EXTERNAL ("oldLayout must be VK_IMAGE_LAYOUT_GENERAL or
VK_IMAGE_LAYOUT_UNDEFINED"). Left open by the text: whether Direct3D 11's making of a texture with
no initial data counts as an access "outside of Vulkan"; such a texture's bytes are undefined
either way, and the acquire that names the general layout is allowed by the VUID.

The suite now states this rule: every_device_acquires_a_direct3d_11_plane_from_the_general_layout_
first_included replaces the first-use test and reads the old layouts from Work::acquired, the
general layout for every acquire, with and without the call first. The d3d11 module's doc,
import_d3d11_surface's Layout, Ownership and precondition paragraphs, external_writes_done's doc
and the runtime README say so; the consumer's precondition no longer names the call.

Not yet run on a device: the red test's run at d68f165aae and this commit's run of tests::d3d11
on the UHD 630 wait for the card, which potluck does not list on the Windows host as this is
committed; their jobs are reported with the lane's tip. The Windows cross-build of this commit is
its compile check.
2026-12-02 02:22:45 -08:00
Anees Iqbal d68f165aae Runtime tests: a Direct3D 11 picture drawn before rt's first commit is read whatever order external_writes_done arrives in
A consumer's video path showed green frames: planes Direct3D 11 wrote, read by rt, came back without
Direct3D 11's content. A plane's first acquire names the undefined layout unless
Surface::external_writes_done was called before the first commit that uses it, and section 12.5.1
lets a transition from the undefined layout discard ("implying that the contents of the image
subresource need not be preserved").

The new test draws picture 1 with Direct3D 11 and waits for it, imports the planes, commits and
waits for rt's read of them with no external_writes_done before it, then makes the consumer's call
and reads again. Both reads must be picture 1's exactly. It prints the first read's matching and
zero bytes and each acquire's old layout (Work::acquired).

Its run at this commit on the UHD 630 is named in the fix's message.
2026-12-02 02:13:33 -08:00
Anees Iqbal ad49a715ff Runtime tests: a group sent apart is read from the values its members were given, not by a clock
every_device_signals_each_member_of_a_group_sent_apart failed once on llvmpipe in the merge check
at 1da727a583 (m3-max-77710, lvp_rt: "no value between the busy work's 6 and the group's 9 before
L's end") and passed at 2f5f35ca47 (m3-max-77732) and in round 89fb420796-1202-0117. Its proof
needed a host thread polling the progress semaphore to catch A's value inside the 4-10 ms between
A's end and L's: on a loaded CPU device the thread can be off the CPU for the whole window. The
specification bounds when a timeline signal is seen only from below (a submission's signal
follows its own commands), so a device that showed the value late would also fail it.

The deterministic form the planner asked for, a wait on an event instead of the clock, has no
valid Vulkan shape here. A GPU wait on a host-set event is defunct: "Events signaled by the host
must be signaled before the command buffer waits on those events" (6.6; also
VUID-vkCmdWaitEvents2-pEvents-03840). The runtime's own shared-event wait holds L on the host
until the event is met, so L would never join A's group.

So the test now reads what the runtime gave each member as the group went: Work::assigned, a
record kept for the device tests (as Work::acquired is), of each group member's place in the
commit order and the progress value it retires at. It asserts A then L in commit order, the
busy work's last value < A's < L's = the group's last, and still one submission each. The
timings (A's handler and L's GPU end, from A's GPU end) are printed, not asserted, and so are the
values.

Verified: nothing run yet for this commit; the merge check's lvp_rt and clippy in the device
configurations run it next.
2026-12-02 02:06:32 -08:00
Anees Iqbal e2e76d8879 Translator: a slot's direct base and address are made once where they dominate; an access adds its carry alone
PR 22's carry form cost about 10 SPIR-V instructions for each direct access against 2 before,
and engine_access_size::a_device_access_of_whole_words_is_one_access failed its bounds at
2f5f35ca47 (m3-max-77753, first identity profile: the uint-offset float4 load and store 24
against a bound of 16, the float4-offset load 23 against 16, the pointer chase 33 against 24;
the old form 16, 16, 15 and 24). Most of that was work repeated on every access: the base's u64
bitcast back to words and its split, and an add of the offset's zero high word; and
slot_address added the bias with the same sequence at every use.

Now:
- pointer::direct_base: the slot's address less the bias as its two words (the SlotGuestBase
  push word split, or in a replay variant that word less 2^31 with a borrow), remembered under
  SlotMemo::DirectBase and recalled where its block dominates (EmitCx's invariant memo, as
  slot_bounds does). Reach::Direct holds the words; biased_slot_address, which only the direct
  reach called, goes.
- psb::add_slot_offset: OpIAddCarry of the low word and the offset, its two words, one add of the
  carry to the high word, the words joined and bitcast: six instructions, with no add of a zero
  word and no 64-bit add of a constant.
- pointer::slot_address: remembered under SlotMemo::Address, so a pointer compare, a converted
  or stored pointer or an access from the word below adds the bias once where it dominates.

The arithmetic is unchanged: the address plus the unsigned biased offset modulo 2^64, carried
into the high word as PR 22 made it. SEMANTICS_VERSION 2309 -> 2310 (module bytes change).

Verified: nothing run yet for this commit; the access-size table, the engine suites and the merge
check run next, and the table is reported against the bounds.
2026-12-02 01:58:07 -08:00
Anees Iqbal ad6940ff92 Runtime: Pushed's doc links PUSH_STAGES by its name in scope
PR 23 imported PUSH_STAGES into command.rs, so the explicit target of the link in Pushed's doc
became redundant, and CI's private intra-doc links step (cargo doc --document-private-items with
-D warnings) failed on metal2vulkan-runtime: "redundant explicit link target" at command.rs:290.

Verified: found by the merge check at 2f5f35ca47 (m3-max-77732, STEP privdoc EXIT=1, the one
error); the next merge check runs the step again.
2026-12-02 01:52:53 -08:00
Anees Iqbal 2f5f35ca47 Translator tests: a constant slot reads exactly at residuals 256 and 4096 above its descriptor base
PR 18 (rponeawa) reported that a shared-range uniform descriptor could start far below the bind
offset (a residual of 256 on a device with a 64-byte uniform offset alignment), past the fixed
array the uniform view declared, so the read left the declared array. Its fix sized the array to
the device's uniform range. 5e3477e60a (11-22) has since removed the uniform view: every buffer
slot's view is a storage word array whose OpArrayLength is the bound range, with no declared size.
So the PR is credited by an empty merge and this test pins its case on the view the tree has: the
last byte of a constant window, read with residuals 0, 256 and 4096 on every tested profile, is
exact.

Verified: run in the merge check at the integrated tip, and with the residual's push word forced
to 0 (the read lands in the 0xEE fill) to show it is not vacuous; results in the PR report.
2026-12-02 01:40:41 -08:00
Anees Iqbal ebc0486b71 Translator: the slot address bias's docs state the carry form PR 22 brought
PR 22 (vistaero) adds a slot's biased 32-bit offset into the low word of its 64-bit base and carries
into the high word, at both direct-reach sites and in slot_address, in place of a 64-bit add of
the zero-extended offset (or of the 64-bit constant 2^31). This commit brings the bias's own doc
comment to that form and words the test's comment by structure.

Which case it was: (b). The old form was right by the specification: the biased offset is
the signed offset plus 2^31, in [0, 2^32), so UConvert's zero extension and a 64-bit add give the
address plus the offset exactly, and IAdd of the 64-bit constant 2^31 is exact. The PR reports
that AMD's Windows Vulkan driver (26.11.2, RX 6950 XT and an integrated Radeon) turned the bias
into a 64-bit immediate add that read 4 GiB below the buffer: a driver compiler fault, noted for
a repro draft. The carry form is rung 1 of the workaround ladder: one form for every device, chosen
by no query. Its 3% check (the XTX, the 5080 and the Iris Xe, arms alternated in one job) is owed
before the integrated commit is called regression-less. The lab has no AMD Windows host, so
the fault itself is built, not run: no venue.

The two subtract sites (biased_slot_address's unbiased arm and the indirect command's stored
word) subtract 2^31, which a sign-extended 32-bit immediate represents exactly. They are left
as they are: no report names them, and the PR's own run on the faulting driver passed with them.

Verified: nothing run for this commit alone (comments only); the merge check at the integrated tip
covers it.
2026-12-02 01:40:15 -08:00
rponeawa 4e067714f2 Merge pull request #18 from rponeawa/fix/shared-uniform-array-capacity 2026-12-02 01:38:19 -08:00
vistaero 2a42256955 🐛 Carry biased buffer offsets into the high address word
Windows Radeon shaders reading the first byte of a bound vertex buffer read
4 GiB below its address when the unsigned 2 GiB bias became a native
64-bit immediate add. Add the offset to the low word and carry into the
high word for direct accesses and recovered slot addresses. Keep the push
layout and invalidate translations emitted under the previous semantics.
2026-12-02 01:38:03 -08:00
vistaero 0c6981dddd Merge pull request #22 from vistaero/amd-buffer-address-carry 2026-12-02 01:38:03 -08:00
Anees Iqbal 4da155fd34 Devtools: the Format enum's doc links to the write function, not the ambiguous write
`[`write`]` on the private Format enum (from 4bcb58dbb1) names both the module's private fn write and
std's write! macro, so rustdoc under -D warnings with --document-private-items refuses it as an
ambiguous intra-doc link: CI's "Private intra-doc links" step reads metal2vulkan-devtools at 1 over
its ceiling of 0. Link the function with [`write()`].

Found by the private-doc step timed for the merge check on x86_64 Linux (job m3-max-77704:
M2V-PRIVDOC metal2vulkan-devtools 1, every other crate 0; the diagnostic in m3-max-77707).
2026-12-02 01:38:03 -08:00
棠渚听潮 9826aa708b Submit aligned render push constant deltas
Track the last push length and record only the changed words for a draw. Keep Managed index and slot reaches on the full draw path, and leave device-wide alias and unslotted reads to the existing post-update checks.

Verified with cargo fmt and runtime Clippy, 207 runtime unit tests with the existing CRLF-sensitive stage test skipped, and the draw-offset regression on Intel Arc B390 including a Managed copy back.
2026-12-02 16:38:05 +08:00
棠渚听潮 d17046ea81 Update render buffer offsets without rebuilding push data
Reuse retained buffers for offset-only binds and track changed slots by stage. Patch indexed push fields and fixed-function bindings for eligible direct draws, and use full validation and filling when the draw cannot reuse them.

Verified with runtime clippy, the 207 lib tests in a temporary copy with LF in stage.rs, and the offset regression on Intel Arc B390.
2026-12-02 16:38:05 +08:00
vistaero 8f8b930ca1 🐛 Carry biased buffer offsets into the high address word
Windows Radeon shaders reading the first byte of a bound vertex buffer read
4 GiB below its address when the unsigned 2 GiB bias became a native
64-bit immediate add. Add the offset to the low word and carry into the
high word for direct accesses and recovered slot addresses. Keep the push
layout and invalidate translations emitted under the previous semantics.
2026-11-30 23:48:40 +01:00
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