Audio: an XMA write block past the ring's end wraps before the first write #536
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/536"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by AnoHunted on 2026-11-24T04:39:02Z.
Stacked on #248; only the top commit belongs here.
What
In
pump, take the write block (context word 0, bits 27-31) modulo the ring size (word 0, bits 22-26) before the first write of a pass, as #248 does for the read block and asadvance_readdoes.Why
A write block at or past the ring size was used as it was for the first block of a pass: it was written at
output + write * 256, past the end of the ring (possibly into another APU allocation), and only then wrapped with(write + 1) % size.Tested
Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1. New test
xma_write_blocks_past_the_ring_end_wrap: a ring of four blocks followed by a guard area filled with a pattern, write block 6 (block 2 of the ring), read block 1, a looping silent stream, one pass. It checks that the guard area is untouched, that blocks 2, 3 and 0 are written and block 1 is left for the title, and that the write block ends at 1 with the ring no longer writable.cargo test -p victory-hle xma_ -- --test-threads=1andcargo test --workspace -- --test-threads=1AMD and other GPUs: not tested (no GPU code is touched).
Not tested
Behaviour against a real title; only the synthetic context above.
No game files were used.
Imported from Marvisak/VIctory. Originally posted by Exorion1er on 2026-11-24T09:33:19Z.
#248 is fully contained here: the same one-line read-block fix (
write == field(9, 0, 5) % size) and the same test,xma_read_blocks_past_the_ring_end_wrap, with identical code. This PR also adds the write-block wrap and its test. Merging both would give two tests with the same name, so #248 can close if this lands.Checked by reading both diffs against
main. Both merge cleanly. AI-assisted (Claude Code).Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:51:45Z.
Review: APPROVED
Tested
7a5d85eon Windows 11, RTX 5070, MSVC:cargo test -p victory-hle89 passed, includingxma_write_blocks_past_the_ring_end_wrapandxma_read_blocks_past_the_ring_end_wrap. Clippy's 1 warning is the existingfield_reassign_with_defaultat xmem.rs:747.% sizebefore the first write closes the same hole #248 closed for the read block.pumpalready returns early onsize == 0, so the modulo can't divide by zero.AI-assisted (Claude Code).