Repository navigation
Conversation
…he mask is not zero A bitwise SALU operation that writes a lane mask (s_and_b32 of a compare and EXEC, s_not_b32 of one) sets SCC to whether its result is not zero. A branch on that SCC already lowers, as the lane's own bit; but sop() refuses every operation writing a mask and marks its SCC "a lane mask read as data" too, so an instruction reading the SCC as data was refused. The console compiler's bounded poll loops read it so: an s_cselect of "some lane is set", combined with an iteration limit, then s_cbranch_scc0 back. Four compute passes of the title's FidelityFX upscaler wait in such loops. In compute programs, where a mask's number is the console's, an SCC of such an operation that an instruction other than a branch reads is now the mask's number (both dwords in wave64) tested for zero, taken where the operation runs; the mask itself stays a mask. Such a program declares the console's wave size, as programs reading a mask as a number already do. Vertex, pixel and mesh programs keep the refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).
- Lowering SCC from a lane-mask operation read as data to wave-any non-zero (across both dwords for wave64) passes cleanly on both RTX 5090 and WARP.
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).
|
Ran the wave32 mask-SCC test at 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 The test passes on the real adapter with native 32-lane waves. The PR also adds 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
left a comment
There was a problem hiding this comment.
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), and crates/victory-shader/src/emit/lower.rs stays under the 512 KiB ceiling at 523,600 bytes.
However, there are two P1 semantic bugs where newly accepted shaders silently diverge from RDNA2 ISA (previously rejected with Err(LANE_MASK)):
- Partial-wave dispatch + bitwise complement/negation flips
SCCfrom1to0:
Incrates/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. - Same
SCCread both as data and bys_cbranch_scc*disagrees across lanes:
Ifs_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 an SCC in mask_sccs is consistent—unified as wave-wide nonzero or rejected rather than silently splitting the wave—and handle partial waves / active classification cleanly for complements). Non-blocking P2 notes: phi joins before an SCC data read, s_wqm_b32/b64 / *saveexec producers, and SCC escaping a whole-wave section are also not yet handled.
|
Hardware verification on Intel (Xe-LPG), 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
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 ( No game files. AI-assisted (Claude). |
|
I combined this exact head 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 With the identical fixture, #3402 alone stops at The merge retains both parent commits and both sets of tests. It moves the mask-SCC helpers to keep |
|
@Lyrnc 15057a5 is a follow-up directly on 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 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. |
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 Shader tests: heap_direct_texture_reads_mark_their_heap_index kills the test process on a real GPU (RTX 5070, main 67e8ae1) #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. Shaders: one lane of a whole-wave section's value, read 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