Skip to content

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

Open
andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/mad24-dxil
Open

andrewpozdnakov7-jpg wants to merge 1 commit into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/mad24-dxil

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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 <andrewpozdnakov7-jpg@users.noreply.github.com> if folding the change into another commit.

AI-assisted with OpenAI Codex.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor Author

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 <andrewpozdnakov7-jpg@users.noreply.github.com> if folding the change into another commit.

AI-assisted with OpenAI Codex.

@cloph-dsp

Copy link
Copy Markdown

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

  • PR Shaders: lower unclamped 24-bit multiply-add through DXIL MAD #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

Copy link
Copy Markdown

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants