Commit Graph
6818 Commits
Author SHA1 Message Date
Anees Iqbal 9769864acf translator: the identity gate counts descriptors, not a fragment function's colour attachments 2026-11-17 21:08:25 -08:00
Anees Iqbal aeea5f1721 translator: vertex and fragment functions lower under the identity domains on the floor's push window
identity_admits took kernels alone. On Device::from_queries' profile (PushWindow::Floor) it now
takes a vertex or fragment function under the same conditions as a kernel: every buffer slot
reached through its pushed device address (SlotGuestBase), textures and runtime samplers by
resource ID, constexpr samplers by pushed index, no descriptor, no unsourced fact. Device::new's
profile refuses them as before (Unsupported{IdentityDomains}, not implemented), so its output is
unchanged. The stages keep their fixed windows (vertex [0, 64), fragment [64, 128)) until the
render push layout is ruled.

Test (tests/engine_identity_render.rs, no GPU): colored_vertex and colored_fragment of the owned
examples fixture compile on from_queries' lavapipe and moltenvk-m3 profiles, the vertex function
pushing its two buffer addresses in its window with no descriptor, root table or parameter
block, both modules passing L3; Device::new's profile still refuses them.
2026-11-17 21:08:25 -08:00
Anees Iqbal 208887e13a rt: given-back dedicated blocks are kept idle with the pooled ones, up to a byte bound per class
A block given back, pooled or dedicated, is now zeroed by the block-maker thread and kept as
its class's latest idle block. It keeps its number, address and mapping, so the consumer's
mapping stays too. Each class keeps at most a bound of idle bytes, MemoryClass::idle_bound:
256 MiB Shared and 128 MiB Private. The class's ready block (its latest idle pooled block) is
a reserve outside that bound. Past the bound, the oldest kept block is freed through
BlockMappings::unmap, whether it is pooled or dedicated. A block longer than the bound, or a
spilled one, is freed at once. This byte bound replaces the count IDLE_MAX = 2.

A take past the pooled length first takes the shortest kept dedicated block that it fits
and fills at least half of (memory::fits), and only allocates when none does. Each reuse
counts in Metrics::dedicated_blocks_reused. Gauges::shared_idle_bytes and
private_idle_bytes count what is kept, the ready block included, and read zero after
teardown.

Why: a program that makes and releases large buffers frame after frame paid a fresh
vkAllocateMemory each time, and the driver's hold on the device's other calls with it. On an
RTX 3090 (NVIDIA's Linux driver, probe ecb66a34eb, job 44126) a 32.6 MB Managed buffer's
dedicated Shared block cost 8.3-10.8 ms in the call and held submissions for up to 7-19 ms.
Old took 1.6-1.8 ms for its second such buffer, a range in a 64 MiB block it already had.
Under the hold, only the first pair pays. Probe 4b48aa5c9b (jobs 44208-44210) made the pair,
gave it back and made it again. The second pair took 0.01-0.02 ms with no submission held
(longest round trip 0.10-0.19 ms, against 0.09-0.11 median), and dedicated_blocks_reused
went 0 to 2 with no block made. That held on the RTX 3090 and the RTX 2080. On the RX 550
the first pair took 3.8-4.6 ms and the second 0.01 ms. On that probe a fresh block's
create, bind, address and map took 18-75 us, the allocation 6.0-11.1 ms and the zeroing
1.2-1.7 ms. Under the hold the zeroing runs on the block-maker thread at give-back.

Tests: a_kept_dedicated_block_serves_a_request_it_fits_and_that_fills_half_of_it (the rule).
every_device_keeps_given_back_dedicated_blocks_for_requests_they_fit: of three 100 MiB
Shared blocks given back, two are kept beside the ready block and the oldest is freed
through the hook. A 60 MiB request takes a kept one, zeroed, as it was, with nothing made;
40 MiB and 101 MiB requests make their own. A dedicated Private block is kept beside the
Private ready block and taken again. Gauges read zero after teardown.
every_device_keeps_idle_blocks_up_to_the_bound_and_frees_the_oldest replaces the two-block
test: 18 Shared blocks given back leave 16 kept beside the ready one, and the oldest is
freed. The hand-out test's dedicated block is past the bound, so it is still freed on
release. API table re-blessed.
2026-11-17 21:02:00 -08:00
Anees Iqbal 32d511d17d harness, matrix: long_4cb runs one size on both runtimes: --size gives a sized row its size, the matrix passes the first runtime's to the later runs, and a row run at two sizes fails uncompared
A workload whose size follows the device (long_4cb) was sized by whichever runtime ran it first in
its process. The matrix times each runtime in its own process, so each sized it from its own base
time, and they could run different work: the RX 550's long_4cb ran at different sizes on the two
runtimes at 594b86d1f2, and its ratio compared unlike runs.

- run_each takes the size where the caller gives one (ScaledTo::base_us is then None) and times no
  base; a size for a workload of one size is an error.
- The command takes --size NAME=N (repeatable; a name it does not know is an error) and prints each
  sized row's size as an `M2V-MATRIX size harness-<runtime>/<row> <size>` record.
- The matrix reads the first runtime's "sized to" lines and passes them as --size to every later
  run: the main run, the warm run and the re-timed pairs.
- results.harness_budget fails a row whose two runtimes' size records differ (or only one has
  one), uncompared; `size` is a record kind.

