[pr-fix][memory][RAYTRACING][AMD] hwrt: BLASes that are refitted get committed buffers, not reused shared-heap units (DARNER_HW_RT_REFIT_COMMITTED, on by default; RX 7900 XTX "device hung") #445
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!445
Loading…
Reference in a new issue
No description provided.
Delete branch "duckey-dev/Darner:hwrt-refit-committed"
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?
Refs #197
Refs #388
Contributor role (optional)
What it changes
f3840d7loses the device ("device hung",0x887A0006) in 8 of 10 runs, within about 1 to 2 minutes of play. DRED: the GPU stops at the barrier right after a wave of BLAS builds and refits. The page-fault addresses are outside every live allocation, all just above0x800000000(for example0x800080000,0x8022a3000,0x8084f4000,0x80a114000). That fits the GPU following a garbage 32-bit BVH node pointer:(ptr & ~7) << 3reaches up to 32 GiB above the structure.Follow-up to my report in #197: the delayed unit return I suggested there was tested and is not enough (units given back only after 2 or 120 frames plus retirement still hung 3 of 3 and 2 of 3 runs); this is the fix.
What the runs show (same PC, same save, same switches, each about 80 to 90 s of play):
f3840d7, hardware RT onDARNER_HW_RT_BLAS_HEAPS=0(every BLAS committed)DARNER_HW_RT_REFIT=0(no refits at all)So the hang needs both refits and BLASes placed in heap units that held another BLAS before. Giving units back later does not help, so this is not a BLAS's memory being reused while the GPU still reads the old one. What the evidence fits is that an in-place refit reads something in the structure that its build did not write, and in a reused unit that is the previous BLAS's tree. I have not proven that inside the driver. AMD's RDNA performance guide advises fully initialising placed resources; a committed buffer never holds another BLAS's tree.
This change is a placement rule for the BLASes that are refitted every frame: a BLAS built with
ALLOW_UPDATEgets a committed buffer (create_blas_buffernow takesrefittable); every other BLAS is still placed in the shared heaps (DARNER_HW_RT_BLAS_HEAPS, fromfa0b1fc) as before.DARNER_HW_RT_REFIT_COMMITTED=0places refittable BLASes in the heaps again. The switch's state is logged once, when it is first read.Per run, about 1,050 to 1,190 refittable BLASes were committed and about 1,850 to 2,250 others were still placed, in 8 to 9 heaps of 64 MB, so most of the shared-heap placement stays.
Cost: committed creation for the refittable BLASes. The log's average is about 300 to 345 µs per BLAS buffer made (both kinds together), against 715 to 848 µs with every BLAS committed (
DARNER_HW_RT_BLAS_HEAPS=0). Frame rate in the clean runs is in the same range asf3840d7runs before their hang. This is not a performance claim.A second, separate pull request (#446) closes an ordering hole in refits (
DARNER_HW_RT_REFIT_BUILT). On its own it did not stop this hang (7 of 7 runs hung).How it was tested
Tested revision: game runs on
f3840d7with this change, diagnostics (diag) builds. This branch is the same change on47d21cd(commitfc606f0);hwrt.rsis the same file atf3840d7and47d21cd. Not run in the game on47d21cd.Commands and results: the game runs in the table above and the A/B below; the gates below.
Changes a default: yes, for every card with hardware ray tracing on (
DARNER_HW_RT=1): refittable BLASes are committed unlessDARNER_HW_RT_REFIT_COMMITTED=0.A/B result, on an RX 7900 XTX, same save, same switches (
DARNER_HW_RT=1 DARNER_RELAY=2 DARNER_PORT_CBV=1 DARNER_EARLY_DEPTH=1), each run about 80 to 90 s of play:f3840d7as is)Gates run on
fc606f0(there is no CI): gates 1 and 2 (cargo clippy --workspace --all-targets --locked -- -D warnings, without and with--all-features) passed. Gate 3: the fullcargo test --workspace --lockedwas stopped after about 27 minutes indarner-shader's tests, which this change does not touch. Run instead:cargo test --locked -p darner-gpu -p darner-hle -p darner(the changed crate and the crates that depend on it): 1,993 passed, 1 failed (host::refresh_tests::unchanged_ranges_are_known, passed when rerun), 82 ignored; the game was running on the same PC during part of these test runs. Thread-timing tests indarner-gpualso fail now and then on main: run back to back,gpu_owned::tests::concurrent_faults_on_same_block_serialize_single_readbackfailed 1 of 10 runs on47d21cdand 1 of 10 on this branch.Gameplay, when relevant: RX 7900 XTX, Ryzen 7 7800X3D, 64 GB, Windows 11; game build Xbox Series 1.0.2.1; hardware ray tracing on. Series S console profile, the game's 1920x1080 output, the title's own upscaler (type 6), frame generation off.
Shader wave sizes tested, when relevant: not relevant (no shader change).
Hardware dependence: seen on an RX 7900 XTX (RDNA 3). #388 (RX 9060 XT, hardware RT) and #69 (device hung with hardware RT) may be the same hang; not tested on those cards. #342 (NVIDIA device loss with hardware RT) works around with
DARNER_HW_RT_REFIT=0, which may point to the same cause; not tested on NVIDIA.Coverage gaps: one card, one save. Not run on NVIDIA or Intel cards, where the change is on by default too. The mechanism inside the driver is not proven.
Checklist
main.docs/asset-policy.md.Checked for overlap
HostAsreuse; tested on this PC, still hung 1 of 1), #279 (also changeshwrt.rs: TLAS reallocation, a different change). Related issues: #197 (my earlier report), #388, #69, #342, #290 (BLAS heaps never given back; same heaps, a different problem).🤖 Generated with Claude Code
In-place refits of BLASes placed in reused units of the shared BLAS heaps page-faulted on an RX 7900 XTX ("device hung", 0x887A0006) at the barrier after a wave of refits, at addresses just over 32 GiB away from any live allocation (the GPU followed a garbage 32-bit node pointer). Committed BLAS buffers, and heap units never reused, did not fault, and delaying the reuse of units did not help. BLASes built with ALLOW_UPDATE now take committed buffers; the rest stay in the heaps. DARNER_HW_RT_REFIT_COMMITTED=0 places them as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested on a different GPU: RTX 5080 16 GB, Ryzen 7 9800X3D, driver 32.0.16.2140, Windows. In game with hardware RT (
DARNER_MENU_RT=hardware, fullscreen, frame gen on), same save/area: main47d21cdvs this PRfc606f0.Method: sampled the
hardware RT BLAS buffers:andhardware RT BLAS memory:lines from the log and compared the end state, where live BLAS is close between the runs (4.4k vs 4.1k). The PR run was longer (~12 min, part of it in the menu), so the sample means are not comparable; the end state and the per-buffer creation cost are.47d21cdfc606f0At comparable live BLAS, 3,438 BLASes (about 41% of the 8.3k buffers) moved out of the shared heaps: heaps 12 -> 8 and heap in use down 252 MB (-40%). The cost is creation: 242.5 us per buffer made on average against 20.6 us, 2.0 s against 0.2 s in all - a little below the 300-345 us the description reports (and far from the 715-848 us with every BLAS committed). No device loss in either run.
Caveat: the run included menu time, so the sample means (placed 1,273 / committed 724 on average) say little; the end state and the per-buffer cost do not depend on play time.
Not tested:
DARNER_HW_RT_REFIT_COMMITTED=0on this GPU, other GPUs, and frame rate (the scenes and durations differ).Drafted with AI assistance (OpenCode).