Ray tracing: the ray test misses inverted boxes, as the console's does (+57 % fps with ray tracing) #3067
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA#3067
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?
@HQasper on GitHub · 2026-11-29 19:52 UTC · original
What it changes
The emulated box test is the same for a box and its mirror. So a child whose minimum is above its maximum on an axis is entered as the box between its corners. A child with inverted infinite bounds (+inf/-inf) is entered at minus infinity, first of the sorted children; only absent children were kept out (bc3cd4b0).
The title's BVH builder writes such boxes: its box-node programs start from +inf/-inf halves. The console's own software form of the test misses them, as the 2026.10 GDKX's software traversal does; it is the usual slab test, where an empty interval is a miss. Walking them costs about a quarter of the frame rate with ray tracing.
What is in it:
Shaders: VICTORY_BVH_INVERTED_MISS=1 …:victory-shader/src/bvh.rs(the reference test and its unit tests),emit/intersect.rs(the emitted code follows the same switch), and the shader cache key.Launcher: …: on by default inapps/victory/src/play.rsandscripts/play-foxhound.ps1.How it was tested
GPU and profile: RTX 5090 (driver 621.24), Ryzen 9 9950X3D, Series X, 1440p (
VICTORY_NATIVE_SIZE=2560x1440because of #2141), DLSS Quality, ray tracing on with the launcher's other ray-tracing defaults (the rehydration limits and the builder's coherence, walk loops at 512), frame generation off.In game, on
829188e(the same code as55d06914): eight runs of 6 minutes from the same save, in the order b r i t t i r b (b: the launcher's ray-tracing defaults all on; r, i, t: PR 1, 2 or 3 off), with shaders and pipelines made beforehand for each variant. The world is reached about 45 s after the first frame. "Way in" is its first 60 s, "play" the next 180 s. Each cell is the mean of two runs, with the two runs' values in brackets. 0 GPU removals and 0 crashes in all eight runs.The card is busy 96-97 % of the time without the switch and 88 % with it. On the first base this was measured on (
8fc2254, ABBA, 180 s settled) it was 26.2 / 22.4 → 31.3 / 30.6 fps.Not measured: without the launcher's other ray-tracing defaults.
Pictures (base
8fc2254): four captures of the opening at the same moments (two each way, in both orders) show no difference that follows the switch.Wave sizes: 32-lane host.
cargo test(cargo test --workspace --locked --no-fail-fast -- --test-threads=4, 2026-11-29): 2,166 passed, 4 failed, 78 ignored. The 4 failures are upstream's (below). Upstream main55d06914itself gives 2,165 passed, 4 failed, 78 ignored. Its 4 failures are threebcpack::tests::oracle_parity_*tests andxtask'srepository_passes_policy, which flags upstream's ownvictory-loader/src/heap_sites/frame_users.rs.Checked for overlap
Written with Claude Code (Claude Opus 5.5); measured on my PC; reviewed by me.
🤖 Generated with Claude Code
Pull request details or commits were not available from GitHub; kept as an issue.
[pr-fix] Ray tracing: the ray test misses inverted boxes, as the console's does (+57 % fps with ray tracing)to Ray tracing: the ray test misses inverted boxes, as the console's does (+57 % fps with ray tracing)github-bot referenced this issue2026-11-30 00:28:41 +00:00
@DoubleD17 on GitHub · 2026-11-30 09:58 UTC · original
We ran a test of this PR with ray tracing on (
VICTORY_BVH_BUILDER=1), on a 12 GB card, on current main (41adb551with this PR merged, head 5b3815e9). The log confirmed the switch: "VICTORY_BVH_INVERTED_MISS: ray tests miss boxes whose minimum is above their maximum".No difference we can measure on this card. With ray tracing on, the card is the limit here: about 4 to 6 fps, the GPU busy 98 to 100 % of the time, and the host's "on the GPU" time is 75 to 185 ms a frame, against 4 to 8 ms with ray tracing off. Main's own three runs spread that widely, so two PR runs cannot show a change of the size you measured (20.0 → 31.4 fps on an RTX 5090).
Light-view seconds only (the idle camera's lighter views, about 7,500 draws a frame):
Main's three runs: 75.5, 184.3 and 125.9 ms on the GPU; 5.8, 3.6 and 4.1 fps.
Memory: ray tracing on fills this card. In the last 100 s of each run, shared memory was 10.3 and 11.0 GB with this PR and 10.6 to 10.8 GB on main, with dedicated memory at 10.5 to 10.7 GB in all of them. With ray tracing off, main's shared memory was 8.5 to 9.0 GB. So on a 12 GB card part of the ray-tracing data probably lives in system memory, which may be why the GPU time moves so much from run to run and why we do not see the gain.
Picture: 0 defects in this PR's three runs (a burst of 80 frames at the end of each, plus a capture at 120 s). The boxes it now misses did not leave holes or missing shadows that we could see.
Setup:
41adb551, against41adb551itself, each with a preload made with these settings;AI Assisted
@HQasper on GitHub · 2026-11-30 15:50 UTC · original
Thanks for testing, and for the picture check: 0 defects is the main thing we wanted to know. The gain we measured (20.0 → 31.4 fps) was on a 32 GB RTX 5090 where ray tracing stays in video memory, so on a 12 GB card that spills into shared memory the run-to-run spread can hide it; we're not changing the PR because of this.
@KruIN689 on GitHub · 2026-11-30 20:37 UTC · original
Tested together with #3063 on an RTX 5080 16 GB: numbers and setup in #3063 (latest comment). In the last comparable pair: +39 % fps, 13x fewer frames over 50 ms, no picture defects seen. (Claude Code, for KruIN689.)
@upipibi on GitHub · 2026-12-01 04:47 UTC · original
Review of #3067 (head ad12947b): AMD's public reference agrees that inverted boxes are misses, and the emitted code matches the PR's reference on the card. Synthetic tests only: no game files. The fps gain is the in-game reports above, not mine.
AMD's form of the test. AMD's ray-tracing library GPURT (MIT) has a software form of the hardware box test, used where the intrinsic isn't. It is
fast_intersect_bboxinsrc/shaders/IntersectCommon.hlsl#L393-L441, with the traverse rule at #L515-L518.min_t <= max_t * (1 + grow * 2^-24), withgrowdefaulting to 6 ulps (RayTracingBoxGrowthNumUlpsDefault,gpurt.h:115).Differential test. I ported that function and its traverse rule to Rust next to
boxes_as. Then I compared, for one present child, whether it's entered: 1,000,000 random rays and boxes per row (origin and box corners in ±10, extent 30, seeded xorshift).boxes_aswithout the switch vs GPURTINVERTED_MISSvs GPURTSo on the cases this PR is about, it brings the test to exactly what AMD's does. Two smaller differences:
min > maxcompare misses it. A sign-selected slab like GPURT's would match it as well. The title's +inf/-inf halves and properly ordered boxes aren't affected, so this is minor.min3/max3treat NaN, which I assumed to be "the other value".The emitted code on the card.
intersect_tests' scene has only one inverted box, on a child that isn't there, so the new compare inemit/intersect.rsnever decides a hit there. I added a node whose present children have a box inverted on x ([31, -1, -1, 29, 1, 1]) and a +inf/-inf box, in both widths:RTX 3070, driver 621.40,
cargo test -p victory-shader --lib -- emit::intersect_tests --test-threads=1:VICTORY_BVH_INVERTED_MISS=1: 12 passed, 0 failed.=0: 12 passed, 0 failed.=1): 8 passed, 4 failed, the four node tests atintersect_tests.rs:591.So those lines make the card tests cover this PR's change, and they might be worth adding. The
bvhtests pass, 19 of 19.Tested with the help of Claude Code (Claude Opus 5.5).