Shaders: sign-extend 24-bit multiply operands with Ibfe #3737

Open
andrewpozdnakov7-jpg wants to merge 2 commits from upstream-pr/3737 into main
andrewpozdnakov7-jpg commented 2026-11-28 13:22:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T13:22:49Z.


Use DXIL Ibfe(24, 0, value) to sign-extend each multiplicand in signed 24-bit MUL, MUL_HI, and MAD. The unsigned forms use their existing logical shift sequence through the same helper. DXIL Ibfe semantics.

Generated compute shader DXIL instructions, main → change DXIL bytes, main → change
Signed MUL 41 → 39 2,344 → 2,412
Signed MUL_HI 45 → 43 2,372 → 2,436
Signed MAD 44 → 42 2,356 → 2,424
Unsigned MUL_HI control 45 → 45 2,372 → 2,372

On Microsoft WARP 1.0.22 with Agility 1.620.2, both revisions matched 6,912 output words against a wide-integer model. The generated cases cover both multiply encodings, the 24-bit sign boundary, ignored upper-byte bits, and full-width MAD addends. The existing integer model and 24-bit lowering tests passed, along with strict all-feature shader Clippy and the asset policy. The table describes emitted DXIL. Game performance was unmeasured.

#3632 covers the unsigned operand mask. #3731 replaces the multiply/add pair after extension. #3007 can replace the multiply-high calculation after extension.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5540556231 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3737). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:22:49Z. --- Use DXIL `Ibfe(24, 0, value)` to sign-extend each multiplicand in signed 24-bit MUL, MUL_HI, and MAD. The unsigned forms use their existing logical shift sequence through the same helper. [DXIL Ibfe semantics](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#ibfe). | Generated compute shader | DXIL instructions, main → change | DXIL bytes, main → change | |---|---:|---:| | Signed MUL | 41 → 39 | 2,344 → 2,412 | | Signed MUL_HI | 45 → 43 | 2,372 → 2,436 | | Signed MAD | 44 → 42 | 2,356 → 2,424 | | Unsigned MUL_HI control | 45 → 45 | 2,372 → 2,372 | On Microsoft WARP 1.0.22 with Agility 1.620.2, both revisions matched 6,912 output words against a wide-integer model. The generated cases cover both multiply encodings, the 24-bit sign boundary, ignored upper-byte bits, and full-width MAD addends. The existing integer model and 24-bit lowering tests passed, along with strict all-feature shader Clippy and the asset policy. The table describes emitted DXIL. Game performance was unmeasured. #3632 covers the unsigned operand mask. #3731 replaces the multiply/add pair after extension. #3007 can replace the multiply-high calculation after extension. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 13:27:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T13:27:46Z.


Windows CI passed on 84a1724, including the workspace tests and both Clippy configurations. The combined check with #3007 also passed all 6,912 output comparisons and all three multiply-high tests. Combined result.

The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7239951714 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3737#issuecomment-7239951714). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T13:27:46Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46149333359/job/140992264047) passed on `84a1724`, including the workspace tests and both Clippy configurations. The combined check with #3007 also passed all 6,912 output comparisons and all three multiply-high tests. [Combined result](https://github.com/Marvisak/VIctory/pull/3007#issuecomment-7239924449). The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
ColorMeBoom commented 2026-11-28 15:51:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-28T15:51:55Z.


Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head 84a1724 on 63bcca4.

  • The PR adds no test of its own, and on main 24-bit multiplies appear only inside two synthetic tests (unsigned v_mul_u32_u24 with constant operands), so nothing here exercises the signed Ibfe path it changes. This run only shows it breaks nothing else.
  • Full victory-shader --lib --features host: 302 passed, 0 failed, 3 ignored.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241794317 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3737#issuecomment-7241794317). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-28T15:51:55Z. --- Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head `84a1724` on `63bcca4`. - The PR adds no test of its own, and on `main` 24-bit multiplies appear only inside two synthetic tests (unsigned `v_mul_u32_u24` with constant operands), so nothing here exercises the signed `Ibfe` path it changes. This run only shows it breaks nothing else. - Full `victory-shader --lib --features host`: 302 passed, 0 failed, 3 ignored. AI use: Claude Code (Claude Opus 5.5).
andrewpozdnakov7-jpg commented 2026-11-28 16:06:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T16:06:55Z.


Thanks, @ColorMeBoom. The existing suite didn't directly exercise the signed path. 96547d5 adds that coverage without changing the lowerer.

The compute fixture checks the low product, signed high product, and wrapping multiply-add in one dispatch. It combines 12 factors per input with four full-width addends. The factors include both sides of bit 23 and pairs that differ only in the ignored high byte. On WARP 1.0.22, all 1,728 result words matched the integer model on both main and the PR. Strict Clippy and Windows CI passed.

If you have another RX 5700 XT slot, could you run just the new test on the updated head? Leave the default adapter enabled to check both the card and WARP.

cargo test -p victory-shader --lib --features host signed_mul24_uses_the_low_24_bits -- --nocapture

Please retain the Git author on cherry-pick or rebase, or add a Co-authored-by trailer for andrewpozdnakov7-jpg [email protected] if folding the commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241985007 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3737#issuecomment-7241985007). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T16:06:55Z. --- Thanks, @ColorMeBoom. The existing suite didn't directly exercise the signed path. [96547d5](https://github.com/Marvisak/VIctory/pull/3737/commits/96547d5c6f876c9ab7e9d36009bfb93861935316) adds that coverage without changing the lowerer. The compute fixture checks the low product, signed high product, and wrapping multiply-add in one dispatch. It combines 12 factors per input with four full-width addends. The factors include both sides of bit 23 and pairs that differ only in the ignored high byte. On WARP 1.0.22, all 1,728 result words matched the integer model on both main and the PR. Strict Clippy and [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46163146683/job/141034724845) passed. If you have another RX 5700 XT slot, could you run just the new test on the updated head? Leave the default adapter enabled to check both the card and WARP. cargo test -p victory-shader --lib --features host signed_mul24_uses_the_low_24_bits -- --nocapture Please retain the Git author on cherry-pick or rebase, or add a Co-authored-by trailer for andrewpozdnakov7-jpg <[email protected]> if folding the commit. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3737:upstream-pr/3737'
git switch 'upstream-pr/3737'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3737'
git switch 'upstream-pr/3737'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3737'
git switch 'upstream-pr/3737'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3737'
git switch 'main'
git merge --squash 'upstream-pr/3737'
git switch 'main'
git merge --ff-only 'upstream-pr/3737'
git switch 'main'
git merge 'upstream-pr/3737'
git push origin 'main'
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
Marvisak/VIctory!3737
No description provided.