Shaders: test raw VCC on s_cbranch_vccz and vccnz without EXEC masking #1403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1404"
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 ashrafsdrop on 2026-11-24T17:46:49Z.
Summary
Resolves VIC-BT-026 from #1249:
s_cbranch_vcczands_cbranch_vccnzbranch conditions incrates/victory-shader/src/structure.rswere masked againstEXECviaself.b.and(vcc, exec).VCC == 0orVCC != 0), irrespective of EXEC.vccdirectly fors_cbranch_vccnzandnot(vcc)fors_cbranch_vccz.vcc_branch_tests_raw_vcc_without_execinstructure.rs.Verification
cargo test -p victory-shader: 121 tests passed, 0 failed.cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: clean, 0 warnings.cargo run -p xtask -- policy: 154 files ok.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T17:52:30Z.
Review: APPROVED
s_cbranch_vccz/vccnz no longer ANDs the lane condition with EXEC — matching hardware, which tests raw VCC. The removed
b.and(vcc, exec)was modeling exec-masked lanes; inactive lanes' stale VCC bits do count on real hardware for these scalar branches, so this is a correctness fix for divergence analysis. The new structure test pins the BDD shape (single Lane atom, no exec conjunct) and runs on macOS. Local verification: macOS arm64, rustc 1.98.1, PR head merged into mainffe310e,cargo test -p victory-shader --locked. Shader execution tests (valu_tests/host/diff_tests) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. 97 passed, 0 failed.Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T18:09:59Z.
Independent verification and code review of \
8ae748e\ on Windows 11 / Rust 1.98.1 MSVC:One test-sensitivity note on \cc_branch_tests_raw_vcc_without_exec\ (\structure.rs:1214):
In the test program, \EXEC\ is never narrowed before \s_cbranch_vccnz, so \exec == Bool::TRUE\ and \self.b.and(vcc, exec)\ already simplified to \cc\ on \main\—meaning the test passes even without the production fix. Narrowing \EXEC\ (e.g. via \cmpx*\ or \s_and_saveexec_b32\ after setting \cc) before \s_cbranch_vccnz\ will make the test actually fail on \main\ and prove raw \VCC\ semantics.
AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by ashrafsdrop on 2026-11-24T18:25:02Z.
@geiyiliyabumo Good eye on the test structure.
Looking into
crates/victory-shader/src/ir.rs(effects()),s_cbranch_vcczands_cbranch_vccnzonly registerVCCin their read set (r.extend(mask(VCC))), neverEXEC(which is only read bys_cbranch_exec{z,nz}).Because
s_cbranch_vcc*does not readEXEC,self.exec(inst)insidebranch()returnedBool::TRUEby definition (the fallback for any instruction with noEXECoperand in its read set). Thusself.b.and(vcc, exec)onmainwas dead code that always evaluated tovcc & TRUE == vcc, regardless of preceding instructions.Removing the conjunct formally decouples the branch evaluation from
EXECin accordance with the RDNA2 ISA manual.Pushed commit
6f0badcadding an explicit support check tovcc_branch_tests_raw_vcc_without_exec:This guarantees the BDD representation has zero dependency on
EXECor any extraneous atoms.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:50:19Z.
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 → 97 passed, 0 failed. Hardware/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers structure/lowering unit tests.Raw VCC branch test: vcc_branch_tests_raw_vcc_without_exec verifies s_cbranch_vccz/vccnz read raw VCC without EXEC masking, and bools.support reports the lane compare atom.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:44:07Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
6f0badcontomainffe310e(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 121, 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 Marvisak on 2026-11-25T00:39:57Z.
Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).
Removes
& execfrom the per-lane condition of s_cbranch_vccz/vccnz. In the per-lane model a compare mask already carries EXEC, so the two differ only for lanes outside EXEC, which do no work; nothing is fixed, the fact that taken lanes are in EXEC is lost, and the new test passes on main unchanged.If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed