Repository navigation
Shaders: lower v_mul_hi_u32_u24 and v_mul_hi_i32_i24 - #156
Conversation
|
Tested
No game data used. |
…32_i24) into the integration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
|
RDNA2 hardware check of the rule: matches. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) runs
So "the high dword of the same 48-bit product, operands zero- or sign-extended from 24 bits" is what the hardware does, and the upper 8 bits of each operand are ignored. AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run. |
catminou4
left a comment
There was a problem hiding this comment.
Verified locally on macOS 26 arm64, rustc 1.98.1 (aarch64-apple-darwin) at head 8142a94:
cargo test -p victory-shader --locked: compiles clean, all ungated tests pass (no regressions vs main's 56).
Scope note: valu_tests/image_tests in victory-shader are #[cfg(all(test, windows))] — they need the Windows host backend (D3D12/dxil.dll), so they did not run here. What I verified is compilation on macOS plus all ungated tests. For this PR that means the new v_mul_hi lowering coverage still needs a Windows run before merge — I can't execute it on this machine. The lowering changes themselves compile everywhere.
The high dword of the 48-bit product whose low dword v_mul_u32_u24 and v_mul_i32_i24 already give: the low 24 bits of each operand, zero- or sign-extended, through the existing mul_hi. The test module gets lowers_valu, a one-thread compute program with root constants in v1..v4 and a buffer store of v0 (built with lower_with), so a vector instruction can be checked for lowering without a GPU. AI-assisted (Claude Code).
8142a94 to
344704e
Compare
…fied together Merges Marvisak#156 Marvisak#162 Marvisak#168 Marvisak#169 Marvisak#368 Marvisak#379 Marvisak#456 Marvisak#587 Marvisak#990 Marvisak#1021 Marvisak#1048 Marvisak#1052 Marvisak#1053 Marvisak#1095 Marvisak#1142 Marvisak#1190 Marvisak#1211 Marvisak#1223 Marvisak#1259 Marvisak#1293 on top of the bundle of Marvisak#1402 (which is on Marvisak#1319, on main ffe310e), each head unchanged. Hunks that conflicted in emit/lower.rs, emit/valu_tests.rs and emit/diff_tests.rs were merged by keeping both sides (additions next to each other); a PR was kept only if cargo clippy -p victory-shader --all-targets -- -D warnings still passed with it. No instruction name is handled in two places. Marvisak#98 is not in this version: an offline measurement on a retail dump showed it loses 31 programs that validate on Marvisak#1402. cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features, is clean and cargo test --workspace --locked passes (381 passed, 6 ignored; main has 342 passed, 6 ignored). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keep the existing LDS write/barrier proof and preserve descriptor record counts while reading addresses from the host heap.
Rebuilt on
mainffe310e(344704ereplaces8142a94): the lowering is the same, the test helper now uses main'slower_withandroot.v_mul_hi_u32_u24andv_mul_hi_i32_i24, which the emitter refuses by name, now translate. One file,crates/victory-shader/src/emit/lower.rs(61 added).What is in it
v_mul_u32_u24/v_mul_i32_i24): the high dword of the same 48-bit product. The low 24 bits of each operand are zero- or sign-extended with the shift pair the low-dword forms already use, then multiplied through the existingmul_hi.lowers_valu, in thelowertest module: a one-thread compute program with four root constants copied tov1..v4and abuffer_store_dwordofv0, so a vector instruction can be checked for lowering on any host, without a GPU. It is built with the test module'slower_withand is the non-GPU half of whatvalu_tests::build_valu_csbuilds.the_24_bit_multiplies_lower_both_halves, that lowers all four 24-bit multiplies (VOP2 0x09 to 0x0C).Tested
macOS 27 arm64, Rust 1.98.1, debug, no GPU and no game files:
cargo test -p victory-shader: 97 passed, 0 failed, 1 ignored (96 onmainffe310e, plus the new test).cargo fmt -p victory-shader -- --check: no diff in the lines this PR adds.cargo clippy -p victory-shader --all-targets --locked -- -D warningsstops on two unused imports inemit/mod.rson macOS, onmainas well (their users are Windows-only), so clippy as CI runs it was not checked here.cargo xtask policy: 154 files ok.Checked on hardware by others (see the comments)
v_mul_hi_u32_u24,v_mul_hi_i32_i24and the two low-dword forms on RDNA2 silicon (gfx1036), 500 operand pairs each, all matching the rule above.cargo test -p victory-shaderon Arch Linux, 57 passed.These are measurements of the instruction rule on hardware, not runs of this PR's emitted DXIL.
Not tested (by me)
valu_tests,diff_tests) are Windows-only and need a GPU, which I do not have. A run on a GPU by someone who has one would be welcome.victory-gpu,victory-hle,victory-loader) were not built.Independent of #148 (different instructions; both add a test to the same module, so whichever lands second may need a trivial rebase, which I will do).
No game data: the test input is hand-written instruction words.
AI-assisted: yes (Claude Code).
🤖 Generated with Claude Code