xshader: add the exact f16 dot helper only with the f16 dot products #631

Merged
JohnVonWells merged 1 commit from upstream-pr/631 into main 2026-12-01 20:31:22 +00:00
JohnVonWells commented 2026-12-01 17:52:49 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by JohnVonWells on 2026-12-01T17:52:49Z.


Fixes the compile failure reported on #615: a program that uses only the integer dot products no longer compiles.

Cause

#615 put the exact f16 dot helper, tb_dot2_f16, in DOT_HELPERS, which is added to every program with any v_dot* instruction. tb_dot2_f16 calls the 128-bit helpers and tb_f32_norm128 from float64_arith::HELPERS, but output.rs adds those only for v_dot2_f32_f16 and v_dot2c_f32_f16. A program with only the integer forms gets a function that calls undeclared names. DXC rejects that even though nothing calls the function. The tests missed it because they always translated the f16 forms next to the others.

Fix

tb_dot2_f16 moves to its own block, DOT_F16_HELPERS. It is added after the f64 arithmetic helpers, and only for the two f16 forms. DOT_HELPERS keeps the integer helpers. Programs with an f16 dot product get the same text as before. Programs with only integer dot products lose the unused function.

Checks

Each dot form was translated alone and compiled with DXC (cs_6_0, -O3), then validated with dxv:

Form main (bb52b9bb) this change
v_dot2_f32_f16, v_dot2c_f32_f16 ok ok
v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_i32_i8, v_dot4_u32_u8, v_dot8_i32_i4, v_dot8_u32_u4, v_dot4c_i32_i8 fails: use of undeclared identifier 'tb_u128_shl' ok
  • integer_dot_products_leave_out_the_f16_dot_helper fails without the change.
  • cargo test --lib: 752 passed.
  • Formatting: clean. Clippy: only the existing unknown-lint warning.
  • tools/native_rdna2/check_translated.py: PASS. The f16 dot products still match the card in every word.
  • python tuxbox.py check on an RX 6950 XT: 16 of 17 steps passed. "Lanes and fixtures on the GPU" failed on two gates:
    • lanes-selftest-texture-publication is #625. It fails the same way on main.
    • lanes-descriptor-tail failed once in that run. Run alone afterwards, all its gates passed twice with this change and twice on main. This change doesn't touch it.

Run on AMD only. A run on an NVIDIA card is still missing.

AI-assisted.

<!-- greyfinch-sync:brcly/TuxBox:issue:5591325034 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/631). Originally posted by [JohnVonWells](https://github.com/JohnVonWells) on 2026-12-01T17:52:49Z. --- Fixes the compile failure reported on #615: a program that uses only the integer dot products no longer compiles. ## Cause #615 put the exact f16 dot helper, `tb_dot2_f16`, in `DOT_HELPERS`, which is added to every program with any `v_dot*` instruction. `tb_dot2_f16` calls the 128-bit helpers and `tb_f32_norm128` from `float64_arith::HELPERS`, but `output.rs` adds those only for `v_dot2_f32_f16` and `v_dot2c_f32_f16`. A program with only the integer forms gets a function that calls undeclared names. DXC rejects that even though nothing calls the function. The tests missed it because they always translated the f16 forms next to the others. ## Fix `tb_dot2_f16` moves to its own block, `DOT_F16_HELPERS`. It is added after the f64 arithmetic helpers, and only for the two f16 forms. `DOT_HELPERS` keeps the integer helpers. Programs with an f16 dot product get the same text as before. Programs with only integer dot products lose the unused function. ## Checks Each dot form was translated alone and compiled with DXC (`cs_6_0`, `-O3`), then validated with dxv: | Form | main (bb52b9bb) | this change | |---|---|---| | `v_dot2_f32_f16`, `v_dot2c_f32_f16` | ok | ok | | `v_dot2_i32_i16`, `v_dot2_u32_u16`, `v_dot4_i32_i8`, `v_dot4_u32_u8`, `v_dot8_i32_i4`, `v_dot8_u32_u4`, `v_dot4c_i32_i8` | fails: `use of undeclared identifier 'tb_u128_shl'` | ok | - `integer_dot_products_leave_out_the_f16_dot_helper` fails without the change. - `cargo test --lib`: 752 passed. - Formatting: clean. Clippy: only the existing unknown-lint warning. - `tools/native_rdna2/check_translated.py`: PASS. The f16 dot products still match the card in every word. - `python tuxbox.py check` on an RX 6950 XT: 16 of 17 steps passed. "Lanes and fixtures on the GPU" failed on two gates: - `lanes-selftest-texture-publication` is #625. It fails the same way on main. - `lanes-descriptor-tail` failed once in that run. Run alone afterwards, all its gates passed twice with this change and twice on main. This change doesn't touch it. Run on AMD only. A run on an NVIDIA card is still missing. AI-assisted.
1093i3511 commented 2026-12-01 18:07:12 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-12-01T18:07:12Z.


Checked on the three ProjectScarlett programs from my #615 report (7baa6a35…, 6da9859f…, 1d52e9cf…): with fb17e160's translator each fails with undeclared identifier 'tb_u128_shl'; with a5b0d3db tb_dot2_f16 is gone from all three, and each compiles with DXC 1.9.2609 (cs_6_6) and passes dxv. RX 6600 host, Linux DXC.

<!-- greyfinch-sync:brcly/TuxBox:comment:7320432854 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/631#issuecomment-7320432854). Originally posted by [1093i3511](https://github.com/1093i3511) on 2026-12-01T18:07:12Z. --- Checked on the three ProjectScarlett programs from my #615 report (`7baa6a35…`, `6da9859f…`, `1d52e9cf…`): with fb17e160's translator each fails with `undeclared identifier 'tb_u128_shl'`; with a5b0d3db `tb_dot2_f16` is gone from all three, and each compiles with DXC 1.9.2609 (`cs_6_6`) and passes `dxv`. RX 6600 host, Linux DXC.
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!631
No description provided.