Repository navigation
Conversation
The four packed-normalized conversions were refused by name, so any program using one failed to translate. Each source (abs/neg applied; the f16 forms read their op_sel half) is clamped to [-1, 1] or [0, 1], multiplied by 32767 or 65535 and rounded to nearest even once, from the exact product; NaN gives 0. src0 goes to the low half, src1 to the high. The product is formed in 64-bit integers from the float's bits: in f32, x * 32767 needs up to 39 significant bits and can round onto a tie before the rounding to an integer. GPU tests run the four opcodes on the host GPU and WARP against an f64 reference, including inputs where an f32 product lands on a tie. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
RDNA2 hardware measurement of the rounding rule (the description lists "no console hardware"): the hardware rounds the exact product once, as this PR does. One note on f16 denormals below. Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written
For example, f16 denormals. "Denormals give 0" holds for the f32 forms. A denormal half can be as large as ±6.1e-5, though, and times 32767 that is up to about 2. With the FP16 denormal mode allowing input denormals ( 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. |
Large f16 denormals (up to about 6.1e-5) scale to 1 or 2 in snorm and unorm, so they tell the input-denormal modes apart; the lowering widens the half to f32 exactly and keeps them, as RDNA2 does with FP16 input denormals allowed (measured on gfx1036 and reported on the pull request: half 0x83d6 gives i16 0xfffe, 0x823f gives 0xffff). The test now covers such halves and checks those two results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Lyrnc thank you for measuring this on RDNA2, especially the f32-product traps. I added your suggestion in dab7a58: the f16 test now has large denormal halves ( AI-assisted (Claude Code). |
# Conflicts: # crates/victory-shader/src/emit/valu_tests.rs
|
Merged current Note for testing: AI-assisted (Claude Code). |
catminou4
left a comment
There was a problem hiding this comment.
Merges cleanly with main; macOS arm64, rustc 1.98.1, cargo test -p victory-shader --locked with the PR merged into main 8e79c80 → 70 passed / 0 failed / 1 ignored.
Forming the product in integers from the float bits (mantissa × 32767/65535, then one round-to-nearest-even at the right shift) avoids the double rounding an f32 x * scale would introduce — that's the correct way to get exact v_cvt_pknorm_*. I checked the edge handling: saturation at |x| ≥ 1, denormals → 0, NaN → 0, sign applied only for the signed forms, and the s-cap at 63 keeps shifts defined while preserving the result. The f64 reference in the tests is the right oracle.
Note: the execution tests are Windows-gated (host device), so macOS coverage here is the lowering/compile path; Windows CI runs the real checks.
|
AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of
|
|
@slint6614-dev thank you for the RDNA4 and RDNA2 runs, and for the negative control. @Parakeet-Wheat if you have a moment: your count on #707 showed that PR doesn't touch the title. Could you run the same check here? That's the number of AI-assisted (Claude Code). |
|
@mercuryVM here are the counts for
Offline translation and validation only; no shader contents or extracted data included. AI-assisted (Claude Code); run on my machine. |
|
@Parakeet-Wheat thank you. Zero in the title: I've put that at the top of the description. This PR is instruction-set completeness only. AI-assisted (Claude Code). |
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:
cargo test -p victory-shader valu_tests: 15 passed, 0 failed (includingv_cvt_pknorm_f16_rounds_the_exact_productandv_cvt_pknorm_f32_rounds_the_exact_producton both RTX 5090 and WARP)cargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy: ok
Very thorough integer-bit exact-product rounding (norm16) avoiding f32 intermediate rounding errors, with clean NaN/denormal/saturation handling and solid GPU verification. Approving.
AI-assisted (Gemini 4 Neon).
Merged by hand: its norm16 helper landed beside two_sum/f16_nearest, and its tests were appended to the module header and tail, which had gained dot2 and thread-group-info tests since its base. The PR tip is a merge of upstream main; only its feature change differs from the merge base. Applied as the net diff of upstream PR Marvisak#596 (head be92188), 2 commits.
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
What
v_cvt_pknorm_i16_f32,v_cvt_pknorm_u16_f32,v_cvt_pknorm_i16_f16andv_cvt_pknorm_u16_f16(VOP3 0x368, 0x369, 0x312, 0x313) were refused, so any program that used one failed to translate. They now lower:x * 32767can need up to 39 significant bits, so it can round onto a tie before the rounding to an integer. That is why Shaders: an audit of which opcodes lower, and 100 more that do #163 left these refused ("needs the console rounding and NaN rules").One new helper,
Lower::norm16, incrates/victory-shader/src/emit/lower.rs. It sets theINT64flag, assrc64already does.Effect on the title: none
Measured by @Parakeet-Wheat on the retail 1.0.2.1 shaders, in a comment below: the title contains 0
v_cvt_pknorm_*(and no unpackedv_cvt_norm_*); its only packing conversion isv_cvt_pk_u8_f32.victory translate --list --validategives the same outcome onmainand on this PR: 21,736 validated, 4,003 failed, 162 rejected. So this PR only completes the instruction set. It doesn't unblock anything in the game, and it can wait behind work that does.Overlap
I searched open and closed PRs and issues: #376 lowers the unpacked
v_cvt_norm_{i16,u16}_f16, and #163 lists all six as refused. No PR lowers thepknormforms. This PR does not touch #376's opcodes, and either can land first without a conflict in the match.Tested
Windows 11, NVIDIA RTX 5070, AMD CPU. No game data.
valu_tests.rs,v_cvt_pknorm_f32_rounds_the_exact_productandv_cvt_pknorm_f16_rounds_the_exact_product. They run hand-assembled compute programs on the hardware device and on WARP, validate them withdxil.dll(10.0.26100), and compare against an f64 reference (the product is exact in f64). Inputs: ±0, ±1, ±2, ±inf, ±NaN, 0.5 (a tie in both scales), denormals, the smallest normal, values just below 1, and inputs found by search where an f32 product lands exactly on a tie but the exact product does not. The test asserts that those inputs really tell an f32 implementation apart from the exact one. The f16 cases put junk in the unread high halves and include large denormal halves;0x83d6and0x823fare checked against the hardware's results (0xfffe,0xffff).v_cvt_pknorm_i16_f32(NaN, 0.5) = 0x7fff0000, want 0x40000000).cargo test --workspace: all passed (victory-shader 71 passed).rustfmt --edition 2024 --checkon both changed files: clean.cargo clippy -p victory-shader --all-targets: no warnings.cargo xtask policy: 151 files ok.Not tested
D = {(snorm/unorm)S1, (snorm/unorm)S0}) and the D3D float-to-norm rules (NaN → 0, round to nearest even). If the console multiplies in f32 before it rounds, results differ by one step on the rare inputs the trap search finds. In [0, 1] the only exact tie is 0.5, so nearest-even and half-up agree on every exact tie.AI-assisted (Claude Code).
🤖 Generated with Claude Code