Ray tracing: shadow-ray traces and the full structure builder translate on 32-lane GPUs #156
No reviewers
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/fxceless--victory-fork!156
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-156"
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?
@sedzz on GitHub · 2026-11-24 21:56 UTC · original
sedzz:rt/shadow-traces-and-builder-32-lane→main· +285 −44 · 4 files · 4 commits · openWhat
Two translator/host gaps kept the title's ray-tracing programs from running on a host whose waves are 32 lanes (the console's are 64). This PR closes both.
With
VICTORY_HOST_WAVE=32on a 32-lane card:the ray-tracing structure builder stays off ... missing=3.Changes
1. Buffer views picked from the view heap at a computed index (
shader.rs,mod.rs,descriptor/host.rs,lower.rs)The shadow-ray trace programs read the address of their structure out of a heap descriptor they choose with a per-wave index, then walk the memory behind it. The translator could only take such an address from a fixed table position (
view_addressrefusesa.dynamic).The host now keeps, after the strides of
SLOT_STRIDES, two more dwords per heap slot: the low and high dword of the title address of the buffer view there. They are written where the strides are written. The shader reads them by heap slot (SLOT_ADDRESSES,Lower::slot_address). No new root parameter and no change todraw.rsor the pipeline code.Cost: the table grows from 8 MB to 24 MB per view heap.
2.
lane_uniformproves three more things (lower.rs)Each only where no lane of a wave can part from the others:
tid >> 6of the entry thread number, in a group whose x size is a multiple of 64, is the same in all lanes of a console wave;ds_read_b32at such an address is;The structure builder's block-scan programs fetch a wave-uniform running total with
v_readfirstlaneinside such a loop. Without the proof they asked for an exchange between the two host waves where not every lane runs, which cannot be done (it needs a group barrier).shortcut:(marked in the code) an LDS read is taken to see what a read by another wave of the same instruction would. A write by another wave between the two host waves' reads is not looked for; the scan programs read after a barrier.Testing
Hardware: one NVIDIA RTX 3090, Windows 11 (32-lane waves). Nothing else was tried.
cargo clippy --release -p victory-shader -p victory-gpu: clean.cargo test --release -p victory-shader -p victory-gpu: 110 + 210 passed, 0 failed.victory translate --validate --pipelineswithVICTORY_HOST_WAVE=32over the structure-builder library: 52 emitted, 52 validated, 52 pipelines.What this does not do
VICTORY_BVH_BUILDER=1(also withVICTORY_BVH_QUARANTINE=1) the builder now does start (all 53 programs have host pipelines), but in my runs the frame time went from about 0.3 s to about 4 s and the scene came out washed out in white. I did not try it without quarantine. Nothing here changes its default.Does it only work on this GPU?
I only know it on the 3090. By construction:
lane_uniformproofs only matter where a console wave64 program runs as two host waves of 32 and would need an exchange between them. On a host with 64-lane waves that path is not taken, so it should be inert there.🤖 Generated with Claude Code
@ryotdev on GitHub · 2026-11-24 22:19 UTC · original
I found a wrong-code case in
lane_uniformonebc2c91. A wave-uniform condition can be false for every lane. If a guarded write to a VGPR is skipped, the register keeps its old value in each lane.The regression initializes
v1to the thread ID, conditionally overwrites it, restores EXEC, and reads the first lane ofv1. When the condition is false, console lane 0 holds 0 and lane 32 holds 32. Markingv1uniform lets the upper host wave use 32 where the 64-lane read should broadcast 0. The test hits this with a constant move, a thread-ID shift, and a same-address LDS load.I put a fix and the synthetic test in fb57dd0, directly on your PR head. All three divergent cases failed before the change and pass afterward. The paired cases still take the optimization when the old VGPR is uniform too.
AI-assisted. Tested the shader library on Linux with
cargo test --locked --offline -p victory-shader --lib(171 passed, 2 ignored) and ran the repository asset policy. The test covers the compiler proof; the effect on the game’s shaders is unmeasured.@simplesmenterafael on GitHub · 2026-11-24 23:05 UTC · original
Tested
ebc2c91together with ryotdev'sfb57dd0on another 32-lane card, on Windows 10. Counts only, no title data.Machine: Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 3050 8 GB (driver 32.0.16.2124), AMD Ryzen 5 3600, 16 GB. D3D12 Agility SDK 1.620.2 (Marvisak/VIctory#175/#362, needed on Windows 10 for SM 6.6).
rustc 1.98.1.victory translate --validate --pipelinesover the structure builder's DLL,VICTORY_HOST_MAX_WAVE=32:a first-lane read where not every lane runs(at 0x23c, 0x23c, 0x258)fb57dd0The three that failed before are the same three the runtime names on this machine as the stages that keep the builder off (
missing=3 of=53).Without
VICTORY_HOST_MAX_WAVE(64-lane translation) both builds give 52 emitted, 52 validated and 43 pipelines (9 refused withE_INVALIDARGon this card), unchanged by the PR.Tests:
cargo test --workspace --locked --no-fail-fast499 passed, 0 failed, 7 ignored (includinga_guarded_uniform_write_can_keep_different_values_in_each_lane); both clippy runs from CI clean;cargo xtask policyok.Not done yet: a title run with
VICTORY_BVH_BUILDER=1. A 20-minute run (cold shader cache after the rebuild) did not reach the point where the builder is first dispatched, so I have no in-game verdict, frame time or picture to report for it yet. No device removal in that run.Tested and written with Claude Code (Claude Opus 5.5).
@adamMasMusic on GitHub · 2026-11-25 00:12 UTC · original
In-game result with the builder on, RTX 3070 8 GB, Windows 10 22H2 + Agility 1.620, Series X profile. Tree: main at
4e17478+ #81 + #150 + this PR + ryotdev's fb57dd0 (+ #40, #51, #52, #63 and a local save-folder fix). Diagnostics build,VICTORY_BVH_BUILDER=1, no quarantine.the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53.0xffffffffffffffff(outside the address space), then reads of0x8/0x28. That looks like the garbage-bounds case the fork's ray-tracing notes describe. No device removal.With the builder off (default), the same tree runs fine, at ~1.8 fps in a diagnostics build. Faces in cutscene close-ups come out black with only the eye rims lit, in every run. They also go black in a dark shot without this PR, so I read it as the missing ray-traced bounce light rather than a bug here.
@YeokiNoewChi on GitHub · 2026-11-25 00:37 UTC · original
RTX 3070 Ti, fork main
4e17478+ #23 #24 #25 #51 #52 #32 #58 #71 + #92 #115 + this PR,VICTORY_HOST_WAVE=32 VICTORY_BVH_BUILDER=1, loop limit 256.0xc0000005at+0x44bac6creading0xbe0b35d3(a pointer read from title memory, r14 = 0xbe0b35cb).VICTORY_BVH_QUARANTINE=1added gets past that point (no access violation in the next ~2 minutes), so one of the builder's stages appears to store into title memory it should not.0x80000003at+0x4da6315, as the quarantine switch's comment predicts (the title reads back sizes/counters the quarantined stages never deliver).AI-assisted (Claude Code).
@justlovett0 on GitHub · 2026-11-25 03:22 UTC · original
Tested on Windows 10 (19044), RTX 3080 (32-lane waves), title build 1.0.2.1, release + diagnostics.
With this PR + #213 and
VICTORY_HOST_WAVE=32, the structure builder translates fully: the log reports "the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53" withVICTORY_BVH_BUILDER=1— the previousmissing=3 / stays offstate is gone.However, once the builder engages in-world the title crashes ~7 s later: unhandled
0xc0000005reading0x7c0000000008(nothing mapped there) — i.e. garbage bounds/addresses produced by the builder, matching the "partly working builder wrote garbage bounds into title memory" note indocs/fork-ray-tracing.md.VICTORY_BVH_QUARANTINE=1did not avoid the crash (and ran at ~3300 ms/frame). So translation is solved here, but the builder's output is still incorrect on this card.With the builder left OFF, the irradiance-cache shade shaders translate (with #11) and the static world renders lit. Sharing in case the garbage-bounds path is reproducible on other 32-lane NVIDIA cards.
@m335671 on GitHub · 2026-11-26 06:49 UTC · original
Tested on an RTX 4070 12 GB (32-lane): with this PR and #646, the structure builder runs without
VICTORY_FIRSTLANE_OWN, and the title held 12 minutes in the first room. The room's indirect light is still black, though, and the four shadow-ray programs this PR brings up aren't bound there.Setup
main9c184b3+ #1093 (ambient light off) + #1096 + #215 + #799, then #646 (36a2257) and this PR (80a9589).pub use shader::{…}list inemit/mod.rs, where both sides add names; I kept both.VICTORY_BVH_BUILDER=1, noVICTORY_FIRSTLANE_OWN, plusVICTORY_WAVE_LDS_LOOSE=0 VICTORY_INDIRECT_GATHER=1 VICTORY_CARD_REHASH_RUNS=1 VICTORY_TEXTURE_NO_WAIT=1 VICTORY_TEXTURE_BACK=1 VICTORY_LATE_WAIT=3.Offline (
VICTORY_HOST_MAX_WAVE=32 translate --list --pipelines, whole shader pack, against9c184b3alone): +4 pipelines,shadowmask:CS_TraceShadowRays_Full,_Half,_Quarterand_Eighth; none lost._FullAdaptivestill stops at0xae80ona lane mask holding lanes elsewhere read as data.In the title
the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53, with no first-lane shortcut.Not tested: scenes that use the new shadow-ray programs, release builds, other GPUs.
AI use: the runs were done on my machine. Claude Code (Claude Opus 5.5) built and ran them, resolved the merge, read the logs and wrote this comment.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.