Verified: python3 scripts/matrix/test_results.py, 29 OK; with the size check removed, the new test
fails (negative control). The matrix's harness script, rendered and run against a stand-in harness,
passes `--size long_4cb=4096` from the first runtime's line to the second's run. Harness unit test
a_scaled_workload_given_its_size_runs_at_it_and_times_no_base: build and run in the check job.
2026-11-17 20:57:07 -08:00
Anees Iqbal b96e61afa3 docs: VALIDATION.md's matrix says a harness time is host time and a ceiling is only ruled
The `time` record kind is what a program waits on, timed on the host (commit-to-complete where the
workload times it, else the wall time a run adds), since the harness's matrix_time change on this
branch; the harness budget lists no ceiling now, and one is given only by a ruling after the work
on its row. The doc said GPU time and measured-ratio ceilings.

Verified: the text only; python3 scripts/matrix/test_results.py, 28 OK on this branch.
2026-11-17 20:55:18 -08:00
Anees Iqbal a1a5ada454 matrix: the harness budget lists no ceiling: a ceiling is ruled after the work on its row, never taken from a measured ratio
The 2080's frame_5cb ceiling of 1.166 was its measured commit-to-complete ratio at 594b86d1f2,
which turned a red into a budget without a ruling. The GPU-time ceilings dropped earlier on this
branch were ratios of another measure. With none listed, every row over HARNESS_BUDGET fails its
leg until a ruling, made after the work on that row, gives it a ceiling.

Verified: python3 scripts/matrix/test_results.py, 28 tests OK.
2026-11-17 20:55:18 -08:00
Anees Iqbal 8b8e9e5475 harness tests: frame times its command buffer's commit to completion too
The matrix judges frame by its commit-to-complete time now (check job m3-max-44116 failed on the
old assertion that frame does not time it).
2026-11-17 20:55:18 -08:00
Anees Iqbal b74e1a50b9 harness, matrix: a row is judged by host time: commit-to-complete where the row times it, else the wall time a run adds; the GPU time is a diagnostic
The matrix judged every plan row by its GPU time (first command buffer's GPUStartTime to the
last's GPUEndTime), which is not what a program waits on, and whose placement changed between
builds. The harness's matrix time is now run::matrix_time: the steady time of each run's mean
commit-to-complete time where the plan times its command buffers' (frame, frame_5cb, long_4cb;
frame now times it too), else the steady time of the host wall time each run adds
(Report::wall_us, the timed loop's period with two runs in flight). The GPU time stays in the
table as a diagnostic; a new line per row prints the matrix time, what it is, and the wall p50.

results.py's ceilings were GPU-time ratios. They are now host-time ratios: frame_5cb on the 2080
keeps a ceiling of 1.166, its commit-to-complete ratio at 594b86d1f2; the others are dropped, and
the first matrix on host time sets the ceilings of the rows still over the budget.

Re-judged from the 594b86d1f2 matrix's harness output (c2c p50 of every command buffer, new over
old; the records hold no host wall time, so the burst rows and frame cannot be re-judged):
- frame_5cb: 780M Phoenix 0.671, 780M HawkPoint 0.693, RX 550 0.820, XTX 1.003 (pass, as on GPU
  time); 2080 1.166 (GPU 0.928: now over the budget, its ceiling 1.166); 3090 0.760 (its GPU
  ceiling 1.137 leaves the list); UHD 3.535 (GPU 2.395; fails either way).
- long_4cb, both runtimes at one size: 780M Phoenix 1.273, 780M HawkPoint 1.309, XTX 1.291,
  2080 1.345, 3090 1.266, UHD 1.154: pass on GPU time (0.99-1.01), fail on host time: a group's
  first command buffers are seen complete with its last. RX 550: the runtimes ran different sizes
  (1024 and 2048), so its ratio (1.014) is not comparable until both run the same work.

