shader(rayquery): lift wave64 bvh64 and deep-cascade/merged bvh32 loops to RayQuery #4171
No reviewers
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!4171
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4170"
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?
@steven-seagull27 on GitHub · 2026-11-30 16:58 UTC · original
steven-seagull27:shader/rayquery-wave64-and-cascade-lift→main· +1345 −71 · 5 files · 1 commits · openSummary
Extends hardware DXR 1.1
RayQueryshader lifting (VICTORY_HW_RT=1) across wave64image_bvh64_intersect_rayshaders and wave-sharedimage_bvh_intersect_ray(bvh32) shaders with deep branch cascades, mask-PHI joins, inactive-lane preserved registers, and cross-query post-loop merge blocks:Wave64
image_bvh64_intersect_rayunfolded widening (emit/mod.rs,emit/lower.rs):hw_rt() && hw_rt_lift()is active on a shader containingimage_bvh*instructions, skip the earlyfolded (before wave-wide)attempt inemit_strictso unfolded wave-wide forms (without_skips,SafeSingleWavewiden) can liftbvh64loops toRayQueryrather than interleaving two console lanes per host lane onto the forced-miss software fallback (folded (last resort)remains as fallback if no unfolded form translates).lower_with_particlesandlower_with, clone and reuse the analyzedrayquery::Planacross PHI retries and propagateneeds_every_lane/LANE_MASKerrors directly without re-lowering underPlan::default(), preventing unliftedds_wrxchg_rtn_b32traversal-stack accesses inside divergent loops from pollutingNEEDSprior toSafeSingleWavewidening.Memoized pairwise ROBDD disjointness under deep cascades (
structure.rs):Bools::atom_bool,Bools::disjoint,Bools::lits_disjoint_seen, andBools::consistent_seen(caching node-pair results inMeets::pairs).(cascade & P) ∧ (cascade & !P) == FALSEin linear ROBDD node-pair steps independent of outer branch-cascade depth, avoidingMAX_MEETbudget exhaustion in top-downBools::meet.Mask-PHI edge refinement &
LiveOutKind::PreserveInit(emit/rayquery.rs):Structured::phi_masksincoming edge equivalences during backward liveness analysis (compute_live_outside) and increase the per-valueObsState::Disjsubsumption cap so infeasible cross-edge paths through mask PHIs are pruned accurately.LiveOutKind::PreserveInit(find_inactive_preserved_phi) for wave-sharedbvh32loops carrying anactive_mask, preserving pre-loop VGPRs that are never overwritten on!active_masklanes inside the loop and only read along!active_maskpaths after loop exit.Cross-query merge PHI boundaries for
MergedQuery(emit/rayquery.rs):expand_ptr_valsandmatch_instance_addrexpansion at cross-query merge PHIs (arg_from_other_query/addr_arg_from_other_query) so shared post-merge attribute loads are not prematurely claimed asAttrSource::Single.find_merged_attr_loadsto group bothhit_instandhit_trimerge PHIs and include surviving queries' pre-branchtlas_lo_vals.Verification
cargo test -p victory-shader --lib -- rayquerywave64_bvh64_prefers_unfolded_wave_wide_when_hw_rt_is_onbvh32_cascade_phi_masks_and_preserve_init_lifts_and_validatesbvh32_cross_query_merge_phi_lifts_both_queries_and_merged_attr_loadcargo test -p victory-shader --lib -- structure::disjoint_and_consistent_seen_prune_contradictions_under_deep_cascadesa_search_that_remembers_answers_as_one_made_anewcargo clippy -p victory-shader --lib --testscargo run -p xtask -- policy@VibeCodeGuy on GitHub · 2026-12-01 00:21 UTC · original
Offline corpus check (every shader container in a v1.0.2.1 dump: 25,699 unique programs),
maine1251c31againstmain+ this PR at6923eb78, both withVICTORY_HW_RT=1.The 20 changed programs
b0f711280e298008Csrtdirectionalshadows:CS_RTDistantLODLightShadowe8c962358d862e3fCsrtdirectionalshadows:CS_RTDistantShadowTraceLeakPlug32_Tilede9c39e7efe3c508dCsrtdirectionalshadows:CS_RTShadowTrace32HQ534b3645dd344ab2Csrtdirectionalshadows:CS_RTShadowTrace32HQ_TiledFarOnlyfb515ca95d694c18Csrtdirectionalshadows:CS_RTShadowTrace32HQ_Tiled43ce3255529b200aCsrtdirectionalshadows:CS_RTShadowTrace32TemporalHQc2d3fdeffa839418Csrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver2RPPa41f0b553a07e79dCsrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver2RPP_TiledFarOnlyffd9788ba9fec033Csrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver2RPP_Tiled22f3f0f74693bff9Csrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver4RPP_TiledFarOnly693d1d787d4a22ebCsrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver4RPP_Tiled221925bf9ed4e06eCsrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver8RPP_TiledFarOnly7ec122fc9eedf367Csrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_OneOver8RPP_Tiled813783478ebb80e6Csrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_TiledFarOnly1250dc0656b3c091Csrtdirectionalshadows:CS_RTShadowTrace32TemporalHQ_Tiled07c93bfb77fecebbCsshadowmask:CS_TraceShadowRays_Full4e816e1ef600ddcfCsshadowmask:CS_TraceShadowRays_Fullres41d9434155880e8aCssr_tracing:CS_RaytraceVBuffer_RayBinning_ShaderBinning_Mixed8e5d070d8d4793eaCssr_tracing:CS_RaytraceVBuffer_RayBinning_ShaderBinning_Shared_WithFar381ef16494cc782dCssr_tracing:CS_RaytraceVBuffer_ShaderBinning_WithFarHow:
victory translate <dump> --validate --listbuilt for each side (release, cross-built with cargo-xwin, run under Wine),VICTORY_HOST_WAVE=32, plus the four shader-cache-key settingsplaystarts with (VICTORY_EARLY_DEPTH=1,VICTORY_NAN_SCRUB=1,VICTORY_BVH_MISS=1,VICTORY_SAMPLED_MARKS=1). Validator:dxil.dllfrom DXC v1.9.2609. "Changed" compares translate'semittedhash of each module and its bindings. There was no GPU on this side, so no host pipelines were made and nothing was run on a card. Onmainthe same run has 72 failures: 71 mesh programs over the 32 KiB output limit (the known shortcut inmesh_prologue) andCS_TraceShadowRays_FullAdaptive(#2993).For scale: on
main,VICTORY_HW_RT=1itself changes 63 compute programs against the default. The 20 above are all among those 63: the PR changes 20 of the 63 thatVICTORY_HW_RT=1touches. The PR's run with the switch off showed no change at all, so the default path is untouched.6923eb7892to5c7be09bab@paales on GitHub · 2026-12-01 01:41 UTC · original
Written by 🤖:
Tested together with #4338, #4579 and #4144 on an RTX 5070 Ti (#4338). With
VICTORY_HW_RT=1the first cutscene and a save with the boat scene lift every ray query: 13 programs, no software fallback, 4.4 lifted dispatches a frame. Card time 24.5 ms a frame against 99.4 ms withVICTORY_BVH_BUILDER=1. WithoutVICTORY_HW_RTthe build runs as before (median frame 33.3 ms both, submitting thread 24.5 against 23.9 ms).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.