Hardware ray tracing: top levels name only bottom structures already submitted (device lost with VICTORY_HW_RT=1) #4338

Closed
github-bot wants to merge 14 commits from github-bot/gh-4337 into main AGit
Owner

@⁠harrisotiropoulos-jpg on GitHub · 2026-11-30 19:02 UTC · original
harrisotiropoulos-jpg:fix/hwrt-tables-name-submitted → main · +1065 −852 · 33 files · 14 commits · closed without merging

What it changes

With VICTORY_HW_RT=1 (#3706, off by default).

as_map is written as lists are recorded, up to a frame ahead of the submitting thread. A top level's remap table (fill_blas_table) is filled as its list is submitted, from the newest entries of as_map. So a top level could name a bottom structure whose build was recorded but not yet submitted, and rays walked memory that held no structure yet.

  • HwRtManager::shown holds, per console address, the bottom structure whose build or copy lies in lists submitted so far. The remap table is filled from it. Entries are published by a submission-time step of the list that builds or copies them (HostList::at_submit), so they follow submission order. Evicted and freed structures are taken out of it, and those replaced go through retire.
  • A top level has 4 MB at least. One that grew took a new buffer, and lists in flight that read the slot naming it then read the new one, not built yet.

How it was tested

  • GPU and profile: RTX 4080 16 GB, Ryzen 7 9800X3D, 32 GB, Windows 11; Series X, 1440p, DLSS performance, frame generation 2x, hardware ray tracing on.
  • Before: the device was lost in four of four runs on 30 Nov, after 8 to 77 s of play (0x887A0005, no list of ours stopped), also with every shader write copied back.
  • After: no loss in the seven ray tracing runs that followed (39 to 179 s of play each).
  • Not an isolated A/B: those runs were of v2026.11.30.01/.02 with other changes of ours, some made in the same hours, and VICTORY_HW_RT_REFIT=0. This branch, the same code on main, was built and unit tested but not played by itself. No unit test covers the ordering.
  • Wave sizes: no shader change.
  • cargo test --release -p victory-gpu --lib: no. 1,131 passed and 2 failed: list::thin::tests::bindings_record_no_work and shader_cache::tests::every_switch_of_the_translator_is_in_the_key. Both fail on main (e1251c319) too. cargo check passes; clippy with -D warnings reports only lines already on main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3706 (what this fixes), #4144 (same file, BLAS/TLAS cost; it does not change which structures a top level may name, and is likely to conflict in hwrt.rs)

🤖 Generated with Claude Code

**@⁠harrisotiropoulos-jpg** on GitHub · 2026-11-30 19:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337) `harrisotiropoulos-jpg:fix/hwrt-tables-name-submitted` → `main` · +1065 −852 · 33 files · 14 commits · closed without merging ## What it changes With `VICTORY_HW_RT=1` (#3706, off by default). `as_map` is written as lists are **recorded**, up to a frame ahead of the submitting thread. A top level's remap table (`fill_blas_table`) is filled as its list is **submitted**, from the newest entries of `as_map`. So a top level could name a bottom structure whose build was recorded but not yet submitted, and rays walked memory that held no structure yet. - `HwRtManager::shown` holds, per console address, the bottom structure whose build or copy lies in lists submitted so far. The remap table is filled from it. Entries are published by a submission-time step of the list that builds or copies them (`HostList::at_submit`), so they follow submission order. Evicted and freed structures are taken out of it, and those replaced go through `retire`. - A top level has 4 MB at least. One that grew took a new buffer, and lists in flight that read the slot naming it then read the new one, not built yet. ## How it was tested - GPU and profile: RTX 4080 16 GB, Ryzen 7 9800X3D, 32 GB, Windows 11; Series X, 1440p, DLSS performance, frame generation 2x, hardware ray tracing on. - Before: the device was lost in four of four runs on 30 Nov, after 8 to 77 s of play (0x887A0005, no list of ours stopped), also with every shader write copied back. - After: no loss in the seven ray tracing runs that followed (39 to 179 s of play each). - Not an isolated A/B: those runs were of v2026.11.30.01/.02 with other changes of ours, some made in the same hours, and `VICTORY_HW_RT_REFIT=0`. This branch, the same code on main, was built and unit tested but not played by itself. No unit test covers the ordering. - Wave sizes: no shader change. - `cargo test --release -p victory-gpu --lib`: no. 1,131 passed and 2 failed: `list::thin::tests::bindings_record_no_work` and `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`. Both fail on main (e1251c319) too. `cargo check` passes; clippy with `-D warnings` reports only lines already on main. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3706 (what this fixes), #4144 (same file, BLAS/TLAS cost; it does not change which structures a top level may name, and is likely to conflict in `hwrt.rs`) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
as_map is written as lists are recorded, up to a frame ahead of the
submitting thread; a top level's remap table is filled as its list is
submitted, from the newest entries: it could name a structure whose build
the card had not run yet. Structures are now shown to top levels in the
order of submission. A top level has 4 MB at least, so that it does not
move under lists in flight that read the slot naming it.

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

