Shaders: the console's two nested waterfalls over a per-lane texture and sampler offset are proven by their shape (VICTORY_WATERFALL_NESTED, on unless 0) #4068
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!4068
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4068"
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?
@kMagic142 on GitHub · 2026-11-30 15:30 UTC · original
kMagic142:pr-waterfall→main· +1235 −823 · 33 files · 13 commits · closed without mergingWhat it changes
When a sample's texture and sampler both sit at per-lane table offsets, the console compiler wraps it in two nested waterfall loops. The outer loop reads the first waiting lane's sampler offset (
v_readfirstlane_b32), narrows EXEC to the lanes with the same one (v_cmpx_eq_u32), keeps that EXEC and loads the sampler. The inner loop is the oneTracer::waterfall_shape(#458) proves, over the texture offset. A latch then moves the kept EXEC back and drops those lanes from the waiting ones (s_andn2_wrexec).Tracer::waterfallrefuses the pair as "a waterfall loop nested in another or split over blocks", andwaterfall_shapefollows only the inner loop. So on main both stay loops: each pass has a first-lane read and a compare, and in a wave of 64 run as two host waves of 32, an exchange of the first lane's value between the halves.Tracer::nested_waterfall_shape(resource.rs) proves the outer loop by its exact shape and the inner one withwaterfall_shape. It runs only wherewaterfallandwaterfall_shapeboth refuse. It requires:v_cmpx_eq_u32/_i32compares (the same rules aswaterfall_shape), moves of EXEC, the table loads at those offsets, waits ands_nop; it runs straight into the inner loop and enters it with the EXEC the compares left;s_andn2_wrexecretry, and the branch to the head;When all of that holds, every lane makes its access once, with both of its own table entries. One pass of per-lane loads does the same. As for one loop, both loads become non-uniform heap reads and the compares hold in every lane.
It is on by default, and
VICTORY_WATERFALL_NESTED=0leaves these loops as they are on main. The switch is in the shader cache key (KEYEDinshader_cache.rs). Only programs that contain such a pair translate differently.How it was tested
Where it comes from: our fork, which is based on v2026.11.28.03 with local changes. That tree is not main and does not have #458. There, an earlier version of this proof handled the same pair; it was opt-in at first and is on by default in our later builds. That version was built on our own single-loop proof instead of
waterfall_shape. It also lacked the checks that nothing past the loops reads the outer offset or the EXEC copies. This PR is that proof ported ontowaterfall_shape, with those checks added, so it is stricter than the version we ran.GPU and profile: RTX 5090 on Windows, Series X profile, DLSS Quality, no frame generation, no ray tracing.
What we counted on our tree: with the single loop already proven, 698 console waterfall loops over first-lane table offsets were still unproven in the programs one gameplay run translated. 356 of those 698, in 42 programs, were these nested pairs. With #458 doing the single loop on main, the remaining set there may differ. The heaviest program with such pairs that we saw is the pixel program
94d281151ca58b4fof the mesh passef5409053e14aa82, which has nine such samples. Before the change, that draw took 0.29 and 0.38 ms of card time a frame in two runs.Before and after: we did not measure this change on its own. No run isolates its effect on frame or card time, and there is no picture comparison for it alone. It has not been run on main.
For shader changes, the wave sizes tested: the new unit tests take the pair at 32 and at 64 lanes. In the title it ran only at the wave size our fork used for these programs, not at 32 and 64 separately.
cargo testpassed for the crates it touches: yes, on main (41adb551) with this branch applied:cargo xwin check -p victorypasses, andvictory-shader's waterfall tests pass (35 passed, 0 failed), among themnested_console_waterfalls_over_a_texture_and_a_sampler_offset_are_oneand the five variants that must stay unproven.The new tests are in
resource.rs.nested_console_waterfalls_over_a_texture_and_a_sampler_offset_are_onechecks wave32 and wave64: two compares, two first-lane reads, and both loads per lane. Five variants must stay unproven:every_switch_of_the_translator_is_in_the_keyinvictory-gpucovers the new switch.Checked for overlap
waterfall_shapefor the single loop. This proof uses it unchanged for the inner loop.waterfall_shapekeeps that check for the inner loop.resource.rs, but in other functions (VALU address operands).KEYEDlist inshader_cache.rsgains one name, which may conflict textually with other open PRs that add switches there.@VibeCodeGuy on GitHub · 2026-11-30 22:28 UTC · original
Offline corpus check (every shader container in a v1.0.2.1 dump: 25,699 unique programs),
maine1251c31againstmain+ this PR at4b1cf1de.The 683 changed programs by family
PS_MirrorPedTextured_EightPS_PedAlphaPrepassPS_PedAlphaPrepass_DecalsPS_PedTextured_Eight_AlphaPS_PedTextured_Eight_DecalsPS_StudioPedTextured_EightPS_DeferredPedDecalTexturedPS_DeferredPedTexturedNCPS_MirrorReflectionDeferredPedTexturedNCPS_CascadeShadows_texture_alphaPS_PedAlphaPrepass_FirePS_PedAlphaTransmissionPS_PedAlphaTransmission_DecalsPS_PedAlphaTransmission_FirePS_PedTextured_Eight_FirePS_DeferredPedTexturedNC_PackedPS_MirrorReflectionTextured_EightPS_Textured_EightPS_VoxelizeVisiblityPS_DeferredPedTextured_AlphaClipNC_TintPS_DeferredPedTextured_AlphaClip_Decal_TintPS_AlphaPrepassPS_DeferredTextured_AlphaClipPS_DeferredTexturedPS_MirrorReflectionDeferredDecalTexturedPS_MirrorReflectionDeferredTextured_AlphaClipPS_MirrorReflectionDeferredTexturedPS_DeferredPedTextured_AlphaClipNC_DecalPS_DeferredPedTextured_AlphaClipNC_Decal_TintPS_DeferredPedTextured_AlphaClipNCPS_MirrorReflectionDeferredPedTextured_AlphaClipNCPS_MirrorReflectionDeferredPedTextured_AlphaClipNC_Tintped_standard_garment_2lyr:CS_RaytracingResolveped_standard_lod_muv:CS_RaytracingResolveped_standard_lod_muv_cutout:CS_RaytracingResolveped_standard_lod_muv_emissive:CS_RaytracingResolveped_standard_muv:CS_RaytracingResolveped_standard_muv_anisotropy_sheen:CS_RaytracingResolveped_standard_muv_anisotropy_sheen_secmo:CS_RaytracingResolveped_standard_muv_blendshape:CS_RaytracingResolveped_standard_muv_blendshape_cutout:CS_RaytracingResolveped_standard_muv_cutout:CS_RaytracingResolveped_standard_muv_cutout_secmo:CS_RaytracingResolveped_standard_muv_diffraction:CS_RaytracingResolveped_standard_muv_diffraction_secmo:CS_RaytracingResolveped_standard_muv_emissive:CS_RaytracingResolveped_standard_muv_emissive_secmo:CS_RaytracingResolveped_standard_muv_iridescence:CS_RaytracingResolveped_standard_muv_iridescence_secmo:CS_RaytracingResolveped_standard_muv_retroreflection:CS_RaytracingResolveped_standard_muv_retroreflection_secmo:CS_RaytracingResolveped_standard_muv_secmo:CS_RaytracingResolveweapon:CS_RaytracingResolveweapon_garment_2lyr:CS_RaytracingResolveweapon_muv_anisotropy_sheen:CS_RaytracingResolveweapon_muv_clearcoat:CS_RaytracingResolveweapon_muv_cutout:CS_RaytracingResolveweapon_muv_emissive:CS_RaytracingResolveweapon_muv_iridescence:CS_RaytracingResolvePS_AlphaTransmissionPS_FPWeaponRedDotMotionBlurMaskPS_FPWeaponRedDotHow:
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).@trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed