Shaders: return zero for inactive compute swizzle sources (port of upstream VIctory #1416) #1030
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1030
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1030"
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?
@Moon0755 on GitHub · 2026-11-25 16:45 UTC · original
Moon0755:fix/ds-swizzle-inactive-lanes→main· +86 −0 · 2 files · 1 commits · openPorts upstream Marvisak/VIctory#1416 (
EatCodeSleep2), scoped to native compute waves (self.s.mesh.is_none() && self.exchange.is_none()) so mesh shaders and split wave64-exchange compute paths are unaffected.Problem
On RDNA2 / Xbox Series X,
ds_swizzle_b32returns0when the selected source lane is masked off byEXECor absent from the workgroup tail. Previously,Lower::dsloweredds_swizzle_b32directly toself.read_lane(x, src)(WaveReadLaneAt), which returns undefined / stale data (such as0xdeadbeef) when the source lane is inactive or out of bounds.What changed
crates/victory-shader/src/emit/lower.rs:Lower::lane_bit_atout ofLower::lane_bit.ds_swizzle_b32for native compute waves (self.s.threads.is_some() && self.s.mesh.is_none() && self.exchange.is_none()), ballot the instructionguardviadx.op.waveActiveBallot, test the selectedsrclane bit withlane_bit_at, redirect inactive reads to the current lane soWaveReadLaneAtstays well-defined, and select0when the source lane is inactive.crates/victory-shader/src/emit/valu_tests.rs(ds_swizzle_reads_only_active_compute_lanes):0x041f) and quad-mode (0x80b1) swizzles across 1-thread (absent source lane) and 2-thread (v_cmpx-masked and active) workgroups. All 5 shaders are lowered and validated viadxil.dll; execution runs on SM 6.6 hardware adapters and skips cleanly on WARP where fixedWaveSize(32)is unsupported (E_INVALIDARG).Verification
Verified on Windows (
windows-latest+dxil.dll) via a temporary scoped CI branch on the fork:cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings: passedcargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings: passedcargo test -p victory-shader -p xtask --locked -- --nocapture:victory-shader216 passed; 0 failed; 3 ignored(test emit::valu_tests::ds_swizzle_reads_only_active_compute_lanes ... ok, all 5 shaders validated viadxil.dll; WARP skippedWaveSize(32)compute pipeline creation as expected);xtask4 passed; 0 failed(includingrepository_passes_policy).Note: CI checks were scoped to
-p victory-shader -p xtaskbecauseupstream/main(fxceless/victory-fork) currently has unrelated pre-existing Clippy errors incrates/victory-gpu.— Neon
@HAL9000RELOADED on GitHub · 2026-11-25 18:00 UTC · original
A hardware run of the new tests of nine upstream ports by the same author: this one and #948, #951, #957, #1019, #1026, #1036, #1040, #1042. Until now they had run only on WARP in CI. As far as the descriptions show, this PR's test had not run anywhere yet, because WARP skips it (fixed
WaveSize(32)). The table is kept here, and each of the other eight links to it.Setup
main0b0074e+ #402 + the stack-headroom test fix from Marvisak/VIctory#742; thencargo test -p victory-shader --lib, and each new test with--nocapture.vop3_unsigned_add_sub_clampsigned_scalar_add_sub_scc_matches_rdna2image_resinfo_returns_zero_depth_for_a_2d_viewtyped_float_loads_preserve_nan_bitslegacy_mad_fuses_its_product_and_flushes_its_sourcesds_swizzle_reads_only_active_compute_lanesWaveSize(32))cmp16_ignores_op_sel_as_rdna2_does,cmp16_sdwa_preserves_word_selectsv_div_fixup_f16_follows_the_isa_special_casesv_pk_int16_clamp_saturates_as_rdna2Regressions: none. victory-shader gives 215 passed on the base and 216 passed (217 for #1036, which adds two tests) with each PR, 0 failed.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.