Repository navigation
Conversation
…dmask Shaders: lower v_ldexp_f16 and resolve Structured::other in v_cndmask_b32 (Marvisak#1223, Marvisak#1221)
|
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you lower, so this is a no-regression result only (same 10 SPIR-V validation failures as the base). Not tested: in-game. |
…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>
|
Automated triage for the maintainers. Merge candidate. The rebase is clean against current CI: passing. Recommending a look, not approving. Generated by Claude Code |
|
Rebased onto \main\ (\940d32f) at $sha. Verified on RTX 3060 Ti + WARP: \�_ldexp_f16_matches_rdna2\ passed, strict Clippy (--all-targets\ and --all-features) clean, \cargo xtask policy\ ok. |
ba53233 to
f470dd2
Compare
|
Addressed triage review at $sha: dropped the extra |r| >= 65520 -> ±inf\ override and outdated \legacyF32ToF16\ comment so \loat_result\ → |
f470dd2 to
423310e
Compare
AI-generated & verified with Gemini 4 Neon (High Mode) — not written by a human engineer. Lower `v_ldexp_f16` (`D.f16 = S0.f16 * 2^(S1.i16)`) in `valu16` / `valu16_op`: - Widens `S0` via `half_fsrc` (exact for all f16 normals and subnormals, honoring `opsel[0]`, `abs[0]`, `neg[0]`) and sign-extends `S1` from 16 bits via `half_src`. - Clamps the exponent to `[-64, 64]` and constructs `2^e` directly as a normal finite f32 (`(e + 127) << 23`), so `±0 * finite = ±0` (never `0 * inf = NaN`), `±inf * finite = ±inf` (never `inf * 0 = NaN`), and extreme exponents (`i16::MIN` / `i16::MAX`) overflow/underflow f16 cleanly without intermediate f32 faults. - Writes back via `float_result` (honoring `clamp`, `opsel[3]`, and preserving the untouched half of the destination VGPR). Verified with synthetic GPU + WARP + dxil.dll tests in `valu_tests.rs` on NVIDIA GeForce RTX 3060 Ti (Windows 11, Rust 1.98.1). No game data used. Co-Authored-By: Gemini 4 Neon (High Mode) <noreply@google.com>
423310e to
921092c
Compare
fuzeofficlal
left a comment
There was a problem hiding this comment.
The clamped power-of-two f32 scaling (emit/lower.rs:7003-7025) is exact for all finite f16 inputs with zero double rounding (verified exhaustively across all 63,490 non-NaN half encodings × 136 exponents = 8,634,640 combinations against direct half round-to-nearest-even) and preserves ±0, ±Inf, and NaNs across extreme signed i16 exponents while deferring rounding/overflow to float_result -> narrow16.
Non-blocking follow-up notes:
- In
valu_tests.rs:2297-2304, the e64 fixture exercisesop_selon VOP3-promoted0x13b(v_ldexp_f16); on RDNA2 (section 6.2 / Table 21), half selection/preservation on promoted VOP2 ops is encoded via SDWA (WORD_1+dst_unused:PRESERVE), so an SDWA fixture alongside legal e64abs/clamp(and notingomodstays safely refused infloat_result) would tighten coverage. rustfmt --edition 2024 --checkflags new linesvalu_tests.rs:2307, 2337, 2348.emit/lower.rsafter merging ontoorigin/mainis522,152 B(2,136 Bunder cap; note stacking with#2160would exceed524,288 Bby1,082 B).
Local verification at 921092c9 (and cleanly merged onto origin/main at d86cca0e): xtask policy (191 files ok), cargo clippy -p victory-shader --all-targets (default and --all-features, 0 warnings), census_tests (1/1), and emit::valu_tests on both RTX 5090 and WARP (36/36, including v_ldexp_f16_matches_rdna2) all passed. Approving.
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).
- Sign-extending the 16-bit integer exponent, clamping to
[-64, 64]so2^eis always a normal finite f32 (preserving±0,±inf, and NaN semantics), rejecting float modifiers on the integer exponent operand, and multiplying in f32 beforefloat_resultcleanly handles both VOP20x3band VOP30x13b. cargo test -p victory-shader --lib emit::valu_tests::v_ldexp_f16 -- --test-threads=1: passed on RTX 5090 andVICTORY_WARP=1.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
What's wrong
v_ldexp_f16(VOP20x3b/ VOP30x13b) is decoded ingfx10/opcodes.rsbut not lowered incrates/victory-shader/src/emit/lower.rs, causing shaders scaling half-precision values by powers of two (HLSLldexponmin16float/float16_t) to fail lowering.Fix
v_ldexp_f16invalu16/valu16_op:abs/negmodifiers onS1(which is a signed 16-bit integer exponent), while honoringabs[0]/neg[0]/opsel[0]onS0viahalf_fsrcandopsel[1]onS1viahalf_src(sign-extended fromi16toi32).eto[-64, 64]and construct the exact f32 power of two(e + 127) << 23before multiplying in f32:2^eis always a finite positive normal f32,±0 * 2^estays±0(never0 * inf = NaN) and±inf * 2^estays±inf(neverinf * 0 = NaN).[2^-24, 65504], soe >= 64always overflows f16 to±inf(2^-24 * 2^64 = 2^40) ande <= -64always underflows f16 to±0(65504 * 2^-64 < 2^-47).legacyF32ToF16rounds toward zero on host drivers (saturating finite overflows to0x7BFFinstead of±inf), promote finite results with|r| >= 65520.0(the binary16 round-to-nearest-even overflow threshold) to signed±infbeforefloat_result.float_result(legacyF32ToF16+write_half, preserving the untouched half and honoring VOP3clampandopsel[3]).emit::valu_tests::v_ldexp_f16_matches_rdna2incrates/victory-shader/src/emit/valu_tests.rstesting VOP2 normals, subnormals (0x0001 * 2^24,1.0 * 2^-15), overflow/underflow (i16::MAX,i16::MIN),±0 * 2^32767,±inf * 2^-32768,NaN, and VOP3abs[0] + opsel:[1,0,0,1] + clamp.Verification (Real GPU + WARP + CI Gates)
Tested on Windows 11, NVIDIA GeForce RTX 3060 Ti (driver
32.0.16.1656), Rust1.98.1:cargo test -p victory-shader --lib v_ldexp_f16_matches_rdna2: ok (dxil.dllvalidator + RTX 3060 Ti hardware + Microsoft WARP)cargo test -p victory-shader --locked: 121 passed, 0 failed, 1 ignoredcargo clippy --workspace --all-targets --locked -- -D warnings: pass (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (0 warnings)cargo xtask policy:asset policy: 154 files okScope & Non-Overlap
#157coversv_ldexp_f32; no open PR or issue coversv_ldexp_f16.