Shaders: the SCC of a lane-mask operation, read as data, is whether the mask is not zero #3401
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T22:25:16Z.
What 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
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:27:57Z.
Review: APPROVED
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).
Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-26T22:39:50Z.
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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:47:14Z.
Review: CHANGES_REQUESTED
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.Imported from Marvisak/VIctory. Originally posted by zzm1234560621-prog on 2026-11-27T00:16:12Z.
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).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T00:20:09Z.
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.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T06:56:49Z.
@Lyrnc 15057a5 is a follow-up directly on
d9ed313for the two blocking SCC observations.With a 16-thread group in Wave32, the original produced SCC=0 in all 16 results after complementing VCC. The patch reconstructs the numeric mask on a partial wave and all 16 results show SCC=1. It also rejects the case where the same mask SCC is consumed as scalar data and as a branch condition, so the same SSA value cannot take different meanings. Both focused regressions and strict shader Clippy (default and all features) passed.
If you take the patch, please retain Git authorship when cherry-picking or rebasing. If folded into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted with Codex. Synthetic shaders only.
I also resolved the test-file overlap and the shader file-size limit in c75cc68, which combines the two reviewed follow-ups. Both SCC regressions and both section-lane tests passed in the combined app-local WARP build.
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-27T13:01:17Z.
@andrewpozdnakov7-jpg thanks, taken as is:
15057a5is now on this branch with your authorship, as a fast-forward ofd9ed313. On an RTX 5080 (610.88), both mask-SCC tests pass (mask_operation_scc_read_as_data_is_the_waves_any_on_gpuandwave64_mask_operation_scc_reads_both_dwords), andcargo clippy -p victory-shader --lib --tests -- -D warningsis clean.Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T13:33:23Z.
AMD run: RX 5700 XT (RDNA1, 32–64 lanes, so the 64-lane cases run instead of being "lowered and validated only"), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Each tree was merged onto
main63bcca4and run on the native adapter (VICTORY_WARPunset), no game files. Head15057a5.wave64_mask_operation_scc_reads_both_dwordsdispatched and passed on 64-lane hardware, both cases (lanes above 40 and above 63, which put the mask in the high dword). The RTX 5080 run above is 32-lane only, so this is the first time it ran rather than only being validated.mask_operation_scc_read_as_data_is_the_waves_any_on_gpu: 5 passed, 0 failed.complement_sets_mask_scc_even_in_a_partial_waveanda_mask_scc_used_as_data_and_branch_is_rejectedpass.crosslane: 9 passed, 0 failed. DPP16 18/18, DPP8/DPP8FI 5/5,ds_swizzle_b326/6.victory-shadersuite (--features host): 306 passed, 0 failed, 3 ignored.cargo clippy -p victory-shader --all-targets --features host -- -D warnings: clean.ff81029(this PR atd9ed313+ #3402 atd1158c9) passes too: 308 passed, 0 failed, and both 64-lane tests dispatch. Results are on #3402.AI use: Claude Code (Claude Opus 5.5).
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T22:12:26Z.
Verified on AMD Radeon 780M (RDNA3, wave32 + wave64, Windows 11) at
15057a5, before/after with this PR's four new tests:63bcca4+ this PR's tests15057a5mask_operation_scc_read_as_data_is_the_waves_any_on_gpuwave64_mask_operation_scc_reads_both_dwordscomplement_sets_mask_scc_even_in_a_partial_wavea_mask_scc_used_as_data_and_branch_is_rejectedSo 4/4 wrong → 0, and all 9
emit::crosslane_testspass. The wave64 case was only lowered and validated on the RTX 5090; here it ran natively on 64 lanes and both dwords gave the right SCC (lanes above 40 → 1, above 63 → 2). Both of fuzeofficlal's P1 cases are covered on AMD: the partial-wave complement keeps SCC = 1, and an SCC read as both data and branch is refused instead of splitting the wave.AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T13:35:05Z.
Follow-up to my 780M run above: this PR and #385 both change the console-lanes decision in
Lower::new, so they conflict. #385 moves the condition intophi::mask_uses_console_lanes, this PR addsconsole_lanes |= !mask_sccs.is_empty()after it. Resolved by keeping #385's call and adding this PR's line right after it, plus bothletlines above (rowsfrom #2398,mask_sccsfrom here).Branch
kilolimaVI/VIctoryintegration/shader-10(9dd3e7c) = main + #3097, #2999, #3617, #3717, #1315, #3716, #2398, #385, #1262 and this. On the Radeon 780M:emit::crosslane_tests, whole victory-shader lib 354 passed / 0 failed / 3 ignored, victory-gpu (diagnostics) 246 passed, rest of the workspace, both clippy configurations and the asset policy passAI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-29T14:12:23Z.
A corpus measurement for this PR: the four "a lane mask read as data" refusals are unchanged with it applied
I reran the shader census on
kilolimaVI/VIctoryintegration/shader-10(9dd3e7c3), which has this PR in it, with the same command and counting rule I posted in #201:main63bcca43integration/shader-10Same four programs, same offsets:
So the SCC-of-a-lane-mask-operation shape this PR fixes is not the shape these four hit: they consume the mask itself as data. That is said as information, not as a complaint about the PR — it just means these four are still on the table for someone, and picking this PR expecting them to go is not going to work.
What it does not say: anything about the 780M, wave32, wave64 or the tests. My number is a translation census on one machine.
Written with an AI assistant.
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-29T18:48:22Z.
@kilolimaVI RDNA1 row for
integration/shader-10(9dd3e7c): RX 5700 XT (Navi 10, wave32 + wave64, driver 32.0.21045.29003), Windows 11 26200.victory-shader --lib --features host: 354 passed, 0 failed, 3 ignored. That's the same count as on your 780M, and no GPU test was skipped for a missing wave size, since this card runs both.tracing_attributes) partway through, so those numbers would be incomplete, not failures.AI use: Claude Code (Claude Opus 5.5).
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.