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

Merged
Leyukaka merged 1 commit from upstream-pr/2952 into cpp-migration 2026-11-26 23:18:49 +00:00
Leyukaka commented 2026-11-26 23:10:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T23:10:52Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5518390539 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2952). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T23:10:52Z. --- 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.
MasterDomino commented 2026-11-26 23:18:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T23:18:46Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6081410822 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2952#pullrequestreview-6081410822). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T23:18:46Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
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!2952
No description provided.