@⁠KruIN689 on GitHub · 2026-12-01 00:26 UTC · original

Independent test of #4338 together with #4339 (VICTORY_RT_BIG_ASIDE=40000). RTX 5080 16 GB (driver 621.40), Ryzen 9 9950X3D, 47 GB, Windows 11. Series X, native 1440p, DLSS and FG off, VICTORY_HW_RT=1.

Method: both PRs merged onto our fork's main, which is upstream 84bd61e2 plus a spread sweep, #3272, #3063/#3067 and #4234. Auto-driven roaming (walk and drive), 2+2 alternating runs of 6 min, stats over the last 4 min. Warm shader cache.

run fps frames over 50 ms per 1,000 mean p99 longest device lost / errors
with both 24.7 76 56.3 ms 142 ms 0
without 28.2 80 61.4 ms 132 ms 0
with both 25.8 73 56.8 ms 136 ms 0
without 25.2 80 57.1 ms 160 ms 0
  • #4337: no device loss in any run, with or without it, so these runs can't show the fix, but nothing regressed: no errors, and p99 slightly lower. It matches what we saw earlier with pooled AS memory: placed BLAS buffers reused 2 s after a BLAS went removed the device twice, consistent with a TLAS table naming a BLAS whose build was not submitted yet. That makes this fix's reasoning look right to us.
  • #4338: with a warm cache no frame waited over 1 s for a pipeline in either build, so the aside path had nothing to do. A cold-cache first start would be the case to measure.
  • fps: the mean difference is within roaming noise (±2 fps run to run on this route).

(Measured and written with Claude Code, for KruIN689.)

**@⁠KruIN689** on GitHub · 2026-12-01 00:26 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337#issuecomment-7296341346) Independent test of #4338 together with #4339 (`VICTORY_RT_BIG_ASIDE=40000`). RTX 5080 16 GB (driver 621.40), Ryzen 9 9950X3D, 47 GB, Windows 11. Series X, native 1440p, DLSS and FG off, `VICTORY_HW_RT=1`. Method: both PRs merged onto our fork's main, which is upstream 84bd61e2 plus a spread sweep, #3272, #3063/#3067 and #4234. Auto-driven roaming (walk and drive), 2+2 alternating runs of 6 min, stats over the last 4 min. Warm shader cache. | run | fps | frames over 50 ms per 1,000 | mean p99 | longest | device lost / errors | |---|---:|---:|---:|---:|---:| | with both | 24.7 | 76 | 56.3 ms | 142 ms | 0 | | without | 28.2 | 80 | 61.4 ms | 132 ms | 0 | | with both | 25.8 | 73 | 56.8 ms | 136 ms | 0 | | without | 25.2 | 80 | 57.1 ms | 160 ms | 0 | - **#4337:** no device loss in any run, with or without it, so these runs can't show the fix, but nothing regressed: no errors, and p99 slightly lower. It matches what we saw earlier with pooled AS memory: placed BLAS buffers reused 2 s after a BLAS went removed the device twice, consistent with a TLAS table naming a BLAS whose build was not submitted yet. That makes this fix's reasoning look right to us. - **#4338:** with a warm cache no frame waited over 1 s for a pipeline in either build, so the aside path had nothing to do. A cold-cache first start would be the case to measure. - **fps:** the mean difference is within roaming noise (±2 fps run to run on this route). (Measured and written with Claude Code, for KruIN689.)
Author
Owner

