Shaders: enforce inactive-lane EXEC rules for DPP16, DPP8 and ds_swizzle_b32 (port of Marvisak#1582) #845
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/845"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by Capt-Speed on 2026-11-28T07:39:08Z.
Port of
Marvisak/VIctory#1582toVIctory-NVIDIA(main@63b902f), preservingVIctory-NVIDIA's pixelquad_readfast path and extending coverage to Wave64halves, native Wave64, pixel edge rendering, and two additional cross-lane edge cases found during multi-GPU testing.Changes
EXECenforcement (crates/victory-shader/src/emit/lower.rs):src_lane_active(guard+waveActiveBallotvialane_bit_offor wave/mesh paths;quad_readofguardfor convergent pixel quads) acrossDPP16,DPP8/DPP8FI, andds_swizzle_b32.lane(select(valid, src, lane)) before issuingwaveReadLaneAt, avoiding undefined out-of-range or inactive-lane reads while still applyingbound_ctrl(0vs write-disable) andfi(fetch_inactive).halves, and 1D mesh quads.cross_lane):Err("a pixel quad read inside divergent control flow")whenself.s.pixel && quad && !all_lane_blocks(self.x.st), matchingpermlane's existing refusal pattern rather than silently reading stale neighbour values on hardware (observed failing 52/96 lit pixels on AMD Radeon Graphics before this check).all_lane_blocks == true, and convergent WQM / straight-lineguardpixel quad ops remain onquad_read.halvesdestinationrow_mask(dpp):DPP16destination row indices fromself.console_lane()instead of hostlane, so console lanes32..63map to rows2..3(row_mask = 0x4 / 0x8) instead of aliasing rows0..1. On non-halves/exchangeshaders,console_lane()returnslane_index()directly.crates/victory-shader/src/emit/crosslane_tests.rs):crosslane_testscovering Wave32 (29 cases), Wave64halves(7 cases includingrow_mask=0x4/0x8), pixel quad edge drawing (RTX + WARP), and divergent pixel quad refusal.Verification
Environment: Windows 11, NVIDIA GeForce RTX 5090 D (driver 621.14, SM 6.8, Wave 32..32), Microsoft WARP, and Windows SDK
dxil.dll1.8.2502.11.63b902f)16d9c75)DPP16(18 cases)DPP8/DPP8FI(5 cases)ds_swizzle_b32(6 cases)halves(EXEC_LO=0x55555555,EXEC_HI=0x77777777, RTX 5090 D)row_mask=0x4/0x8)ds_swizzle_b32(RTX & WARP)quad_read(+1/-1) intactDPP16 0xB1&ds_swizzle_b32 0x80B1)ShaderError::Unsupported)wave64_testsxtask repository_passes_policy --lockedcargo clippy -p victory-shader --lib --tests --locked(default &--all-features)(Pre-refusal multi-GPU cross-checks on AMD Radeon(TM) Graphics native Wave64 also moved the 5 Wave64 cases from
1/5/232/320lanes to5/5/320/320lanes, and RTX mesh quad draws moved from4/8to8/8matching quads.)Notes & Known Boundaries
crates/victory-shader/src/updates theVICTORY_TRANSLATORBLAKE3 key (victory-gpu/build.rs), so first launch with this change will re-translate cached shaders on demand under the new key (existing cache files remain intact).fi:1inside true hardware branches: Same limitation as upstreamMarvisak#1582—fi:1(DPP16 fi:1/DPP8FI) fetches inactive lanes under straight-lineguardnarrowing, whereas inside a true DXIL hardware branch (br i1) lanes that skipped the branch arm do not executewaveReadLaneAtand return undefined values per DXIL rules.Cargo.lockand workspace manifests are unchanged; no external crates added.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T07:44:44Z.
Review: APPROVED
Tested locally merged onto
main(63b902f).cargo xtask policypassed (295 files ok).cargo test -p victory-shader --lib emit::crosslane_tests::passed (8 passed; 0 failed, verifying DPP16/DPP8/DPP8FI/ds_swizzle_b32 inactive-lane EXEC rules, Wave64 halves, and pixel-quad edge/guarded swizzle behavior on GPU).cargo test -p victory-shader --lib emit::lower::tests::passed (15 passed; 0 failed; 1 ignored).cargo test -p victory-shader --lib emit::tests::passed (22 passed; 0 failed; 1 ignored).cargo clippy -p victory-shader --lib -- -D warningspassed with 0 warnings.Thorough RDNA2 cross-lane inactive-source EXEC semantics with strong GPU execution coverage. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Aniseto on 2026-11-28T07:50:19Z.
Ran the cross-lane inactive-lane tests at
16d9c75on 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.All eight
emit::crosslane_testspass on a real 32-lane adapter, including thedpp16,dpp8/dpp8fiandds_swizzle_b32inactive-source cases. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti. Native wave64 and pixel-quad refusal paths were not exercised by this filter.Not tested: native wave64 hosts, the pixel quad reads in divergent control flow, a paired smoke run, the full workspace suite, AMD and Intel GPUs, 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 trustno1-coder/VIctory-NVIDIA. Originally posted by upipibi on 2026-11-28T21:14:31Z.
Tested on Ampere: RTX 3070 (
10de:2484), driver 616.56, native Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile. The system WARP is the one that ships with Windows.16d9c75c8, merged onto main923e38cc8(--no-ff, clean, no conflicts). The PR's base is63b902f, 264 commits behind main. The merge changes the same three files by the same amounts as the PR:crosslane_tests.rs+1543,lower.rs+126/-23,mod.rs+2. The head was still16d9c75c8when I finished.Ampere shows the bug on main, and the PR fixes it. On main's
lower.rsthe 3070 fails the same Wave32 cases as the 5090 D in the description: DPP16 6/18, DPP8/DPP8FI 3/5,ds_swizzle_b322/6, 11/29 in all. With the PR, the 3070 passes 29/29, and the wave64halvescases pass 7/7 (448/448 lanes).The tests
VICTORY_WARP=1, 3 runs: 8 passed, 0 failed, 0 ignored each (0.25 s). Four of these eight passes check nothing. See below.What each of the 8 tests does:
cpu_reference_oracle_boundary_checksdivergent_pixel_quad_reads_are_reported_as_unsupportedpixel_quad_swizzle_and_dpp_validate_and_create_pipelinehardwarethenwarp; no drawdpp16_inactive_source_and_bound_ctrl_match_rdna2_on_gpudpp8_and_dpp8fi_inactive_source_match_rdna2_on_gpuds_swizzle_b32_inactive_source_returns_zero_on_gpuwave64_halves_dpp_and_swizzle_match_rdna2_on_gpupixel_quad_edge_dpp_and_guarded_swizzle_match_on_gpuhardware, then onwarpThe four compute tests call
wave32_hardware_info. It returnsNonefor an adapter with the software flag, or one without a 32-lane wave size, and then the test printshardware device does not support 32-lane waves; skippedand passes. WithVICTORY_WARP=1,Host::new(false)opens WARP, so all 29 Wave32 cases and the wave64 test skip:The same thing happens on any runner without a 32-lane card. So only the pixel edge test gives WARP data.
Adapters seen
For one run of each setting, I added a temporary
eprintln!. It resolvesdevice.GetAdapterLuid()throughEnumAdapterByLuidand printsGetDesc1andWaveLaneCountMin/Maxat every device the tests open. I removed it afterwards.hardware10de:24840x0warp1414:008c0x2(software)VICTORY_WARP=1hardwareincluded1414:008c0x2(software)The wave64 test prints its own adapter line:
NVIDIA GeForce RTX 3070 | SM=0x68 | Wave=32-32 | RT=D3D12_RAYTRACING_TIER(12) | Mesh=D3D12_MESH_SHADER_TIER(10). In theVICTORY_WARP=1runs, the pixel edge test'son hardwareline is WARP too.With the PR, every run gave
[PASS]for each of the 18 + 5 + 6 Wave32 cases and the 7 wave64 cases (64/64 lanes) on the 3070. The pixel edge test printed96 lit texelson hardware and on WARP.Negative control: main's
lower.rs, PR's testsgit checkout 923e38cc8 -- crates/victory-shader/src/emit/lower.rs.git diff --stat 923e38cc8 -- crates/:crosslane_tests.rsandmod.rsonly (the tests, plus my temporary prints). It builds, with the same single warning as main.VICTORY_WARP=1, 3 runs: 6 passed, 2 failed, 0 ignored each. Four of the six passes are the skips described above.All six runs gave the same values.
VICTORY_WARP=1)cpu_reference_oracle_boundary_checkspixel_quad_swizzle_and_dpp_validate_and_create_pipelinedpp16_...dpp8_and_dpp8fi_...ds_swizzle_b32_...wave64_halves_...pixel_quad_edge_...divergent_pixel_quad_reads_are_reported_as_unsupportedThe failing Wave32 cases on the 3070, as the test prints them (first wrong lane):
0x10010004/0x000100020x10010004/0xdead00020x00010002/0xdead00020x10000004/0xdead00020x10010006/0x000100020x10000010/0xdead00000x10000004/0x000000000x00000000/0xdead00000x10000010/0x000000000x10000008/0xdead00000x00010008/0xdead00080x10010006/0x000100020x10000004/0x000000000x10010006/0x000100020x10000002/0x000000000x10000004/0x000000000x10000004/0x000000000x10000004/0x00000000The six DPP16 cases that pass on main are the three
fi:1cases, the twobranchedcases withbc:1, and the full-EXECbank_maskcase. DPP8 andds_swizzlealso pass theirfi:1andbranchedcases. Thefi:0cases on main read the inactive source lane's value. RDNA2 gives0(bound_ctrl:1/ds_swizzle) or keeps the oldvdst(0xdead....,bound_ctrl:0) instead.wave64_halves_...stops at its first wrong lane (crosslane_tests.rs:1320):wave64 halves dpp16 row_shr:1 bc:0 fi:0: lane 2 got 0x10010004 want 0xdead0002. I replaced the assert with a count and ran it once more on main's code, then put it back. The 3070 then gave 1/7 cases and 336/448 lanes right:0x10010004/0xdead00020x10010004/0x000100020xdead0020/0x000100200xdead0030/0x000100300x10000002/0x000000000x10000002/0x00000000The two
row_maskcases are wrong only in the upper half, which keeps the oldvdstin rows 2 and 3. That is the row-aliasing the PR fixes withconsole_lane(). The description's main baseline is "1/5 (232/320 lanes)" on a 5090 D. It used a different set of cases, so I can't compare the numbers directly.pixel_quad_edge_...panics atcrosslane_tests.rs:1547withhardware: texel (0, 0) guarded quad swizzle got 1.5, want 0. In a default run that leg is the 3070, and the WARP leg never runs. With a count in place of the assert, one more run on main's code gave the same result on both adapters: 96 lit, 0 wrong unguardeddx, 52 wrong guarded. All 52 are even-x texels (want0). They returned 1.5 (15), 3.5 (13), 5.5 (10), 7.5 (7), 9.5 (5) and 11.5 (2). That matches the description's "52/96 wrong" on RTX and WARP.divergent_pixel_quad_reads_are_reported_as_unsupportednever opens a device. It panics atcrosslane_tests.rs:1442withexpected Unsupported at offset 56, got Ok(HostShader { stage: Ps, ..., because main lowers the divergent quad read without an error. Its result says nothing about the card.cargo test -p victory-shader --lib --locked(default, once each)923e38cc8: 356 passed, 0 failed, 8 ignored (268 s).923e38cc8: 348 passed, 0 failed, 8 ignored (292 s).The PR adds no compiler warnings. The one warning in both builds, unused
colour, is main's (lower.rs:13896on main,:13999on the merge).CI
gh pr checks 845: no checks reported on the branch. I did not run clippy.Overlap
VICTORY_WAVE_PAIRS=1) makes the samerow_maskrow-index change, but only whenself.twin.is_some():let row_lane = if self.twin.is_some() { self.console_lane() } else { lane };#845 uses
self.console_lane()unconditionally.git merge-treeof the two heads has exactly one conflict, this line inlower.rs. It is a mechanical conflict. I did not check whether #845's form covers #348's paired form; that is a hypothesis.row_mirrortests and talks about DPP within 32 lanes.git merge-treewith #845 is clean.Not tested
fi:1inside a real DXIL branch (the known limit in the description).VICTORY_SHADER_OPT, clippy, the release build, and the rest of the workspace.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.