Replay: a capture made with default settings loses the device on load (its memory is left not resident) #550
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/Belobug--VIctory-Belobug-AMD!550
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-550"
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?
@adrianmjim on GitHub · 2026-11-27 11:11 UTC · original
adrianmjim:replay/resident-memory→a-publier· +46 −4 · 2 files · 2 commits · openOn an RX 7900 XT, a
victory replayof a capture recorded with default settings loses the device (DXGI_ERROR_DEVICE_HUNG, 0x887A0006) while it loads the contents, before any recorded command runs. With this change the replay dropsD3D12_HEAP_FLAG_CREATE_NOT_RESIDENTwhen it makes the recorded memory again.Machine: RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300,
a-publier4eb6cfd. Replays are of diag builds with--features diagnostics. Tests are of the default test profile.What breaks
4eb6cfd: the plain run (--loops 5) and six--loops 1runs with--breadcrumbs,--until 0:0(twice),--no-restore,--wait-alland--debug-layer. Each printed the 0x887A0006 error and no report. Windows filed four LiveKernelEvent 141 reports during those runs.4eb6cfdwith the Series S profile and the settingsscripts/play.ps1sets by default, plusVICTORY_RECORD,VICTORY_RECORD_AT,VICTORY_CAPTUREandVICTORY_CAPTURE_WORLD.VICTORY_KEYSwas set and thegofile took the place ofVICTORY_RECORD_AT, failed the same way on4eb6cfd: one--loops 3run, the 0x887A0006 error and no report, and another LiveKernelEvent 141. The same capture replayed with the fix 30 s later (17.51 ms, 3 loops), so the card was left in working order.0322b39withoutVICTORY_WAIT_RESIDENT=0holds such memory.9ba5661(a day after0322b39) gives counts of buffers a replay was refused, 1,326 to 3,576 a capture, so replays were being run somewhere around then. I do not know on which card, or whether those captures were made before0322b39or withVICTORY_WAIT_RESIDENT=0. Do replays of captures made with the default settings load on your card? If they do, this is narrower than "every capture".MakeResidentthat D3D12 asks for first. I have not seen what another driver does with that.Cause
0322b39the host makes new memory (blocks of textures, committed textures, its upload and card buffers) withCREATE_NOT_RESIDENTand makes it resident itself (VICTORY_WAIT_RESIDENT, on by default): host.rs#L225-L242. Two of the eight call sites are pool.rs#L676 and resource.rs#L504. TheMakeResidentcall is at host.rs#L341-L348.0x1 | 0x8 | 0x20 | 0x1000(play.rs#L771, used at L793 and L847). Nothing underreplay/callsMakeResident.Measured on the title capture with an instrumented build that is not part of this PR, one run each:
CopyTextureRegion.MakeResidenton the 174 objects. In both the picture is the same bytes as presented.Fix
DROP, the mask of heap flags a replay has no use for, moves to module level, names its flags and now includesD3D12_HEAP_FLAG_CREATE_NOT_RESIDENT. Both creation paths (CreateHeap,CreateCommittedResource) already go through it.By the host's comment, it makes memory not resident so that it can make it resident, and wait for its mapping, before anything names it: lists sent before the memory was made do not wait for it. A replay makes all the recorded memory before it sends its first list, so there is no such order to keep. The alternative is to keep the flag and call
MakeResidenton each such object, as the host does. Both worked here on the title capture. I took the smaller change, and can switch if staying closer to the host is preferred.Tested
cargo test --locked -p victory-gpu --features diagnostics --lib flags_a_replay_drops: 1 passed. The new unit test checks the mask only: the host's flags for a block of textures loseCREATE_NOT_RESIDENTand keep the rest, and a heap opened from memory still loses its sharing flags.cargo test --locked -p victory-gpu --features diagnostics --test replay:a_frame_is_recorded_and_replayedpasses (4 runs of 4). Its heap of placed textures is now made as the host makes one (ALLOW_ONLY_NON_RT_DS_TEXTURES | CREATE_NOT_RESIDENT, thenMakeResident), so the recorded flags are the host's. This covers theCreateHeappath. The committed path shares the mask and has no test of its own.CREATE_NOT_RESIDENTtaken out ofDROP, the same test fails on this card:Player::loadreturns 0x887A0006 (2 runs of 2).cargo test --locked -p victory-gpu --features diagnostics --lib replay::: 26 passed.cargo clippy --locked -p victory-gpu --features diagnostics --tests -- -D warnings: clean.After the fix
Both runs are of
4eb6cfdplus this change.--loops 5:picture: the same bytes as presented, and all 5 loops give the recorded picture. 0.48-0.49 ms on the card.--loops 7:docs/replay.mdhas a section on runs that differ (L109). I did not look into the cause here.Not done
cargo test --workspace --all-features), which I have not tried: there the test now also makes a heap not resident and callsMakeResidenton whatever adapter the runner gives (the test skips itself if there is none). On an adapter that does not fault on such memory the changed test cannot fail without the fix, and the unit test is the only guard.victory-gputests,tests/replay_big.rs, the debug layer (it is not available on this machine), and a capture recorded withVICTORY_WAIT_RESIDENT=0.Seen on the way, not in this PR
--comparegives the "unchanged" report the picture of the experiment's last run.finish()for the unchanged side runs after the experiment's last loop (play.rs#L496-L501) and reads the picture off the card. In all 8 compare runs I made on the world capture with this build the two reports name the same picture hash, and it is the hash of the experiment's last loop. With--compare --no-barriers"unchanged" says 29.2 dB while its own 11 loops are 57.3-58.0 dB. That is a separate PR: #551.command list method Barrier is not recorded, and was called (54 times). The title capture has no such line. The only caller in the host is the full wait around copies done in place (host/place.rs#L171-L201,VICTORY_COPIES_IN_PLACE, on by default), which uses enhanced barriers where the adapter has them.docs/replay.mdlists enhanced barriers under limits. So, by the code, the replay of this capture runs without those waits. I have not measured what that changes.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 11:13 UTC · original · reviewed
🟢 Approval recommended
No active review issues require changes to the replay heap-residency handling.
No open issues 🎉
What changed in this PR
This PR prevents replay loading from recreating captured GPU memory as non-resident, addressing the reported device hang before recorded commands run.
Changes:
CREATE_NOT_RESIDENTfor both heap and committed-resource creation.crates/victory-gpu/tests/replay.rscrates/victory-gpu/src/replay/play.rsReview effort: Balanced
@gut0to on GitHub · 2026-11-27 13:28 UTC · original · reviewed
AI-assisted review: I compared the regression coverage with the failure described in the PR.
@ -3585,0 +3597,4 @@// As the host makes a block of textures: kept apart from render// targets, and not resident until it says so.let blocks = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;let host = blocks | D3D12_HEAP_FLAG_CREATE_NOT_RESIDENT;@gut0to on GitHub · 2026-11-27 13:28 UTC · original
The reported device loss was traced primarily to committed resources (169 in the failing capture), but the integration regression added here exercises only
CreateHeap; the unit test checks the shared mask without exercisingCreateCommittedResource. Could the test capture at least one committed resource withCREATE_NOT_RESIDENTand verify the replay-created resource is resident before its first copy? That would cover the path most directly implicated by the report.@ -3585,0 +3597,4 @@// As the host makes a block of textures: kept apart from render// targets, and not resident until it says so.let blocks = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES;let host = blocks | D3D12_HEAP_FLAG_CREATE_NOT_RESIDENT;@adrianmjim on GitHub · 2026-11-27 13:33 UTC · original
Done in
aff94e3. The scene's committed resources, all but the read-back buffer, are now made withCREATE_NOT_RESIDENTand then made resident, as the host makes its textures and buffers. So the capture carries the flag on both ways a replay makes memory,CreateHeapandCreateCommittedResource.I know of no D3D12 call that says whether a resource is resident, so the check is the replay itself: loading the capture copies the recorded contents into each of them.
On the RX 7900 XT:
cargo test --locked -p victory-gpu --features diagnostics --test replaypasses (4 runs of 4);CREATE_NOT_RESIDENTtaken out ofDROP, it fails atPlayer::loadwith 0x887A0006;Clippy (
-p victory-gpu --features diagnostics --tests -- -D warnings) is clean. I do not know whether CI's adapter faults on such memory; if it does not, the test cannot fail there without the fix, and the mask unit test is the guard.--skip-clampsand--batch-clampsread a capture's batched clamp passes (VICTORY_INDIRECT_BATCH,play.ps1's default) as plain ones #621@MamaLeVrai on GitHub · 2026-11-27 15:56 UTC · original
Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At
aff94e3:victory-gpu396 passed, 0 failed, 34 ignored.AI-assisted (Claude Code); no game data.
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.