Fix the 7–11 minute pool crash (upstream audio fixes), plus GPU stability fixes #959

Open
github-bot wants to merge 23 commits from github-bot/gh-959 into main AGit
Owner

@⁠Sashwiin on GitHub · 2026-11-25 13:48 UTC · original
Sashwiin:share → main · +1732 −118 · 14 files · 23 commits · open

Fixes the pool crash at 7–11 minutes into the world (a certain title's instance pool fills up) by bringing in upstream's 8 XMA/audio fixes; the intro stream no longer stalls, and a test run went 36 minutes without a crash. Also: an opt-in watchdog skip, choosing the host GPU by name, pipeline-library safety, bounded GPU waits, reuse of upload buffers, and an experimental page-pool in-place mode (off by default). Tested on an RTX 5070 Ti laptop with 16 GB of RAM.

🤖 Generated with Claude Code

**@⁠Sashwiin** on GitHub · 2026-11-25 13:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/959) `Sashwiin:share` → `main` · +1732 −118 · 14 files · 23 commits · open Fixes the pool crash at 7–11 minutes into the world (a certain title's instance pool fills up) by bringing in upstream's 8 XMA/audio fixes; the intro stream no longer stalls, and a test run went 36 minutes without a crash. Also: an opt-in watchdog skip, choosing the host GPU by name, pipeline-library safety, bounded GPU waits, reuse of upload buffers, and an experimental page-pool in-place mode (off by default). Tested on an RTX 5070 Ti laptop with 16 GB of RAM. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title ends the process on purpose when its main thread has not advanced
for about 30 one-second ticks (a write to address 0 at +0x23cf683, with a
second one at +0x2215c35 right after the handler call). On a host much slower
than the console a long load can exceed that window.

With VICTORY_NO_WATCHDOG=1 the loader jumps over the abort site and makes the
handler's fault a NOP. Each patch is applied only if the original BLAKE3
starts with the 1.0.2.1 identity and the exact original bytes are at the
offset; otherwise it logs a warning and does nothing. Off by default.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
(cherry picked from commit d2c93fac49c2138402742128b953b45e2299a7b5)
The hook was enabled by the variable being set at all, so =0 or an empty
value turned it on. Treat those as off, as a reviewer suggested.

Checked: cargo clippy -p victory-loader --target x86_64-pc-windows-msvc -- -D warnings is clean and the loader tests build (box, cross-compiled). Not run on Windows.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
(cherry picked from commit 85c04d129a0ad37a9f345b19cfbb3fbedf157327)
Windows' default GPU was always used. VICTORY_ADAPTER=<part of a name>
(case ignored) picks a hardware adapter whose name holds it, logging
every adapter's name. On a laptop with an NVIDIA GPU (32-lane waves
only) and an RDNA 2 integrated one (the console GPU's family, 64-lane
waves natively), the title can run on the latter as a reference for what
it should draw. `translate --cache` follows it too (its host target).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A library belongs to one adapter and driver; on another the host rejects
it, a run starts an empty one and saves it over the old. With
VICTORY_ADAPTER set the library is kept in a folder of that name
(pipelines\adapter-<name>), so a reference run on a second GPU never
replaces the library pre-built on the default one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Run 53 found no library at start ("no host pipeline library yet") where
a 1.8 GB pre-build had been, started an empty one and saved it over the
file. An unreadable file is now left alone (no pipelines kept that run);
one the host rejects (another adapter or driver, damage) is moved aside
as host-pipelines.rejected.bin before an empty one is started.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Host::execute waited for each submission with no end. A host that loses
its device need not signal the fences of the work it dropped:
vkd3d-proton after a GPU fault does not, and by default does not report
the device removed either. The title's submit thread then stays in our
wait, its render thread blocks on its full submission ring, and 30 s
later the title's own watchdog ends the run at image+0x23cf683 (#1118),
with nothing of ours in crashes.log to say that the GPU faulted.

The wait now goes in 250 ms slices:

* between slices the device is asked whether it was removed; if so the
  wait ends and the existing check after the submission reports it;
* a submission still running is said so at 10 s and 20 s;
* at 25 s it is given up with a report of its own ("has not finished a
  submission ... and reports no removal"). The limit is below the
  title's 30 s so the run ends with the cause, not with the title's
  null write. vkd3d-proton's own source calls a wait of over 5 s a lost
  device; Windows resets a device after about 2 s.

A fence that comes is taken as before; a device that is removed and
signals (Windows) is reported by the check after the wait, as before.

Tested on Linux only (RTX 5080, driver 620.70, GE-Proton11-6's Wine,
vkd3d-proton 30b0eb9), on main + #177 + #259, where the world faults the
GPU in every run (Xid 13, fixed by #542):
* without this, with or without VKD3D_CONFIG=fault: the title's crash at
  +0x23cf683 24 to 30 s after the Xid, in 9 of 9 runs, and no report;
* with this and VKD3D_CONFIG=fault: "device removed: 0x887A0005" 4 s
  after the Xid;
* with this and vkd3d-proton's defaults: the two warnings, then the
  stall report 25 s after the submission began.
New unit test of the wait (no GPU); cargo test --workspace under Proton:
333 passed, the same ten environmental failures as main; clippy
-D warnings with and without --all-features; cargo xtask policy. Not run
on Windows.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit b58b779fdedc4e8724bcab295276c455e587c8f9)
The 5 s debug summary showed most busy workers neither reading nor
decoding (run-auto-4: 12.5 busy, 0.8 reading). It now also says how many
workers were telling the GPU side of a write (guards opened, copies and
textures marked) and writing physical pages through a buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
In-place windows and buffers covered private memory only; most of what
the title has copied lies in its page pool (run-auto-11: 137 windows in
place, 2301 turned down as view memory). With the switch the runtime
makes physical-page sections committed (reserved again if the host
cannot), each is opened once as a host heap, which locks nothing, and a
range one run of one section shows gets a buffer placed at its offset.
Such buffers are not held to VICTORY_INPLACE_MB. A view mapped anew lets
go of what was in place there, as before.

Also notes that level 2 hangs the device with the relay (on by default).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The host opens no section of 4 GiB or more (E_INVALIDARG; on the
software adapter 4095 MB opens and 4096 MB does not), and the title asks
for its 6.1 GiB pool in one call, so run-auto-12 opened none of it: 728
windows refused. With VICTORY_INPLACE_POOL=1 the pool is now made of
committed sections of 1 GiB each; runs of pages break at their seams as
they do between allocations. A section the host refuses is remembered
and not asked again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An opened section is resident with the card whole: run-auto-13 opened
four of 1 GiB for 63 MB of windows, the fifth was refused for memory and
command lists then failed to close (E_OUTOFMEMORY). The pool is now made
of 32 MiB sections, opened only where a window lies, and no more than
VICTORY_INPLACE_POOL_MB (2048) of them are opened; past that, windows
are copied as before. The status line says how much is open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
run-auto-16 opened sections up to the 2 GiB cap while the windows in
them were let go (269 remapped), so they held 1952 MB for 453 MB of
windows, and recording a compare then ran the card's share of PC memory
out (E_OUTOFMEMORY). Each open section now counts the buffers placed in
it and is closed when the last goes; the cap is 1024 MB. The status line
says how many were closed again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Decoder::decode took the caller's bit count as the end of the frame. Past
the data the bit reader returns zeros, and a stereo tile header reading
only zeros gives the subframe to no channel, so it never moves on; with a
count beyond the data it never overreads either, and looped for good.
Clamp the end to the bits the data holds. A frame from read_frame always
holds its bits, so its decoding does not change.

Add deterministic noise tests (xorshift64, fixed seeds, as BCPack's):
buffers of noise packets, streams of noise frames with clean and damaged
headers, frames in mono and stereo at each sample rate, bit counts past the
data, and read_frame and packet at any offset. Every walk is bounded and
every decode must give one frame of samples. The bit-count test hangs
without the fix; the others pass on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit d4d1822049fed053c6188ea0b016b0976a71bf41)
A frame that ends in a packet where no frame begins (the tail of a frame that crossed packets, then padding) left the next frame pointing into that padding, which ended the stream early. Now the next frame is found by following each packet's skip to the next packet with frames.

(cherry picked from commit ba42db643c15c1b7fb17ba40464dddda36c1db60)
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 <[email protected]>
(cherry picked from commit 1054fe87de08038e887d6f7c6f44e5b07ac7a9f9)
imdct_half worked out every pre- and post-rotation with sin_cos on each
call (n of them per subframe) and ran its FFT on two fresh Vecs. The
rotations, the bit-reversed order and the butterfly rotations now come
from a table built once for 128, 256 and 512 samples; the work buffers
live on the stack. Every value is computed with the same expression (the
butterflies with the same running product), so the output is bit for
bit what it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 4eb0898b3cbd6d0bbbffad540aca5d7e3531ac58)
When a frame ended a loop, decode cut it at the loop's end subframe, set
the loop's skip (the subframes of the loop's first frame that lie before
the loop) and then took that skip out of the frame in hand: the loop's
last. So the head of the last frame was dropped instead, and the first
frame played from its start, with the audio before the loop in it. The
number of samples came out the same; the seam did not.

