Repository navigation
GPU: the BVH builder runs whole or not at all - #2118
0xkn0wh3r3 wants to merge 1 commit into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):
cargo test -p victory-gpu --lib pipeline::— 18 passed, 0 failed (includingbuilder_dispatches_wait_for_every_builder_pipeline)cargo clippy -p victory-gpu -p victory --all-targets— 0 warningscargo xtask policy— ok (184 files ok)
Clean gating ensuring BVH builder dispatches wait for all builder pipelines before running. Looks good.
AI-assisted (Gemini 4 Neon).
Ported from Marvisak/VIctory#2118 (GPL-3.0-or-later), fixes fxceless#880's crash path: a builder dispatch whose host pipeline is missing was dropped on its own, so the rest of the builder ran on data the missing stages never wrote and put garbage bounds into title memory. - Builder pipelines are known by origin: bytecode in XboxBvhBuilder.dll's image, or its code among the callers. `run` notes the DLL's range when it maps it (start and late loads). - They start compiling when created (no frame wait budget), and a frame holds all builder dispatches back unless every builder pipeline is made; the decision is taken once per frame. - Three tests, including one through create_compute with a refused pipeline.
|
In-game run of this PR (head Build: What this PR did:
Against the same tree without it: without this PR, For comparison: a cruder gate. The fxceless fork / ztrx recognise builder programs by their root signature not fitting the user SGPRs (parameters read from a table at user data 16). I tried a gate built on that rule on the same tree. It also kept the hang away, but it dropped a mean of 518 dispatches a frame (up to 950), against this PR's 53 builder pipelines. So that rule takes more than the builder. Recognising the builder by where its code lies, as here, is the sharper rule. I am not opening that gate as a PR. Not this PR's doing: the GPU time fell from 4.4-6.2 s a frame to 320-410 ms (frames 0.85-1.07 s, 2,200-4,300 draws a frame). But #1819 is in the same build, and the 4.1 s submissions that made most of the old frame time are gone with it. The scenes also differ. I am not claiming that drop for #2118. Not checked: an AMD host, where the builder's 64-lane programs are not refused, so the builder could run whole. In this run sky, fog and atmosphere are lit, but surfaces stay dark. I have not looked at whether this PR plays any part in that. AI-assisted |
|
Automated triage for the maintainers. Verdict: merge candidate (kept). Head On the latest reply: noted. The Windows Ampere run with #2703 is a new data point. Without this PR the device was removed at 133 s and 81 s. With it, both runs lasted 10 minutes with the builder held back. If #2703 lands, this PR should land with it or before it. The CI: passing ( Generated by Claude Code |
The world's ray-traced pass (f607780aa8e502d0) walks the acceleration structures with image_bvh64_intersect_ray, in a loop the title bounds at 65,535 steps per wave. When the builder has not built them, it walks whatever lies in that memory and outlasts the host's GPU timeout: the device is lost (DXGI_ERROR_DEVICE_HUNG). On a host of 32-lane waves some builder programs are refused, the builder is held back for good (Marvisak#2118), and every run ended that way at world entry (RTX 5090). A pipeline with an image_bvh*_intersect_ray program now waits, like the builder's own dispatches, until the builder has run whole once. Titles without XboxBvhBuilder.dll are not held. held_back says why, and the dispatch and indirect paths log it once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A data point from the title on NVIDIA under Linux, where this fixed real corruption for us. RTX 5080, Proton with vkd3d-proton 3.2.0, our stack with #439, #2167 and #2311. Without this PR: #2167 makes the rehydration passes (
That pointer is the fp16 −∞/+∞ empty-child constant With this PR: How it was found: the title's crash log gave the faulting read. Disassembling the title at that address showed the load, and the loaded value matched the constant in |
|
Data point from an RTX 4070 SUPER: with #2176 (wave64 programs as two 32-lane halves), once its cross-half refusals are lifted, all 53 builder pipelines get made, and the builder then hangs the GPU within 2 minutes ( |
|
Thanks for the runs. @r4tedx, the comparison with the root-signature rule (53 pipelines against about 518 dispatches a frame) is the argument for recognising the builder by where its code lies. @desplmfao, the fp16 ±∞ pointer tracing back to @moe-miau, |
The title's acceleration-structure builder (`XboxBvhBuilder.dll`) builds and refits the ray-tracing structures in title memory every frame through some fifty compute dispatches. A dispatch without a host pipeline is dropped on its own (`State::dispatch`, `execute_indirect`), and some of the builder's lack one for a long time or for good: refused on hosts of 32-lane waves (they ask for 64-lane waves), not translated, or still being made. The stages that do run then work on data the missing ones never wrote, and write the result into title memory. On fxceless/victory-fork, where this happened, the builder wrote garbage bounds that crashed the title; that fork's rule is the one taken here. Its dispatches now run only in frames where every pipeline the builder has created has its host pipeline; otherwise none run, and the structures keep what they held. The decision is made once per frame, so a frame never runs part of the builder. Its pipelines are known by origin: bytecode in the builder's image, or a return address in it on the stack when the pipeline is created (`run` passes the DLL's range as it maps it, at start and when the title loads it). They are started at once, so no frame's wait budget holds the builder back. New tests (no game data): - `pipeline::builder::tests::the_builder_runs_only_with_every_pipeline_made` - `pipeline::builder::tests::builder_pipelines_are_known_by_their_origin` - `pipeline::tests::builder_dispatches_wait_for_every_builder_pipeline`: a compute pipeline created from bytecode in the registered image is the builder's, is started at once, is refused (no shader container), and holds back builder dispatches; another pipeline is not held back.
60632d3 to
af8b9ad
Compare
…uilder waits With wave64 programs run as two 32-lane host waves (Marvisak#2176), 118 of the title's programs were still refused here: 80 read a wave mask as data, 32 exchange lanes, a few scan across the wave. Each host wave already stands for one half (its ballot's high dword is 0, `host_lane` keeps lanes in the half), so those now translate with that meaning: exact for programs whose waves work within themselves (compaction, reductions, one atomic per wave), approximate where the console exchanged across the halves. The BVH builder's programs do exchange across them, and run that way they hung the GPU within two minutes on an RTX 4070 SUPER. So on such hosts the builder stays held back (Marvisak#2118), as it is today where its programs are refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Code review and RTX 5090 + WARP verification at head
Clean and well-scoped; LGTM. |
|
@fuzeofficlal thanks for the review and the 5090 + WARP runs. On the |
|
Tested On that base, #439 makes
A bisect over the 72 shaders #439 newly translates narrowed the crash to that one program. With #2118, the refused sibling holds the set as intended, and nothing in the log points at the builder afterwards. AI-assisted (Claude); measured on my machine, no game data shared. |
|
@neonbyte1 thanks, that's a clean demonstration. Bisecting #439's 72 newly translated programs down to |
GPU: the BVH builder runs whole or not at all Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream main merged Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906 and Marvisak#1152 and took up what Marvisak#1769 (LDS bounds, Marvisak#1949) and Marvisak#1763 (typed UAV formats, Marvisak#2462) did; main's code is kept for those. - emit/lower.rs: ds_bpermute within each half (main's Marvisak#573, same as Marvisak#439's); LDS bounds as main's Marvisak#1949 (Marvisak#1769's test-only counter kept, its and_guard dropped); title-memory marks: main's straddling-write lookup (Marvisak#2484) with Marvisak#2167's current head (3cb308d, rebased on 63bcca4): guarded dirty atomics, raw_dword2, memory_null, synthetic_mark_dxil in lower/mark_tests.rs; the old Marvisak#2167 head taken out first. - emit/host.rs: main's shared WARP device and lock (Marvisak#244) with Marvisak#439's adapter list and Host::on (create_device takes an optional adapter). - descriptor/host.rs: main's Marvisak#2462 format checks; Marvisak#1763's tests kept. - gpu host.rs: main's multi-plane present with Marvisak#2310's crumbed copy. - pipeline.rs: Marvisak#2118/Marvisak#2311's builder and BVH checks with main's skip hashes (Marvisak#1320); draw.rs, shadow.rs, main.rs: both sides. - Tests main added since get Marvisak#439's Parts fields and emit's Target. - README: base 63bcca4; rows of PRs merged upstream, superseded or closed taken out, with a note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous renderer (old upstream base 940d32f) is the first parent and is also kept as the branch renderer-2026-11-25-oldbase; the second parent is the rebuild: fork main (upstream main 63bcca4 + our pull requests) with the renderer stack merged on it: Marvisak#439 (on main: update/439-main's resolution), Marvisak#2309, Marvisak#2167, Marvisak#2118, Marvisak#2311, Marvisak#1722, Marvisak#1751, Marvisak#688, Marvisak#1872, Marvisak#2292, Marvisak#2310, Marvisak#2112 (opt-in), Marvisak#2230 (latch on by default), Marvisak#2389, Marvisak#2088 (small windows opt-in), Marvisak#2099's new head, and tonight's Marvisak#491 journal fixes. Merged upstream since: Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906, Marvisak#1152; superseded by main: Marvisak#1769, Marvisak#1763, Marvisak#2366. The picture on this base still shows the overlay that plain upstream main shows too; that is being looked into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows NVIDIA in-game result for this PR together with #2703, which lets most of the builder's dispatches through: RTX 3070 Ti 8 GB (Ampere, 32-lane waves), driver 621.40, Windows 11 26200, TDR delay 8 s.
At the first world frame: AI-assisted (Claude Code); the runs are on my machine. |
|
@davesousa thanks, that's the Windows confirmation. With #2703 letting most of the builder through, the device reset at 133 s and 81 s, with 15 s submissions, without this PR. With it, both runs went 10 minutes with the longest submission at 1.3 s, because the builder was held back with 9 of its 53 pipelines refused. So whichever of #2703 and this PR lands, the other should go with it. |
…hing Run C1 (cool/play-1 6201516, RTX 5070, VICTORY_BVH_BUILDER=1): the 32-lane guard held the builder back (one "held back: the host has no 64-lane waves pipelines=53", no device removal), but the title crashed in loading, writing through a null pointer at the address the Marvisak#2118 thread reported for a half-run builder; without the switch it runs on. Held back is not off: the switch also stopped make::left_out from leaving out the programs that walk the builder's structures (CS_RaytracingResolve, CS_ScreenProbes_ActivateRays), which then ran over structures the held-back builder never built. That this caused the crash is a reading of the code, not reproduced; this change makes the narrow host's run the same as one without the switch, whichever difference it was. builder_allowed(): the switch on a host with 64-lane waves. builder_runs() and both of make::left_out's rules ask it, so on a host without them everything is as without the switch. It warns once, when the switch is set: "the ray-tracing structure builder held back: the host has no 64-lane waves; VICTORY_BVH_BUILDER=1 is ignored, and the builder and the programs that walk its structures stay off as without it". The host is asked only with the switch on. Test: the_switch_is_ignored_on_hosts_without_64_lane_waves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…IDIA device removals The table row for upstream Marvisak#2999 (lane quads and the f16 bias of compute samples); the NVIDIA note names Marvisak#2118, with which lhnizdo saw no reset on an RTX 2080.
The problem
A frame can run only part of the title's ray-tracing structure builder. The stages that run then write wrong results into title memory. In fxceless/victory-fork this wrote garbage bounds and crashed the title.
The title's BVH builder (
XboxBvhBuilder.dll) builds and refits its ray-tracing structures in title memory through about fifty compute dispatches a frame. A dispatch without a host pipeline is dropped on its own while the rest of the list runs (State::dispatch). Some builder pipelines lack one:So the stages that do run work on data the missing stages never produced.
The fix
Builder dispatches run only in frames where every builder pipeline has its host pipeline. Otherwise none run, and the structures keep what they held. The decision is made once per frame (
pipeline::builder::runs), so no frame runs part of the builder.runregisters the DLL's range when it maps it (note_title_dll, at start and when the title loads it later).execute_indirect) of a held-back builder pipeline are dropped.On NVIDIA this keeps the builder off until 64-lane programs run there, instead of running it partly. Pipelines from other code are not affected. The rule comes from fxceless/victory-fork's notes; the code is new.
Testing
Three new tests (no game data):
pipeline::builder::tests::the_builder_runs_only_with_every_pipeline_made: the all-or-none decision. One pipeline refused or still being made holds all back.pipeline::builder::tests::builder_pipelines_are_known_by_their_origin: recognising builder pipelines by bytecode and by caller.pipeline::tests::builder_dispatches_wait_for_every_builder_pipeline: end to end throughcreate_compute, a refused builder pipeline holds back builder dispatches, while other pipelines are unaffected.Runs:
cargo test -p victory-gpu --libon an RTX 5070 Ti: all pass except the two tests that already fail onmainfrom the NVIDIA heap cap (NVIDIA D3D12 (70564ae): stride_tests & synthetic_tests fail due to HEAP_VIEWS (2M > 1M NVIDIA limit) and Stride::Structured with rawBufferLoad #1835).cargo test -p victory: pass.cargo clippyforvictory-gpu(with and without--features diagnostics) andvictory: clean.Not covered
Not run with a game (no game data here).