Skip to content

SHADER-678: ds_swizzle_b32 gives 0 for a source lane that is off in EXEC - #5266

Open
undeadhuman37 wants to merge 1 commit into
ItsNotRexed:mainfrom
undeadhuman37:shader-678-swizzle-exec
Open

undeadhuman37 wants to merge 1 commit into
ItsNotRexed:mainfrom
undeadhuman37:shader-678-swizzle-exec

Conversation

@undeadhuman37

Copy link
Copy Markdown
Contributor

Item: SHADER-678 (claimed in #5256; finding from #3381).

ds_swizzle_b32 shuffled the register of a source lane that is off in EXEC; RDNA2 returns 0 there, as for ds_bpermute. swizzle() now calls g_shuffle(..., zero_inactive=True); the native (non-emulated) path of g_shuffle got the same ballot/mask scheme ds_bpermute_b32 uses. The emulated path already supported zero_inactive.

Depends on: none.

Tested: new tests/semantic/test_ds_swizzle_exec.py (SWAP and BITMASK_PERM under EXEC masks, run in the mini interpreter); 2 of 3 cases fail without the change, all pass with it. compileall ok. Full semantic suite was still running when opened. CPU only, not GPU-checked (no GPU/driver used). docs/design.md updated.

AI-assisted.

🤖 Generated with Claude Code

…EXEC

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Kev-Ball

Copy link
Copy Markdown

The branch starts from ec8ec4c9. Since that revision, #2780 (SHADER-503) merged the inactive-source fix in 4ec15a3f, which is an ancestor of current main 3faac557.

I copied only this PR’s tests/semantic/test_ds_swizzle_exec.py onto clean 3faac557, leaving the translator and interpreter from main, then ran python -I -m unittest discover -s tests/semantic -p test_ds_swizzle_exec.py -v. All three tests passed, including both bitmask subcases and the even-lane swap. That accounts for the difference from the two failures on the branch’s older baseline.

The new test file is absent on main, so a tests-only change would retain the explicit compute regressions if desired. For a further translator change, a case that still fails on current main would identify the remaining gap.

AI-assisted. CPU interpreter, synthetic inputs.

@CryingLaughing

Copy link
Copy Markdown
Contributor

RTX 4080 hardware A/B for the masked-source swizzle, extending the CPU result above. Windows 11, NVIDIA 621.01, Khronos validation 1.4.357.

The same synthetic SWAP and BITMASK_PERM inputs cover inactive sources, inactive destinations, and full-EXEC controls. On native wave32, the parent ec8ec4c9 differed from the expected result at 17/128 words. With wave64 emulated on 32 lanes, it differed at 34/256 words.

Both this PR (ec628ee3) and current main (3faac557) matched 128/128 and 256/256 words, and their GPU dumps were byte-identical for each mode. This confirms #2780 already covers the reported behavior on current main. All six modules passed spirv-val and the runs emitted no Vulkan validation warnings or errors. Synthetic inputs only. AI-assisted with Codex.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head ec628ee39. The fix is already on main; do not merge.

  • Branch (ec628ee39, base ec8ec4c9): python tests/semantic/test_ds_swizzle_exec.py -> 3 tests OK. Restoring the parent tools/rdna2spirv.py: 2/3 fail (BITMASK_PERM lane 2: 22 != 0, SWAP lane 0: 8 != 0), so the new test is meaningful.
  • Main 3faac557b passes that same test file unchanged: copied test_ds_swizzle_exec.py into a clean worktree at 3faac557b -> 3 tests OK, no translator edit. Main already fixed this in 461892759 "fix(shader): return zero for inactive swizzle sources" (Nov 22): ds_lane_read() (tools/rdna2spirv.py:4537-4554, ballot -> mask) handles EXEC-off/absent sources and swizzle() calls it (:1725). docs/design.md already has a ds_swizzle_b32 row with those semantics.
  • gh pr view: mergeable=CONFLICTING; git merge-tree --write-tree HEAD refs/remotes/pr/5266 also conflicts in docs/design.md and tools/rdna2spirv.py, so the stale g_shuffle approach cannot land as-is.
  • git diff --check: clean (irrelevant given the above).

Verdict: close as already fixed on main. The one bit main lacks is the BITMASK_PERM-under-EXEC case (main's SwizzleExecTests covers SWAP and QUAD_PERM with exec 0xdddddddd). If wanted, re-open as a test-only PR that appends those cases to tests/semantic/test_ds_permute.py.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested ec628ee on Windows Server 2022, CPython 3.13.12: pass

  • python -I -m unittest discover -s tests/semantic -p "test_ds_swizzle_exec.py" -> Ran 3 tests, OK
  • Negative control (tools/rdna2spirv.py swapped to upstream/main): FAILED (errors=1)

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants