BVH builder: FIRSTLANE_OWN makes all 53 builder programs translate; the check needs a wave-uniform proof instead #101
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#101
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?
@kalijerry on GitHub · 2026-11-26 03:25 UTC · original
Follow-up to #37, with the prefix-scan half of it measured end to end on hardware.
What happens with the shortcut on
VICTORY_FIRSTLANE_OWN=1 (the existing shortcut in emit/lower.rs, written for exactly this scan) makes all three refused stages translate:
So nothing new is needed in lowering to get the builder on - it needs this shortcut to be correct for these shaders, or the shortcut promoted to the default.
Why it is plausible, and where it can be wrong
The three stages are the builder's prefix scans (39321a95223001ed, 77360df21e12ea43, 9fc111d3be79364f). They read a sum of scalars with v_readfirstlane inside a loop whose exit is per console wave. The value is the same in every lane of the console wave, so the host wave's own first lane holds the answer and the exchange pair is unnecessary.
The shortcut is not exact in general. It returns the host wave's own first lane without checking that the console's first live lane is in it, so it is only right while the value is wave-uniform. lower.rs accepts it as a static switch with that caveat in the comment; under VICTORY_FIRSTLANE_OWN=1 a divergent non-uniform first-lane read yields the wrong lane rather than failing to build.
The right fix
Keep the own_bits.alike fast path (already there, one line above) and extend it to values proved uniform by the scan's own loop shape, or make the fallback exact for the single-wave case: exchange only the has-lane bitmask and the value where a half actually holds a live lane, instead of two full exchange pairs. Then the shortcut can be retired.
Effect on the picture (this is the point)
Builder on is not a small visual change. With the builder off an interior is a flat black frame; with it on, the same interior has bounce light and a bar's shadow across the face. Builder off is the wrong picture, not a cheaper one.
Cost
Builder on currently drops an RTX 3080 to 6.7 / 3.8 fps (149 / 260 ms), dominated by guard lock waits (636 calls, 141 ms a frame) and 3,125 page faults a frame with no copy left in budget. PR #96 removes the descriptor half of that; the guard and fault work is still open.
Verification
0a43566+ VICTORY_BVH_BUILDER=1,VICTORY_FIRSTLANE_OWN=1: all 53 builder programs get host pipelines, no device removal, VICTORY_BVH_QUARANTINE=1 also stable.@bordersky on GitHub · 2026-11-26 04:55 UTC · original · edited 2026-11-26 06:07 UTC
A measurement on the "where can the shortcut be wrong" half, from Linux.
No program of the title's shader archive needs
FIRSTLANE_OWN. An offlinevictory translate --listover the title's shader archive withVICTORY_FIRSTLANE_OWN=0(b0cfe2b): 26,084 programs, and not one of them fails witha first-lane read where not every lane runs. So the only programs that take the shortcut are the builder's own (they come from the builder DLL, not from the archive), and=1changes nothing anywhere else.That makes it possible to take the shortcut by default where it was written for, without the global switch: the programs with spilled user data, the same test
pipeline::of_builderalready uses to recognise the builder (crate::spill::is_spilled).=1keeps today's behaviour (every program),=0turns it off:With it,
VICTORY_BVH_BUILDER=1alone (whatplay.ps1 -RayTracingsets) givesthe ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53, with nothing else set.Runs (RX 7900 XT 20 GB, 32 GB RAM, Arch, Wine (GE-Proton10-34) with the views-in-a-tree wineserver from #111, vkd3d-proton master, Mesa/RADV, Series X profile;
play.ps1settings plusVICTORY_RELAY=1 VICTORY_CARD_STEPS=0 VICTORY_LAND_ECHO=0from #13 and #59, and theplaceholder()fallback from #59). Same spot in the prison dormitory, about 6,800-7,000 draws a frame:VICTORY_BVH_QUARANTINE=1No device removal and no GPU page fault in four builder runs. The interior gets its bounce light and the sun's shadows, as you describe.
This is still the same shortcut, not the wave-uniform proof the issue asks for: it only narrows where it applies to the programs it was written for, and makes
-RayTracingwork without a second switch.One trap for anyone comparing runs: main characters' faces went missing with the builder on (eyes, teeth and hair floating, secondary characters fine). It survived the quarantine and was not the builder: the title's checkpoint save
SARC0015in the save folder was bad. Moved aside, the main character's face was back with the builder still on (the prison intro cutscene of a new game).github-bot referenced this issue2026-11-26 11:21:43 +00:00