XMA: cache IMDCT rotation tables per subframe size #172
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!172
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/172/head"
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?
@TG0000 on GitHub · 2026-11-24 01:05 UTC · original
TG0000:perf/xma-imdct-rotations→main· +296 −34 · 1 files · 1 commits · merged 2026-11-25 00:18 UTCSummary
Caches the pre/post rotation tables, bit-reversal order, and butterfly twiddle factors once per XMA subframe size (128, 256, and 512 samples) in imdct_half (crates/victory-formats/src/xma.rs) and replaces the per-call heap Vec work buffers with stack arrays.
Why
Previously, imdct_half recomputed sin_cos for every pre- and post-rotation on every subframe call and allocated two fresh Vec buffers per call. Precomputing those tables once per subframe size removes the repeated trig work and per-subframe heap allocations while preserving bit-for-bit identical output (each table value uses the exact same floating-point expression and butterfly recurrence as before).
Measured performance (synthetic release benchmark)
3.2×–4.4× (3.7× overall) faster imdct_half across the 128/256/512 subframe sizes in MSVC release builds.Testing
AI-assisted (Claude Opus 5.5).
@DaviTostes on GitHub · 2026-11-24 01:23 UTC · original
Tested
4eb0898on Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-formats: 22 passed, 0 failed, 4 ignored (2 test binaries), including the 3 tests this PR adds.No game data used.
@Marvisak on GitHub · 2026-11-25 00:20 UTC · original
Automated triage for the maintainers.
Merge candidate.
imdct_halfincrates/victory-formats/src/xma.rsnow builds the pre/post rotations, bit-reversal order and butterfly twiddles once per subframe size (128/256/512, in aOnceLocklike the existingwindows()) and uses a stack buffer sized byFRAME_SAMPLESinstead of twoVecs per call. Each table entry uses the same expression and the same per-stage running product as the old per-call code; other sizes still build tables on the spot, andtabled_imdct_gives_the_same_bitscompares the output bit for bit against the old transform for n = 2…2048. The ~3.7x speed-up is for the transform alone; no in-title measurement.CI: no check runs on the head commit.
Generated by Claude Code