Shaders: s_cbranch_vccz/vccnz tests raw VCC, not VCC & EXEC #2406
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!2406
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2406"
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?
@makmatvey on GitHub · 2026-11-25 13:04 UTC · original
makmatvey:cursor/shaders-vcc-branch-raw-1c6e→main· +55 −6 · 1 files · 1 commits · openWhat
s_cbranch_vccz/s_cbranch_vccnzon the console test the full VCC register. Structuring usedVCC & EXEC, so a branch flipped when only inactive lanes held VCC bits (an earlier compare left them, or a scalar write set them after EXEC was narrowed).Tracked as VIC-BT-026 in #1249. Related focused slice of the stalled bundle in #1336 (needs rebase).
Change
In
crates/victory-shader/src/structure.rs, the VCC branch arms use the lane's VCC bit alone. EXEC branches are unchanged.Tests
cargo test -p victory-shader --locked --lib cbranch_vcc_tests_raw_vcc_without_exec_masking— passcargo test -p victory-shader --locked --lib structure::— 12 passed, 1 ignoredcargo clippy -p victory-shader --locked -- -D warnings— cleanNo game data used.
@upipibi on GitHub · 2026-11-25 13:22 UTC · original · edited 2026-11-25 13:53 UTC
Duplicate check: this and #2405 (ashrafsdrop, opened 31 s earlier) make the same edit in
structure.rs. So does the older #1336 (wbkepler, 2026-11-24, now conflicting): it has the samevcchunk and the samecbranch_vcc_tests_raw_vcc_without_exec_maskingtest as this PR (added in an edit). Both replaceself.b.and(vcc, exec)with rawvccfors_cbranch_vccz/s_cbranch_vccnz.Correction (edited): I first wrote that either one fixes it. From reading
main940d32f, neither changes behaviour.exec(inst)returnsBool::TRUEwhen the instruction doesn't read EXEC (structure.rs:914-919), and the VCC branches don't read it, soand(vcc, exec)already reduces tovcc. steven-seagull27 ran both PRs' tests on the parent and they pass there (comment). The bug that's left is in neither PR: the branch is decided per lane from the lane's VCC bit, not wave-wide fromVCC != 0. His test-only commite0b10c17fails on all three trees.The differences:
self.exec(inst)read into thes_cbranch_execz/execnzarms. That doesn't change behaviour either.v_cmp's lane bool after av_cmpxthat changes EXEC. This one checks constant VCC under an EXEC of 0.AI-assisted (Claude Code). Read from the two diffs and
mainonly; nothing run.@oni-swr on GitHub · 2026-11-25 13:34 UTC · original
WARP verification + comparison with #2405
Tested: PR head
583fc17689225a0e08e3c35cc5efa2d839d05e1a, onorigin/main940d32f69b22265690a0b5a15d6ded572ba33baf(the PR is one commit on that base, so the merge was a no-op).Environment:
VICTORY_D3D12_WARP=1(software WARP), Windows 11 Pro 10.0.26200, rustc 1.98.1, DXC 1.9.0.5512 (dxcompiler), dxil.dll 1.8.2502.11 onPATH.cargo test -p victory-shader --lib --lockeddefect_test, all ignored on main too)cargo clippy -p victory-shader --all-targets --locked -- -D warningscargo xtask policyasset policy: 182 files ok, exit 0The new test
structure::tests::cbranch_vcc_tests_raw_vcc_without_exec_maskingran and passed (not skipped). I did not run it against unpatched main, so I have not shown that it fails without the fix.Diff comparison with #2405 (same file, same lines in
Lanes::branchinstructure.rs). I agree with the earlier duplicate-check comment, and I ran the code, which that comment did not:Boolis identical to #2405. This PR also moves theexec()read into theexecz/execnzarms and adds a comment explaining why VCC is not masked. That has no behavioural effect.s_mov_b32 vcc_lo, -1/0) under av_cmpx-narrowed EXEC and checksBool::TRUE. #2405 uses a per-lanev_cmpresult and checks the lane atom and its polarity, so it exercises a symbolic VCC. The two cover different cases. Either PR could take the other's test.Limits: WARP only, no physical hardware GPU, no game files or dumps. Diff reviewed in full: the only changes are in
structure.rs, with no process, network or filesystem actions.AI use: Claude Code (Claude Sonnet 5.5)
@steven-seagull27 on GitHub · 2026-11-25 13:35 UTC · original
I ran a Wave32 readback on this head (
583fc17), #2405 and their common parent. All three still split a scalar branch across lanes when VCC has only bit 0 set and a later compare narrows EXEC to lane 1. Fors_cbranch_vccnz, lane 0 stored 11 and lanes 1–31 stored 23. The scalar result should be 11 for all 32. The complementaryvcczcase was also wrong in 31/32 lanes; the zero-VCC controls matched throughout.The RTX 5080, built-in WARP and WARP 1.0.22 returned the same output arrays. I also ran this PR’s structural test on the parent, where it already passes. The test-only commit applies to either PR. Full per-opcode results and rerun instructions · Wave32 reproducer
AI-assisted with Codex. Synthetic shaders only.
@steven-seagull27 on GitHub · 2026-11-25 14:26 UTC · original
I pushed the same wave-wide branch fix based on this PR’s head. To apply it on
583fc17, run the following commands.The original mixed-lane test went from 62/128 wrong to 0/128 wrong on both the RTX 5080 and WARP 1.0.22. The RTX also matched all 872 Wave32 words in the two-wave tests. WARP 1.0.22 matched both full-wave groups (512 Wave32 words and 1,024 Wave64 words). Its 45-thread Wave32 group missed 26/360 words, which a native HLSL ballot reproduces. Its 85-thread Wave64 group returned 38, 0, 0, 0, 16 and 8 incorrect words out of 680 across six fresh processes. An optimized native HLSL shader also reproduced intermittent wrong decisions on this runtime. Built-in WARP skipped the fixed-width shaders. Full comparison and compiler limits
AI-assisted with Codex.
@Marvisak on GitHub · 2026-11-25 15:31 UTC · original
Automated triage for the maintainers.
Proposed close (no change in behaviour). As with #2405: in
crates/victory-shader/src/structure.rs,Lanes::execreturnsBool::TRUEfor an instruction that does not read EXEC, andir.rsgivess_cbranch_vccz/s_cbranch_vccnzonly a VCC read, soand(vcc, exec)was alreadyvcc; moving theexec()call into theexecz/execnzarms makes no difference either. The new testcbranch_vcc_tests_raw_vcc_without_exec_maskingpasses on the parent940d32ftoo, and the added comment describes a behaviour change this diff does not make. What is actually wrong, per the readbacks in the comments, is that the branch is decided per lane rather than once for the wave fromVCC != 0; a PR that fixes that, with a test that fails onmain, would be welcome. CI: passing.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.
Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 16:51 UTC · original
The EXEC-mask removal is right — hardware tests raw
VCC(VCCZ/VCCNZreflect the whole scalar register, and inactive lanes can hold VCC bits), so masking with EXEC can flip the branch.One level the fix doesn't reach:
s_cbranch_vcc*is uniform — the whole wave takes one path (VCCZ is a scalar flag, not per-lane). Keepingvccas a per-laneBoolstill lets the structurer treat it as divergent, which is the deeper bug #2405 fixes (scalar-mask preservation + bounded uniform counter, with Wave32/Wave64 readback tests failing on main). For triage: this is a correct partial fix; #2405 is the complete one — merging order matters for the test expectations each asserts.@zed6000 on GitHub · 2026-11-25 21:40 UTC · original
Measured offline on the title's shaders (the method in #1247): this head (
583fc17) merged onto main13f91ca(a clean merge), compared program by program overshaders.rpf1.0.2.1 with dxil.dll 1.8.2502: 0 gained, 0 lost. For comparison, #2405, which targets the sames_cbranch_vccz/vccnzsemantics, loses 1,829 programs on the same base (details there). Offline counts only; no program names or data.@zed6000 on GitHub · 2026-11-25 21:47 UTC · original
Following up for anyone picking up the wave-wide fix suggested above: steven-seagull27's
86fde8aon top of this head, merged onto13f91ca, loses 18,170 programs offline (mostly "a scalar VCC branch requiring the guest wave width": 14,095). This head alone loses none. #2405, which carries the same fix plus a per-lane fallback, loses 1,829. The breakdown is on #2405. Offline counts only; no program names or data.@steven-seagull27 on GitHub · 2026-11-26 01:20 UTC · original
Updating my earlier cherry-pick recommendation after @zed6000’s A/B. I withdraw
86fde8aas a release candidate. On the same shader archive and base, your head583fc17lost zero validated programs, my cherry-pick lost 18,170, and #2405’s revised34c7ec2lost 1,829. Changing the result from a wrong translation to an explicit refusal can be appropriate for an individual shader. These counts do establish a release cost. Same-base comparisonThe mixed-lane test still distinguishes the implementations. The raw-VCC head gave 62/128 wrong output words on my RTX 5080. The wave-wide version gave 0/128 there, and @upipibi independently got 0/128 on an RTX 3070. #2405 has taken the wave-wide commit with authorship, so I’m following up there on preserving compiler proofs. RTX 3070 readbacks
AI-assisted with Codex.
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.