Shaders: ignore pre-loop table loads when proving waterfall offsets #1253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1253"
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?
Imported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-24T16:49:04Z.
Summary
Fixes
resource::trackso a uniforms_load_dwordx4executed in an earlier basic block with an offset derived fromv_readfirstlane_b32does not get recorded in a later waterfall loop block'soffset_atread set and cause the waterfall proof to fail.Root Cause
In
resource::track, when an instruction inside basic blockbconsumes aSource::Loaded { load, .. }descriptor whose scalar load ran in an earlier block (load.0 != b) and whose dynamic offset came fromv_readfirstlane_b32,trackpushed that pre-loop first-lane read intooffset_at[b].1.Tracker::waterfall(block, accesses, reads)requires every read inreadsto reside insideblock(read.0 == block) and feed that loop'sv_cmp_eq_*waterfall mask, so including a pre-loop first-lane read from block 0 rejected a valid waterfall loop in block 1 (for example, when a shader loads a uniform sampler once before the loop and waterfalls a per-lane texture table offset inside the loop).Changes
crates/victory-shader/src/resource.rs:Source::Loadeddescriptor'sfirst_lane_sourcetooffset_at[b]when the scalar load itself ran earlier in the same block (load.0 == b && load.1 < i).loadsalongsidereadsbefore extendingout.waterfall.loads.pre_loop_first_lane_waterfalland unit testa_first_lane_load_before_a_waterfall_loop_stays_uniform.crates/victory-shader/src/emit/waterfall_tests.rs:lanes_sample_the_entry_their_offset_names_in_the_console_waterfallto executepre_loop_first_lane_waterfallend-to-end on DXIL (wave_ops == true,nonuniform_handles == 1).Verification
cargo test -p victory-shader --locked waterfallcargo clippy -p victory-shader --all-targets --all-features -- -D warningscargo run -p xtask -- policyImported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T16:56:53Z.
Review: APPROVED
Tested merged cleanly onto
main(ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):cargo test -p victory-shader resource::: 32 passed, 0 failedcargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy: okClean tracking of scalar index arithmetic in waterfall table offsets. Approving.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-24T17:16:21Z.
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).No program gained or lost and the failure table is identical to the base: nothing in this capture reaches the class, so this is a no-regression result only.
Not tested: in-game.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:27:17Z.
Automated triage for the maintainers.
Needs work (evidence only). In
track(crates/victory-shader/src/resource.rs), aSource::Loadeddescriptor's first-lane offset now counts toward a block's waterfall proof only if its table load ran earlier in that same block (load.0 == b && load.1 < i).waterfall.loadsis also deduplicated. By my reading this is sound. A table load before the loop, with an offset fromv_readfirstlane_b32, runs once and is uniform. Onmain, its read joins the in-loop proof,Tracker::waterfallrejects it, and the image that is waterfalled in the loop falls back to the first lane's entry.a_first_lane_load_before_a_waterfall_loop_stays_uniformand the extendedlanes_sample_the_entry_their_offset_names_in_the_console_waterfallcover this on the GPU. The description now matches the diff, and the trailing-whitespace nit is fixed. CI: passing (check).What is still open: there is no sign the title has this shape. The fixture is hand-written. The earlier 768-program offline check in this thread found no program that changed. Any of these would move it forward:
victory translate --validate --listcomparison on currentmainshowing which programs change.Without that, the change is a correct-looking fix for a case not seen yet. Whether to take it on code reading alone is for the maintainer.
On your reply: thanks for the cleanup. A tester with a capture can supply the comparison, and that is all this needs.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:56:28Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.147 passed / 0 failed / 2 ignored. Scalar index arithmetic followed in waterfall table offsets (+3 tests) — waterfall readback correctness; pairs with #1408's wave prefix sums.
[PR #1253] Shaders: follow scalar index arithmetic in waterfall table offsetsto [PR #1253] Shaders: ignore pre-loop table loads when proving waterfall offsetsImported from Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-25T17:27:31Z.
Updated:
offset_reads/WATERFALL_SCALED_INDEX_WAVE32text).pre_loop_first_lane_waterfallincrates/victory-shader/src/resource.rs.On title data: this was found by code inspection while auditing
resource::track+Tracker::waterfall, and I don't have a local title shader capture to runvictory translate --validate --listagainst — if a tester with a capture can check whether--validate --listchanges on it, that would confirm whether any title shader hits this pre-loopv_readfirstlane_b32+ loop waterfall combination today.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.