Shaders: dispatch BVH box/triangle/box16 ALU by node type and hoist ray sign check #2206
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2206
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2206/head"
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?
@RVZO6 on GitHub · 2026-11-25 07:59 UTC · original
RVZO6:rvzo/bvh-dispatch→main· +876 −43 · 2 files · 1 commits · closed without mergingbvh_lanesincrates/victory-shader/src/emit/lower/bvh.rscurrently evaluates box, triangle, and instance/procedural intersection ALU unconditionally for every lane and then selects among the results. Insidebvh_box, it also unpacks all 24 fp16 coordinates viadx.op.legacyF16ToF32even for box32 nodes and repeats theray.inv >= 0sign check 12 times across the four child boxes.Claimed on #1633 (
https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155420630).The change
crates/victory-shader/src/emit/lower/bvh.rs:node_dwords/Lower::memoryloads in the entry block before branching (so no memory/page-table load moves into a new divergent branch — safe on WARP and all GPUs).bvh_lanesby node type (boxvstrianglevsother) and merge the fouri32result words via phis so coherent waves skip unused intersection paths.bvh_box, guard the 24legacyF16ToF32unpacks behind anis16branch against the box32f32bitcasts (joining via 24f32phis) and hoist the 3-axisray.inv >= 0sign check once across all four child boxes without altering FP evaluation order.crates/victory-shader/src/emit/bvh_tests.rs:dxil.dllvalidation testbvh_dispatch_branches_by_node_type_and_guards_box16verifying node-type dispatch,is16gating, hoisted ray sign check, and WARP-safe load placement (including guarded BVH lowering).coherent_and_mixed_node_types_on_the_gpu_equal_the_referencechecking both coherent and mixed-lane waves against the software reference.Not a duplicate of
No open PR or
CLAIMS.mdentry branchesbvh_lanesby node type, guardsbox16fp16 unpacking, or hoists the ray sign check incrates/victory-shader/src/emit/lower/bvh.rs.Tested
windows-latestMSVC + Windows WARP SM 6.6 CI run45570823602(Clippyclean,Clippy, diagnostics buildclean,Tests:731 passed; 0 failed; 10 ignored,victory-shader:262 passed; 0 failed; 3 ignored,xtask:6 passed; 0 failed):emit::bvh_tests::bvh_dispatch_branches_by_node_type_and_guards_box16 ... okemit::bvh_tests::coherent_and_mixed_node_types_on_the_gpu_equal_the_reference ... ok(executed on Windows WARP SM 6.6)emit::bvh_tests::tests passed.Not run: the title; any hardware GPU. The title was not used in these tests.
AI-assisted: T3 Code (Antigravity, gemini-4-neon)
@sinan-cmyk on GitHub · 2026-11-25 10:52 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
c7963ef3ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 13:29 UTC · original
Automated triage for the maintainers.
In
emit/lower/bvh.rs, the PR replaces theselects inbvh_laneswith branches and phis by node type, splitsbvh_boxinto box16 and box32 blocks, and hoists theray.inv >= 0compare. By my reading the results are the same as onmain(box forty & 6 == 4, triangle forty < 4, otherwiseINVALID), and CI passes. A dump-based run found no change in validation counts.It is a performance change, but it comes with no measurement. Branching per lane inside a wave can be slower than the current branch-free selects when node types differ across lanes, which is the normal case during traversal. Please add a before/after timing: a GPU or WARP microbenchmark of the lowered shader, or frame times in the title. The 800 added test lines in
emit/bvh_tests.rsare also a lot for a change that keeps behaviour; tests that pin the CFG shape will break on any later rework. A smaller test of equivalent results would serve better.A measured gain would change this verdict.
Generated by Claude Code
@RVZO6 on GitHub · 2026-11-25 17:14 UTC · original
Closing per triage feedback: per-lane BVH branching needs a real GPU/title traversal benchmark to ensure divergent rays do not regress, which I cannot measure without hardware GPU + title.
Pull request closed