Test: tests::a_row_is_judged_by_host_time_never_its_gpu_time (wall time without commit-to-complete,
the mean of a run's places with it, the steady time of those means, none without host times).
scripts/matrix/test_results.py passes (28 tests).
2026-11-17 20:55:18 -08:00
Anees Iqbal 80bd8ca764 rt: pooled blocks are 16 MiB of Shared memory and 64 MiB of Private
A pooled block's length is now per memory class, MemoryClass::block_len: 16 MiB Shared and
64 MiB Private on every device. It replaces the one 256 MiB BLOCK_LEN. take_block gives a
pooled block up to the class's length and a dedicated one past it. Textures are placed in
texture blocks up to the Private length. The harness and the replay player's places take
blocks of the class's length.

Why: a driver may hold the device's other calls for the whole of a block's
vkAllocateMemory, and the hold grows with the bytes, so the length sets how long one hold
lasts. On an RTX 3090 (NVIDIA's Linux driver, probe at 70d7cae48e, jobs 44050 and 44053
with the RTX 2080), a pipeline creation beside a Shared block's making took 40-45 ms at
256 MiB and 6-8 ms at 16 MiB (3-4 ms settled). 16 MiB is the largest piece a guest's
allocator takes. Private holds less: 3.4-4.6 ms beside a 64 MiB block, at most 1 ms more
than beside a 32 MiB one. At 64 MiB, a texture or a Managed buffer's device copy of 32 MiB
takes a pooled block.

Tests: every_device_pools_16_mib_shared_and_64_mib_private_blocks covers the lengths, the
dedicated block past each, and a 32 MiB texture placed in a texture block. The memory,
command, places, spill and upload tests use the class's length. The memory test reads a
Private block back a Shared block's length at a time. API table re-blessed (the BLOCK_LEN
const goes, MemoryClass::block_len comes).
2026-11-17 20:51:54 -08:00
Anees Iqbal 9dada05c84 Re-bless the golden hash table after SEMANTICS_VERSION 2170
The pinned-subgroup-size change (48833908aa) bumped SEMANTICS_VERSION and
changed the simdgroup fixtures' modules; golden_hashes_match_the_table failed
with it, and AGENTS.md re-blesses on development after the merge. Blessed by
job m3-max-44193 at 1cd01ce3d7 (inventory, golden hashes and printouts all
exit 0; only golden_hashes.tsv changed, 280 rows); the commits since touch rt
only.
2026-11-17 20:50:16 -08:00
Anees Iqbal 50a09b553a rt README: the Managed copy form's known gap: a write reaches a texture over the device copy from the next submission
A command that writes a Managed buffer, or another texture over a range that meets the texture's,
reaches a texture over the device copy in an image of its own only from the upload that leads the
next submission: later commands of the same command buffer, or of a command buffer submitted with
it, read the older texels. A command buffer that wrote such a texture and is never committed
leaves its entry with the buffer until the buffer is released. Both were in the code's docs; the
known gaps of textures now say so where a user reads them.
2026-11-17 20:49:10 -08:00
Anees Iqbal 0277ef8dfe rt README: an M3 Max shows a texture over a Managed buffer an untold host write; the documented contract stays the rule
The probe managed_texture_stale_write.m (job m3-max-44076, macOS 27.0.1): after a host write with
no didModifyRange:, the texture over the Managed buffer shows the written bytes, as after a told
write; the macOS 27 SDK marks Managed storage as having no effect on Apple silicon. The runtime
keeps Metal's documented contract (copies in only at Managed events), which leaves the untold
write's visibility undefined.
2026-11-17 20:47:55 -08:00
Anees Iqbal 23633ab1f1 conformance probes: what a texture over a Managed buffer shows after an untold host write
The stale case of Metal's Managed contract (a host write with no didModifyRange:), run on a Mac
only to record what Metal does there, beside the told write as its control. Apple GPUs may alias
Managed memory, so the documented contract, not this answer, is the runtime's rule.
2026-11-17 20:47:55 -08:00
Anees Iqbal 4b88203551 rt: a texture over a Managed buffer's device copy that the device's linear image does not take is copied at Metal's Managed events
Where the device's linear image does not hold a texture over a Managed buffer's device copy in
place (another pitch, an offset off the image's memory alignment, a format or usage the linear
tiling lacks), the texture was refused (Gap::TextureOverBuffer). It is now an optimal image of
its own, copied from and to the device copy only at Metal's own Managed events, with no tracking
of commands:

