Commit Graph
130 Commits
Author SHA1 Message Date
Anees Iqbal 62c563f564 replay: the over-copies' causes among the executed counters
The report counted over-copies and their bytes, and those over imported blocks, but not why the
runtime keeps each texture in an image of its own. The runtime already splits them by cause in
Metrics (over_copies_host_memory, _pitch and the ten like them, each with its bytes). The backend
now reports all twelve pairs, so a frame's, a completed group's and the total's over-copies split
by cause. This is what the planner asked for to split the 48,710 small over-copies across the link.

Validation only; the runtime is unchanged. The replay stage test now also checks that two of the
keys are there.
2026-11-20 20:10:00 -08:00
Anees Iqbal 9027bd2aa3 rt: count scheduled-to-start under earlier GPU spans, GPU-end-to-handler steps and calibrations
The clean 5080 re-play's print needs three things the stage sums alone cannot give.

First, how much of each command buffer's span from scheduling to GPU start lies under other
command buffers' GPU spans, the runtime's own uploads and copy-ins included, against the part
under none of them. This is Metrics::scheduled_to_gpu_start_behind_nanos.

Second, its span from GPU end to handlers split at the completion thread's own steps. This is
Metrics::gpu_end_to_handler_steps_nanos, six steps:
- seen: GPU end to the thread seeing the completion;
- told: telling the submit thread;
- stamp read: reading the round's timestamps;
- calibration: a calibration, where the round runs one;
- earlier: the round's earlier retirements, their handlers included;
- own: its own retirement until its handlers begin.
The same steps are kept for the command buffers of 1,024 us or more (gpu_end_to_handler_tail
and its steps), so a 1-8 ms tail can be placed in a step.

Third, the calibrations and their calls' time. The counter that only the tests had becomes
Metrics::calibrations, beside calibration_nanos.

The replay backend reports all of these as executed counters.

Counting only; nothing changes form. There are no new waits, locks or allocations. What each
count costs:
- Completion thread, per round: two clock reads (the stamp read's start and end), and a third
  where it calibrates. The period check reuses the stamp read's end, so it no longer reads the
  clock itself.
- Per command buffer retired: one clock read where its retirement begins, then for one that
  counts stages:
  - one pass over a fixed ring of the latest 128 GPU spans, a stack array in the completion
    thread;
  - a sort, on the stack, of those that meet its span;
  - one relaxed atomic add for the behind part;
  - six for the steps, and seven more for one in the tail.
- Per upload or copy-in retired: the timestamps it already read go into that ring. There is no
  second query read.
- Per calibration: two clock reads and two relaxed atomic adds.

Retirement returns an upload's and a copy-in's two timestamps (times::retire_own). The
completion thread places them on the host clock by the calibration as it stands
(Calibration::at, which moves nothing), and the program's command buffers' spans as placed.

Tests:
- host tests for the ring's merged, clipped union and its oldest-first replacement;
- a host test for the round's steps adding up to the span;
- the device stage test now checks that the six steps add up to gpu_end_to_handler_nanos, that
  the behind part is at most scheduled_to_gpu_start_nanos, and that the device start
  calibrated;
- the replay stage test checks the same through the report's keys.
2026-11-20 20:09:37 -08:00
Anees Iqbal b1b5168fd6 Replay report: untimed waits, the runtime's stage sums and its stage histograms by frame
The 5080 play of a 3090 compute recording waited 42.5 s of 95.1 s wall with 23.1 s of gpu_busy;
before a fix is ruled on, the report must say where the other 19.4 s went. Three reads were
missing from it:

- A waited command buffer with no GPU interval (start 0, or end not past start) adds nothing to
  gpu_busy while its wait counts in full. Each frame's end line now has untimed_waits and
  untimed_wait (the wait spent on them), and the report sums them in an `untimed waits` line.
- The runtime already histograms every command buffer's commit to scheduled, scheduled to GPU
  start, GPU run and GPU end to handler, but only in power-of-two buckets, which give no seconds.
  Metrics now keeps each stage's sum beside its histogram (commit_to_scheduled_nanos and the
  three like it), counted in the same call as the bucket.
- The player printed none of it. The backend's executed counters, so every frame line and the
  total, now carry the four sums, held_starts and held_start_gap_nanos, runtime_command_buffers
  and runtime_command_buffer_gpu_nanos (the uploads and copy-ins that run outside every Metal
  command buffer's GPU interval), and untimed_command_buffers. The four histograms print at the
  play's end as `stages F ...` lines, cumulative as each frame ended, and `stages end ...`.
  They are not per-frame counters, so the 69k `completed` lines of a long play do not grow by
  92 keys each.

Tests: the runtime's stage histogram test also checks each sum against the three command
buffers' own times (exact for the first three stages, bounded by the host time after each
finished for the fourth); a player test on the synthetic backend counts a frame's untimed
waits (none and zero-length intervals) and the report's sum; a lavapipe replay test reads the
new counters and the stages lines across two frames.
2026-11-20 19:44:55 -08:00
Anees Iqbal 999b82bfe2 player: a pipeline state's making counts what it made, lowered, loaded and VkPipelines, and a load makes its content new
What: each group and each slow making carries "L lowered, D loaded, P VkPipelines"
(translations, translations_loaded, pipelines_created). A making is of "new" content where it
made any of them, and "held" where it made none.

Why: the warm pass of m3-max-60954 showed the first form calling a load-only compute state
"held", and using the word "cold" in a second pass.

Verified: the same test, which now also checks the counts and the held state's zero driver time,
green in m3-max-60980.
2026-11-20 17:38:00 -08:00
Anees Iqbal 10d00d44b4 player: each pipeline state's making split into the translator's, the driver's and the rest
What: the replay report gains a `pipeline makes N states: ...` summary line and up to ten
`pipeline make slowest K #ID KINDS ...` lines, documented in docs/REPLAY-STREAM.md. KINDS is
kernel, vertex or post-tessellation vertex, plus +fragment.

How: each render and compute state's making is read from metal2vulkan-runtime's own Metrics on
the player's thread before and after it, with the wall time on rt::host_time (the counters' own
clock): translation_nanos against pipeline_creation_nanos, and the rest as "other". No runtime
counter is added. rt makes every state on the calling thread, and the only other thread that can
run beside a making is the player's own pre-pass. So the pre-pass pool now tallies its
prepare_dispatch calls begun and ended. A making that ran while one of them ran is counted
("beside a pre-pass call") and marked, since its figures include that call's work. The compute
states' `pipeline I wall_nanos=` lines take their wall time from the same clock.

Why: the next cold number needs its cause beside it: per pipeline, the translator's work against
the driver's vkCreate*Pipelines.

Verified: replay::rt_replay::each_pipeline_state_s_making_is_split_into_the_translator_s_and_the_driver_s_time
on lavapipe (m3-max-60980, with fmt, clippy plain, m2v_gpu and m2v_cpu_icd, and workspace
Rustdoc green). Without the line it fails at the summary-line find. On a real card: the cold and
warm states-only plays of one recorded stream on an RTX 3090 (m3-max-60954).
2026-11-20 17:38:00 -08:00
Anees Iqbal 2628c03fb2 player: a Windows host's video surfaces through an NT handle (--video-handle opaque-win32)
The Windows plays of boot-idle-780m-1 stopped at frame 212, the stream's first video surface:
"error newTextureWithDescriptor:iosurface:plane:: the device exports no DmaBuf" (60780). The
video stand-in knew only the Unix routes, a dma-buf (the default) and an opaque fd, while the
runtime exports a surface on Windows through an NT handle (ExportHandle::OpaqueWin32), and
answers NoExport for a dma-buf there, correctly.