@⁠paales on GitHub · 2026-12-01 01:40 UTC · original

Written by 🤖:

Test of this PR together with #4579, #4171 and #4144, cherry-picked onto a build of main from 30 Nov with texture PRs (#720, #4207, #4138, #4494, #4510). RTX 5070 Ti 16 GB, 12 cores, Windows 11. HDR full screen, 1440p, DLSS Performance, 30 fps cap, all pipelines preloaded.

The first cutscene of a new game, 5 to 60 s after its first scene frame:

no ray tracing VICTORY_BVH_BUILDER=1 VICTORY_HW_RT=1
median frame 33.3 ms 52.7 ms 47.9 ms
seconds with a frame over 100 ms 3 40 22
card time a frame (busy) 19.2 ms (66 %) 99.4 ms (91 %) 24.5 ms (62 %)
submitting thread a frame 23.9 ms 67.9 ms 39.7 ms
  • No lost card and no crash in 6 runs with VICTORY_HW_RT=1: 4 of the cutscene and 2 of a save that ends on the boat (82 s each).
  • Every ray query lifted: 13 programs, no software fallback.
  • With the RT cores the CPU is the limit. The submitting thread waits for its helpers in the buffer and texture refreshes 28 % of its time (8 % without ray tracing). The structure builds take about 75 ms of CPU a second (BLAS prep).
  • The cherry-pick of #4579 on top of this PR conflicts in the HwRtManager fields and in title_memory_freed. Both sides stay: shown beside MeshletCache, mgr.hide beside drop(removed_as), and ibs.forget(lo, hi) beside the clamped_ibs range invalidation of #4144.
**@⁠paales** on GitHub · 2026-12-01 01:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337#issuecomment-7297773692) _Written by 🤖:_ Test of this PR together with #4579, #4171 and #4144, cherry-picked onto a build of `main` from 30 Nov with texture PRs (#720, #4207, #4138, #4494, #4510). RTX 5070 Ti 16 GB, 12 cores, Windows 11. HDR full screen, 1440p, DLSS Performance, 30 fps cap, all pipelines preloaded. The first cutscene of a new game, 5 to 60 s after its first scene frame: | | no ray tracing | `VICTORY_BVH_BUILDER=1` | `VICTORY_HW_RT=1` | |---|---|---|---| | median frame | 33.3 ms | 52.7 ms | 47.9 ms | | seconds with a frame over 100 ms | 3 | 40 | 22 | | card time a frame (busy) | 19.2 ms (66 %) | 99.4 ms (91 %) | 24.5 ms (62 %) | | submitting thread a frame | 23.9 ms | 67.9 ms | 39.7 ms | - No lost card and no crash in 6 runs with `VICTORY_HW_RT=1`: 4 of the cutscene and 2 of a save that ends on the boat (82 s each). - Every ray query lifted: 13 programs, no software fallback. - With the RT cores the CPU is the limit. The submitting thread waits for its helpers in the buffer and texture refreshes 28 % of its time (8 % without ray tracing). The structure builds take about 75 ms of CPU a second (`BLAS prep`). - The cherry-pick of #4579 on top of this PR conflicts in the `HwRtManager` fields and in `title_memory_freed`. Both sides stay: `shown` beside `MeshletCache`, `mgr.hide` beside `drop(removed_as)`, and `ibs.forget(lo, hi)` beside the `clamped_ibs` range invalidation of #4144.
Author
Owner

@⁠rvrvrvr221 on GitHub · 2026-12-01 12:31 UTC · original