- in, from the device copy, by the upload that leads the next submission using the texture,
  where a did_modify_range met its range (after the upload's copy of that range) or submitted
  device work wrote the buffer (a binding whose compiled interface writes it: the translator's
  uses, not the declared access; a blit or fill into it) or another texture over a range that
  meets its;
- back, where device work wrote the texture, before the next reader of the device copy (a
  binding that reaches the buffer, a blit from or into it, a copy into another texture over a
  range that meets its, a synchronize_resource, a did_modify_range over it). A reader recorded
  after the write takes it in its own commands; the upload that leads a submission, which runs
  before the submission's commands, takes it only once the write's segment was submitted
  (Segment::managed_wrote; the segment's submission settles each write it made).

The buffer keeps each such texture's entry (ManagedOvers). A texture released while its copy
back is owed leaves its image with the buffer until a reader takes it or the buffer is released;
a lookup by id skips a released entry, whose id a texture made since may hold. The Shared rules
(crate::over's per-submission copies) now apply only to textures over a buffer of no device copy
(copied_shared). The planner ruled that Managed keeps its device side; this is that side's copy
form.

Tests (device cfg): the Managed device test (100 uses copy in once; a modify over the range
copies once, one outside it not at all; a kernel's write owes one copy, a read none; a written
texture read through its buffer by a blit; a synchronize; two textures over one range; a
released texture whose buffer goes copies nothing back and frees its image; one released before
a kernel reads its buffer goes back first), and a kernel that declares a Managed buffer
read-write and never touches it owes no copy. README, Gap::TextureOverBuffer's doc and
docs/REFUSALS.md follow.

Verified: lint m3-max-44117 and device legs m3-max-44136 (780M HawkPoint, 3090), 44137 (RX 550),
44138 (XTX, 2080, 780M Phoenix, lavapipe), 85/85 each with the validation layer on, on the same
tree based on ed6d11d477. The Managed tests ran on the six GPUs and took the Shared rule on
lavapipe. An earlier form, which marked a write's copy back owed at its encoding, failed the last
step on five GPUs (m3-max-44101, 44102, 44103): the upload leading the write's own submission
took it before the write ran.
2026-11-17 20:47:55 -08:00
Anees Iqbal 1cd01ce3d7 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-17 20:46:36 -08:00
Anees Iqbal 48833908aa translator: a flattened kernel takes its pinned subgroup size as a constant, never SubgroupSize
In the flattened tiers (Direct and Cluster32) a kernel's linear local index is
lin = SubgroupId * S + SubgroupLocalInvocationId, and S was the SubgroupSize builtin. If a driver
answers that builtin wrongly, lin is wrong, and so are the positions of every simdgroup in a
threadgroup larger than one subgroup. On the UHD 630's Windows driver, a SPIR-V 1.3 compute
module (glslang) read SubgroupSize as 0 under a required size of 32 with full subgroups, while its
SubgroupId and lanes were right. rt's own SPIR-V 1.5 module for the harness's reduce_sum read it
right on the same GPU: simd_reduce matched the CPU reference.

Where the tier's requirement pins a size (SubgroupRequirement::size: 32 for Direct, the cluster
size for Cluster32, on a stage in requiredSubgroupSizeStages), the pipeline is created with that
required size, so the subgroups run at it. lin now multiplies by it as a constant, and the module
declares no SubgroupSize builtin. The same holds on every device, with no query and no device
identity. Where the stage pins no size, lin still reads the builtin, as before.

The constant is a literal from the same requirement that sets the pipeline's required size, not a
specialization constant: the size is fixed when the module is lowered for the profile, and no
pipeline of the module runs at another size.

SEMANTICS_VERSION 2170: flattened modules change.

Test: lower::dispatch::tests::a_pinned_subgroup_size_reads_no_subgroup_size_builtin. With a
pinned size of 32 or 64, the serialized module holds no OpDecorate BuiltIn SubgroupSize, and every
kernel builtin keeps Metal's value on the CPU interpreter at that subgroup width. Unpinned, the
module still declares the builtin. Without the change, the pinned module declares it and the test
fails.
2026-11-17 20:45:50 -08:00
Anees Iqbal 5a8d7521f1 rt tests: the in-place texture's allocation count is taken with the block-maker thread settled on both sides
Matrix d2fa098f0c's XTX leg (m3-max-44061) failed every_device_holds_a_texture_over_a_buffer_in_place
once: live allocations 4 against 3 around buffer.new_texture, texture blocks 0 on both sides, every
alignment answer 256 (as in the passing runs). Since 5c9ca33c48 the device makes its ready blocks
in Device::new, and the block-maker thread refills the ready Shared block the test's take_block
used, off the test's thread: the count read before the texture could miss the refill and the one
after see it.

Both counts are now taken once the pool holds a ready block of each class (settled), so the
refill falls before the first; a block the texture took from the pool would show as the refill it
causes, and one it allocated as a live allocation, so the claim stays exact (no tolerance). A
negative check: the plain texture the test makes later moves the same settled count.
2026-11-17 20:40:15 -08:00
Anees Iqbal 37f83d74a4 replay: the rt backend reads useResource:usage: and synchronizeResource: arguments as the stream's resource, {Buffer: object} or {Texture: object} (gb on the 3090 stopped there, m3-max-44112) 2026-11-17 20:39:21 -08:00
Anees Iqbal d7d9beaf7d harness: create_state keeps its float constants apart from the Metal constant values it makes of them; the texture view's doc links the trait's new_texture
The first state's check reads the constants as float pairs (check job m3-max-44075 failed to
compile where the Metal values shadowed them). The rt adapter's new_texture_view doc linked
Self::new_texture, which rustdoc does not resolve in a trait impl: cargo doc -p
metal2vulkan-harness failed with -D warnings on development.
2026-11-17 20:38:12 -08:00
Anees Iqbal a285ce86db harness: create_state's first is the creation and one dispatch of the new state through to completion, the creation alone beside it
The row timed new_compute_pipeline_state alone. The new runtime makes the VkPipeline there,
while the old one makes none and compiles at the first dispatch, so the row compared unlike
work. `first` is now the fair sum for both runtimes: the creation, then one dispatch of the new
state (one thread, one round of signed_zero_products into a Shared buffer) committed and waited
for, its float4 checked against the kernel's arithmetic. The row also prints the creation alone
(CreateReport::first_create_us), so the time can still be placed. The matrix line `first` is the
sum. The 1,000 creations of a seen content are unchanged.

The authored harness test checks that the first state's timed work makes a VkPipeline on each
runtime; on the old runtime it fails without this change, where the creation makes none.
2026-11-17 20:37:57 -08:00
Anees Iqbal 9d136f70ad rt: a released slot's command buffer gauge falls before the slot goes back
QueueInner::release pushed the slot and woke a waiting command_buffer() before the gauge fell,
so a command buffer made in that slot could raise the gauge first: the 2080 leg read 65 live
command buffers on a queue of 64 (m3-max-44097, every_device_keeps_its_gauges_flat_under_ten_
thousand_empty_commits at 80fcfd0d5c). The gauge now falls first, so it never reads more live
command buffers than the queue holds, which is what the test asserts.
2026-11-17 20:37:03 -08:00
Anees Iqbal f1c73d60bc A dispatch of a kernel that writes no memory records nothing
The translator states on a pipeline's interface whether some stage writes memory another
invocation or a later command can read (PipelineInterface::writes_memory, the union of the
stages' StageInterface::writes_memory: a store to a buffer or through a device address, a
texture write or an atomic update, in the entry or any function it calls; the
ExecutionStatus words are the product's and do not count). The cache's artifact format and
semantics versions move with the new field.

rt reads it into the compute state's interface. A dispatch of a kernel without it, direct
or indirect, is checked as Metal checks it and then records nothing: no bind, no push, no
vkCmdDispatch, and the indirect buffer is not kept or read. Metrics gains
dispatches_without_effects, which counts them. Such a kernel has no effect a program can
observe, so the only difference is less GPU and encode time than Metal's.

Tests: the translator's a_compute_pipeline_states_whether_its_kernel_writes_memory (a kernel
that returns at once, one that only reads, one that writes only its own thread's array: no;
a store behind a branch, a noinline callee's store: yes, on the function and the linked
pipeline, each validated), and rt's
every_device_records_nothing_for_a_dispatch_of_a_kernel_without_effects (a direct, an
indirect and an unbound dispatch of a kernel the interface says writes nothing leave the
buffer unchanged and count three).
2026-11-17 20:35:35 -08:00
Anees Iqbal be3426c673 harness: new_texture_view's doc names new_texture as plain code, not an intra-doc link
Rustdoc cannot resolve Self::new_texture from the trait impl's method, and
'cargo doc --workspace --all-features --no-deps' with -D warnings failed on it
(matrix d2fa098f0c, lint job m3-max-44059: unresolved link at
crates/metal2vulkan-harness/src/rt.rs:479). Verified by the doc job that
follows this commit.
2026-11-17 20:30:40 -08:00
Anees Iqbal 3fd4b72b2c replay: the report counts the recorded ranges a newer one met in part (parted), on both backends; the rt backend counts the compute pipeline IDs it cannot give as a typed gap (gap_pipeline_ids), summed on a gaps line 2026-11-17 20:28:46 -08:00
Anees Iqbal ad33c4269f replay: the rt backend plays fences on compute and blit encoders (rt's Fence, 05ce4db691); a render encoder's fence calls stay skipped with it 2026-11-17 20:28:46 -08:00
Anees Iqbal d0b7ead2c3 replay: a recorded range that meets a live one in part ends the older range, as the program reused that memory; gb's stream places a buffer over one still live in its block (m3-max-44056, 44065) 2026-11-17 20:28:46 -08:00
Anees Iqbal 5733e58c4e replay: the rt backend answers a compute pipeline state's resource ID as none, reported as differing, where the play stopped (gb, lavapipe, m3-max-44039) 2026-11-17 20:28:46 -08:00
Anees Iqbal 0383fdbded rt: the timestamp read waits for the two values, and reads only a command buffer that wrote both
On MoltenVK 1.4.2 (M3 Max) the timeline semaphore signals before the timestamp queries are
available for most command buffers: a read without VK_QUERY_RESULT_WAIT_BIT then answered
NOT_READY and the command buffer had no GPU times. Probe jobs on the M3 (MoltenVK admitted past
its floor items for the measurement only): m3-max-43673 read both ways at retire, 58 of 72 reads
NOT_READY with both availability bits 0, one NOT_READY then available a moment later, 13 Ok;
m3-max-43654 read with WAIT: every one of the test's 34 command buffers got its times, the read
holding the completion thread p50 2.0 us, p90 21.8 us, p99 76.3 us, max 80.5 us.

A WAIT read of a query never written may never return, so the completion thread reads only a
command buffer whose segments wrote both queries (stamps_written == 2); one that wrote fewer has
no times, as before. The readback site's bound and the README's list of sites say so.
2026-11-17 20:23:53 -08:00
Anees Iqbal 59f4094a65 Reflow the import lists the rebase resolution unioned 2026-11-17 20:23:03 -08:00
Anees Iqbal ec0687d290 rt tests: the empty stream's handlers run in commit order on completed command buffers with equal nonzero GPU times, and so does the texture synchronize's
Each of the 10,000 empty command buffers carries a completed handler that checks its place in
commit order, the status Completed, and gpu_start_time == gpu_end_time > 0; the test asserts
10,000 ran and none was wrong. The texture synchronize that now takes no submission asserts its
completed handler saw it completed and its GPU start and end equal and nonzero.
2026-11-17 20:22:52 -08:00
Anees Iqbal d02e69b956 rt tests: the tests an empty command buffer changes: uploads go with one that has commands, a texture's synchronize takes no submission, and the empty stream settles the pool first
A command buffer with nothing for the GPU takes no submission, so it no longer carries the
device's pending upload: the two blit tests whose first command buffer existed to send the
textures' uploads give it a command. A synchronize of a texture without named bytes records
nothing, so its command buffer takes no submission and no barrier: the test now asserts
(0, 0, 1) for submissions, barriers and synchronizations. The empty stream's gauge baseline is
taken once the block-maker thread has made its ready blocks, and a mismatch prints both sets.

Found by the RX 550 leg m3-max-44023 at 53310f18a2.
2026-11-17 20:22:52 -08:00
Anees Iqbal 5879cbdb74 rt: a command buffer with nothing for the GPU takes no submission
A command buffer whose segments hold no commands, no event wait and no event signal records
nothing at commit (no timestamps, no end barrier) and gets no submit entry. The submit thread
schedules it as it reaches it; it joins the group its queue holds, or completes with the queue's
submission in flight before it, or at once where nothing is in flight. Handlers keep commit order.

Its gpu_start_time and gpu_end_time are one time, never 0: the latest GPU end of its queue's
command buffers before it, or its commit where that is later. That is the shape the M3 reports
for a command buffer that does no work (conformance probe 45b5778d03, job m3-max-43955).

Tests: an empty command buffer between two busy ones completes between them with no submission
and equal times at or after the first's end; one alone completes with equal times not before its
commit; 10,000 empty commits take no submission, keep live command buffers within the queue's 64
and return every gauge to its baseline.
2026-11-17 20:22:52 -08:00
Anees Iqbal ed6d11d477 rt README: the Shared read times are medians of 10 runs, in each of two passes 2026-11-17 20:18:16 -08:00
Anees Iqbal beb77e8eab rt README: Shared on a discrete GPU is system memory, with the streaming read times
The planner closed the Shared-read rows as a property of the memory type: rt equals the old
runtime within 0.3% on the RTX 3090, RTX 2080, RX 550 and RX 7900 XTX (jobs m3-max-44010 to
44013, harness arms built at 409da2e7c9 and c9ba2da818 on c370d13dac, two passes of 10 runs),
both placing Shared in the host-visible, coherent, cached type, and the device-local host-visible
type is not a route (host reads at 18 to 37 MB/s; a 246 MiB heap where resizable BAR is off). The
README records the streaming numbers as that property.
2026-11-17 20:18:05 -08:00
Anees Iqbal a0171878fe rt tests: the width checks take the first index of the Texture class's range
Texture indices start past the storage images' (IndexClass::range); a grant of index 1 is past
the class's range (leg m3-max-44018, Limit::IndexRange).
2026-11-17 20:17:09 -08:00
Anees Iqbal 132c1fc35f rt tests: the width checks' textures take an index of a grant
A texture shaders read takes an index; the width checks at the answer's pitch made SHADER_READ
textures with none, refused on every GPU (legs m3-max-43984..43986). Each now takes index 1 of a
Texture grant, freed when it drops.
2026-11-17 20:17:09 -08:00
Anees Iqbal 8db961145b rt: the linear texture alignment answer is the device's linear row rounding alone
minimum_linear_texture_alignment no longer requires the linear image's memory alignment
(VkMemoryRequirements::alignment) to divide the answer. The answer is the smallest power of two P
at which the device lays every probed width's rows at the row rounded up to P, the largest over
the usages, and Metal's 16 where no P explains a format's pitches. The in-place test is
unchanged: a texture is in place only where its place in the buffer's memory is a multiple of the
image's memory alignment too, and is copied (over a Managed buffer's device copy, refused)
elsewhere. Nothing changes on NVIDIA, AMD or lavapipe, whose linear images' memory alignment
equals their row rounding (probe jobs 43742-43744). On the UHD 630, whose linear rows round to 64
bytes and whose linear images' memory aligns to 4,096 (probe 43758), the answer goes from 16 (no
P held) to 64, so a guest that pads its rows to the answer gets the device's own pitch.