VideoHandle gains OpaqueWin32 (`--video-handle opaque-win32`): the surface is exported as an NT
handle at the opaque fd's layout, pitch multiple 4, start multiple 1, no rows below. The runtime
lays both opaque handles alike, each plane's LINEAR image at the driver's own pitch (its guide,
the surfaces' handles), and its own Windows surface tests make the surface at those multiples
(tests/surface.rs: the NVIDIA row and BUSY_ROWS on Windows). command-replay and
docs/REPLAY-STREAM.md name the route.

Test: new_runtime::tests::each_video_handle_names_its_export_and_layout.
2026-11-20 16:53:38 -08:00
Anees Iqbal 1fc878dc12 player: count every creation it does not attempt, by selector, reason and root
A call that makes an object on a skipped receiver, or naming a skipped object, made its result
skipped without a line: such a pipeline state counted only in skipped_objects or skipped_calls,
so a stream's 494 render pipeline states against the play's 493 passed unseen.

Each such creation is now counted by its selector and reason (its receiver is skipped, or it
names a skipped object), the reason naming the selector that made the chain's first object
skipped; each skipped object keeps that root, inherited along the chain and removed at release.
The report prints a `not attempted SELECTOR N: WHY, the first #ID (its root #ROOT)` line for
each, the counter `not_attempted`, and a line that adds up the pipeline states: render states
made, refused and not attempted, and the compute states the same. The existing counts are
unchanged.

Test: new_runtime::tests::creations_not_attempted_are_counted_by_kind_and_root (a library from
source skipped, a function of it, two render states of that function, one refused state).
2026-11-20 15:52:07 -08:00
Anees Iqbal 66e8f70882 replay player: the m2v.privateBytes snapshot path goes; the unsnapshotted count stays
What, deleted:
- Backend::snapshots, and its answers on the runtime backend (false) and the tests' mock;
- Player::without_snapshots and the player's snapshots flag, and command-replay's
  --snapshots yes|no option; the device line is now `device NAME runtime rt`;
- the split around a named dispatch (split, blit_between, the player's own objects and the
  open-encoder tracking it needed), the snapshot compare, Snapshot, Around and sized;
- Report's private, splits and split_executed, with the `private ...` and `split N executed`
  lines, and PrivateBytes with its re-export; the covered and receivers lines lose their
  always-zero snapshot range counts;
- Covers::meets, which only the split used.

Kept: the records are still read ahead, with the same check of their form and that each names
an earlier call. Each dispatch they name plays as the program made it and counts on the
`unsnapshotted` line.

Tests: the split test goes. The two no-snapshot tests become one that checks the named
dispatch plays as recorded and is counted, and one that checks a record naming no earlier call
stops the play. The covered and receivers tests take the new line text.

Docs: REPLAY-STREAM.md drops the option, the snapshot wording, the `private` line and the bytes
before as a write path, and says what the player does with the records now.

Why: the runtime backend is the only one left, and it answered snapshots() false, so on every
play the split, the compare and their report fields could not be reached. Only the mock reached
them.

How verified: the lane's compile gate with the validation suite on lavapipe.
2026-11-20 11:18:04 -08:00
Anees Iqbal c120b74608 replay player: a noted buffer's address in written bytes moves with the buffer
What: once the stream notes a buffer escaped (m2v.bufferEscaped), the player no longer stops at a
written word whose value lies in that buffer's recorded range (PlayError::NotedWord, now deleted).
It moves the word with AddressMap::move_noted to AddressMap::relocated(value), the address the play
gave the innermost live range the value lies in plus the same offset, the same move an address
argument gets. This happens after the census counts and before the bytes reach the backend, on
all five write paths:
- set*Bytes data;
- a copied buffer's contents;
- m2v.write;
- the m2v.copyFromGuestRam pieces;
- the m2v.privateBytes bytes before a dispatch.
A new stream count, noted_words, counts the words moved. The census counts are still taken from
the bytes as the stream holds them.

Why: the runtime backend makes objects where it has room, so a pointer the program wrote into
memory held the recorded address and pointed at nothing in the play. The stop ended every replay
of a stream whose buffers escape (one of reims's plays stopped at frame 216). Every live range has
the address the backend made its object at; a make without one already stops at the make. So
every noted word can be placed, and the stop has no case left. A pointer into memory no live
range holds cannot be told from data and plays as recorded, as before. This runs on every
backend and device; nothing is keyed by identity.

Docs: REPLAY-STREAM.md section 5 (written words and the escape note) and section 10 (the stream
counts and the addresses line), VALIDATION.md, and command-replay's addresses line, which gains
noted_words.

Tests:
- Unit (mock backend), a_word_into_a_buffer_noted_escaped_moves_with_it. After the note, a word
  in an m2v.write and a word in setBytes data each move to the mock's base plus their offset,
  and are counted as noted. The same word written before the note, and a word into a buffer with
  no note, play as written.
- lavapipe, a_noted_buffer_s_address_in_written_bytes_moves_and_a_kernel_follows_it. A block at a
  recorded address holds a data buffer noted escaped (kind 0) and a buffer whose written word is
  the data buffer's recorded address plus 16. The fixture kernel ab_address (out[i] = held.p[i])
  follows the moved word, and out holds the data words from the fifth on, exactly.
- Negative: the two tests on development's tip without the move. The play stops with NotedWord.

How verified: the lane's compile gate with the validation suite on lavapipe, and the negative job.
2026-11-20 10:50:42 -08:00
Anees Iqbal 58beab6630 REPLAY-STREAM: the player as it plays now, on the runtime alone
The player's one backend is the runtime's (replay/new_runtime, through
rt_replay, from command-replay play). The doc still described a second
backend over the deleted runtime and every rule where the two parted:

- Section 5's recorded-address placement (pins, heaps split by their
  buffers and textures, PlayError::Unpinned) is deleted; the backend
  places each object where the runtime has room and moves the address
  arguments. The resource-ID rule says the runtime's own placement.
- Section 9's heap note on the old player goes.
- Section 10: one copy rule for Managed buffers, one announced-bytes
  rule, no old backend refusal list; the snapshot procedure is replaced
  by what the backend does (it takes none, so each named dispatch plays
  as it is, on the unsnapshotted line) and the split line goes with it;
  the executed counts are the runtime's metrics (Device::counters, as
  new_runtime's counters() reads them); the tiled-texture stand-in and
  the video-surface pages no longer name the old forms; the report's
  device line reads 'runtime rt', and its pinned line and the old
  runtime's gauges and covers go.
- 'the new runtime' and 'either runtime' read 'the runtime'; two plays
  compare across devices or commits.

Not built; docs only. The gate for the whole pass follows.
2026-11-20 10:27:18 -08:00
Anees Iqbal 8871d40bdf Validation: delete the old runtime's lane, parity harness, player backend and old-only tools
The old runtime goes at the cutover, and validation's old-runtime-only parts go with it:

- runtime_lane/ (the old runtime's device tests) and the Metal predication probe that pinned
  its streams. Its one rt-based module, the replay player's rt device tests, moves to
  replay/rt_replay.rs with its three old-runtime comparisons cut (the census test on both
  runtimes goes; its rt half is its own test) and a pipeline cache directory of its own in the
  scratch root.
- parity/ (Metal programs compared with the old runtime alone) and its Metal records under
  corpus/observations/parity.
- The player's old backend (replay/old_runtime): command-replay always plays on the new runtime,
  and `--runtime` is gone.
- corpus-draw-ab and format-scout (old-runtime-only tools), scripts/making-bench (corpus-draw-ab's
  bench), and the eleven public fixtures only the deleted sources used.
- The nextest overrides of runtime_lane tests, the queue-plan test group and the few-channels
  profile; the matrix's device-test filter now names replay::rt_replay.
- VALIDATION.md, REPLAY-STREAM.md and validation's README lose the lines of what went.

The candidate executor's runtime path, and validation's dependency on metal2vulkan-runtime, go in
the next commit.
2026-11-20 05:42:33 -08:00
Anees Iqbal 5458ac7954 validation: a check or dump of a buffer with two copies names the copy it read
A two-copy stream's Managed buffer has a CPU copy, which Metal's contents answers, and a device
copy, which commands read. The player's check and dump read the CPU copy (Backend::read on the new
runtime), and nothing said so: on a discrete card, two plays' dumps of #106455 agreed as CPU copies
while the device copies the kernel read differed (count word 1848 against 12), and the verdict
'inputs equal' rested on them.

Now a check line of such a buffer ends '(CPU copy)' or '(device copy, read back)', a dump holds
cbC-objO.copy with those words, and compare-dumps compares only the same copy of both plays,
reporting 'copies differ' otherwise and counting the buffers compared as CPU copies and as device
copies in its summary. The new runtime's play reads the device copy with --read-device-copies yes:
through a blit into a Shared buffer of the play's own where the runtime keeps one, through the
buffer's mapping where the device's one copy is the GPU's and the player keeps the CPU's. On a
device that keeps a device copy, the report's 'managed digests' line after its device line says
which copy the play reads. Backend::read_copy names it; the old runtime's backend names none.

Tests: a_read_of_a_buffer_with_two_copies_says_which_copy_it_took (no device: both labels in the
check lines and dumps, the compare of like and unlike copies) and, on a device,
a_check_of_a_managed_buffer_names_the_copy_it_read (a blit's fill reaches the device copy: the CPU
copy reads zeros, the device copy read back reads 7s; the header line where the device keeps a
device copy). docs/REPLAY-STREAM.md section 10 says it.
2026-11-19 20:00:32 -08:00
Anees Iqbal f61fee8aac replay: the new runtime's play reports its commits' waits for the work lock
The executed counters take the runtime's commit_lock_wait_nanos, so a frame's line gives its
commits' waits for the work lock, summed; the backend's lines give commit_lock_wait_max_nanos,
the longest wait in the play, which is a maximum and no frame's counter. The runtime has no
product metric of the other calls' waits for the lock (the surface make's included): only the
device tests' per-thread total times those (crate::submit::waits).

