Builder quarantine that holds; tracing where the builder's results land #935
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!935
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/935/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?
@TheoGegout on GitHub · 2026-11-25 13:11 UTC · original
TheoGegout:rt-builder-quarantine-and-trace→main· +716 −27 · 19 files · 3 commits · closed without mergingBuilder quarantine that holds; tracing where the builder's results land
The fix
VICTORY_BVH_QUARANTINE=1leaked. Copy-backs into title memory are declaredper list, not per dispatch:
memory::readydeclares every numbered copywritten once per list, and draws through descriptor tables declare theirs. So
another shader's declaration in the same list carried the structure builder's
stores back into title memory too.
A list that records a quarantined builder stage now copies nothing back
(
HostList::quarantine), including what was declared before it.Measured on an AMD Radeon RX 6800 XT (Series X profile, prologue):
VICTORY_BVH_BUILDER=1: the title crashes 3 to 12 s after the builder'sfirst frame.
VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1before this change: samecrash, about 12 s in.
The card was then lost (
0x887A0006), with about 1.1 s of GPU time per frameonce the builder runs.
Diagnostics (behind
diagnostics, all off by default)VICTORY_BVH_TRACE=1(bvhtrace.rs): infinities (0x7f800000,0xff800000) written into title memory by shader copy-backs, title buffercopies and texture read-backs, counted per 4 MiB block before and after the
builder's first dispatch; the root arguments of builder dispatches; the
copies reachable by raw address.
instruction's byte offset and the program's number (
program_id, FNV-1a ofits code) beside the page, in records of
FAULT_DWORDS. The record layoutchanges, the buffer size does not (1024 records of 4 dwords).
VICTORY_BVH_WARMUP=<frames>: the builder runs quarantined for its firstframes.
What the runs showed (also in
docs/fork-ray-tracing.md)runs.
field of one of the title's own objects that holds
+inf,-infor a pairlike
0xff8000007f800000.none before the builder runs and many after (36 to 66 blocks of 4 MiB), none
in the corrupted objects' blocks; buffer copies and read-backs carry none. So
the title's own code writes them, presumably from builder results it reads
(bounds, sizes) that are wrong.
VICTORY_BVH_WARMUP=10crashes as soon as theresults are let through.
global_atomic_fmin/fmax(258 of them in the builder) gives exact resultswith 65,536 threads on one address, in a custom write-back L0 buffer (as the
4 MiB windows are made) and in a default buffer.
programs that walk the structures (not from the builder), through real title
addresses whose pages had no copy yet.
Checks
cargo build --release -p victoryand--profile diag --features diagnosticscargo test --release -p victory-shader: 215 passedcargo xtask policy: ok🤖 Generated with Claude Code
@TheoGegout on GitHub · 2026-11-25 14:07 UTC · original
Follow-up: I tried to fix the rehydrate stages' lost reads, and both attempts run into the raw-address copy limit. Notes for whoever picks this up.
What the rehydrate program reads.
5e68767498c57eb6(the big rehydrate stage, 36 KB of native code) reaches its data through two levels of pointers that nothing names before it runs:+0x5cit holds the address of an array;+8(42 =R32_UINT, 57 =R16_UINT) and the address of the index data at+24;Only the first level is made ready, so the other reads give zeros. The lost accesses of a frame include addresses like
0x3ae1aand0xf0020: offsets from a pointer read as 0.Attempt 1: name what the rehydrate call's descriptions name. The loader shim read the call's build descriptions and geometry descriptions (D3D12's public layouts) and handed the structures, sources, index and vertex buffers to
memory::readyfor the stages recorded during the call. Still crashed. With the quarantine fixed in this PR it now crashed too, where it ran 74 s before. The rehydrate program still lost about 500 reads in two frames, through the deeper pointers.Attempt 2: chase pointers before every builder stage. Read 4 KiB behind each address a stage's arguments name, name every dword pair that looks like a 40-bit title address, and go one level deeper. Every copy number was taken within 1.7 s of the builder starting:
Why this is a wall. Memory by address goes through host copies of 4 MiB windows, 1023 at most (about 4 GB of system memory). The title rehydrates hundreds of batches of up to 16 structures each, spread over several GB of addresses, and many structures land in a window of their own. Making everything the rehydrate stages read ready does not fit in 1023 windows. Raising the limit costs the same again in system memory. I believe the way through is shaders reading title memory in place instead of through copies (
VICTORY_INPLACE), extended to the mapped views the structures live in. Those views are turned down today.Until then,
VICTORY_BVH_SKIP_REHYDRATE=1keeps the title running with the builder's other stages on. The two attempts are not in this PR.@TheoGegout on GitHub · 2026-11-25 16:12 UTC · original
Closing in favour of two PRs, as discussed on #994:
bvhtrace.rsand crash-memory dump replace the ones here.VICTORY_BVH_SKIP_REHYDRATEand the rehydrate diagnosis indocs/fork-ray-tracing.mddescribed the overrun's effects, so they are not carried over.Pull request closed