Tests: tests::over places its textures at the answer rounded up to the linear image's memory
alignment (a test-only Device::linear_memory_alignment), and checks at widths 1, 3, 17, 64, 65 and
100 that a texture whose pitch is its row rounded up to the answer is in place; it prints how many
of its five formats answer 16. README and the getter's doc state what the number is and that
offsets are honoured in place only at the image's memory alignment.
2026-11-17 20:17:09 -08:00
Anees Iqbal 1ada6e8b1c rt: a texture over a buffer of no device copy that the device's linear image does not take is copied between the buffer and an image of its own
Where the in-place linear image does not hold a texture over a Shared buffer (or a Managed one
without a device copy) for its pitch, place, memory type or format features, the texture is now
an optimal image of its own instead of a Gap::TextureOverBuffer. The device copies the buffer's
bytes into it and back, one vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region a texture,
with no CPU copy (crate::over):

- in, once a submission: the upload that leads it copies into every such texture a segment uses
  before any command of the segment wrote the buffer; inside a segment, a use after a write of
  the buffer copies in again first; a segment leaning on the leading copy for a buffer an earlier
  segment of the held group wrote leads a new group;
- back, after a write of the texture: before the next command of the segment that reaches the
  buffer, and at the segment's end, whose end barrier then reaches the host.

