Keep XMA input valid when looping back to the start of a buffer #2714

Open
github-bot wants to merge 1 commit from github-bot/gh-2714 into main AGit
Owner

@⁠VlREX on GitHub · 2026-11-25 18:39 UTC · original
VlREX:fix/xma-loop-buffer-start → main · +16 −6 · 1 files · 1 commits · open

A zero read position selects the first frame in the input buffer. When a loop requested that position, the decoder previously cleared the valid-input bit as though there were no next frame. Preserve the optional next position until the context update so a real offset of zero survives. The synthetic two-packet regression failed before the change and verifies the first frame is decoded again, with the requested subframe skip, and normal playback continues when the loop count runs out. All nine audio module tests passed in an isolated Windows GNU run. No in-game verification.

**@⁠VlREX** on GitHub · 2026-11-25 18:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714) `VlREX:fix/xma-loop-buffer-start` → `main` · +16 −6 · 1 files · 1 commits · open A zero read position selects the first frame in the input buffer. When a loop requested that position, the decoder previously cleared the valid-input bit as though there were no next frame. Preserve the optional next position until the context update so a real offset of zero survives. The synthetic two-packet regression failed before the change and verifies the first frame is decoded again, with the requested subframe skip, and normal playback continues when the loop count runs out. All nine audio module tests passed in an isolated Windows GNU run. No in-game verification.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:37 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:51 UTC · original

Elegant fix - Option is exactly the right type for 'no next frame' vs 'next at bit 0'. The loop path assigning Some(field) preserves a genuine zero loop start, and the regression verifies both halves: input stays valid through the wrap and invalidates normally when loops run out.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714#issuecomment-7171488678) Elegant fix - Option<usize> is exactly the right type for 'no next frame' vs 'next at bit 0'. The loop path assigning Some(field) preserves a genuine zero loop start, and the regression verifies both halves: input stays valid through the wrap and invalidates normally when loops run out.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:38 UTC · original

Independent Windows 11 verification and review of 69d5708 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo xtask policy: 184 files ok.
  • cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-formats: 38 passed, 0 failed, 5 ignored.
  • cargo test --locked -p victory-hle: 147 passed, 0 failed (lib, including a_loop_to_the_start_of_the_buffer_keeps_the_input_valid), plus fidelityfx (1) and no_dll_planting (1) clean.
  • 5-way XMA merge compatibility: verified clean zero-conflict sequential git merge-tree across the entire 5-PR stack #2694 + #2708 + #2709 + #2710 + #2714.

Review Notes

  • Switching next from a 0 sentinel to Option<usize> keeps valid == 1 when loop_start == 0 while still clearing the valid bit on true end-of-stream (frame.next == None), and pairs directly with #2708 when the next decode() sees at < 32. Clean and ready to merge.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714#issuecomment-7172581897) Independent Windows 11 verification and review of `69d5708` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo xtask policy`: **184 files ok**. - `cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-formats`: **38 passed, 0 failed, 5 ignored**. - `cargo test --locked -p victory-hle`: **147 passed, 0 failed** (`lib`, including `a_loop_to_the_start_of_the_buffer_keeps_the_input_valid`), plus `fidelityfx` (1) and `no_dll_planting` (1) clean. - **5-way XMA merge compatibility:** verified clean zero-conflict sequential `git merge-tree` across the entire 5-PR stack **#2694 + #2708 + #2709 + #2710 + #2714**. ### Review Notes - Switching `next` from a `0` sentinel to `Option<usize>` keeps `valid == 1` when `loop_start == 0` while still clearing the valid bit on true end-of-stream (`frame.next == None`), and pairs directly with #2708 when the next `decode()` sees `at < 32`. Clean and ready to merge.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 19:41 UTC · original

Independent WARP/CPU verification

Head: 69d5708107565d3740bcdb408d8e41d397042544
Base: origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca
Status: open, non-draft; clean merge tree; no oni-swr comment on this head.

Environment: Windows x64, WARP selected (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), dxil.dll 1.8.2502.11 from Windows SDK 10.0.26100.0; rustc 1.98.1.

Commands (each with CARGO_TARGET_DIR=D:\victory-warp-2690-target and the WARP variables above):

  • Baseline and PR: cargo test --locked -p victory-hle
  • PR targeted: cargo test --locked -p victory-hle a_loop_to_the_start_of_the_buffer_keeps_the_input_valid
  • PR lint: cargo clippy --locked -p victory-hle --all-targets -- -D warnings

