Shaders: the SCC of a lane-mask operation, read as data, is whether the mask is not zero #3401
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!3401
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3401"
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?
@Lyrnc on GitHub · 2026-11-26 22:25 UTC · original
Lyrnc:fix/mask-op-scc-as-data→main· +339 −0 · 2 files · 1 commits · openWhat was refused
Four compute programs of the title's FidelityFX upscaler DLL (
amd_fidelityfx_upscaler_xbox.dll) stop withemit: a lane mask read as data:8e614708143ef917(wave32),17af85f170e66f30,477b52e73ddeb6f2,8b437ab61d8008fe(wave64). They are four of the six untranslated passes of the title's own upscaler that theREADME lists under Series S.
Each waits in a bounded poll loop whose exit test reads the SCC of a lane-mask operation as data. The shape,
as this PR's test writes it:
sop()refuses every SALU instruction that writes a lane mask, and the refusal marks all it writes, its SCCtoo, as
a lane mask read as data. A branch on such an SCC already lowers (it is the lane's own bit,structure'sscc_lane), but nothing resolved an SCC that another instruction reads as data, so thes_cselectcarried the refusal on to the loop's branch.What changed
emit/lower.rs:mask_sccs_read_as_datafinds the SCC values of bitwise operations (s_and/or/xor/andn2/orn2/nand/nor/xnor/not,32 and 64 bit) that write a lane mask and no EXEC, read by an instruction other than an
s_cbranch.sop(), such an operation in a compute program (MaskData::Console: host lane n is console lane n) setsits SCC to the mask's number tested for zero (
mask_nonzero:mask_dword's ballot, or its exact number for amask holding lanes elsewhere such as a complement; both dwords in wave64), taken where the operation runs. The
mask itself stays a mask, read as a number where it is read, as before. Vertex, pixel and mesh programs keep
the refusal (their ballots are over the host's wave).
The ISA rule (
SCC = D != 0over the whole register, the lanes outside EXEC included) was checked on RDNA2hardware (below).
Tests
emit/crosslane_tests.rs, hand-encoded words:mask_operation_scc_read_as_data_is_the_waves_any_on_gpu(wave32, 32 lanes, hardware adapter; skipped where32-lane waves are not available):
s_and_b32of a compare with some lanes set / none set;s_not_b32of amask set in every running lane under a branch on the even lanes (the odd lanes' bits make it not zero);
s_andn2_b32of EXEC and that mask (zero); and a poll loop of the shape above that must leave at the samecount in every lane. Each
s_cselectresult is checked in all 32 lanes, so a lowering that used the lane'sown bit fails.
wave64_mask_operation_scc_reads_both_dwords: a wave64 program whose mask is set only in the high dword (andone with no lane set); lowered and validated everywhere, run where the host has 64-lane waves.
Results:
validated (no 64-lane waves on NVIDIA).
the wave64 program dispatched on 64-lane waves.
lower.rsfrom main) both fail at lowering witha lane mask read as data.sequences (
s_and_b32of a compare with and without lanes set,s_not_b32ands_andn2_b32under anarrowed EXEC, the poll loop; wave64
s_and_b64with only high-dword lanes set, none set, low-dword lanesset) read through
s_cselect_b32: 0 differences from SCC = (result != 0) over the whole register.cargo clippy -p victory-shader --lib --tests -- -D warnings: clean.cargo xtask policy: 191 files ok.cargo test -p victory-shader --lib -- --test-threads=1on the RTX 5080, skippingheap_direct_texture_reads_mark_their_heap_index(it kills the test process on this machine, as #2571 reports):300 passed, 3 failed, 3 ignored. The three (
stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on main63bcca4here.Census (offline, the title's shader pack, exe and DLLs)
translate --list --validateovershaders.rpf, the executable,XboxBvhBuilder.dllandamd_fidelityfx_upscaler_xbox.dll, validator dxc 1.9.2609dxil.dll, main63bcca4against this branch,compared program by program:
63bcca48e614708143ef917(wave32) now validates.17af85f170e66f30,477b52e73ddeb6f2,8b437ab61d8008fe(wave64) get past this refusal and stop at the nextone,
a whole-wave section step the simulation does not follow: their wave OR reduction finishes in the highhalf and is read at lane 63 after the section. #3402
handles that; with both, all four validate (24,937 -> 24,941 programs validated, compute 1,985 -> 1,989, nothing else changes).
DXIL compared by hash).
This touches the same lines of
sop()as #3016 (the SCC of a waterfall loop'ss_andn2_wrexec), which fixesthe other four
a lane mask read as dataprograms of the pack (827b309e779552d7,82a2ad6d07417d36,90a0692af4320129,9ffcaff533995118); the two changes are independent and combine by hand.Not tested
VICTORY_FIDELITYFX_DIR, and thegame was not started.
WaveSize(64)compute pipelinewhatever this change does.
AI use: Claude Code (Claude Opus 5.5) found the refusal in the offline census, wrote the change, the tests and
this text, and ran the checks on our machine; Lyrnc reviews what goes out. No game data is included (hashes,
counts and error text only; the snippet above is the test's, written by hand).
🤖 Generated with Claude Code
@Dukestar69 on GitHub · 2026-11-26 22:27 UTC · original · approved these changes
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1: 7 passed, 0 failed on RTX 5090 and 7 passed, 0 failed onVICTORY_WARP=1(mask_operation_scc_read_as_data_is_the_waves_any_on_gpuandwave64_mask_operation_scc_reads_both_dwords).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).
@Aniseto on GitHub · 2026-11-26 22:39 UTC · original
Ran the wave32 mask-SCC test at
d9ed313on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.The test passes on the real adapter with native 32-lane waves. The PR also adds
wave64_mask_operation_scc_reads_both_dwords, which I did not run here: this card cannot dispatch aWaveSize(64)pipeline. The thread has no comments yet; the author ran the same test on an RTX 5080, so this adds a second NVIDIA part with driver 32.0.16.2124.Not tested: the wave64 GPU path, the title's FidelityFX shaders, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
@fuzeofficlal on GitHub · 2026-11-26 22:47 UTC · original · requested changes
Good catch on
s_cselect/ scalar polling loops using the SCC of bitwise lane-mask instructions. The existing test suite passes (40/40 on both RTX 5090 and WARP, with all 5 Wave32 cases running on RTX 5090 and the Wave64 case passing DXIL validation), andcrates/victory-shader/src/emit/lower.rsstays under the 512 KiB ceiling at523,600bytes.However, there are two P1 semantic bugs where newly accepted shaders silently diverge from RDNA2 ISA (previously rejected with
Err(LANE_MASK)):SCCfrom1to0:In
crates/victory-shader/src/structure.rs:703-710, entryEXECis modeled asBool::TRUE. Becauseimplies(m, Bool::TRUE)is always true atstructure.rs:1198, an operation likes_not_b32 s20, vcc_loin the entry block markss20inself.active. On a partial wave (e.g., 16 threads in Wave32 or 32 in Wave64) where every running lane setsvcc, natives20is0xFFFF_0000(SCC = 1), yetlower.rs:1874skipsmask_numberbecauses20is inactiveand runswaveActiveBallot(!vcc)over only the active host lanes, returning0and turningSCCinto0.SCCread both as data and bys_cbranch_scc*disagrees across lanes:If
s_and_b32 s20, vcc_lo, exec_lo(say only lane 0 set under fullEXEC) has itsSCCread bys_cselect_b32 s21, 1, 2and then branched on bys_cbranch_scc1on the same SSASCCvalue,lower.rs:454+lower.rs:3648gives_cselectthe wave-wide bit (1in all lanes), whilestructure.rs:1204/structure.rs:1368andlower.rs:10248still branch per-lane usingscc_lane(taking the branch only in lane 0 instead of the whole wave). (The loop test atcrosslane_tests.rs:1122-1142missed this because the branch ands_cselectconsume differentSCCdefinitions.)Please address both cases (ensure
s_cbranch_scc*on anSCCinmask_sccsis consistent—unified as wave-widenonzeroor rejected rather than silently splitting the wave—and handle partial waves /activeclassification cleanly for complements). Non-blocking P2 notes: phi joins before anSCCdata read,s_wqm_b32/b64/*saveexecproducers, andSCCescaping a whole-wave section are also not yet handled.@zzm1234560621-prog on GitHub · 2026-11-27 00:16 UTC · original
Hardware verification on Intel (Xe-LPG),
d9ed313on top of63bcca4:Full suite on the same head: 297 passed, 7 failed, 3 ignored — and every one of the seven is the set this adapter already fails on unmodified
63bcca4(documented in #3196: three BVH tests one ULP off from this driver's reassociation,arithmetic_matches_the_hardwareand the MAD signed zero which #3212 fixes,image_atomics_of_64_bitsand the view-heap test which #3203 and #3178 cover, andfspx_…dot_products). So the PR adds no failure here, and the two extra passes over the 295 the baseline has are its own tests.cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.On the shape itself: reading the SCC of a mask-producing scalar op as data is a good catch, and it is a different question from the one I assumed on #3253 — there the missing value was the mask (
s_and_b32/s_cmpwriting EXEC/SCC) and I argued for materialising at the use site; here the SCC is a scalar "any lane", so it belongs at the write, where you put it. I have said so on #3253 so the two do not get confused.No game files. AI-assisted (Claude).
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 00:20 UTC · original
I combined this exact head
d9ed313with #3402 atd1158c9and published the tested merge and Wave64 regression.The regression runs the two patterns in a single synthetic shader. The first true comparison is in lane 63 on iteration 2 of a bounded poll. The shader then performs the whole-wave OR and reads lane 63 after restoring EXEC. Readback must contain
0x55555557in the 32 participating lanes and the original sentinel 7 in the other 32.With the identical fixture, #3402 alone stops at
a lane mask read as dataand #3401 alone stops ata whole-wave section step the simulation does not follow. The combined branch validated and dispatched the Wave64 shader in three fresh WARP 1.0.22 processes, with all 64 words matching each time. The cross-lane and wave suites reported 18 passed. This WARP runtime skipped Wave32 dispatches. Strict clippy with default and all features and the 192-file asset-policy check passed.The merge retains both parent commits and both sets of tests. It moves the mask-SCC helpers to keep
lower.rsbelow the size limit. Maintainers can use the composition when ordering the two PRs. If folding the new regression into another commit, please retain the Git author or addCo-authored-by: andrewpozdnakov7-jpg.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.