Commands track what they write only while such a texture lives (a device count); a command
recorded while none lived counts as a write through an unbound address, so a texture made later
never leans on a copy that could precede it. Each copy counts in Metrics::over_copies and its
bytes in bytes_copied. The accepted difference (a CPU write between two held members' commits
races an uncompleted command buffer, which Metal leaves undefined) is stated at the rule and in
the README.

A texture over a Managed buffer's device copy that the linear image does not take stays a
Gap::TextureOverBuffer: the Managed branch waits on the measurement of whether a Managed buffer
keeps a device side at all.

Tests: tests::copy_over (every device under the device cfgs): a render target over a Shared
buffer at one alignment past the device's pitch copies in once per command buffer and takes the
host's writes; a fill then a use in one command buffer copies once, after the fill; a fill and a
use in two command buffers committed back to back takes the filled bytes; a blit's write to the
texture is in the buffer once the command buffer completes.

A view of such a texture shares its parent's image and id, so it is tracked and copied as its
parent; the live count counts the parent alone. An ended segment keeps its tracking, cut to the
textures that lean on the leading copy, for the submit thread to read in place.
2026-11-17 20:17:09 -08:00
Anees Iqbal 9a9135b4c9 Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-17 20:12:11 -08:00
Anees Iqbal 05ce4db691 rt: Fence, MTLFence, whose updates and waits on compute and blit encoders record nothing
A command buffer's encoders run in order and a queue's command buffers in commit
order, each encoder's writes reaching the commands after it through the barrier
at its end or its segment's end, so a wait after an update already sees them. A
fence keeps the first queue whose encoder uses it; a use on another queue is
Gap::FenceOtherQueue, as Metal's fence orders one queue and MTLEvent orders
queues. Another device's fence is Refusal::OtherDevice.

Test: every_device_orders_a_wait_after_an_update_and_records_nothing_for_either
fills a buffer in one command buffer and updates the fence from a blit and a
compute encoder, waits in a second committed before the first completes and
copies the buffer out, and counts the same submissions, barriers, bytes copied
and passes with the fence calls as without; a second queue's compute and blit
encoders get the gap. REFUSALS.md and api_signatures.tsv regenerated.
2026-11-17 20:11:26 -08:00
Anees Iqbal 5c9ca33c48 rt: the device makes its first block of each class before it returns
The block-maker thread made the pool's first Shared and Private blocks after Device::new
returned, so their allocations ran beside the consumer's first calls. On NVIDIA's Linux driver
(620.70.06), a vkAllocateMemory of host-visible memory holds the device's other calls,
vkCreateComputePipelines and vkQueueSubmit2 among them, until it returns: a 256 MiB Shared
block's allocation took 39 to 56 ms on an RTX 3090, and a pipeline state created right after
Device::new waited 47 to 61 ms behind it (2.4 to 3.1 ms once the block was made in
Device::new; scratch probe f3c15f7ca3, job m3-max-43980).

Device::new now makes READY (one) block of each class on its own thread before it starts the
block-maker thread, which keeps one of each ready after that as before. Memory held is the
same; Device::new takes the two allocations and their zero fills longer.