Results: baseline 148 passed, 0 failed (146 unit + 2 integration); PR 149 passed, 0 failed (147 unit + 2 integration). Targeted regression 1/1 passed. Clippy passed.

Negative control: restored the old 0 == no next frame invalidation; the new loop-to-zero test failed (exit 101), as expected. No implementation bug found.

Not tested: physical GPU, retail title, release build. AI-assisted: Codex (gpt-6-luna).

**@⁠oni-swr** on GitHub · 2026-11-25 19:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714#issuecomment-7172632313) Independent WARP/CPU verification Head: `69d5708107565d3740bcdb408d8e41d397042544` Base: `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` Status: open, non-draft; clean merge tree; no `oni-swr` comment on this head. Environment: Windows x64, WARP selected (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`), `dxil.dll` 1.8.2502.11 from Windows SDK 10.0.26100.0; rustc 1.98.1. Commands (each with `CARGO_TARGET_DIR=D:\victory-warp-2690-target` and the WARP variables above): - Baseline and PR: `cargo test --locked -p victory-hle` - PR targeted: `cargo test --locked -p victory-hle a_loop_to_the_start_of_the_buffer_keeps_the_input_valid` - PR lint: `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` Results: baseline 148 passed, 0 failed (146 unit + 2 integration); PR 149 passed, 0 failed (147 unit + 2 integration). Targeted regression 1/1 passed. Clippy passed. Negative control: restored the old `0 == no next frame` invalidation; the new loop-to-zero test failed (exit 101), as expected. No implementation bug found. Not tested: physical GPU, retail title, release build. AI-assisted: Codex (gpt-6-luna).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:17 UTC · original

Automated triage for the maintainers.

In crates/victory-hle/src/modules/audio.rs decode, the next read position becomes an Option<usize>, so a loop whose start field (context dword 3) is 0 no longer clears the input's valid bit as if the stream had ended. I checked this against main: decode already treats a read position below 32 as "the first frame of the buffer", so 0 is a real position there and the old 0 == no next frame sentinel conflicted with that. The test is now parameterised over loop starts 32 and 0, and the 0 case asserts that the valid bit stays set. CI (check) passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714#issuecomment-7177370716) <!-- victory-triage v1 head=69d5708107565d3740bcdb408d8e41d397042544 verdict=merge-candidate at=2026-11-25T23:17:33Z --> Automated triage for the maintainers. In `crates/victory-hle/src/modules/audio.rs` `decode`, the next read position becomes an `Option<usize>`, so a loop whose start field (context dword 3) is 0 no longer clears the input's valid bit as if the stream had ended. I checked this against `main`: `decode` already treats a read position below 32 as "the first frame of the buffer", so 0 is a real position there and the old `0 == no next frame` sentinel conflicted with that. The test is now parameterised over loop starts 32 and 0, and the 0 case asserts that the valid bit stays set. CI (`check`) passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-26 00:49 UTC · original · approved these changes

Verified against origin/main (63bcca4):

  • Keeping XMA input valid when looping back to the start of a buffer passes all audio tests cleanly.
  • cargo test -p victory-hle audio::: 9/9 passed (including a_loop_to_the_start_of_the_buffer_keeps_the_input_valid).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-26 00:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714#pullrequestreview-6067059533) · **approved these changes** Verified against `origin/main` (`63bcca4`): - Keeping XMA input valid when looping back to the start of a buffer passes all audio tests cleanly. - `cargo test -p victory-hle audio::`: 9/9 passed (including `a_loop_to_the_start_of_the_buffer_keeps_the_input_valid`). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 12:17 UTC · original

NVIDIA full-suite run, to go with the reports above by DenRakEiw, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head 69d5708 (on its base 13f91ca).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: a_loop_to_the_start_of_the_buffer_keeps_the_input_valid.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 12:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2714#issuecomment-7191806627) NVIDIA full-suite run, to go with the reports above by DenRakEiw, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head `69d5708` (on its base `13f91ca`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `a_loop_to_the_start_of_the_buffer_keeps_the_input_valid`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2714/head:github-bot/gh-2714'
git switch 'github-bot/gh-2714'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2714'
git switch 'github-bot/gh-2714'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2714'
git switch 'github-bot/gh-2714'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2714'
git switch 'main'
git merge --squash 'github-bot/gh-2714'
git switch 'main'
git merge --ff-only 'github-bot/gh-2714'
git switch 'main'
git merge 'github-bot/gh-2714'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2714
No description provided.