shader: accept inline, literal and SGPR-pair values in direct C++ 64-bit shifts #2952

Manually merged
github merged 1 commit from gh-pr/2952/head into gh-pr/2952/base 2026-11-27 01:30:27 +00:00
Owner

@⁠Leyukaka on GitHub · 2026-11-26 23:10 UTC · original
Leyukaka:shift64-sources → cpp-migration · +163 −3 · 5 files · 1 commits · merged 2026-11-26 23:18 UTC

Fixes #2951 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch cpp-migration.

Change (src/gfx1013_direct_compute.inl): v_lshrrev_b64 and v_lshlrev_b64 accepted only a VGPR pair or the inline 0 as the shifted value. They now also take:

  • a nonzero inline integer (-16..64), sign-extended to 64 bits;
  • a 32-bit literal, zero-extended;
  • an even SGPR pair (s[2k:2k+1], k <= 52), read through operand32, so the numeric-SGPR check applies to both words.

These are the rules tools/startup/gfx2hlsl.py applies to the same shifts through i64_words. Inline floats, odd or special scalar sources and v_ashrrev_i64 stay refused. The shift amount handling is unchanged.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on cpp-migration ea07313b plus this commit.

  • native_shift64_hardware passed. It covers -1, -16, 64, 1, the literal 0x80000001 and an SGPR pair with different words, each shifted right and left by 0, 1, 31, 32, 33 and 63, with one source per dispatch. Two 32-lane groups are compared with a 64-bit integer reference, and the guards are checked.
  • native_shift64_controls passed: an inline float as the shifted value is refused.
  • native_dpp_quad_hardware, native_dpp_mirror_hardware and native_compute_clear still pass.

Mutation checks, run by hand; each fails the hardware test on its own case:

  • zero-extending the inline value: inline -1;
  • sign-extending the literal: literal;
  • swapping the SGPR pair's words: SGPR pair.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests built from this branch.

  • Of 2,689 compute requests, 243 compiled on ea07313b and 249 with this commit; none that compiled before stops compiling.
  • On ea07313b, 38 requests stop first at "direct 64-bit shift operand". With this commit none does: 6 compile, and most of the rest stop next at:
    • "non-contiguous resource descriptor" (13);
    • "unsupported wave64 scalar mask operation" (10);
    • "direct image opcode or descriptor modifiers" (4).
  • #2951 quoted 21 request keys: those are the ones among the 38 that were dispatched in the start-up run below (13,814 dispatches). Most of them now stop at one of the refusals above.
  • The runtime still uses the Python translator, so I matched pipelines by request key against a 600 s start-up run. 3 of the 6 newly compiled pipelines were dispatched 381 times in that run.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-26 23:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2952) `Leyukaka:shift64-sources` → `cpp-migration` · +163 −3 · 5 files · 1 commits · merged 2026-11-26 23:18 UTC Fixes #2951 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch `cpp-migration`. **Change** (`src/gfx1013_direct_compute.inl`): `v_lshrrev_b64` and `v_lshlrev_b64` accepted only a VGPR pair or the inline `0` as the shifted value. They now also take: - a nonzero inline integer (-16..64), sign-extended to 64 bits; - a 32-bit literal, zero-extended; - an even SGPR pair (`s[2k:2k+1]`, `k <= 52`), read through `operand32`, so the numeric-SGPR check applies to both words. These are the rules `tools/startup/gfx2hlsl.py` applies to the same shifts through `i64_words`. Inline floats, odd or special scalar sources and `v_ashrrev_i64` stay refused. The shift amount handling is unchanged. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on `cpp-migration` `ea07313b` plus this commit. - `native_shift64_hardware` passed. It covers `-1`, `-16`, `64`, `1`, the literal `0x80000001` and an SGPR pair with different words, each shifted right and left by 0, 1, 31, 32, 33 and 63, with one source per dispatch. Two 32-lane groups are compared with a 64-bit integer reference, and the guards are checked. - `native_shift64_controls` passed: an inline float as the shifted value is refused. - `native_dpp_quad_hardware`, `native_dpp_mirror_hardware` and `native_compute_clear` still pass. **Mutation checks**, run by hand; each fails the hardware test on its own case: - zero-extending the inline value: `inline -1`; - sign-extending the literal: `literal`; - swapping the SGPR pair's words: `SGPR pair`. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` built from this branch. - Of 2,689 compute requests, 243 compiled on `ea07313b` and 249 with this commit; none that compiled before stops compiling. - On `ea07313b`, 38 requests stop first at "direct 64-bit shift operand". With this commit none does: 6 compile, and most of the rest stop next at: - "non-contiguous resource descriptor" (13); - "unsupported wave64 scalar mask operation" (10); - "direct image opcode or descriptor modifiers" (4). - #2951 quoted 21 request keys: those are the ones among the 38 that were dispatched in the start-up run below (13,814 dispatches). Most of them now stop at one of the refusals above. - The runtime still uses the Python translator, so I matched pipelines by request key against a 600 s start-up run. 3 of the 6 newly compiled pipelines were dispatched 381 times in that run. AI-assisted.