Test: every_device_holds_a_block_of_each_class_when_it_is_made: as Device::new returns each
class holds a ready block and the blocks gauge counts them, and the block-maker thread makes
none in the 200 ms after.
2026-11-17 20:10:27 -08:00
Anees Iqbal d2fa098f0c replay: a message to nil (receiver 0, no result, no class named) plays nothing, as Objective-C does nothing for it; gb's stream holds such a replaceRegion 2026-11-17 20:05:15 -08:00
Anees Iqbal 8cfda4b5e1 rt: the cache's writes make a missing pipelines directory, the pending count uses try_update, and the test kernel has a digest 2026-11-17 19:58:23 -08:00
Anees Iqbal 72f75ea087 rt: each VkPipeline is made through a VkPipelineCache of its own, kept as one file, under the consumer's cap
The device-wide VkPipelineCache and its blob (written every 10 s and at the end, up to
256 MiB) are gone. Each VkPipeline is made through a small cache started from its file,
pipelines/<pipelineCacheUUID>/<SHA-256 of its creation: SPIR-V, entry, stage flags, required
subgroup size, constant IDs, the runtime's layout and the specialization>. The reaper reads
the cache's data and writes it as the file unless it is no longer than the file's (the
pipeline came from it), then destroys the cache: nothing is written on the calling thread,
and a hit writes nothing. At most 64 caches wait for the reaper; past that the data is
dropped (a miss next time), never back-pressure. Without a directory a pipeline is made with
no cache.

Translations and pipelines share one LRU store inside DeviceOptions::pipeline_cache_cap
(None = 512 MiB), ordered by use: a file's time on disk, moved forward at a use when older
than an hour, so the order holds across runs and processes. File reads and writes run
outside the store's lock. Metrics::cache_bytes_written counts the bytes written. The README
says a consumer should pass a directory (None compiles cold every boot).

Tests: the store's cap across both kinds; eviction by time on disk of files others wrote;
a file another removed is a miss; on every device, a second device writes nothing and leaves
every file as it was while the first's bytes written equal the files'; a second process adds
one pipeline file for its new pipeline and rewrites none.
2026-11-17 19:58:23 -08:00
Anees Iqbal 26a7658e0e rt tests: a texture's image is read once the pending upload has run
The upload copies a Managed buffer's changed ranges at its end, after everything recorded into
it before (the blit lane's change). The in-place test read the image over a Managed buffer through
the same upload, so the read ran before the did_modify_range copy and saw the device copy's zero
fill, on every GPU (legs 43804, 43805, 43806). Texture::image_bytes (test-only) now has the
pending upload submitted and waits for it before recording its read, so it sees what the next
command sees.
2026-11-17 19:54:28 -08:00
Anees Iqbal 4ab2897bf1 rt: the over-buffer device test holds a shader-read-write texture in place, and prints a render target's form
A render target over a buffer is not held in place on NVIDIA (2080, 3090), so the in-place
checks use a texture shaders read and write, at indices of a grant; the render target's
answer is printed per device. The bytes the test copies are the plain texture's upload and
three image reads.
2026-11-17 19:54:28 -08:00
Anees Iqbal 7424f5301b rt: what holds a texture's memory is named in fields the image keeps, and the device test compares the answer asked again 2026-11-17 19:54:27 -08:00
Anees Iqbal 231a0cc003 rt: a texture over a Managed buffer lies in its device copy; blits and dispatches that write a texture over a Shared buffer reach the host
The in-place linear image binds in the bytes shaders reach: a Managed buffer's device copy
where it has one, so replace_region writes the consumer's bytes and copies the rows' span
into the copy as did_modify_range does, and get_bytes reads the consumer's bytes as Metal
reads a Managed texture's CPU copy. A blit or dispatch that writes a texture over a Shared
buffer marks its segment's end to reach the host, as a write to the buffer does.

The device test (tests/over.rs) checks the alignment answer, the in-place texture over a
Shared and a Managed buffer (nothing allocated or staged, the image the buffer's bytes as the
host changes them, replace_region and get_bytes, a blit's write reaching the host), the
layout refusals and the gap.
2026-11-17 19:54:27 -08:00
Anees Iqbal 9646734a11 rt: a texture over a buffer is the device's linear image on the buffer's memory, where its layout is met
Buffer::new_texture (newTextureWithDescriptor:offset:bytesPerRow:) binds a linear image,
made preinitialized and kept in the general layout, at the texture's place in the buffer's
block, where the device's own linear image of the texture lays its rows at the guest's pitch,
the place meets the image's alignment and memory type, and linear tiling keeps every format
feature of optimal tiling the usage uses. Nothing is copied: replace_region and get_bytes
write and read the buffer, and the hazard sets track the texture under the buffer's id.
Rows not whole texels apart or shorter than a row, an offset off a texel, or texels past the
buffer are refused (Refusal::BufferTextureLayout); what the device's linear image does not
hold is Gap::TextureOverBuffer until the copy form is built.

Device::minimum_linear_texture_alignment answers per format the smallest power of two at
which the device's linear images of nine widths lay their rows at the row rounded up to it,
and of which the image alignment is a factor, across read, read+render and read+write.
2026-11-17 19:54:27 -08:00
Anees Iqbal e432e01fd0 replay: the rt backend's skipped objects carry no unread kind; a new block's free range is pushed (clippy, job m3-max-43948) 2026-11-17 19:50:26 -08:00