Read with it (player built at this change's first form, 307b1998f9, job m3-max-55631; no
validation layer; the player commits from one thread, so these say only that the runtime's own
threads, submit, completion and block maker, hold no caller long):
- syncview-4k-780m, whole (1501 frames), Radeon 780M (RADV), job m3-max-55670: 0.609 ms of waits
  over 8066.2 ms of frames (0.008%), the mean frame's share 0.007%, the worst frame's 0.301%
  (0.022 of 7.436 ms), the longest wait 23.3 us, no frame's waits past 1 ms;
- glbench-3090-r2 to frame 300 (301 frames), lavapipe, job m3-max-55669: 3.680 ms over
  39383.2 ms (0.009%), the mean frame's share 0.007%, the worst frame's 0.431% (0.015 of
  3.370 ms), the longest wait 1.367 ms, in the one frame whose waits passed 1 ms (1786.6 ms long).

Verified: see the check job named in the landing.
2026-11-19 18:46:06 -08:00
Anees Iqbal bc45258bdf replay: a tiled texture of more than one level plays on the new runtime as the old runtime plays the call
The new runtime takes no form of the SPI newTiledTextureWithDescriptor:offset:bytesPerRow:, and the
player made an ordinary texture in its place whose texels were not the program's: on lavapipe the
two runtimes' plays of one stream first parted at the frame whose draws first read such a
texture. Those texels now come from the buffer, as the old runtime gives them.

What the old runtime does, read from its code:
- crates/metal2vulkan-runtime/src/buffer_texture.rs:534-591 (Buffer::new_tiled_texture) and
  shadow.rs:228-250 (the module's "Copies taken at use"): a texture of more than one level is one
  image of its own. The first command of an encoder that uses any of its levels after the making
  (or after did_modify_data, or a replace_region of the first level) takes the copy, before that
  command and inside its command buffer. The take copies every texel of the first level from the
  buffer at the offset, rows bytesPerRow apart, then makes each later level from the first as
  generate_mipmaps makes it. It reads no level past the first from the buffer.
- shadow.rs:386 (LevelsCopy) and :404 (LaterLevels): the later levels come from generate_mipmaps'
  plan for the format (the device's blit chain, the compute filter, or the integer picks). For a
  format that generate_mipmaps leaves as it is or refuses, they are kept.
- buffer_texture.rs:537-538: a texture of one level is the texture over the buffer that
  new_texture makes.

The stand-in, through the runtime's public API only:
- An ordinary texture of the descriptor.
- At the first use since its making, the take is owed to that use's command buffer. A use is an
  encoder's command or a render pass's attachment naming the texture or a view of it, skipped
  encoders included.
- The take runs as one blit encoder (copy_from_buffer into level 0, then generate_mipmaps) in a
  command buffer of the play's own. It is committed on that command buffer's queue, after its
  copies from the guest's RAM and just before it, so it reads the bytes as they are when that
  command buffer runs. A format the runtime refuses mipmaps of (MipmapFormat, MipmapFilter)
  keeps its later levels.
- Counted apart from the stream's work: tiled_textures, tiled_takes, tiled_take_bytes,
  tiled_mipmap_generations, tiled_levels_kept, and tiled_gpu_nanos (its GPU time, in no frame's
  gpu_busy, as the guest RAM's copies are). The report has a "tiled textures over a buffer" line.
- A tiled texture of one level plays as the public texture over the buffer.
- A replaceRegion of a tiled texture's first level is refused. On the old runtime it writes the
  bytes and owes another take; no stream played here has one.

Where it differs from the old runtime: the take runs ahead of the whole command buffer, not just
ahead of the using encoder, so what an earlier encoder of that command buffer writes into the
bytes or the texture lands after it.

The tiled kind leaves the substitutes: substituted_tiled_textures is gone. The "substitutes read"
line now counts gap substitutes alone.

Tested by:
- rt_replay::a_tiled_texture_takes_its_buffer_s_bytes_and_levels_at_first_use (lavapipe, both
  runtimes): a 128x2 two-level tiled texture whose 2x2 squares hold one colour each. Blits of both
  levels read the buffer's texels and the squares' colours, with equal digests on both runtimes
  and one take counted.
- The unit test of the substitute lines, now gaps alone.
2026-11-19 16:55:04 -08:00
Anees Iqbal c601423452 docs: a picture difference traced to a counted player substitute is the second accepted class
The planner's ruling on the replay matrix's rule (c): besides a first parting draw traced to a
function that carries a static precision note, one traced to a counted player substitute (an
ordinary texture the play makes in place of one the runtime cannot make, whose texels are not the
program's) is accepted with its size printed, and its row says where the replay substitutes what.

Docs only.
2026-11-19 16:55:04 -08:00
Anees Iqbal 5f6cdc6b56 replay: a picture difference is sized, and each frame's end carries the system's clock
A digest play that checks a present (--check-presents) now also keeps the shown texture's bytes
as presents/frame-F.bytes in its --out directory, with a `shown ID frame F format P width W
height H` line from the backend's shape of the texture (Backend::texture_shape, old and new
runtime). compare-plays, with no --frame, prints for each frame whose digests differ and whose
bytes both plays kept the texels that differ and their share, the largest difference of each
channel in the format's units (8-bit unorm, 10:10:10:2 and half-float layouts; bytes for
another), and the box the differing texels lie in. The bytes stay on the host that played them.

Each frame's end line gains unix_nanos, the system's clock at the frame's end, so a job wrapper's
own timestamped device samples can be set beside the presents.

REPLAY-STREAM.md gains both, and the planner's two rules: a picture difference at the judged
frame is accepted only when sized and its first parting draw is traced to a function with a
static precision note and no state difference; an NVIDIA time row bins presents by the covering
clock sample's state, at least 30 an arm, else "not comparable by time" with the counts.

Tests: replay::tests::a_kept_present_writes_the_shown_texture_s_bytes_and_each_end_its_time,
a_picture_difference_is_sized_by_texels_channels_and_box,
two_plays_kept_pictures_that_differ_are_sized.
2026-11-19 16:55:04 -08:00
Anees Iqbal c46b159238 replay: the new runtime's play reads a Private texture through a copy
A check of a Private texture (a stream's m2v.check, or the shown texture of a present that
--check-presents lists) read it with getBytes, which the runtime refuses for a Private texture as
Metal does, so a digest play on the new runtime stopped at the first listed present whose texture
is Private ("the CPU reaches no Private or Memoryless texture"; syncview plays on Iris and the
3090 stopped at frame 296). The old runtime's play reads every texture through a blit. The new
runtime's now copies a Private texture's first level into a Shared block on its read queue, as it
reads a Private buffer, and waits for it; a texture the CPU reaches keeps getBytes.

Test: rt_replay::a_private_shown_texture_is_checked_through_a_copy clears a Private 4x4 RGBA8
texture to red, shows it at present 0 and lists that present; the check's sha256 is the 16 red
texels'.
2026-11-19 15:37:23 -08:00
Anees Iqbal 6812e2991c rt: no device enables VK_EXT_zero_initialize_device_memory; the runtime writes every zero
Under RADV (Mesa 26.2.6) an RX 7900 XTX's memory allocated with
VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT read earlier processes' bytes, so the
form's zeros are not the zeros Metal's newBufferWithLength:options: and a new texture
owe. Metal says a new buffer is zeroed; the runtime now writes those zeros itself on
every device, with no per-device exception and no start check.

The extension leaves the optional list; its feature, the allocation flag and the
zero-initialized image layout go, with Capabilities::zero_initialize_memory,
Features::zero_initialize and ZeroInitializeDeviceMemoryFeatures. BlockInfo::zeroed
and the zeroed-take and zeroed-texture metrics lose their source and go. A placed
texture is cleared in its upload on every device (texture_clears); the harness zeroes
every buffer through new_buffer's zero_from; the player's judged zeroed-texture
metrics are the clears alone. The rt README records why the extension is unused.

Verified: see the check job named in the landing.
2026-11-19 15:29:30 -08:00
Anees Iqbal 42fd38d03a replay: the player's video surface waits for its ready point once it is made
The surface make now submits and waits for nothing (9c4eca8313): each in-place plane image leaves
the undefined layout in the runtime's next submission, a move that may discard the memory's bytes,
and the consumer calls Surface::wait_until_ready before the other API's first write. The player's
rt arm made video surfaces without that wait, so its plays of a video recording did not do what the
product does between a surface's make and its first picture. It now waits once at the make (the
earliest the player knows the surface's format and size), before any m2v.externalWriteDone
acquires it, and the report's executed counters carry the runtime's surface_waits.
docs/REPLAY-STREAM.md section 10 says so.

Test: runtime_lane::rt_replay::a_video_surface_is_waited_for_at_its_ready_point_once (Unix: one
surface for two plane textures, two acquires, surface_waits equal to the surfaces made in place).
2026-11-19 14:30:47 -08:00
Anees Iqbal c6d78ec93f replay: --check-presents checks the texture a listed frame's present shows
A timing verdict between two plays (compare-plays) needs equal digests at the judged frame, and a
stream without m2v.check records (the desktop-and-video recording has none) gave no frame a
verdict. command-replay play --check-presents F,... now checks, at the m2v.present of each listed
frame, the texture the present shows, as an m2v.check of it with no recorded checksum would: a
check line of that frame, which compare-plays reads as the frame's digest. A present of nil
checks nothing. The readback is the player's own work (uncounted) and its time is the frame's
read, so the digests come from a play apart from the timed ones; docs/REPLAY-STREAM.md says so
in the player's section and in the verdict rule.

Test: replay::tests::a_listed_present_checks_the_shown_texture (no checks unlisted; checks at
frames 1 and 3 of the listed 1, 2, 3, frame 2's present being nil; the line's digest is the
backend's bytes; every present still ends its frame).
2026-11-19 14:20:06 -08:00
Anees Iqbal 798dfcda6a replay docs: the video surfaces' form and --video-handle
docs/REPLAY-STREAM.md section 10 now says how the new runtime's backend plays a buffer made as a
video surface's pages (one surface through Device::new_exported_surface, its plane textures' views,
the acquire at m2v.externalWriteDone, no shapes or refills), what --video-handle picks (dma-buf with
the VA-API layout, opaque-fd with NVIDIA's), what the video-surfaces report line and the video_*
counters count, and how the old runtime's backend plays the same buffer; section 4's table says the
same for the two records. Docs only.
2026-11-19 14:20:06 -08:00
Anees Iqbal 347a33736a replay rt: the report counts patch draws through a pipeline record without tessellation
A render pipeline record without the tessellation key comes from a recorder
that did not carry it (glbench-3090-r2, glbench-3090-r3 and glbench-780m-r1
hold 19 post-tessellation records, none with the key; the newer recorders
write the key on every record, the defaults included), so the program's
tessellation state there is unknown and the player draws with Metal's
defaults in its place. The new runtime's backend marks each such state at its
making, carries the mark to the encoder at setRenderPipelineState:, and counts
the patch draws it plays through one: patch_draws_unrecorded_tessellation in
each frame line and the total, and a report line saying the state is unknown.
A released state drops its mark. REPLAY-STREAM.md says a record without the
key does not hold the program's state.

Test: a_record_without_the_tessellation_key_is_unrecorded (the key check and
the line). Checked by a potluck check job on msi (clippy in three
configurations and the touched tests).
2026-11-19 13:37:53 -08:00
Anees Iqbal a1508fdd14 replay: each frame's end line names its longest command buffer and its GPU time
A frame's `end` line gave only `gpu_busy`, the union of the GPU intervals of the command buffers
the frame waited for, so no report could say how long one submission ran: a frame of 1871 commits
with 12.7 s of GPU time could be one long command buffer or many short ones.

The player now keeps, beside the union, the longest single interval among those it already reads
(`Backend::gpu_interval`, the runtime's completion record) and that command buffer's stream id,
and the line prints them as `gpu_longest=N gpu_longest_cb=ID` after `gpu_busy`: the first of equal
ones, 0 and 0 where the runtime gives none. No query, wait or submission is added.

docs/REPLAY-STREAM.md section 10 states the two fields.

Tests: a new fake-backend test, replay::tests::a_frame_end_names_its_longest_command_buffer, and
the end-line assertion of a_frame_end_counts_overlapping_gpu_intervals_once, which takes the new
fields.
2026-11-19 13:37:53 -08:00
Anees Iqbal 56958391f8 replay rt: the report counts translator refusals and substitutes by kind
The rt backend's report lumped every translator refusal of a pipeline state under one
`Translation` key, so a play's `skipped render states` and `skipped compute states` lines named
only the first refusal's WHY, and counted gap substitutes with no kind at all. A census that joins
a play's refusals against open refusal sites needs each one's kind.

- `skipped render states` and `skipped compute states` key a translator refusal as
  `Translation(KIND)`: `Unsupported(FEATURE)` with the refused feature as Rust prints it for
  debugging, `LimitExceeded(LIMIT)`, `Internal(KIND)`, or the error's variant alone. Never a symbol
  or a location, which name the program's functions.
- A new `substituted textures KIND N, the first #ID` line per kind of substitute: `Tiled`, or the
  runtime's gap as Rust prints it (`TextureView { kind: TextureType }`). The counters
  `substituted_tiled_textures` and `substituted_gap_textures` stay as they were.
- docs/REPLAY-STREAM.md section 10 states both.

Tests: two device-free tests in replay::new_runtime::tests. The refusal test fails on the old
single `Translation` key; the substitute test does not build without the per-kind count.
2026-11-19 13:37:53 -08:00
Anees Iqbal 11fba036f2 player: the managed-read count on the report and compare-plays for a timing verdict
A timing verdict between two plays of one stream (old against new, or two commits) needs both
plays by a player that serves every read class the stream has, equal player-side counts at the
judged frame and equal digests there. Nothing in the tree checked any of it: the rows were made
by hand from two reports.

The report gains a `managed reads on two copies` line. Counted from the stream's calls alone,
alike on every runtime and device, it gives the GPU's reads of Managed bytes that no
announcement took to the GPU copy, in two kinds apart:
- made-with reads, of the bytes a buffer was made with, which the player serves on both
  runtimes since d88af7befe (the line says "served");
- stale reads, of bytes an m2v.write put in with no didModifyRange:, which Metal leaves undefined
  and both runtimes play by one rule ("played as recorded").
With no identity record, a no-copy buffer's writes before its first use are served
(fb183b48f7) and not counted. A one-copy identity record counts none. The count lives in
replay/stale.rs and is fed from the player's make, write, commit and release.

Each check line now names its frame (`check #ID frame F SHA ...`), so a digest can be matched to
the frame it judges.

`command-replay compare-plays --a REPORT --b REPORT [--frame F]` (replay/compare.rs) reads two
reports and prints:
- whether each player serves every read class (it has the managed reads line);
- the frames whose player-side counts differ: stream calls, draws and dispatches, and every
  executed skip and refusal count;
- the frames whose digests differ, naming the stale reads as the first suspect on a two-copy
  play;
- with --frame, the verdict (GPU-busy and wall time, "b is P% faster|slower than a") or why there
  is none.
docs/REPLAY-STREAM.md states the verdict rule as the planner ruled it. Stale reads bar no
verdict.

Tests (replay::tests):
- a_two_copy_stream_s_managed_reads_are_counted_by_kind
- a_no_copy_buffer_s_writes_before_first_use_are_not_stale_with_no_identity
- two_plays_compare_for_a_verdict_only_where_counts_and_digests_agree
2026-11-19 13:27:10 -08:00
Anees Iqbal fb183b48f7 player: the old backend gives a no-copy Managed buffer of a two-copy stream with no identity its writes before first use
The new runtime's backend plays a stream with no identity record under
--managed two-copy by its first-use rule. A no-copy Managed buffer made with
no bytes is fresh until the command buffer that first names it commits, and
a write into it while fresh reaches its GPU copy too (did_modify_range). That
write is the nearest record the stream has of the buffer's bytes at its
making (docs/REPLAY-STREAM.md, Managed buffers). The old backend had no
such rule. Those writes reached only its CPU copy, so on a device that keeps
two copies its GPU copy read zeros where the new runtime's read the bytes.

The old backend now follows the same rule. It notes each encoder's command
buffer, marks a buffer's first use when an encoder names it, drops the mark
at that command buffer's commit, and announces a fresh buffer's writes. Its
managed line counts the buffers whose contents came from first use, as the
new runtime's does. docs/REPLAY-STREAM.md states the two-copy rule for both
runtimes: which writes before first use reach the GPU copy, and what an
identity record changes.

Found by a synthetic stream of our own on the RX 550 (m3-max-53813): with no
identity record under --managed two-copy, rt read the write and old read
zeros. Recordings it touches: gb-3090-r2 (641 Managed objects read without
them, the first in frame 0) and windrag-780m-b2 (15), where played as two
copies.

Test: a_two_copy_stream_with_no_identity_gives_a_no_copy_buffer_its_writes_
before_first_use (replay_streams), which fails without the fix on a device
that keeps two copies. The made-with test's managed line now carries the
count.
2026-11-19 12:46:43 -08:00
Anees Iqbal d88af7befe player: a two-copy stream's Managed buffers start their GPU copy from the bytes they were made with
docs/REPLAY-STREAM.md says a Managed buffer that plays with two copies has
a GPU copy that starts from the bytes it was made with: a copied buffer's
contents, or a no-copy one's bytes at its making. Neither backend did so.
The player stripped every newBufferWithDescriptor: descriptor's contents
before the backend's making and wrote them afterwards as a CPU write. So
the new runtime's new_buffer, written to take them, never got them, and the
old backend made every such buffer zeroed. Under two copies neither GPU
copy held the bytes, and a draw reading the buffer before any
didModifyRange: read zeros where the recording's GPU read the bytes.

This changes the new runtime's plays too, not only the old runtime's. The
player now passes the descriptor to the backend with its contents and still
writes them once the buffer is made. The new runtime's backend takes them
as it was written to. The old backend's making takes them, both a
descriptor's contents and newBufferWithBytesNoCopy's pages. Where the buffer
plays as the runtime's Managed buffer, it writes them and announces them
(didModifyRange: over them).

Found by synthetic streams of our own on the RX 550 (m3-max-53813): under
a two-copy identity record, a no-copy and a copied Managed buffer made with
7s read zeros through a blit on both backends. The GPU-free count has the
recordings this touches: glbench-3090-r2, r3 and r4, gb-3090-r3, r4 and r5,
web3d-3090-r2 and r3, nvdec-3090 and nvdec-3090-wd.

Tests: a_two_copy_stream_s_managed_buffers_start_from_the_bytes_they_were_
made_with, in rt_replay (new runtime) and replay_streams (old runtime). Both
play one stream, rt_replay::made_with. They fail without the fix on a
device that keeps two copies.
2026-11-19 12:31:16 -08:00
Anees Iqbal 1f41d7b75e player: the old backend plays a one-copy stream's Managed buffers as Shared
A stream recorded with one copy (its identity record's hasUnifiedMemory, or
--managed one-copy) keeps every Managed buffer's CPU writes visible to the
GPU with no didModifyRange:. The new runtime's backend plays such buffers
as Shared (docs/REPLAY-STREAM.md, Managed buffers); the old backend took
the trait's no-op and played them as the old runtime's Managed buffers,
which on a device without unified memory keep a GPU copy that m2v.write
never reaches. On the RX 550, syncview f355's quad index buffer (#49287, a
no-copy descriptor-form Managed buffer written once by m2v.write) read
[0, 0, 0, 0] on old's GPU copy against [1, 0, 2, 3] on rt's, so old's
draws were degenerate strips that drew nothing: old timed less work than
the program asks for on every discrete card for such streams.

The old backend now takes recorded_unified_memory and --managed, makes a
Managed buffer or block Shared under one copy, and says so in its report's
managed line. Device test: a one-copy stream's Managed buffer written with
no didModifyRange reaches a blit's read (replay_streams.rs), which fails
without the fix on a device that keeps two copies.
2026-11-19 11:53:33 -08:00
Anees Iqbal 6de7e37ba5 replay judge: a finished rt play prints its judged totals, held equal to the base
The replay player prints, on the new runtime, the matrix's judged metrics of a play: one
`M2V-MATRIX metric replay-rt/STEM/RANGE/NAME N` record per metric, `N` the play's executed total
(`Report::total`) of submissions, passes, barriers less `texture_clear_barriers`, bytes copied and
pipelines created, and of the new textures zeroed, the clears and the zero-initialized ones as one
count and their bytes as one. The split between a clear and a zero-initialized texture follows
where the pool places it and may differ between two plays of one stream, so the two are judged
summed, and the barrier after an upload's clears is left out of the barriers. A play that did not
finish its range (it stopped, or ended before frame F's present where it plays to F) or whose
backend skipped anything prints none (`judged_records`).

The matrix's rule holds a `replay-` metric equal to the base's, failing a change either way, and
fails a leg that lacks a record its base has: a short play does not pass (`EQUAL_METRICS`). The
counters' docs say the split may differ between two runs of one program; VALIDATION.md and
REPLAY-STREAM.md say what the judge does.

Tests: the judged totals on the fake backend (the net barriers, the summed zeroings, a counter
not reported as 0, no other counter, the range in the key), a short play, a stopped one and a
skipping one printing nothing, and the rule's equality and missing-record cases in
test_results.py. Verified: cargo fmt; `python3 -m unittest discover -s scripts/matrix` (84 tests,
OK). The Rust build, clippy and tests run in the checks dispatched at this commit.
2026-11-19 11:15:33 -08:00
Anees Iqbal 8c3fae2243 replay: the rt arm plays guest-RAM copies in the host's one-copy form
The new runtime's backend played a copy back to the guest's RAM as one
buffer copy per run, word-widened, in the guest's own blit encoder, and a
copy from the guest's RAM as one copy per piece in that encoder. The host
does neither: on the new runtime every staged fill and download is one rt
buffer-to-buffer copy, since rt answers no linear row pitch. In f355 of
the syncview stream the per-run form made 8,029 copies from 28 calls,
with a barrier pair each, which the host never makes.

Now each call is one copy, in a command buffer of the backend's own on
the call's queue, through a Shared scratch of its own (new module
new_runtime/guest_ram.rs):
- copy back: one copy of the whole words the runs span, committed just
  after the call's command buffer; a wait for that command buffer waits
  for the copy too (the guest sees its RAM written when its command
  buffer completes), then the CPU copies each run out of the scratch;
- copy in: the pieces gathered on the CPU into the scratch laid out as
  the bytes they span (gaps and edges from the target's mapping), one
  copy committed just before the call's command buffer; into a buffer
  with no mapping, one copy per run of touching words, so no gap is
  written.
Surface texel copies stay in the guest's blit encoder. The work is
counted apart as the stand-in (guest_ram_* counters, guest_ram_gpu_nanos
for its command buffers' GPU time, outside gpu_busy) and the report's
"guest RAM: copy-back played in the one-copy form" line. The old arm is
unchanged. staged_guest_ram_bytes and copied_back_guest_ram_bytes give
way to guest_ram_fill_bytes and guest_ram_download_bytes.

Tests: the copy-back device test now expects one copy of 100 bytes and
two runs copied out; a new device test plays copies in to a Shared and a
Private buffer and reads both back. docs/REPLAY-STREAM.md section 10
describes the form.
2026-11-19 08:01:21 -08:00
Anees Iqbal 0e9889dfaa replay: the rt backend reads a Private buffer back through a blit into a Shared buffer of the play's own
The new runtime's player backend refused every read of a Private buffer
("a Private buffer": it has no contents). The gate's per-command-buffer
compare (`--dump-command-buffers`, `compare-dumps`) therefore read none of
them on rt: its play pair over glbench-780m-r2's command buffers
58254..58416 on the 3090 (m3-max-52237, development b8ea291aa5) left 41
dumps unread on rt, among them every buffer the probe gate had found
differing, and the compare said DIFFER for that alone. The probe had read
them through a blit of its own that never landed.

NewRuntime::read now copies a Private buffer's bytes with one blit into a
Shared block the play takes for the read and gives back, on a queue of the
play's own made at the first such read, and waits for the copy. The
player reads only after the work that writes the buffer completed. A
length that is not a multiple of 4 stays the copy's own refusal. The
stream's checks never named a Private buffer (a refused read ends a play),
so only the dumps change.

Test: rt_replay::a_private_buffer_reads_back_through_a_copy: a blit fills
a 16-byte Private buffer with 0x5a; the backend's read answers those
bytes. Before this change the read was refused.

Verified by the check named when this lands.
2026-11-19 07:02:13 -08:00
Anees Iqbal 905b16b79a command-replay: --gpu-wait-timeout bounds the play's device waits
The replay command took only the 10 s default for every device wait, so a play on a CPU
device (lavapipe) whose command buffer takes longer than 10 s ends with status 86 though
nothing hangs. It now takes --gpu-wait-timeout SECONDS (1..=600) as the other device-executing
commands do, applied before any device opens; a value outside the range is an error line and
status 2. Needed for the CPU-ICD repro of a GPU hang (docs/VALIDATION.md, the suspected-hang
protocol). Verified: clippy and the player build; the lavapipe play that uses it is the check.
2026-11-19 06:46:48 -08:00
Anees Iqbal ee1a8aee7c REPLAY-STREAM: the new runtime's player binds a range as the single-slot bind of each 2026-11-19 06:17:51 -08:00
Anees Iqbal d75eab9c2b validation: the per-command-buffer compare of two plays applies the cover rule, word by word
The 3090 chain gate compared rt's and the old runtime's plays command buffer by command buffer
through a probe that never lands: whole-object checksums of each buffer a command buffer named,
then a script that asked the probe's dumps of Covers. A whole-object checksum is no compare under
the cover rule: a buffer partly under a texture's write differs under the cover, and a word that
differs outside it shows only as the same mismatch. This lands the compare in the player's own
tooling, on the player's own Covers (94d7c1620c's rule, unchanged).

- Player::dumping(command buffers, dir): once each listed command buffer completed (its wait
  seen, before the next call plays), every buffer its encoders named is written into dir as
  cbC-objO.bin, with cbC-objO.cover holding the ranges of it the cover rule held covered then, or
  cbC-objO.unread where the backend could not read it. A write failure ends the play
  (PlayError::Dump). Off unless asked.
- compare_dumps(a, b) (replay/dumps.rs) compares two plays' dumps word by word, leaves out a word
  wholly inside a range either play held covered (the old runtime answers no slot access, so its
  plays cover less), and reports every other differing word per command buffer and buffer, a dump
  one play lacks, and a dump either could not read.
- command-replay: --dump-command-buffers FIRST..LAST --dump-dir DIR on play; compare-dumps --a DIR
  --b DIR prints a line per buffer that differs outside every cover and a summary ending agree or
  DIFFER, exit 0 / 1 / 2.
- Covers::ranges(object), read-only, for the dump.
- docs/REPLAY-STREAM.md, section 10: the options, the files and the compare's lines.

Tests (no GPU, the player on the test backend, two plays each that differ only in the words at
bytes 0x10 and 0x1800 of a 0x2000-byte heap buffer whose first 0x1000 bytes a texture's write
covers after the command buffer bound it):
- replay::tests::the_dump_compare_reports_a_differing_word_outside_every_cover: the dump's cover
  is 0..4096; the word at 0x10 is covered, the one at 0x1800 (word 1536) is reported; DIFFER.
- replay::tests::the_dump_compare_reports_a_word_whose_cover_the_buffer_s_last_write_voided: the
  encoder binds the buffer again after the dispatch (a binding counts as a write), the dump holds
  no cover, and both words are reported.
- replay::tests::the_dump_compare_agrees_on_alike_plays_and_reports_a_dump_one_play_lacks.
The test backend now keeps a heap buffer's bytes as it keeps a device buffer's, so a write into
one reads back.

Verified: the check job named at hand-over compiles it and runs the replay tests.
2026-11-19 06:06:56 -08:00
Anees Iqbal 0c36de79d9 replay: a surface's pictures fill its shapes at their first use, as the product's lazy fill does
m2v.externalWriteDone (a decoded picture landed in a receiver buffer) no longer refills the
buffer's shapes at once. As the product's per-shape form does after a video command buffer, every
shape of the buffer owes a fill from it, its own write lost; the first command buffer whose
encoders use a texture of the buffer (a binding, a pass's attachment, a blit, a useResource)
fills every owing shape of the buffers it uses before its commit, by blits in a command buffer of
the player's own committed then. A picture another lands over before any use is never copied.
The eager form copied every picture at its landing, so a burst of pictures landing at one present
was copied there whether used or not.

New counters: surface_pictures_filled (pictures a fill took) and surface_pictures_unfilled (those
another landed over before any use, or whose buffer went first); the surfaces line also gives the
pictures not used yet. The copy-from-guest-RAM comment now names the product's fill from the
pages, not a refill. docs/REPLAY-STREAM.md sections 4 and 10 say so.

Verified: the new device test a_surface_picture_fills_its_shapes_at_their_first_use (two pictures
land before a kernel reads the texture: one fill of one shape, the second picture read, the first
never copied) runs in the check that follows this commit; not yet run. The eager form fails it
(two refills).
2026-11-19 05:26:09 -08:00
Anees Iqbal a2576535bd replay: a plain surface shape takes shader read and render-target usage alone
The surface form's usage word, as ruled final. A shape no texture over it declares shader
write, shader atomic or Metal's unknown usage for (a plain shape) is made with shader read
and render-target usage alone: rt gives such a texture its format and that format's sRGB
sibling as views, and no storage view, so a plain shape's attachment reads are not refused
and its image carries the short view list. A shape shaders may write keeps the usage Metal
gives a texture whose use it does not know (shader atomic where declared), with the long
view list, so a storage plane's textures of other formats of the same bytes a texel stay
views of it with no copy.

A texture or view of a format other than a plain shape's own or that format's sRGB sibling
is refused (surface_format_refusals), and textures over a plain shape that declare
pixel-format-view usage are counted (surface_plain_format_views). docs/REPLAY-STREAM.md
section 10 says so.

Verified: the new test a_plain_surface_shape_views_as_its_format_and_its_srgb_sibling_alone
(a sibling view found, another format refused as a texture and as a view, counted) runs in
the device suite of the check that follows this commit; not yet run.
2026-11-19 04:51:43 -08:00
Anees Iqbal 0b8fe27977 replay: the surface form counts order-case shapes
surface_order_shapes counts the shapes shaders may write made over a plane that holds a shape
of their extent shaders may not write: the order case, which the storage bit makes another
shape. The doc's counter list reflows. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal a5f4f03a32 replay: the surface form counts the slot writes a pipeline state's interface declares
surface_declared_writes counts the draws' and dispatches' surface texture slots whose bound
state's interface writes them, beside surface_usage_writes, those taken as writes by usage
with no interface at hand: together they say which binds write a shape. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal 079fe12625 replay: a surface shape takes storage for shader atomic usage too; the shapes' sort and drop count as clippy and the type checker want
The planner's storage test is shader write, shader atomic or unknown usage (an image atomic is
a storage image's operation); a shape made for a texture that declares shader atomic carries it.
The idle shapes sort by recency with sort_unstable_by_key, and the overlap drop's count filters
by reference. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal aa8dd9f131 replay: surface textures play as the product's per-shape form, with the usage word
The rt player's surface form now mirrors the product's per-shape form (reims's
surface cache, shapes.rs): a shape is a plane's (receiver, plane, offset, pitch)
texture of one extent and texel size, and every shape is current over its whole
extent by the product's three rules. A new shape is filled from the buffer once
the dirty shapes are written back; a copy back to the guest's RAM first writes
every dirty shape back; at the end of an encoder that may have written a shape,
the write goes through the buffer into each other shape of its plane that a live
texture views or that is dirty, and the plane's other shapes go. Writes are noted
from pass attachments, blit destinations, the slots the bound pipeline state's
interface writes (texture_accesses), and by usage where no interface is at hand.
The newest-entry rule, its download at a new shape and the older-shape use
counter are gone.

The usage word: a shape is made with shader read, render-target and
pixel-format-view usage, and shader write (a storage view) only for a texture
that declares it or Metal's unknown usage; the shape key carries that bit. A
storage shape serves a later texture of its extent that does not declare it; a
declaring texture over a plane whose shape has no storage is another shape.

The report and counters give overlap copies and bytes, straddled texels,
unordered writes, usage writes and write-backs. The device test now checks a
copy from the guest's RAM reaching both shapes of a plane and a blit through one
shape reaching the other at its encoder's end. Not yet compiled.
2026-11-19 04:51:43 -08:00
Anees Iqbal 9c2288b3ae REPLAY-STREAM: the refills' bytes and GPU time among the surface counters
681a736c40 added surface_refill_bytes and surface_refill_gpu_nanos and the longest refill
command buffer on the surfaces line; the doc's list of the counters now names them and says
which frame a refill's GPU time falls in. Doc only.
2026-11-19 03:18:35 -08:00
Anees Iqbal d95591c966 replay: the rt backend plays textures over a surface as views of one texture per receiver range and shape
The rt backend played newTextureWithDescriptor:iosurface:plane: as a substitute, an ordinary
texture whose texels are undefined, so two textures over one surface shared nothing and the
3090 chain's rt plays varied where the old arm, which plays the texture over its receiver
buffer, repeated.

It now plays it as the product makes it: one Device::new_texture_for_views texture (an entry)
per receiver range (receiver buffer, plane, offset, bytesPerRow) and shape (width, height,
bytes a texel), with shader read and write, render-target and pixel-format-view usage, and
every recorded surface texture a view of it at the texture's own index. The receiver buffer
holds the pages' bytes as the stream writes them:
- a new entry is filled from the buffer by a blit in a command buffer of the backend's own,
  committed at the making: after every earlier commit, with no wait;
- a new shape over a range first downloads the range's newest entry into the buffer at that
  entry's extent, then fills the new entry, so bytes map by byte offset; an older shape's entry
  goes once no texture of it lives and is not kept current, and the calls that name such a
  texture after a newer shape are counted (surface_older_uses), argument buffers unseen;
- a copy from the guest's RAM into a range also copies the range into its newest entry, and a
  copy back first copies the newest entry into the range, both in the copy's own blit encoder:
  replace_region would land ahead of the encoders already in the command buffer, and get_bytes
  would add a wait the old arm does not have;
- a recorded CPU write into a range uploads the texels it covers (replace_region) until the
  buffer's first m2v.externalWriteDone, the new record of another API's write landing (a
  decoded picture), which refills every entry of its buffer by a blit committed then; the old
  backend plays that record as nothing;
- another call naming a receiver buffer as a buffer is refused, and a texture of a format that
  reads across a surface's two planes is skipped (skipped_surfaces_across_planes).

The player leaves a receiver buffer's checks and snapshot ranges uncompared on every runtime
(verdict receiver, a receivers line), as the texels live apart from it; the rt backend reads a
texture back for a check, laid out as the old backend lays it out. The surface substitute key
goes; substitutes_read counts the tiled and gap substitutes (and their views) a call named, the
substitutes line naming the first, and the doc's claim that a substitute makes a play no gate
result, which no code made true, now says what holds. The surface record's keys move to args.rs,
shared by both backends.

Census before building (job 51225, gb-3090-r3): 653 entries made, none after an uncommitted
guest-RAM copy into their buffer, so a fill committed at the making misses no copy there.

Tests: the surfaces unit test (the texels a write reaches); the player's receiver test; the
device test of two formats over one surface, a new extent, a copy from the guest's RAM and an
older-extent use. To be run by the check job.
2026-11-19 03:18:35 -08:00
Anees Iqbal a615269526 replay: the covered line counts the covers a binding took off, as a binding may be a read
The stream carries no buffer access, so a buffer binding (set...Buffer...) or a useHeap: of the
object's heap counts as a write and takes a cover off. That errs toward comparing; a residual
difference in such an object's later compares may be the covering texture's bytes, not the
play's. The report's covered line now says how many covers a binding took off.

Verified: the covers unit test gains a fourth round (covered again, then bound) asserting
binding_uncovers 1 and the new line; to be run by its check job.
2026-11-19 03:17:36 -08:00
Anees Iqbal 0c00926c84 replay: the rt backend tallies the textures over buffers held in an image of their own by pixel format and usage
The known-gap line for the pool side's copy at commit wants the classes of the textures the
device's linear image does not take, per card; the report gave only their count. The backend now
keeps, for each texture over a buffer the runtime held in an image of its own (the gauge rose
across the making), its descriptor's pixel format and usage, and prints them, most first, on a
'textures over buffers in an image of their own, by pixel format and usage' line.
REPLAY-STREAM.md lists it.
2026-11-19 03:17:36 -08:00
Anees Iqbal 2385a0a489 replay: the rt backend counts the render encoders it skips by kind
The tessellation plays reported skipped_encoders=214 (and 205) with no kind, so whether a pass
met NoAttachment, a storage gap or a property the runtime's descriptor does not hold could not
be told from the report. The backend now keeps each skipped render encoder's kind with its count
and first frame and call, and prints `skipped render encoders KIND N, the first at frame F,
call C`: `ParallelRenderCommandEncoder`, `Unheld(KEYS)` for a pass whose descriptor sets
properties the runtime's does not hold, or the runtime's gap for the pass (Debug). The
skipped_encoders count is unchanged. REPLAY-STREAM.md lists the line.
2026-11-19 03:17:36 -08:00
Anees Iqbal 94d7c1620c replay: a heap texture write covers what it meets; the compares leave it out until written again
Metal leaves an aliased resource's contents undefined once another resource is written over
its memory. In a placement heap, a texture write over a buffer's (or another texture's)
recorded range leaves the recording holding its runtime's layout of the texels there, and the
play its own (rt shares the memory as a placement heap does; the old arm makes the heap's
buffers and textures apart and keeps the bytes from before). identity's liveness pass over u4
(to frame 315) found 16,942 covers of a heap buffer's range by a heap texture write and no
read through a covered buffer before its next write or release: the bytes are dead, and a
compare of them is no verdict.

The player now tracks, by structure alone (covers.rs), each object the stream places in a
placement heap (its heap, recorded offset, and length: a buffer's own, a texture's as the
runtime answers its size, read ahead) and the texture writes: a draw's or dispatch's to the
texture slots its pipeline state's interface marks written (Backend::texture_writes; the new
runtime answers from ComputePipelineState / RenderPipelineState::texture_accesses, the old
runtime answers no slot access, so on it only the following count), a render pass's to every
texture its descriptor names, a blit's to its destination, generateMipmapsForTexture:, a
useResource:usage: with write usage and replaceRegion:. A write of a texture over a buffer is
the buffer's. A texture write covers the bytes of every other object placed in its heap that
its range meets; the object is written again by the player's writes into it (m2v.write,
contents at creation, copies from the guest's RAM, a snapshot's bytes before), a blit into it,
and, as the stream carries no buffer access, any binding of it to an encoder, a write-usage
useResource:usage: or a useHeap: of its heap. A check of a covered object reports `covered`
and a snapshot range meeting covered bytes `covered`, neither compared; a `covered N: ...`
line counts the covers and what they left out. REPLAY-STREAM.md says so, and says
gap_pipeline_ids is bookkeeping: nothing is skipped for it.

Test (replay::tests): a placement heap with a buffer and two textures at offset 0; a dispatch
whose state writes slot 0, which holds the first texture, covers the buffer and the second
texture; their checks are `covered`; the buffer written whole is compared again, the second
texture stays covered; a dispatch of a state that only reads the slot covers nothing.
2026-11-19 03:17:36 -08:00
Anees Iqbal c9637b0d08 replay: a descriptor-form no-copy buffer is a pool buffer; only the bytes form imports
The planner ruled the mapping: the player plays every descriptor-form no-copy buffer
(newBufferWithDescriptor: with noCopy) as a pool buffer, a buffer of a recorded block where
its recorded range lies in one and a place of its own elsewhere, and imports only the bytes
form (newBufferWithBytesNoCopy:length:options:deallocator:, the host's own in the recordings).

The recordings do not tell the program's own no-copy memory (an import in the product) from
the host's pool buffers, so that memory plays as a pool buffer too: a known gap. The host's
recorder makes a buffer over the program's memory only with a pinnedGpuAddress and no
zeroFrom (zeroFrom and unpinned buffers are always the host's own), so the report's gap line
bounds the gap by those outside every block, with their bytes. REPLAY-STREAM.md states the
mapping and the gap.

The test plays three descriptor-form buffers outside every block (one pinned with no
zeroFrom, one unpinned, one pinned with zeroFrom), a texture over the first read through a
blit, and checks the counts line, the gap line's bound of 1, and that the imported side
counts only the bytes-form buffer's texture copy.
2026-11-19 01:07:23 -08:00
Anees Iqbal c8e65bd9cb REPLAY-STREAM.md: the report's textures over buffers line 2026-11-19 00:49:43 -08:00
Anees Iqbal 01d40ad5fc replay: a descriptor-form no-copy buffer inside a recorded block is a buffer of it; others import
The product's no-copy buffers are not all imports. A newBufferWithDescriptor: with noCopy whose
recorded address and length lie inside a live block's recorded range (m2v.newBlockWithLength:
storageMode:) is the program's buffer in that block's storage, a pool buffer on rt; it now plays
as a buffer of that block at that offset, as m2v.newBufferInBlock:offset:length:options: does
(the in-block buffer path is one method both use), its bytes at its making put there first. Only
a descriptor-form one outside every block (the program's own no-copy memory) and the bytes form
(the host's own buffers in the recordings, never the program's) go through the import.

The backend keeps each live block's recorded range (imports::NoCopies) and counts the three
kinds; the report's no-copy buffers line replaces the no-copy imports line. REPLAY-STREAM.md says
which plays how. The no-copy device test adds a block recorded at an address and a
descriptor-form buffer recorded inside it: it reads the bytes written into the block there, and
the line counts it in the block, beside one descriptor-form and one bytes-form import. Verified
so far: nothing; the build and tests run in the check job.
2026-11-19 00:49:42 -08:00
Anees Iqbal 5250b8dd7b rt: the over-copies over imported blocks are counted on their own side
Metrics::over_copies_imported and Metrics::over_copy_bytes_imported count the copies between a
texture over a buffer and its image of its own where the bytes shaders reach are in an imported
block (host memory or a dma-buf), beside over_copies and over_copy_bytes, which still count every
such copy; the rest are over the runtime's own blocks, where the device's linear image does not
take the texture. One mechanism: OverCopy carries whether its buffer's bytes are imported, and
Counters::over_copied adds the imported side where it is. A first-boot report can then read the
imports' copies alone, and a play the pool buffers' copies (total less imported).

The api_signatures rows, the doc lines (Metrics, over.rs, the README) and the player's per-frame
counters carry the two. Tests: copy_over's device test asserts its texture over a buffer in a
taken block moves neither imported counter; the import test asserts every copy of its texture
over an imported block counts on the imported side, its texels' bytes each; the player's no-copy
device test asserts its one copy is imported. Verified so far: signatures.py --check; the build
and tests run in the check job.
2026-11-19 00:45:36 -08:00