Repository navigation
Audio: an XMA write block past the ring's end wraps before the first write - #536
Merged
Merged
Conversation
… forever The decoder fills an XMA voice's output ring until the write block (word 0, bits 27-31) comes round to the title's read block (word 9, bits 0-4). The write block wraps modulo the ring size (word 0, bits 22-26), and so does a read block moved on by command 18, but a read block the title set up at or past the ring's end was compared as it was: no write block ever equalled it. With a stream that loops forever the pass never ended, holding that voice's lock, so the title's next command on the voice (advance, disable) waited for good, and releasing the context arrays did too. Take the read block modulo the ring size as well, as the write side already does. A test sets up read block 6 on a ring of four with an endless loop and requires the pass to end within seconds, with blocks 0 and 1 filled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…write The write block (context word 0, bits 27-31) was used as it is for the first block of a pass, so one at or past the ring size (bits 22-26) was written past the ring's end, possibly into another APU allocation, before it wrapped with (write + 1) % size. Take it modulo the ring first, as the read block is taken, and as advance_read does.
Closed
Contributor
|
#248 is fully contained here: the same one-line read-block fix ( Checked by reading both diffs against |
mercuryVM
approved these changes
Nov 24, 2026
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 7a5d85e on Windows 11, RTX 5070, MSVC: cargo test -p victory-hle 89 passed, including xma_write_blocks_past_the_ring_end_wrap and xma_read_blocks_past_the_ring_end_wrap. Clippy's 1 warning is the existing field_reassign_with_default at xmem.rs:747.
- Taking the write block
% 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. - #248 is already on mercuryVM/VIctory main, so only the top commit is new there. It merges cleanly.
AI-assisted (Claude Code).
mercuryVM
added a commit
to mercuryVM/VIctory
that referenced
this pull request
Nov 24, 2026
…ng's end wraps before the first write Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nazmi
pushed a commit
to nazmi/VIctory
that referenced
this pull request
Nov 24, 2026
…write Applied as the net diff of upstream PR Marvisak#536 (head 7a5d85e), 2 commits: 7a5d85e,1054fe87.
github-actions Bot
added a commit
to KevinPratap/VIctory
that referenced
this pull request
Nov 24, 2026
…ps before the first write
github-actions Bot
added a commit
to KevinPratap/VIctory
that referenced
this pull request
Nov 24, 2026
github-actions Bot
added a commit
to KevinPratap/VIctory
that referenced
this pull request
Nov 24, 2026
…ps before the first write
github-actions Bot
added a commit
to KevinPratap/VIctory
that referenced
this pull request
Nov 24, 2026
github-actions Bot
added a commit
to KevinPratap/VIctory
that referenced
this pull request
Nov 24, 2026
…ps before the first write
github-actions Bot
added a commit
to KevinPratap/VIctory
that referenced
this pull request
Nov 24, 2026
Steenax6
pushed a commit
to Steenax6/VIctory-NVID
that referenced
this pull request
Nov 26, 2026
…write The write block (context word 0, bits 27-31) was used as it is for the first block of a pass, so one at or past the ring size (bits 22-26) was written past the ring's end, possibly into another APU allocation, before it wrapped with (write + 1) % size. Take it modulo the ring first, as the read block is taken, and as advance_read does. Source: Marvisak/VIctory 7a5d85e (AnoHunted), merged upstream as PR Marvisak#536. (cherry picked from commit 7a5d85e) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.