Shaders: dwords read from the first lane outside a waterfall's own reads are one lane's (#2829) #2831
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!2831
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2831"
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?
@BastienRodz on GitHub · 2026-11-25 21:39 UTC · original
BastienRodz:shader/first-lane-reads-outside-waterfall→main· +114 −5 · 1 files · 1 commits · openWhat's wrong
Tracer::classifytraced everyv_readfirstlane_b32result as the dwords each lane holds. That is right only for the reads that a waterfall loop at the access compares, whichtrackproves (first_lane_words). Reads that reachclassifyanother way were never proven:v_readfirstlane_b32 s24, v4; v_mov_b32 v4, s24). Every lane now holds the first lane's descriptor, yet the image traced toFetchedand each lane sampled its own entry. In a vkd3d-proton run with entry(v0 & 1) << 5, the lanes read[1.0, 2.0, 1.0, 2.0, ...]where the console gives1.0in all of them.s_cselector joined at an SGPR phi after the read. The dwords only had to agree in the lanes that access the descriptor, but the first lane can be another one. In the test, lane 0 kept its old VGPRs while the accessing lanes overwrote theirs under EXEC.RDNA2 ISA, V_READFIRSTLANE_B32: "Copy one VGPR value to one SGPR ... Lane# = FindFirst1fromLSB(exec) (Lane# = 0 if exec is zero). Ignores exec mask for the access."
What the fix does
descriptortraces the access's own first-lane reads as before: the reads the waterfall proof covers.classifynow handles any other first-lane read differently. It traces the read over the lanes that run it, the reach of its block. A source that can differ between lanes is refused with the existing "a descriptor read from the first lane outside a waterfall loop", the same rule main already applies to a first-lane read at the access with no waterfall loop.Tracer::first_lanes, andSource::per_lane(whether lanes may hold different descriptors).Tests
New
resource::tests::first_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_owncovers both shapes.resource.rsfrom main it fails ("not refused: ...Fetched { load: (0, 5) }").Other runs, all under Wine and vkd3d-proton:
resource::testspass, as do the 5 GPUwaterfall_tests(lanes sampling their own texture, nested arms,v_cmpx-narrowed loops).victory-shaderlib was run one test per process, on this head and on main with only the new test added. The results are identical except for that test: 255 ok, 14 failed, 2 crashed and 3 ignored with the fix. The failures and crashes are the same host quirks on both builds: semantics and hardware comparisons, 64-bit image atomics,stub_pipeline_is_created, and a few synthetic DPP or gather tests.cargo clippy --workspace --all-targets --locked -- -D warningsis clean.Not tested
Fixes #2829
No game data. Found and written with AI assistance (Claude Code), reviewed and run locally.
🤖 Generated with Claude Code
@BastienRodz on GitHub · 2026-11-25 21:44 UTC · original
Windows run of this head (
7416990) onwindows-latest, WARP,cargo test --workspace --locked --no-fail-fast -- --test-threads=1: https://github.com/BastienRodz/VIctory/actions/runs/45706300597victory-shaderlib: 271 passed, 0 failed, 3 ignored, includingresource::tests::first_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_ownand everywaterfall_testsGPU test.@fuzeofficlal on GitHub · 2026-11-25 21:48 UTC · original
Verified
74169903on Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll):cargo xtask policy: 184 files ok;cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings.resource::tests34/34 passed (includingfirst_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_own),emit::waterfall_tests5/5 passed (RTX 5090 + WARP +dxil.dll),emit::lower::tests27/27 passed.per_lanehandling to directTracer::descriptoraccess sites and usingl.reach[b]inTracer::classifycleanly catches non-waterfallv_readfirstlane_b32descriptor reads.git merge-treeagainstorigin/mainand #2830 (orthogonal and complementary: #2831 rejects non-waterfall per-lane descriptor assembly inresource.rs, while #2830 selects the guarded active lane for value-levelv_readfirstlane_b32inemit/lower.rs).@Machad3x on GitHub · 2026-11-25 22:02 UTC · original
Hardware result: tested at head
74169903. One host: RTX 3080 Ti, driver 621.24, Windows 11, a fork stacking open PRs, Series X mode. Cherry-picked together with #332 and #2816: the shader tests pass apart from one failure the stack had before, and one 7-minute run in play had no device removal. Window scene medians 670 ms a frame and 307 ms GPU step (694 and 331 without the three; one run each).Ran with AI assistance (Claude Code).
@cloph-dsp on GitHub · 2026-11-25 23:31 UTC · original
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.
git diff --checkagainst merge-base13f91cais clean; 1 file, +114/-5.resource::tests::first_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_ownis absent from the base commit.cargo test --locked -p victory-shader --lib -- resource::tests::first_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_own --exact --quiet-> 1 passed (273 filtered out).cargo test --locked -p victory-shader --lib -- resource::tests --quiet-> 34 passed, 0 failed.AI-assisted (Hy4 flash).
@Marvisak on GitHub · 2026-11-26 03:21 UTC · original
Automated triage for the maintainers.
On
main,Tracer::classify(crates/victory-shader/src/resource.rs) traced anyv_readfirstlane_b32descriptor dwords as each lane's own. That is only proven for the reads a waterfall loop at the access compares. Reads copied back to VGPRs, or picked or joined after the read, came out as per-laneFetchedeven though every lane holds one lane's value.The PR changes two things:
descriptorkeeps the proven per-lane path for reads at the access (the newfirst_laneshelper).classifynow traces other first-lane reads over the reach of their block. A source that can differ between lanes (Source::per_lane) is refused with the messagemainalready uses.The cited ISA wording backs this. The new test covers both shapes, and others confirmed passes on WARP, an RTX 5090 and vkd3d-proton.
The trade-off: affected programs now get a refusal instead of wrong sampling, and how many title shaders hit this is not measured. A run over a shader dump would settle that.
Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.
Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 21:57 UTC · original · reviewed
Sound tightening for #2829: dwords that are all readfirstlane results defined in one block only carry that block's lanes in 'runs', and a per-lane result outside a proven waterfall now refuses instead of treating a uniform broadcast as each lane's own descriptor. Conservative in the right direction. LGTM.
@Dukestar69 on GitHub · 2026-11-26 03:27 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --lib resource::tests: 36 passed, 0 failed (including newfirst_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_own).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 12:10 UTC · original · approved these changes
Reviewed and verified
74169903againstorigin/main(63bcca43; clean three-waygit merge-treepreservingmain'sTracer::sumcache):v_readfirstlane_b32classification to carry blockreach(crates/victory-shader/src/resource.rs:1107-1141) cleanly catches the copy-back ands_cselectpaths targeted by #2829 while continuing to reject partial first-lane descriptors.xtask policy(184 files ok),cargo clippy -p victory-shader --all-targets -- -D warnings(default and--all-features) clean,resource::tests(34 passed),emit::lower::tests(27 passed), andemit::waterfall_tests(5 passedon both RTX 5090 and WARP).Note for merge ordering: the pre-existing
made_rawmismatch wheredescriptorunwrapsself.made_raw(&words)(resource.rs:1084-1088) whilefirst_lane_words(resource.rs:1516-1526) inspects the raw operands is addressed orthogonally in #2869; a three-way merge of #2831 + #2869 applies cleanly with zero conflicts so both paths sharewords()once both land.@andrewpozdnakov7-jpg on GitHub · 2026-11-26 12:54 UTC · original
I reproduced the same-register masked rewrite from #2829 using this PR’s
s_cselectfixture. The only input change is that the four maskedv_mov_b32instructions copy froms[28:31]again. On7416990the added case returnsa per-lane descriptor written where some lanes may keep the old one.The optional follow-up applies directly to
7416990. When a lane can skip a plain VGPR move, it accepts the move if the previous definition in the same block copies the same value and is proved to execute in every relevant lane. The new case now traces both arms of the select to table offset0x20. The existing cases where lanes really hold different descriptor words still refuse with the original errors. Separate loads from the same address remain distinct.63bcca4: 36 resource tests, 5 WARP waterfall tests, policy check passed.Follow-up commit
acfb0eb. If you take it, please retain its Git author on cherry-pick or rebase, or addCo-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding it into another commit.AI-assisted with Codex.
@BastienRodz on GitHub · 2026-11-26 12:55 UTC · original
Thanks for reproducing the masked-rewrite case and sharing
acfb0eb!I'd rather keep #2831 minimal on
74169903— it already has themerge-candidatetriage verdict and several independent reviews/runs on this head, and changing the head would reset those for a relaxation of a conservative refusal on a synthetic redundant-move shape. It would make a clean separate follow-up PR on top once #2831 lands (especially if any title shader hits this pattern).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.