The pending skip is still applied to the frame in hand, and the loop's
skip is set after it, for the frame decoded next.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 985d8d4b025384b5f13a3177ef906c8b6cce6840)
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.

(cherry picked from commit 7a5d85e6a2867081ed54515ce7f33bae3fcb643d)
(cherry picked from commit 643fc6dfecffbd06de7313897b7d4bc4ffef6564)
Read complete payload bytes directly inside an XMA2 packet. Keep the bit reader for packet headers, interleaved stream skips and the final partial byte. Add coverage for all eight alignments at packet boundaries and EOF. On Windows x86-64, 36,720 synthetic reads matched the previous implementation, including returned bytes and the next frame position. A release microbenchmark of read_frame measured 1009 to 168 ns for 128-byte frames and 7977 to 1062 ns for 1 KiB frames (median of nine runs).

(cherry picked from commit 03a6f22906b4372ec08d003e9103997659647b0f)
One upload buffer was made and freed per copy recorded into a list:
155,286 of them (61.7 GB) in run-auto-20, and the driver held 242 blocks
of 32 MB (5.4 GB) of write-combined memory for them. A list now takes a
buffer of the next power of two (at least 64 KiB, at most 32 MiB) from
the ones earlier lists gave back, and gives its buffers back when it is
reset after its submissions ran (or dropped); at most 256 MB is kept.
VICTORY_UPLOAD_POOL=0 makes one buffer per copy, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:39 +00:00
Author
Owner

@⁠Sashwiin on GitHub · 2026-11-25 13:52 UTC · original

Overlaps: the watchdog commits match #364; GPU selection overlaps #261/#750 (this one picks by name); some XMA fixes overlap #301, #627 and #877. The new part is the evidence: with upstream's 8 XMA commits the intro stream stops stalling and the 7–11 minute pool crash is gone (36 min in the world, no crash). Happy to split this PR or drop the overlapping commits.

**@⁠Sashwiin** on GitHub · 2026-11-25 13:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/959#issuecomment-7164408612) Overlaps: the watchdog commits match #364; GPU selection overlaps #261/#750 (this one picks by name); some XMA fixes overlap #301, #627 and #877. The new part is the evidence: with upstream's 8 XMA commits the intro stream stops stalling and the 7–11 minute pool crash is gone (36 min in the world, no crash). Happy to split this PR or drop the overlapping commits.
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 14:39 UTC · original

An independent Linux check on ffe4a3a passed 13 built-in XMA tests, with three ignored. A source-built seven-packet stream also preserved a 1,031-bit frame and reached the next frame across an interleaved continuation and empty packet. The same input passes #627, and 0b0074e instead points into padding.

The other synthetic control distinguishes the two implementations. When a packet's declared first-frame position is beyond its payload, #627 rejects it. On main and this head the parser can select a bit in a later packet's header as the next frame. This favors keeping #627's bounds check when splitting the shared packet traversal changes. I also confirmed the APU edits overlap #567 and the deferred loop-start skip overlaps #301.

These results cover the XMA parser and source comparison. They do not reproduce the Windows audio path or attribute the reported 36-minute in-game result to an individual change.

AI-assisted using Codex.

