Skip to content

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

Open
andrewpozdnakov7-jpg wants to merge 2 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/signed-mul24-ibfe
Open

andrewpozdnakov7-jpg wants to merge 2 commits into
Marvisak:mainfrom
andrewpozdnakov7-jpg:codex2/signed-mul24-ibfe

Conversation

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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

AI-assisted with OpenAI Codex.

@ColorMeBoom

ColorMeBoom commented Nov 28, 2026 •

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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

AI-assisted with OpenAI Codex.

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.

2 participants