v_lshrrev_b64 and v_lshlrev_b64 accepted only a VGPR pair or the inline
0 as the shifted value. They now also take a nonzero inline integer,
sign-extended to 64 bits, a 32-bit literal, zero-extended, and an even
SGPR pair, the rules gfx2hlsl.py applies through i64_words. Inline
floats stay refused.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:30:24 +00:00
github manually merged commit bcaf4133b7 into gh-pr/2952/base 2026-11-27 01:30:27 +00:00
Author
Owner

@⁠MasterDomino on GitHub · 2026-11-26 23:18 UTC · original · approved these changes

Review of head bcaf4133, tested merged onto cpp-migration 641add96 (with #2950). It auto-merges cleanly, and CI on the head is green. Approving and merging.

Code read: the accepted sources match gfx2hlsl.i64_words:

  • an even SGPR pair up to s[104:105], or a VGPR pair, with both words read through operand32;
  • inline -1..-16, which gives an all-ones high word;
  • positive inlines and the literal, which are zero-extended.

Inline floats, odd or special scalars and v_ashrrev_i64 stay refused. One side effect is worth stating: VGPR pairs now also go through operand32's numeric check, where before they were read raw. Your capture run says nothing that compiled before stops compiling.

Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release. ctest --preset release --no-tests=error -R '^native_' gives 40 tests, 39 passed and 1 skipped (77, native_comparison_pso_warp), including native_shift64_hardware and native_shift64_controls.

Mutation here: dropping the sign extension of negative inlines fails native_shift64_hardware at ('inline -1', 'right', 0, …). With it restored, it passes.

I will close #2951 by hand.

AI-assisted; the commands above were run locally.

**@⁠MasterDomino** on GitHub · 2026-11-26 23:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2952#pullrequestreview-6081410822) · **approved these changes** Review of head `bcaf4133`, tested merged onto `cpp-migration` `641add96` (with #2950). It auto-merges cleanly, and CI on the head is green. Approving and merging. **Code read:** the accepted sources match `gfx2hlsl.i64_words`: - an even SGPR pair up to `s[104:105]`, or a VGPR pair, with both words read through `operand32`; - inline -1..-16, which gives an all-ones high word; - positive inlines and the literal, which are zero-extended. Inline floats, odd or special scalars and `v_ashrrev_i64` stay refused. One side effect is worth stating: VGPR pairs now also go through `operand32`'s numeric check, where before they were read raw. Your capture run says nothing that compiled before stops compiling. **Run on AMD:** Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release. `ctest --preset release --no-tests=error -R '^native_'` gives 40 tests, 39 passed and 1 skipped (77, `native_comparison_pso_warp`), including `native_shift64_hardware` and `native_shift64_controls`. **Mutation here:** dropping the sign extension of negative inlines fails `native_shift64_hardware` at `('inline -1', 'right', 0, …)`. With it restored, it passes. I will close #2951 by hand. AI-assisted; the commands above were run locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.