**@⁠avt0m4t48** on GitHub · 2026-11-25 14:39 UTC · [original](https://github.com/fxceless/victory-fork/pull/959#issuecomment-7165623167) An independent Linux check on `ffe4a3a` passed 13 built-in XMA tests, with three ignored. A source-built seven-packet stream also preserved a 1,031-bit frame and reached the next frame across an interleaved continuation and empty packet. The same input passes #627, and `0b0074e` instead points into padding. The other synthetic control distinguishes the two implementations. When a packet's declared first-frame position is beyond its payload, #627 rejects it. On main and this head the parser can select a bit in a later packet's header as the next frame. This favors keeping #627's bounds check when splitting the shared packet traversal changes. I also confirmed the APU edits overlap #567 and the deferred loop-start skip overlaps #301. These results cover the XMA parser and source comparison. They do not reproduce the Windows audio path or attribute the reported 36-minute in-game result to an individual change. AI-assisted using Codex.
Author
Owner

@⁠Ym1r1710 on GitHub · 2026-11-25 15:09 UTC · original

Tried just the 8 upstream XMA commits from this PR on their own (cherry-picked onto current main plus #812, no watchdog / GPU selection / in-place pool commits). RTX 5080 16 GB, Windows 11, Series X profile.

15 min run (stopped it at 904 s myself), no crash, no device removal. Frame rate stayed flat at 6.7-7.0 fps the whole way, including the 7-11 minute window. Cherry-picks applied clean.

So the audio part alone seems to be enough for the pool crash, at least on my setup. Can't say for sure the base would have crashed on this machine though, I didn't do a long run without them.

**@⁠Ym1r1710** on GitHub · 2026-11-25 15:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/959#issuecomment-7166406109) Tried just the 8 upstream XMA commits from this PR on their own (cherry-picked onto current main plus #812, no watchdog / GPU selection / in-place pool commits). RTX 5080 16 GB, Windows 11, Series X profile. 15 min run (stopped it at 904 s myself), no crash, no device removal. Frame rate stayed flat at 6.7-7.0 fps the whole way, including the 7-11 minute window. Cherry-picks applied clean. So the audio part alone seems to be enough for the pool crash, at least on my setup. Can't say for sure the base would have crashed on this machine though, I didn't do a long run without them.
Author
Owner

@⁠ThomasHFWright on GitHub · 2026-11-25 18:12 UTC · original

Linux/Proton follow-up: selected the eight audio-only commits documented below, plus the stricter continuation-packet parser from #627 (b786897943). Original authorship/provenance retained. I did not import this PR's unrelated GPU, watchdog or page-pool bundle.

CachyOS, Ryzen 7 9800X3D, RTX 5090, NVIDIA 620.73.04, GE-Proton 11-14 with the pinned Linux runtime. Native formats: 35 passed / 5 ignored. Full HLE: 104 passed / 1 pre-existing Wine failure (missing WSAConnectByList). New malformed-input, continuation bounds, ring wrapping, multi-frame skip bookkeeping and short/misaligned output tests pass. Cached transform and byte-gathering equivalence checks pass. Application build and all-target/all-feature Clippy pass.

Two combined title trials rendered incomplete world scenes, then hit the same existing fixed-pool breakpoint after 518.31 s and 432.27 s. Neither recorded an NVIDIA Xid, native allocation failure or OOM. Both started from verified copies of the same seven-file profile; the second used a separate writable data folder. They also contain half-data changes (and a later shader-analysis correction), and reuse warmed caches, so they are not isolated audio A/B tests. This does not show the audio subset resolving our progression blocker.

An inherited limitation remains: a skip consuming all decoded PCM can still result in a zero output block; the added skip tests cover bookkeeping, not that timing case.

Source pins, tests and limitations: https://github.com/ThomasHFWright/LinVictory/blob/linux-edge/docs/linux-improvements.md
Title results: https://github.com/ThomasHFWright/LinVictory/blob/linux-edge/docs/linux.md

AI-assisted integration/testing with OpenAI Codex. Aggregate results only; no game files, generated data or raw logs attached.

**@⁠ThomasHFWright** on GitHub · 2026-11-25 18:12 UTC · [original](https://github.com/fxceless/victory-fork/pull/959#issuecomment-7170592315) Linux/Proton follow-up: selected the eight audio-only commits documented below, plus the stricter continuation-packet parser from #627 (b786897943cae296dd2094bbc4779fa987410040). Original authorship/provenance retained. I did not import this PR's unrelated GPU, watchdog or page-pool bundle. CachyOS, Ryzen 7 9800X3D, RTX 5090, NVIDIA 620.73.04, GE-Proton 11-14 with the pinned Linux runtime. Native formats: 35 passed / 5 ignored. Full HLE: 104 passed / 1 pre-existing Wine failure (missing WSAConnectByList). New malformed-input, continuation bounds, ring wrapping, multi-frame skip bookkeeping and short/misaligned output tests pass. Cached transform and byte-gathering equivalence checks pass. Application build and all-target/all-feature Clippy pass. Two combined title trials rendered incomplete world scenes, then hit the same existing fixed-pool breakpoint after 518.31 s and 432.27 s. Neither recorded an NVIDIA Xid, native allocation failure or OOM. Both started from verified copies of the same seven-file profile; the second used a separate writable data folder. They also contain half-data changes (and a later shader-analysis correction), and reuse warmed caches, so they are not isolated audio A/B tests. This does not show the audio subset resolving our progression blocker. An inherited limitation remains: a skip consuming all decoded PCM can still result in a zero output block; the added skip tests cover bookkeeping, not that timing case. Source pins, tests and limitations: https://github.com/ThomasHFWright/LinVictory/blob/linux-edge/docs/linux-improvements.md Title results: https://github.com/ThomasHFWright/LinVictory/blob/linux-edge/docs/linux.md AI-assisted integration/testing with OpenAI Codex. Aggregate results only; no game files, generated data or raw logs attached.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-959'
git switch 'github-bot/gh-959'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-959'
git switch 'github-bot/gh-959'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-959'
git switch 'main'
git merge --squash 'github-bot/gh-959'
git switch 'main'
git merge --ff-only 'github-bot/gh-959'
git switch 'main'
git merge 'github-bot/gh-959'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.