Shaders: lower unclamped 24-bit multiply-add through DXIL MAD #3731

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3731 into main
andrewpozdnakov7-jpg commented 2026-11-28 12:41:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T12:41:57Z.


Use DXIL IMad and UMad for the unclamped v_mad_i32_i24 and v_mad_u32_u24 forms. The two multiplicands still read their low 24 bits with the original signed or unsigned extension, and the entire 32-bit addend contributes to the wrapping result.

DXC disassembly of generated compute shaders showed:

Fixture Instructions, main → change DXIL bytes, main → change
One signed MAD 44 → 43 2,356 → 2,420
One unsigned MAD 44 → 43 2,356 → 2,420
Chain of 16 alternating MADs 134 → 118 2,804 → 2,932

The operation takes one fewer DXIL instruction per MAD. The intrinsic declaration adds bytes in these modules. These are emitted instruction and file sizes. GPU execution time and game performance were unmeasured.

On Microsoft WARP 1.0.22 with Agility 1.620.2, the new reference test matched all 726 inputs for each opcode on both main and this change. The full semantics group passed 35 tests with one existing ignored test, including the existing 5,780-input probes per MAD opcode. Strict all-feature shader Clippy and the asset policy passed.

The unsigned operand mask in #3632 and saturating clamped forms in #2926 cover different parts of these operations.

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:5540224634 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3731). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T12:41:57Z. --- Use DXIL `IMad` and `UMad` for the unclamped `v_mad_i32_i24` and `v_mad_u32_u24` forms. The two multiplicands still read their low 24 bits with the original signed or unsigned extension, and the entire 32-bit addend contributes to the wrapping result. DXC disassembly of generated compute shaders showed: | Fixture | Instructions, main → change | DXIL bytes, main → change | |---|---:|---:| | One signed MAD | 44 → 43 | 2,356 → 2,420 | | One unsigned MAD | 44 → 43 | 2,356 → 2,420 | | Chain of 16 alternating MADs | 134 → 118 | 2,804 → 2,932 | The operation takes one fewer DXIL instruction per MAD. The intrinsic declaration adds bytes in these modules. These are emitted instruction and file sizes. GPU execution time and game performance were unmeasured. On Microsoft WARP 1.0.22 with Agility 1.620.2, the new reference test matched all 726 inputs for each opcode on both main and this change. The full semantics group passed 35 tests with one existing ignored test, including the existing 5,780-input probes per MAD opcode. Strict all-feature shader Clippy and the asset policy passed. The unsigned operand mask in #3632 and saturating clamped forms in #2926 cover different parts of these operations. 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 12:46:08 +00:00 (Migrated from github.com)

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


Windows CI passed on 7c6f908, including the workspace tests and both Clippy configurations. The independent combined check with the unsigned operand mask and clamped forms is recorded in #3632.

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:7239453184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3731#issuecomment-7239453184). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T12:46:08Z. --- [Windows CI](https://github.com/Marvisak/VIctory/actions/runs/46145959726/job/140981971404) passed on `7c6f908`, including the workspace tests and both Clippy configurations. The independent combined check with the unsigned operand mask and clamped forms is recorded in [#3632](https://github.com/Marvisak/VIctory/pull/3632#issuecomment-7239448096). 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.
cloph-dsp commented 2026-11-28 12:55:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T12:55:35Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #3731 at head 7c6f9081c93bb1f65429fa62a4d765af186ae53d, base/parent 63bcca43c6a00a758510398fa43096ce7e4f7df0.
  • cargo test --locked -p victory-shader --lib -- emit::semantics_tests::mad24_wraps_with_a_full_width_addend --exact --test-threads=1 --quiet → 1 passed, 0 failed, 305 filtered, exit 0.
  • git grep -F for the test name on the base returned no match (test is new on this PR); git diff --check 63bcca4 HEAD clean (2 files, +42/-10).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic test was replayed; full workspace suite and clippy were not run locally.
  • GPU/driver: N/A (CPU-only shader semantics test). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7239564187 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3731#issuecomment-7239564187). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T12:55:35Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #3731 at head `7c6f9081c93bb1f65429fa62a4d765af186ae53d`, base/parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. - `cargo test --locked -p victory-shader --lib -- emit::semantics_tests::mad24_wraps_with_a_full_width_addend --exact --test-threads=1 --quiet` → 1 passed, 0 failed, 305 filtered, exit 0. - `git grep -F` for the test name on the base returned no match (test is new on this PR); `git diff --check 63bcca4 HEAD` clean (2 files, +42/-10). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic test was replayed; full workspace suite and clippy were not run locally. - GPU/driver: N/A (CPU-only shader semantics test). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
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 7c6f908 on 63bcca4.

  • mad24_wraps_with_a_full_width_addend passes: v_mad_i32_i24 / v_mad_u32_u24, 726 inputs, zero mismatches on the card and on WARP.
  • Full victory-shader --lib --features host: 303 passed, 0 failed, 3 ignored.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241794526 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3731#issuecomment-7241794526). 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 `7c6f908` on `63bcca4`. - `mad24_wraps_with_a_full_width_addend` passes: `v_mad_i32_i24` / `v_mad_u32_u24`, 726 inputs, zero mismatches on the card and on WARP. - Full `victory-shader --lib --features host`: 303 passed, 0 failed, 3 ignored. AI use: Claude Code (Claude Opus 5.5).
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/3731:upstream-pr/3731'
git switch 'upstream-pr/3731'

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