Files
metal2vulkan/docs
Anees Iqbal 40e135c308 replay: the new runtime's backend rounds each buffer's place to its recorded granule
The backend packed buffers first fit at Metal's 256-byte alignment, so a program's write past
a buffer's end landed in the next buffer. A recorded stream's program did that: an append
list of 4000 records took about 870 more on one play, and the overrun went 17340 bytes into
twelve 4-byte counters and the start of a 48000-byte buffer that the player had packed behind
it. The recording had given each of those buffers its own 32 KiB-granular range, so the same
overrun landed in the list's own slack there. The clobbered counters then feed the next
rounds; a 780M page fault past a 64 MB buffer and a hang on a 3090 follow them (expected, the proof plays pending).

Each buffer's place now spans its length rounded up to its recorded granule: the largest
power of two that divides its recorded gpuAddress, from 256 bytes to 64 KiB, and 256 bytes
where the stream records no address (the player's own staging included). Both copies of a
two-copy Managed buffer take it. A buffer past the class's block length takes a block of its
own of the rounded span. The backend's new "places by recorded granule" line counts the
places by granule and gives the most bytes of slack held at once.

Test: rt_replay's buffers_keep_the_slack_of_their_recorded_granule plays two 4-byte buffers
recorded at addresses of 32 KiB and 64 KiB granules and reads back their relocated addresses
from a third: they lie apart by at least the lower one's granule (256 bytes apart before).
docs/REPLAY-STREAM.md says how the backend places buffers.
2026-11-18 14:53:10 -08:00
..