Shader: branch-only SCC from s_and_b32/b64 VCC & EXEC chooses a different arm per lane #3491
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#3491
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@steven-seagull27 on GitHub · 2026-11-27 09:43 UTC · original
On official main
63bcca43,s_and_b32/b64 s18, vcc, execfollowed directly bys_cbranch_scc0/1makes each active lane choose its own branch. The scalar AND sets SCC when any bit of its result is set, so all active lanes of that console wave should take the same arm. These programs compile, validate, and dispatch.For example, in one console Wave64 group, lanes 0–47 are active and the comparison matches only lane 37. The chosen arm writes
2and the other arm writes1. Both adapters returned2only at lane 37 and1at the other 47 active lanes. All 48 should contain2. Lanes 48–63 correctly kept their initial zero.Results
Each cell gives incorrect output dwords over nine dispatches. Each invocation has its own in-bounds dword. The three GFX variants use SCC exclusively as a branch condition. The DXC control computes the group-wide decision with groupshared memory and writes only for active lanes.
s_cbranch_scc0, one common stores_cbranch_scc0, store in each arms_cbranch_scc1, store in each armThe RTX 5080 used driver
32.0.16.2140and reports 32–32 physical wave lanes. App-local x64 WARP1.0.22.0reports 4–128. For these specific programs main emits 32 or 64 threads per group with no fixed host wave size. The RTX therefore executed the 64-thread case on two physical 32-lane waves. The selected WARP wave width was not instrumented. DXC disassembly of the translated stores shows a direct branch onselected == threadIdInGroup, with no reduction across active lanes.Reproduce
The test-only commit adds hand-written GFX10 instructions and a separate PC HLSL control. The synthetic sources and full nine-case matrix are in b803d16.
The test locates PC DXC in the Windows SDK, or accepts its path through
VICTORY_PC_DXC. It prints the control and each variant before failing the final assertion on this revision. For the same portable WARP run, usecargo test --locked -p victory-shader --lib --no-runto locate the test executable. Put a copy in its own directory beside the x64d3d10warp.dllfrom WARP 1.0.22, set$env:VICTORY_WARP = "1", and launch that copy withmask_branch_repro --ignored --nocapture --test-threads=1.Relation to existing work
Lyrnc’s #3401 handles mask SCC consumed as scalar data. The review and andrewpozdnakov7-jpg’s follow-up address a definition used as both data and branch condition. The six branch-only outputs here were byte-identical across main, #3401 at
d9ed3138, and the follow-up at15057a5b. I also compared #233 at87d1f423with a 32–32 target and #2633 at706c006cwithhost_wave32enabled. Both emitted the same six bytecodes for these programs.The synthetic cases build on DoubleGhosty’s SCC fix and the branch-arm store regression in that fork. Its cross-half lowering differs from official main. On official main the failure here is the wrong value in active lanes. Across this matrix there were zero unexpected writes to inactive lanes.
github-bot referenced this issue2026-11-27 10:43:12 +00:00
@steven-seagull27 on GitHub · 2026-11-27 10:44 UTC · original
I have a source-only fix for the branch-only case in this issue on top of #233 at
87d1f42. It selects the existing whole-wave control flow when an eligible one-wave compute group branches on the scalar condition from a native-widthVCC & EXEC. The selection excludes mixed-use conditions and multiwave groups. Commit 79c6a98The original synthetic reproducer covers three branch variants. Results below are incorrect 32-bit outputs per variant. All three produced the same counts, and all inactive-lane sentinels remained intact.
Both DXC controls passed. The added source tests cover a partially active mask, a match inside or outside that mask, and exclusions for multiwave groups and a scalar-data consumer. Strict shader Clippy and the repository policy check passed.
The commit uses the control-flow implementation in #233. To apply it on that PR’s branch:
AI-assisted with Codex.
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 11:16 UTC · original
Independent WARP run of the test in this issue, to go with the source-only fix above.
Setup: app-local WARP SM 6.6 (
D3D12Core1.620.2,d3d10warp1.0.22), PC DXC 1.9.2609,--test-threads=1. The test is Steven's, kept with authorship (cde6aa2); no game data, synthetic only.63bcca4#320960b3e1Target { 32, 32 }, no console flow#320960b3e1lower.rs)#320960b3e1So forcing the 32-lane split changes nothing, while the existing whole-wave control flow gets every case right: a test-only
wants_console_flowoverride makes all six translated variants agree with the DXC reference, with no inactive-lane writes.That matches the approach in
79c6a98(select the whole-wave path when a one-wave compute group branches on a native-widthVCC & EXEC). The override is a diagnostic in a local tree, not a proposed fix; I have not run79c6a98itself here.@steven-seagull27 if it helps, I can run the same matrix against
79c6a98on WARP and report what it gives for these 840 cells.