[pr-fix][RAYTRACING] hwrt: a refit reads only a source whose build has been submitted (DARNER_HW_RT_REFIT_BUILT, on by default) #446
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
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!446
Loading…
Reference in a new issue
No description provided.
Delete branch "duckey-dev/Darner:hwrt-refit-source-built"
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?
Contributor role (optional)
What it changes
Each BLAS now carries a flag that is set when the list recording its build is submitted (
HostList::at_submit). A refit whose source is not flagged yet is built anew instead, as a request that matches no source. The first eight such refits, then every power of two, are logged.DARNER_HW_RT_REFIT_BUILT=0gives the old behaviour.This is a real ordering hole, but not the cause of the "device hung" with hardware RT on the RX 7900 XTX: on its own it still hung 7 of 7 runs. That hang is the subject of #445.
How it was tested
Tested revision: game runs on
f3840d7with this change, diagnostics (diag) builds. This branch is the same change on47d21cd(commit78cff43);hwrt.rsis the same file atf3840d7and47d21cd. Not run in the game on47d21cd.Commands and results: the game runs below; the gates below.
Changes a default: yes, for every card with hardware ray tracing on.
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:f3840d7aloneGates run on
78cff43(there is no CI): gates 1 and 2 (cargo clippy --workspace --all-targets --locked -- -D warnings, without and with--all-features) passed. Gate 3: not the fullcargo test --workspace --locked(it ran over 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,989 passed, 5 failed, 82 ignored. The 5 are thread-timing tests outsidehwrt.rs(ingpu_owned,watch,host::watch_pipeandrangelock); each passed when rerun. The game was running on the same PC during part of these test runs. Such tests also fail now and then on main:gpu_owned::tests::concurrent_faults_on_same_block_serialize_single_readbackfailed 1 of 10 runs on47d21cd.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: likely general (an ordering question, not a card's); tested only on an RX 7900 XTX.
Coverage gaps: no frame-rate figure for this change alone; not run on NVIDIA or Intel cards.
Checklist
main.docs/asset-policy.md.Checked for overlap
HostAsreuse; it also holds back copies whose source is not built yet, which are copies, not refits), #318, #279 (also changehwrt.rs).🤖 Generated with Claude Code
I checked the tests at
78cff430. I see coverage for refit budgeting and masking unbuilt structures, but not for the refit planner’s decision before and after the source build is submitted. I’d like to add a game-free regression that checks for a full build before submission and a refit afterward, with a dropped list as a negative control. Is anyone already covering that, or would you like me to take it?Written by 🤖, results are mine.
NVIDIA data point, tested via my integration branch (theforgotten669/Darner
integration/rtx4090@eba6512): 9800X3D, RTX 4090, driver 621.47, Series X 4K, DLSS Quality, FG 2x, hardware RT, Reflex boost.The hole is hit far more here than the 64 in ~10 s on the 7900 XTX: the first "built anew instead" came ~21 s after hardware RT started, and the count passed 8,192 within 16 min (last logged
refits=8192, at the power-of-two step). 19-min city drive: 1.1 M refits, 122 k BLAS builds, 83 k TLAS builds, no ERROR lines, no device removal, closed normally.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), same save/area: main47d21cdvs this PR78cff43.The ordering hole is real on NVIDIA too, not only on the RX 7900 XTX: the log's counter (the first eight refits, then every power of two) reached
refits=128, so at least 128 refits named a source whose build had not been submitted (the true count is 128 to 255). The BLAS stats agree:blas_update_fbis 14 on main and 172 with this change.47d21cd78cff43blas_update_fb)The PR run was longer (5m52s against 5m11s), so the refit totals differ; per minute the refit rate is about the same (93k vs 95k), while
blas_update_fbgoes from 2.7 to 29 a minute. The 128 is a lower bound because only powers of two are logged.Not tested:
DARNER_HW_RT_REFIT_BUILT=0on this GPU, other GPUs, and whether an image ever showed the bad read (no visual check beyond playing; no device loss in either run).Drafted with AI assistance (OpenCode).
A case where this change stops a device loss: RTX 4080, a save that loses the device on main within a few loads.
A/B on this PR's commit
78cff43(release profile), same save, same settings, same PCDARNER_HW_RT_REFIT_BUILT0The log confirmed
on=true/on=falsein every session. With it on, the counter's last logged step was 512, 256 and 512 (blas_update_fb623 of 391,723 refits in the longest session). The first 16 came in the same millisecond the world first appeared.The three losses with it off (
0x887A0006): 10 s into the first world; 15 s into the third load; 11 s into the first world.Unpatched builds, for reference: main
d91d8e4lost the device 1 s into its second load. Releasef3840d7lost it in every session where the save was loaded a second time (three sessions), and in none where it was loaded once.Steps: hardware RT on,
DARNER_THIN=1. Load a save, wait until in the world, load the same save again; repeat.Two signatures, one build. Of the three switch-off losses on
78cff43, one was nvlddmkm event 13Graphics SM Warp Exception ... MMU Fault,ESR ...=0xf812b60 ...=0x1104(the signature #279 names, and the one main andf3840d7gave every time). The other two had no event 13: three event 153 over 5 s and 23 to 25 submissions on the card with none finishing for 3 to 4.5 s, which reads as a hang. Same exe, same switch, so the same hole seems to end either way. A local build carrying #279 and #268 lost the device with the MMU fault too, three times.Where the card stops. Light breadcrumbs on
f3840d7(DARNER_D3D12_DRED=light, diag):a list stopped at command 650 of 963 (op 31) of "darner host list 129", commands 649 to 657 all op 31 (BuildRaytracingAccelerationStructure); every other list finished or not begun. The last things recorded, on two threads within 80 ms: 88 structure copies (mode 1), about 100 BLAS builds and rehydrates, and 5 TLAS builds on each of two lists. With the debug layer or full breadcrumbs the game ran at half speed and did not lose the device, so those gave nothing.Two notes on the counter
source_builtis tested beforeallow_update,update_scratch, the flags andgeom_keys, so it also counts sources that would not have been refitted anyway. The logged figure is an upper bound on the refits this change turns into builds; tested last in that chain it would be exact.at_submitto tell the harmless cases from the others.Not tested: #445 (not applied in any run above); long play sessions.
RTX 4080 16 GB, driver 621.47, Ryzen 7 9850X3D, 32 GB, Windows 11. Series S profile, 2560x1440 output, DLSS Quality, frame generation off,
DARNER_HW_RT=1 DARNER_RELAY=2 DARNER_THIN=1 DARNER_CARD_STEPS=2.Drafted with AI assistance (Claude Code); the runs and results are mine.
Data point from an RTX 4070 Ti 12 GB on the release: the guard fires 64 to 255 times in every world entry here, and the one Aftermath dump I have of our world-entry loss on a build without it points at an AS build or refit.
PC: RTX 4070 Ti 12 GB, driver 621.24, Ryzen 7 7800X3D, Windows 11. Native 1440p, hardware RT, no frame generation, one save started from the command line.
With the guard (own release build of
9b288a70): 6 launches of 90 s, each 41 to 46 s in the world.refits=logged on "a refit's source not built yet ... built anew instead"The line prints at powers of two, so that is 64 to 127 or 128 to 255 refits a launch, all in the first seconds of the world.
Without it (
f3840d73, today, with the Aftermath Monitor running): one launch lost the device 11 s after the first world draws, still streaming in.nvlddmkm13 "MMU Fault" on one SM,0x887A0006. The dump says page fault, "Failed to translate the virtual address", and the faulting warp is in the driver'sray_tracing_01, type "AS Build or Refit". No title shader is named.I'll say so here if the loss shows up on the release.