Find the first XMA frame when a buffer starts with continuation data #2708
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2708
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2708"
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?
@VlREX on GitHub · 2026-11-25 18:33 UTC · original
VlREX:fix/xma-stream-walk→main· +46 −9 · 2 files · 2 commits · openThe audio context assumed packet zero announced a frame on initial input and on buffer switches. Follow the stream skip counts past packets with no frame starts, and check the announced offset is in its packet and buffer. Explicit playback positions still use the supplied offset. This changes initial frame selection; #2694 covers advancing from an already decoded frame. Two synthetic regression tests failed with the old selection logic. Windows GNU victory-formats tests: 40 passed, 5 ignored. No game data used.
@kotekompotek on GitHub · 2026-11-25 18:50 UTC · original
Right split with #2694: this fixes initial selection (packet zero need not announce a frame - continuation data is legal), #2694 fixes advancing. Walking the stream skip chain until a packet with frames != 0 and then bounds-checking the announced offset inside both packet and buffer covers both failure shapes. Nice that the existing decode tests got switched to first_frame so they pin it end-to-end.
@oni-swr on GitHub · 2026-11-25 18:54 UTC · original
Independent WARP/CPU verification
PR head:
09a519b9a5120380019adff3537cd56e0feb6fc4Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, WARP only (
VICTORY_WARP=1+VICTORY_D3D12_WARP=1),dxil.dll1.8.2502.11 (Windows SDK 10.0.26100.0), no physical GPU touched, no game files/dumps/retail hashes.CARGO_TARGET_DIRon D:,--lockedthroughout.origin/main=13f91caee25f2fdf2c062be5f7a27f058e51cbca; merges cleanly (git merge-tree); open, non-draft, nooni-swrcomment on this head.Commands / results (
cargo test --locked -p victory-formats -p victory-hle):cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings→ clean.first_framestop at packet 0 (index += ...→return None) makesfirst_frame_follows_stream_skips_past_continuation_packetsFAIL.Baseline note: on the very first baseline
victory-hlerun,dstorage::tests::a_page_list_filled_after_its_request_startsfailed once (assertion left==right); it passed 3/3 reruns in isolation and in a full rerun (146/146), so it looks like a flaky pre-existing test unrelated to this PR.Review: logic is correct: skips packets with
frames == 0following the stream skip count, bounds-checks the first-frame offset against the packet and the data length, and useschecked_mul/add. The loop terminates becausepacketreturnsNonepast the data. Both new tests cover a continuation-packet case and the out-of-payload offset. Nit (non-blocking): the newfirst_frametests were inserted between the doc comment ofnoise_packets_walk_and_decodeand that test, so that doc comment is now attached to the wrong test. The debug log now reportsframe.startinstead ofat, which is more accurate.Not tested: physical hardware GPU, retail game run, release build.
AI use: Claude Code (Claude Sonnet 5.5). Claim: #1633
@fuzeofficlal on GitHub · 2026-11-25 18:54 UTC · original
Independent Windows 11 verification and boundary review of
09a519b9(on13f91ca):Verification (
rustc 1.98.1MSVC)cargo clippy --locked -p victory-formats -p victory-hle --all-targets -- -D warnings: 0 warnings.cargo test --locked -p victory-formats: 40 passed, 0 failed, 5 ignored (both newfirst_frametests pass).cargo test --locked -p victory-hle: 146 passed, 0 failed (lib), plusfidelityfxandno_dll_plantingchecks clean.git merge-treewith #2694 (1cd96506); the two PRs touch disjoint paths (first_frameinitial/buffer-switch lookup vsnext_framestepping) and complement each other cleanly.Review Notes
first_framesafely advances past leading continuation packets (frames == 0) via strictly increasingindex += 1 + header.skip as usize, bounds packet reads viapacket(data, index)?, rejects out-of-packetoffset >= PACKET_BITS, uses checked arithmetic for bit offsets, and verifiesstart / 8 < data.len()— safe on empty, truncated, all-zero, or malformed buffers.if at < 32 { xma::first_frame(data) } else { Some(at) }preserves explicit loop/resume offsets (at >= 32) while fixing buffer-start continuation streams.@Marvisak on GitHub · 2026-11-25 22:22 UTC · original
Automated triage for the maintainers.
Merge candidate (recommend a look). When an XMA context starts at the beginning of its input buffer,
decodeincrates/victory-hle/src/modules/audio.rsused packet 0's first-frame offset even when packet 0 announced no frame (continuation data), so it read from a meaningless position. The newxma::first_frame(crates/victory-formats/src/xma.rs) follows the stream's packet-skip counts to the first packet that announces a frame, the same walknext_framealready does, and bounds-checks the offset against the packet and the buffer with checked arithmetic. It terminates becausepacketreturnsNonepast the data. Explicit read positions (at >= 32) are unchanged, and the existing decode tests now start throughfirst_frame. It is complementary to #2694 and merges cleanly with it and with #2709/#2710/#2714.Nit: the two new tests were inserted between
noise_packets_walk_and_decodeand its doc comment, so that comment now sits onfirst_frame_follows_stream_skips_past_continuation_packets.CI:
checkpassing on this head.Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 05:18 UTC · original · approved these changes
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:xma::first_framewalks packet headers following1 + header.skipuntil a packet announces frames (header.frames != 0), bounds-checksHEADER_BITS + header.first_frame_bit < PACKET_BITSandstart / 8 < data.len()with checked arithmetic, and avoids reading into continuation packets or out-of-payload offsets whenaudio::decodestarts a fresh buffer.cargo test -p victory-formats xma: 22 passed, 0 failed (includingfirst_frame_follows_stream_skips_past_continuation_packetsandfirst_frame_rejects_an_offset_outside_the_announcing_payload).cargo test -p victory-hle audio: 8 passed, 0 failed.cargo clippy -p victory-formats -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@futurepro62 on GitHub · 2026-11-26 11:55 UTC · original
NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head
09a519b(on its base13f91ca).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo 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: 775 passed, 0 failed, 9 ignored.first_frame_follows_stream_skips_past_continuation_packets,first_frame_rejects_an_offset_outside_the_announcing_payload.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#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_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.