Skip to content

[upstream #925] Recompiler: translate ds_permute_b32 - #166

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

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

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

ds_permute_b32 was untranslated (the isa_coverage census lists it as missing; no open PR or issue covers it). It is the forward form of ds_bpermute_b32. Each active lane sends DATA0 to lane ((ADDR + offset) >> 2) & 31 of its own 32-lane half, in wave64 too. That was measured on RDNA2 in native wave64 in the comments below (by @KENAJBBY and @certified-retart), and it matches ds_bpermute_b32 in xcl-dev#772. Of several senders to one lane the highest-numbered one wins, a lane no active lane sends to gets 0, inactive lanes neither send nor receive, and no LDS memory is used.

The first version of this PR (874a9fd) took the target mod 64 and could send across the halves. It was wrong on the hardware, and its test agreed with it only because the reference model had the same mistake.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: each lane looks at the 32 senders of its half in lane order through rla_half_fn, as ds_swizzle does, so the highest active sender wins. The split wave64 form needs no exchange. In a wave64 VS / PS that may run in 32-lane waves the instruction is refused: lanes 32..63 of the console wave don't exist there, and upper_lanes doesn't model this instruction's writes to them.
  • crates/xcl/src/gpu/recomp/tests.rs: gpu_ds_permute_b32 compares against the measured model in wave32, wave64 and split wave64. The cases are a reversal (within each half), two senders per lane with high address bits set, offset 8 (wrapping in its half), offset 128 (the identity), and inactive senders and receivers. ds_permute_b32_refused_where_upper_lanes_do_not_exist checks the refusal, and that compute and non-split pixel modes translate. Against the first version's translation the GPU test fails: wave64 split=true lane 1: v10, left: 4158, right: 4126 (lane 62's value where the hardware gives lane 30's).

Tested

  • head c3e3442, rebased onto main 6bac4b4
  • NVIDIA GeForce RTX 5080 (driver 617.42, 32-lane waves), AMD Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug, DXC 1.9.2602.17
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 721 passed, 0 failed, 41 ignored
  • SKIPPED on this adapter (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware; no XCL_SAMPLE_* set
  • The native wave64 form of the first version was run on RDNA4 and RDNA2 by @4usphs and @eizispark (comments below). It hasn't been rerun on native wave64 for this head.

Regression run
main:

xcl-smoke v1
commit: 9aec53df7004bd9018ef3df67532f85d66ee261c
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15195 MB

This PR:

xcl-smoke v1
commit: c3e34429cbb8a216c6f88015f772367614e371be
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 1671 (PresentX 1671)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14709 MB

Not tested

  • the native wave64 form of this head (no 64-lane GPU here)
  • a wave32 program in 64-lane hardware waves, and pixel shaders (helper lanes)
  • whether the VS / PS refusal is still needed now that no lane reads the other half
  • a title that uses the instruction: the regression run won't show whether one does

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests and this description, and ran the tests above. The hardware model comes from the measurements in the comments.

🤖 Generated with Claude Code


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

It was untranslated (the isa_coverage census listed it as missing). Each
active lane sends DATA0 to lane ((ADDR + offset) >> 2) & 31 of its own
32-lane half: in wave64 too, as measured on RDNA2 in native wave64 (xcl-dev#925,
like ds_bpermute_b32 in xcl-dev#772). Of several senders the highest lane wins,
a lane nobody sends to gets 0, inactive lanes neither send nor receive,
and no LDS memory is used.

Each lane looks at the 32 senders of its half in lane order, through the
half-local lane read ds_swizzle uses, so the split wave64 form needs no
exchange. In a wave64 VS / PS that may run in 32-lane waves the
instruction is refused: the console wave's lanes 32..63 do not exist
there.

Tests: a GPU test against the measured model (reversal within halves,
colliding senders, high address bits, offsets 8 and 128, inactive lanes)
in wave32, wave64 and split wave64, and the refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

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

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