Skip to content

[upstream #1052] gpu/recomp: emit direct QuadReadAcross intrinsics for symmetric DPP quad swizzles - #98

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1052
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1052

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

This pull request implements direct Shader Model 6.0 quad swizzle intrinsic emission for symmetric DPP16 and ds_swizzle_b32 cross-lane permutations:

  1. Direct quad intrinsic emission in XCL recompiler:
    In crates/xcl/src/gpu/recomp/emit.rs, DPP quad permute and ds_swizzle_b32 operations previously fell back to calling rla (or xcl_x_rla_half). In pixel shaders, rla executed 4 sequential QuadReadLaneAt(v, 0..3) lookups followed by a selection ladder, and in compute shaders, WaveReadLaneAt.
    We inspect DPP16 control codes and ds_swizzle_b32 offsets to detect symmetric quad cross-lane exchange patterns across each quad:
  • Horizontal neighbor exchange (lanes 0<->1, 2<->3): QuadReadAcrossX(v) (DPP controls 0xB1, 0x161; swizzle offsets 0x80B1, 0x041F)
  • Vertical neighbor exchange (lanes 0<->2, 1<->3): QuadReadAcrossY(v) (DPP controls 0x4E, 0x162; swizzle offsets 0x804E, 0x081F)
  • Diagonal neighbor exchange (lanes 0<->3, 1<->2): QuadReadAcrossDiagonal(v) (DPP controls 0x1B, 0x163; swizzle offsets 0x801B, 0x0C1F)

When matched, the recompiler emits the single-cycle HLSL SM 6.0 quad intrinsic directly (QuadReadAcrossX, QuadReadAcrossY, or QuadReadAcrossDiagonal) instead of the 4-way QuadReadLaneAt lookup and selection ladder. On Intel Arc Xe-cores (and modern SM 6.0 hardware), this maps directly to native single-cycle execution on dedicated quad swizzle hardware.

  1. Unit and GPU hardware test coverage:
    In crates/xcl/src/gpu/recomp/tests.rs:
  • direct_quad_swizzle_patterns: verifies that symmetric DPP controls and swizzle offsets correctly map to QuadIntrinsic, and that asymmetric patterns (shifts, mirrors, rotates, FFTs) return None.
  • gpu_direct_quad_swizzles: executes DPP and ds_swizzle shaders across all 64 lanes on hardware, validating bit-exact horizontal, vertical, and diagonal quad neighbor exchanges across all 4 quad lanes.

Tested

  • Hardware: Intel Arc A770 16GB (Driver 32.0.101.9175), Windows 11 Pro 64-bit, MSVC 14.44.35207
  • Unit tests: cargo test -p xcl --lib direct_quad_swizzle_patterns (passed)
  • GPU execution: cargo test -p xcl --lib gpu_direct_quad_swizzles (passed, bit-exact results across all 4 quad lanes)
  • End-to-end PSO pipelines: cargo test -p xcl --test gpu_pso_e2e (7/7 passed)
  • Regression suites: cargo test -p xcl --lib gpu_sdwa_dpp_and_cross_lane (passed), cargo test -p xcl --lib gpu_ds_swizzle_modes (passed), cargo test -p xcl --lib gpu_ds_swizzle_and_bpermute_zero_inactive_lanes (passed)

Regression run
main (e74dda2):

xcl-smoke v1
commit: e74dda2d4b5c28a81cfa971d14bc417a6be966aa
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1665 (PresentX 1665)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

PR (8de58c8):

xcl-smoke v1
commit: 8de58c8880ab69632833bf72d76ce95d92dd79a4
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14856 MB

Not tested

  • RDNA3 / NVIDIA GPUs, Linux/Wine

AI use

  • Claude Code and Antigravity assisted in identifying symmetric DPP/swizzle permutations and verifying Shader Model 6.0 quad intrinsic mappings.

Mirror of xcl-dev#1052 (auto-synced, do not edit).

…uad swizzles

Detect symmetric quad cross-lane permutations in DPP16 and ds_swizzle_b32 controls and emit direct HLSL SM 6.0 intrinsics:
- Horizontal neighbor exchange (lanes 0<->1, 2<->3): QuadReadAcrossX
- Vertical neighbor exchange (lanes 0<->2, 1<->3): QuadReadAcrossY
- Diagonal neighbor exchange (lanes 0<->3, 1<->2): QuadReadAcrossDiagonal

This avoids falling back to the 4-way QuadReadLaneAt lookup and selection ladder, allowing single-cycle execution on hardware quad swizzle units such as Intel Arc Xe-cores.
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1052 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1052 branch November 25, 2026 00:11
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.

2 participants