cpp-migration: lower v_perm_b32 and v_lerp_u8 in the direct C++ compute path #3015

Closed
opened 2026-11-27 05:22:35 +00:00 by archielcqp-a11y · 0 comments
archielcqp-a11y commented 2026-11-27 05:22:35 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-27T05:22:35Z.


Problem

Target branch cpp-migration. Part of #2935 (instruction coverage: integer ALU). I'm taking this; the pull request follows.

The direct compute path refuses two VOP3 byte operations, v_perm_b32 and v_lerp_u8, with direct DXIL lowering for <name>. A compute request that uses either falls back to gfx2hlsl.py. Both have gfx2hlsl.py pull requests from the start-up census (#2875, #2873), and neither had an issue or pull request for the direct path.

I found them with a local per-opcode probe: one instruction per VOP3 name of src/gfx1013_isa_tables.inl, compiled through compile_dxil ... gfx1013-direct-cs@0 on 999e17cd. It refused 68 of 120 names.

Proposal

Lower both in src/gfx1013_direct_compute.inl with the RDNA 2 ISA definitions, as #2875 and #2873 state them:

  • v_perm_b32: selector byte s of S2 picks byte s of {S0, S1} for 0..7 (S1 low). For 8..11 it gives 0xff or 0x00 from bit 15 or 31 of S1 or S0. 12 gives 0x00, and 13..255 give 0xff.
  • v_lerp_u8: each byte is (S0 + S1 + S2[8i]) >> 1.

Source modifiers and clamp stay refused.

Alternatives

Keep the refusal and the gfx2hlsl.py fallback. That leaves every request that uses either opcode on the Python path, which the migration is meant to replace. Both operations are integer-only with a fully specified result, so a direct lowering has no rounding or format question to settle first.

Verification

A source-built dispatch (tests/native_perm_lerp_check.py controls|hardware):

  • its 64 lanes cover all 256 v_perm_b32 selectors, with a second v_perm_b32 that exchanges S0 and S1;
  • v_lerp_u8 gets per-lane operands;
  • the results are compared with a CPU reference.

The controls check that these references differ from the expected words: exchanged sources, the sign read from the wrong bit, selector 12 as 0xff, and the lerp rounding bit dropped or widened. Mutated lowerings must fail the readback.

AI-assisted.

Checklist

  • I checked for an existing issue or pull request for this change.
  • I did not include game files, dumps, distribution links or credentials.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6640533871 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3015). Originally posted by [archielcqp-a11y](https://github.com/archielcqp-a11y) on 2026-11-27T05:22:35Z. --- ### Problem Target branch `cpp-migration`. Part of #2935 (instruction coverage: integer ALU). I'm taking this; the pull request follows. The direct compute path refuses two VOP3 byte operations, `v_perm_b32` and `v_lerp_u8`, with `direct DXIL lowering for <name>`. A compute request that uses either falls back to `gfx2hlsl.py`. Both have `gfx2hlsl.py` pull requests from the start-up census (#2875, #2873), and neither had an issue or pull request for the direct path. I found them with a local per-opcode probe: one instruction per VOP3 name of `src/gfx1013_isa_tables.inl`, compiled through `compile_dxil ... gfx1013-direct-cs@0` on `999e17cd`. It refused 68 of 120 names. ### Proposal Lower both in `src/gfx1013_direct_compute.inl` with the RDNA 2 ISA definitions, as #2875 and #2873 state them: - `v_perm_b32`: selector byte s of S2 picks byte s of {S0, S1} for 0..7 (S1 low). For 8..11 it gives 0xff or 0x00 from bit 15 or 31 of S1 or S0. 12 gives 0x00, and 13..255 give 0xff. - `v_lerp_u8`: each byte is (S0 + S1 + S2[8i]) >> 1. Source modifiers and `clamp` stay refused. ### Alternatives Keep the refusal and the `gfx2hlsl.py` fallback. That leaves every request that uses either opcode on the Python path, which the migration is meant to replace. Both operations are integer-only with a fully specified result, so a direct lowering has no rounding or format question to settle first. ### Verification A source-built dispatch (`tests/native_perm_lerp_check.py controls|hardware`): - its 64 lanes cover all 256 `v_perm_b32` selectors, with a second `v_perm_b32` that exchanges S0 and S1; - `v_lerp_u8` gets per-lane operands; - the results are compared with a CPU reference. The controls check that these references differ from the expected words: exchanged sources, the sign read from the wrong bit, selector 12 as 0xff, and the lerp rounding bit dropped or widened. Mutated lowerings must fail the readback. AI-assisted. ### Checklist - [x] I checked for an existing issue or pull request for this change. - [x] I did not include game files, dumps, distribution links or credentials.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#3015
No description provided.