Isolated A/B on an RTX 4090: this PR alone (8717169a) against its parent, the v2026.11.30.03 release (e1251c31). The device is still lost with it.

PC: Core i9-13900K, RTX 4090 24 GB (driver 621.40), 32 GB DDR5-6400, Windows 11 Pro (build 26300). Both built release from source, nothing else on top. Same settings for every run: Series X, native 2560x1440, DLSS Balanced (preset M), -Fps 30 -FixedStep, frame generation off, VICTORY_HW_RT=1 and VICTORY_BVH_BUILDER=1, -NoMenu. Runs alternated, same save, played until the device was lost or about 10 minutes of play.

Run Build Ended After launch fps, median of the log's 5 s lines in play
1 v2026.11.30.03 stopped by hand, no loss 13:29 22.2
2 this PR device lost 10:36 24.0
3 v2026.11.30.03 device lost 3:19 21.8
4 this PR device lost 3:22 20.4
5 v2026.11.30.03 device lost 2:34 23.4
6 this PR device lost 2:51 25.6

Every loss is 0x887A0005 ("The GPU device instance has been suspended"), as relay: device lost before publishing queued GPU work (4 runs) or the device was lost before fence value N was reached (run 5), with when the host device went: the submitting thread was preparing a submission (nothing of ours was running on the card). The card had 13.1 to 13.9 GB in use of a 23.4 GB budget at the last report before each loss.

So on this card the PR does not prevent the loss: 3 of 3 runs with it, 2 of 3 without, at about the same times, with no frame rate difference. Six runs can't rule out a smaller effect, but the ordering this PR fixes doesn't look like the cause of the device loss here. This matches the comments in #4324 that VICTORY_BVH_BUILDER=1 alone also loses the device, which this ordering wouldn't touch.

Water was black in every run of both builds, as reported in #4324.

**@⁠rvrvrvr221** on GitHub · 2026-12-01 12:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337#issuecomment-7311258139) **Isolated A/B on an RTX 4090: this PR alone (8717169a) against its parent, the v2026.11.30.03 release (e1251c31).** The device is still lost with it. PC: Core i9-13900K, RTX 4090 24 GB (driver 621.40), 32 GB DDR5-6400, Windows 11 Pro (build 26300). Both built release from source, nothing else on top. Same settings for every run: Series X, native 2560x1440, DLSS Balanced (preset M), `-Fps 30 -FixedStep`, frame generation off, `VICTORY_HW_RT=1` and `VICTORY_BVH_BUILDER=1`, `-NoMenu`. Runs alternated, same save, played until the device was lost or about 10 minutes of play. | Run | Build | Ended | After launch | fps, median of the log's 5 s lines in play | |---|---|---|---|---| | 1 | v2026.11.30.03 | stopped by hand, no loss | 13:29 | 22.2 | | 2 | this PR | device lost | 10:36 | 24.0 | | 3 | v2026.11.30.03 | device lost | 3:19 | 21.8 | | 4 | this PR | device lost | 3:22 | 20.4 | | 5 | v2026.11.30.03 | device lost | 2:34 | 23.4 | | 6 | this PR | device lost | 2:51 | 25.6 | Every loss is `0x887A0005` ("The GPU device instance has been suspended"), as `relay: device lost before publishing queued GPU work` (4 runs) or `the device was lost before fence value N was reached` (run 5), with `when the host device went: the submitting thread was preparing a submission (nothing of ours was running on the card)`. The card had 13.1 to 13.9 GB in use of a 23.4 GB budget at the last report before each loss. So on this card the PR does not prevent the loss: 3 of 3 runs with it, 2 of 3 without, at about the same times, with no frame rate difference. Six runs can't rule out a smaller effect, but the ordering this PR fixes doesn't look like the cause of the device loss here. This matches the comments in #4324 that `VICTORY_BVH_BUILDER=1` alone also loses the device, which this ordering wouldn't touch. Water was black in every run of both builds, as reported in #4324.
github-bot closed this pull request 2026-12-01 18:43:51 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:42 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4337#issuecomment-7321386886) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4338
No description provided.