tombox-xshader: lower ds_swizzle_b32 bit and quad modes in compute shaders #184

Closed
github-bot wants to merge 1 commit from gh-pr/184/head into gh-pr/184/base
Owner

@⁠MeNoSkills on GitHub · 2026-11-22 22:02 UTC · original
MeNoSkills:feat/ds-swizzle-compute → main · +57 −4 · 3 files · 1 commits · closed without merging

Until now ds_swizzle_b32 translated only in a pixel shader with QDMode (bit 15); any other use, including every use in a compute shader, failed with "ds_swizzle outside a pixel shader" (or "without QDMode unsupported"). It is used by compute shaders for lane exchanges within a 32-lane group.

Change

In a compute shader, ds_swizzle_b32 now goes through the same lane-exchange lowering as ds_bpermute_b32 (WaveReadLaneAt, or the groupshared exchange when the shader has no LDS). The source lane inside the 32-lane group is computed per lane from the offset:

  • bit mode (offset[15] = 0): ((lane & offset[4:0]) | offset[9:5]) ^ offset[14:10]
  • quad mode (offset[15] = 1 and offset < 0xC000): (lane & ~3) | ((offset[7:0] >> (2 * (lane & 3))) & 3)

Offsets >= 0xC000 (the rotate and FFT modes) are refused with a message that names them; I do not have the ISA text to check their semantics, so I did not guess. The pixel-shader quad path is unchanged.

Tests

  • exec_mem::ds::ds_swizzle_compute: 12 bit-mode offsets (identity 0x001f, neighbour swap 0x041f, xor 16 = 0x401f, and-masks, broadcast of a lane, mixed masks, 0x7fff) and 8 quad permutations, on 64 threads (two groups of 32), against a reference computed from the formulas above. 20/20 on WARP and on an RTX 4070 Ti; without the change all 20 fail with "ds_swizzle outside a pixel shader".
  • exec_mem::ds::ds_swizzle_rotate_and_fft_are_refused_in_compute.
  • Regression runs on the RTX (Windows 10 19045, MSVC): --lib 85, --test synthetic 22, --test isa_sweep 2 (541 mnemonics), --test mesh 24, --test exec ds_ 18, all passing. pr_gate: 0 problems.

Not verified

No real shader: I do not have a title dump. The source-lane formulas come from the DS_SWIZZLE_B32 description, not from a console shader. Wave64 is not covered (compute here is two 32-lane groups).

**@⁠MeNoSkills** on GitHub · 2026-11-22 22:02 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/184) `MeNoSkills:feat/ds-swizzle-compute` → `main` · +57 −4 · 3 files · 1 commits · closed without merging Until now ds_swizzle_b32 translated only in a pixel shader with QDMode (bit 15); any other use, including every use in a compute shader, failed with "ds_swizzle outside a pixel shader" (or "without QDMode unsupported"). It is used by compute shaders for lane exchanges within a 32-lane group. ## Change In a compute shader, ds_swizzle_b32 now goes through the same lane-exchange lowering as ds_bpermute_b32 (WaveReadLaneAt, or the groupshared exchange when the shader has no LDS). The source lane inside the 32-lane group is computed per lane from the offset: - bit mode (offset[15] = 0): ((lane & offset[4:0]) | offset[9:5]) ^ offset[14:10] - quad mode (offset[15] = 1 and offset < 0xC000): (lane & ~3) | ((offset[7:0] >> (2 * (lane & 3))) & 3) Offsets >= 0xC000 (the rotate and FFT modes) are refused with a message that names them; I do not have the ISA text to check their semantics, so I did not guess. The pixel-shader quad path is unchanged. ## Tests - `exec_mem::ds::ds_swizzle_compute`: 12 bit-mode offsets (identity 0x001f, neighbour swap 0x041f, xor 16 = 0x401f, and-masks, broadcast of a lane, mixed masks, 0x7fff) and 8 quad permutations, on 64 threads (two groups of 32), against a reference computed from the formulas above. 20/20 on WARP and on an RTX 4070 Ti; without the change all 20 fail with "ds_swizzle outside a pixel shader". - `exec_mem::ds::ds_swizzle_rotate_and_fft_are_refused_in_compute`. - Regression runs on the RTX (Windows 10 19045, MSVC): `--lib` 85, `--test synthetic` 22, `--test isa_sweep` 2 (541 mnemonics), `--test mesh` 24, `--test exec ds_` 18, all passing. pr_gate: 0 problems. ## Not verified No real shader: I do not have a title dump. The source-lane formulas come from the DS_SWIZZLE_B32 description, not from a console shader. Wave64 is not covered (compute here is two 32-lane groups).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:13:07 +00:00
github-bot closed this pull request 2026-11-26 06:13:07 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 23:23 UTC · original

Applied in 3828799 (merged in 42511d7) with your authorship kept, thanks. The full tombox-xshader suite passes on WARP.

**@⁠omonkeyz** on GitHub · 2026-11-22 23:23 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/184#issuecomment-7087536952) Applied in 3828799 (merged in 42511d7) with your authorship kept, thanks. The full tombox-xshader suite passes on WARP.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.