Native ray tracing fixes ready to pull: size bound, early builder pipelines, fewer write-watch copies #385
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#385
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@notquiteog on GitHub · 2026-11-26 23:12 UTC · original
Four fixes for the native ray tracing (the structure builder,
VICTORY_BVH_BUILDER=1) are ready for you as a branch. A pull request isn't possible because this repo isn't in GitHub's fork network with ours.a-publier4eb6cfdf9).git fetch https://github.com/notquiteog/victory-nvidia pr/belobug-bvh-fixes, then merge or cherry-pickFETCH_HEAD.Not tested on an AMD card. The numbers below were measured on an RTX card, so the gains on an RDNA card may differ.
Each fix has its own switch. All of them are on whenever the builder is on, and none of them does anything while it is off. Your builder default does not change: it stays opt-in (
VICTORY_BVH_BUILDER=1).1. Compacted-size bound (
VICTORY_BVH_SIZES_BOUND,=0turns it off)The title reads a new structure's compacted size a frame or two after the builder's
GetBVHCompactedSizeprogram was recorded, and it does so without a fence. WithVICTORY_THINthe list is translated and sent by our own threads, so the slot still held another structure's size. The compacting copy then wrote over its neighbours.VICTORY_BVH_SIZES_WAITdid not help because it blocks our sending thread, not the title's.The fix:
GetRaytracingAccelerationStructurePrebuildInfoandBuildRaytracingAccelerationStructureBatched2Xgo through a newvictory-hlemodule,modules/bvh.rs.ResultDataMaxSizeInBytes, which is never smaller than the compacted size) is recorded for each build.Written::SizeLanded) puts the latest bound back if an earlier asking of the same slot lands after it.The new code is in
crates/victory-gpu/src/bvhsize.rs(it has unit tests).Measured on an RTX card with the builder on: card time per frame went from 19 ms to 9 ms.
2. Builder pipelines early (
VICTORY_BVH_BUILDER_EARLY,=0turns it off)The builder's first dispatch made its 53 pipelines one after another on its own thread. With a cold driver cache that took about a second each, so the title's main thread waited past its 30 s watchdog, and the title crashed with a store to address 0. Now each builder pipeline is queued for the pipeline workers when the title creates it, and all of them are promoted at the first dispatch, so they are made in parallel (
make::soon).3. The push (
VICTORY_BVH_PUSH,=0turns it off), inmemory.rsEvery list that read title memory by address used to refresh the whole directory (128 MB) and every arena (64 MB each) through
GetWriteWatch. Onlymemory.rswrites those, so it now puts the dwords that changed into the copies' CPU side as it writes them, and they go up with the next submission.Measured on an RTX card, this saves about 7 ms a frame on the submitting thread with rays on:
GetWriteWatchwent from 8.6 to 4.3 ms a frame.4. One reading of the builder switch, and the ambient stand-in
victory_shader::bvh_builder_on()is now the single place that readsVICTORY_BVH_BUILDER, so the builder rule and the size bounds cannot disagree. It still means=1.ambient::on()asks a newpipeline::builder_whole()instead ofbuilder_runs(). The new check makes nothing, so the probes' resolve on a recording thread never waits for the builder's pipelines, and the stand-in turns itself off once the builder has run whole.Offered separately, not in the branch
Our fork now turns ray tracing on by default: the builder runs unless
VICTORY_BVH_BUILDER=0. After these fixes it ran whole on an RTX card, with no black, NaN or pink pixels. That is our fork's policy, so the branch does not change your default. If you want it, it is a one-line change tobuilder_settingincrates/victory-shader/src/lib.rs.How it was tested
On the branch (off
a-publier4eb6cfdf9), on Windows:cargo build --locked: OK, no warnings.cargo test --locked -p victory-gpu --lib: 401 passed, 0 failed, 34 ignored.cargo test --locked -p victory-shader --lib: 304 passed, 0 failed, 4 ignored.The measurements above come from runs of the original commits on notquiteog/victory-nvidia (RTX card, Series S profile, render scale 0.5, walking). This port was not run in the title, and not on an AMD card.
-xfrom e8258c1bb, 3e423ed0a and df64c27d5. The script changes from df64c27d5 that turned rays on by default were left out.docs/fork-ray-tracing.mdlists the new switches.🤖 Generated with Claude Code
@gw1337x on GitHub · 2026-11-26 23:59 UTC · original · edited 2026-11-27 04:32 UTC
Tested the branch in the title on an AMD card: RX 7800 XT 16 GB (RDNA 3, driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, 48 GB page file, Windows 11 26200 (Memory Integrity off). Diagnostics builds (
--profile diag --features diagnostics) offf87d84and its base4eb6cfd, same boot.Settings:
scripts/play.ps1settings plusVICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, Series X profile,VICTORY_BVH_BUILDER=1, the branch's switches at their defaults. Method: 270 s hands-off from a Chapter I boat save; fps is the layer's 1 s figure from the window title, sampled every second, 45-265 s with 1000+ draws ("steady" from 205 s); per-frame figures fromVICTORY_TIMELINEwindows of 30 frames at 200 s and 240 s. Runs interleaved base, fix, fix, base.GetWriteWatch(all threads)4eb6cfdff87d84ff87d844eb6cfdWhat showed:
wrapped=2, the builder ran with all 53 pipelines, andstructure sizes (VICTORY_BVH_SIZES_BOUND)reports about 43-46 sizes asked with a bound per 10 s (5-19 without, 0-1 put back). I did not check a log line for the early pipeline queuing (fix 2).VICTORY_BVH_PUSHworks here:GetWriteWatchfalls from 5.8-8.8 to 1.6 ms a frame.VICTORY_BVH_BUILDERunset), the branch measured the same as its base: 28.4 vs 28.5 fps steady,GetWriteWatch1.7 vs 1.7-2.1 ms a frame.Caveats: two runs a side, one scene (a boat on open water), picture not compared; the card time drifted upward across the session, which the interleaving is meant to cancel.