shader-compiler: keep the DX9 multiply in v_mac_legacy_f32 #571

Closed
JeffreyBytes wants to merge 1 commit from upstream-pr/571 into main
JeffreyBytes commented 2026-11-30 04:38:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-30T04:38:48Z.


For #334, as asked there.

vector.rs strips _legacy and remembers it, but only v_mul_f32 and v_mad_f32 checked the flag, so v_mac_legacy_f32 came out as a plain a * b + dst. It now uses tb_mull the same way v_mad_legacy_f32 does. No recorded shader uses it.

check_basic_alu_gpu.py gets the inf × denormal case: 0x7f800000 × 0x00400000 + 0x3f800001, which gave 0xffc00000 where the card gives 0x3f800001. It runs after the edges, only in a shader of its own for v_mad_legacy_f32 and v_mac_legacy_f32. The other float models don't flush denormal sources yet, so feeding it to every float shader would fail v_mul_f32 and friends for reasons that have nothing to do with this.

The legacy model in separate now reads a denormal source as zero. The native reference shows these forms flush every denormal whatever MODE says (docs/CONSOLE_REFERENCE.md). That puts 35 more native lanes in line with the model, so ALU_CHECK_REJECTS in test_native_rdna2_float.py drops from 44 to 9 for v_fmac_legacy_f32 and v_fma_legacy_f32.

The unit test mac_legacy_keeps_the_dx9_multiply covers both encodings and fails without the fix.

check_translator_gpu.py --only alu on an RX 6700 XT (RADV), at af15cbfa (the same change before main's rustfmt commit; the rebase onto it was clean):

  • with the fix: PASS 362 instructions on 128 inputs, 0 wrong, 1 refused
  • with only the vector.rs change reverted: FAIL, 1 wrong: v_mac_legacy_f32 on inputs 0x7f800000, 0x00400000, 0x3f800001 got 0xffc00000, wanted 0x3f800001

The refusal is s_bcnt0_i32_b32 in both runs. It has nothing to do with this change.

#446 currently tolerates this as a known translator fault (legacy_rule_fault on v_mac_legacy_f32). I'll drop that from #446 once this lands, or here if #446 goes first.

<!-- greyfinch-sync:brcly/TuxBox:issue:5559094123 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/571). Originally posted by [JeffreyBytes](https://github.com/JeffreyBytes) on 2026-11-30T04:38:48Z. --- For #334, as asked there. `vector.rs` strips `_legacy` and remembers it, but only `v_mul_f32` and `v_mad_f32` checked the flag, so `v_mac_legacy_f32` came out as a plain `a * b + dst`. It now uses `tb_mull` the same way `v_mad_legacy_f32` does. No recorded shader uses it. `check_basic_alu_gpu.py` gets the inf × denormal case: 0x7f800000 × 0x00400000 + 0x3f800001, which gave 0xffc00000 where the card gives 0x3f800001. It runs after the edges, only in a shader of its own for `v_mad_legacy_f32` and `v_mac_legacy_f32`. The other float models don't flush denormal sources yet, so feeding it to every float shader would fail `v_mul_f32` and friends for reasons that have nothing to do with this. The legacy model in `separate` now reads a denormal source as zero. The native reference shows these forms flush every denormal whatever MODE says (docs/CONSOLE_REFERENCE.md). That puts 35 more native lanes in line with the model, so `ALU_CHECK_REJECTS` in `test_native_rdna2_float.py` drops from 44 to 9 for `v_fmac_legacy_f32` and `v_fma_legacy_f32`. The unit test `mac_legacy_keeps_the_dx9_multiply` covers both encodings and fails without the fix. `check_translator_gpu.py --only alu` on an RX 6700 XT (RADV), at af15cbfa (the same change before main's rustfmt commit; the rebase onto it was clean): - with the fix: PASS 362 instructions on 128 inputs, 0 wrong, 1 refused - with only the `vector.rs` change reverted: FAIL, 1 wrong: `v_mac_legacy_f32` on inputs 0x7f800000, 0x00400000, 0x3f800001 got 0xffc00000, wanted 0x3f800001 The refusal is `s_bcnt0_i32_b32` in both runs. It has nothing to do with this change. #446 currently tolerates this as a known translator fault (`legacy_rule_fault` on `v_mac_legacy_f32`). I'll drop that from #446 once this lands, or here if #446 goes first.
brcly commented 2026-11-30 09:38:37 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:38:37Z.


Merged into main as 8ece312f (squashed and credited to you), thanks!

I ran the missing NVIDIA side here, an RTX 4070 Ti SUPER through GE-Proton11-14:

  • With the fix: check_translator_gpu.py --only alu passes, 362 instructions, 0 wrong.
  • With only the vector.rs change reverted: 1 wrong, v_mac_legacy_f32 on your inf x denormal case. NVIDIA returns 0x7fffffff where your card gave 0xffc00000; wrong either way.

Nothing changes across our 46,664 recorded requests, and you can drop the tolerance from #446 now.

<!-- greyfinch-sync:brcly/TuxBox:comment:7274488783 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/571#issuecomment-7274488783). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T09:38:37Z. --- Merged into main as 8ece312f (squashed and credited to you), thanks! I ran the missing NVIDIA side here, an RTX 4070 Ti SUPER through GE-Proton11-14: - **With the fix:** `check_translator_gpu.py --only alu` passes, 362 instructions, 0 wrong. - **With only the `vector.rs` change reverted:** 1 wrong, `v_mac_legacy_f32` on your inf x denormal case. NVIDIA returns 0x7fffffff where your card gave 0xffc00000; wrong either way. Nothing changes across our 46,664 recorded requests, and you can drop the tolerance from #446 now.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!571
No description provided.