Shaders: fix RPO resource tracking, SMEM alignment, raw VCC branch, and readlane/writelane semantics (#1249) #1336
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1336"
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 wbkepler on 2026-11-24T17:32:59Z.
Summary
Fixes five RDNA2 shader ISA and CFG tracking bugs identified in #1249:
VIC-BT-024(crates/victory-shader/src/resource.rs): Iterateresource::track()inreverse_postorder(&p.blocks)rather than raw vector index order so descriptor/waterfalls_loads in higher-indexed blocks (such as copies appended bystructure::split_irreducible()) populateout.scalarbefore lower-indexed consumers inspect them.VIC-BT-025(crates/victory-shader/src/emit/lower.rs): Mask eachs_buffer_load_dword*address term (base,offset,soffset) independently with& !3u32before summing (matching RDNA2 silicon wheresoffset = 3, offset = 3resolves to byte+0, not+4).VIC-BT-026(crates/victory-shader/src/structure.rs): Evaluates_cbranch_vccz/s_cbranch_vccnzon rawvccinstead ofvcc & exec(matching RDNA2 scalar VCC branch semantics;v_cmpalready writesvccunderexec).VIC-BT-030(crates/victory-shader/src/emit/lower.rs,wave.rs): Mask theS1lane-select operand ofv_readlane_b32andv_writelane_b32toS1 & 31(Wave32) /S1 & 63(Wave64) beforewaveReadLaneAt/lane_id == lane.VIC-BT-031(crates/victory-shader/src/emit/lower.rs): Lowerv_writelane_b32unconditionally without gating the destination write onEXECso SGPR spills to inactive lanes in divergent control flow are preserved.Testing
resource.rs,structure.rs,emit/wave.rs, andemit/lower.rs.cargo clippy -p victory-shader --all-targets— cleancargo test -p victory-shader— 126 passed, 0 failed (1 ignored benchmark)cargo xtask policy— 154 files ok(AI-assisted implementation and verification.)
Imported from Marvisak/VIctory. Originally posted by dpalacios69 on 2026-11-24T18:26:37Z.
Independent check on Linux of head
da23e89, merged onto currentmain(ffe310e; a fast-forward):cargo test -p victory-shader --lockedpasses (102 passed, 0 failed, 1 ignored). The 6 test(s) it adds run on Linux and pass.cargo clippy -p victory-shader --all-targets -- -D warningsshows nothing of its own, only the two unused-import errors inemit/mod.rsthatmainalready has on Linux. No GPU run. AI-assisted; no game data.Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T19:50:15Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
da23e89ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 126, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:50Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 102 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests.Fixes RPO resource tracking, SMEM alignment and raw VCC branch handling, plus readlane/writelane lane masking; adds DXIL-level test helpers (eval_i32/calls/selects/cmp_eq) and structure tests that run on macOS (102 passed).
Imported from Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T21:05:06Z.
Follow-up pushed in
4eead6e, prompted by a comparison with #1312 by @ashrafsdrop, who gets the credit for this exception:v_readlane_b32host lanes: this PR masked every lane index by the console wave. In a pixel or vertex program, a computed lane (MaskData::Host) is a host lane, so on a 64-lane AMD host wave the mask cut off lanes 32–63. Those lanes are now left unmasked, the same exception #1312 makes. Constant (console) lanes andv_writelane_b32are still masked. This had no effect on 32-lane NVIDIA hosts.resource.rs): thev_writelane/v_readlaneSGPR spill matcher now compares constant lanes modulo the wave too. Without that, a spill to lane 35 would not match its restore from lane 3 once the lowering wraps them.a_computed_host_lane_in_a_pixel_program_is_not_masked: in a pixel program, a computed lane 35 reacheswaveReadLaneAtas 35, not 3.Verified with clippy
-D warnings(victory-shader + victory diagnostics),cargo test -p victory-shader(127 passed) andcargo xtask policy.Note for the maintainer: this PR and #1312 overlap on the readlane/writelane lane masking and the
write_ichange. Either one can land first, and the other will need a rebase.AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:22:55Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/wave.rs,crates/victory-shader/src/structure.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
upstream-sync referenced this pull request2026-11-25 03:03:34 +00:00
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.