Repository navigation
Shaders: dwords read from the first lane outside a waterfall's own reads are one lane's (#2829) - #2831
Shaders: dwords read from the first lane outside a waterfall's own reads are one lane's (#2829)#2831BastienRodz wants to merge 1 commit into
Conversation
…ads are one lane's `Tracer::classify` traced every `v_readfirstlane_b32` result as the dwords each lane holds. That is right only for the reads a waterfall loop at the access compares, which `track` proves. Reads reached another way were never proven: - copied back to VGPRs before a loop (`v_readfirstlane_b32 s24, v4`, `v_mov_b32 v4, s24`): a per-lane source (a `global_load` entry) came out as each lane's own, though every lane holds the first lane's; - picked by `s_cselect` or joined at an SGPR phi: the dwords had to be the same only in the lanes that access the descriptor, but the first lane may be another (lane 0 kept its old VGPRs, the accessing lanes overwrote theirs under EXEC). RDNA2 ISA, V_READFIRSTLANE_B32: "Copy one VGPR value to one SGPR ... Lane# = FindFirst1fromLSB(exec)". The access's own reads are now traced in `descriptor` as before. Others must give the same descriptor in every lane that runs the reads (the reach of their block); a per-lane source is refused as "a descriptor read from the first lane outside a waterfall loop". Test: `first_lane_reads_no_waterfall_loop_proves_are_not_each_lanes_own` (both shapes; on main the first traces to `Fetched`, the second to `Select` of the first and second buffers). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Windows run of this head (
|
|
Verified
|
kotekompotek
left a comment
There was a problem hiding this comment.
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.
|
Hardware result: tested at head 7416990. 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). |
|
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.
AI-assisted (Hy4 flash). |
|
Automated triage for the maintainers. On The PR changes two things:
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 |
Dukestar69
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Reviewed and verified 74169903 against origin/main (63bcca43; clean three-way git merge-tree preserving main's Tracer::sum cache):
- Moving non-waterfall
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. - Local verification:
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_raw mismatch where descriptor unwraps self.made_raw(&words) (resource.rs:1084-1088) while first_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 share words() once both land.
|
I reproduced the same-register masked rewrite from #2829 using this PR’s The optional follow-up applies directly to
Follow-up commit AI-assisted with Codex. |
|
Thanks for reproducing the masked-rewrite case and sharing I'd rather keep #2831 minimal on |
What'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