xshader: inline float constants in f16 operands, with RX 6800 vectors #202

Closed
github-bot wants to merge 1 commit from gh-pr/202/head into gh-pr/202/base
Owner

@⁠QuentinDanblon on GitHub · 2026-11-23 01:02 UTC · original
QuentinDanblon:pr/hw-f16 → main · +116 −5 · 3 files · 1 commits · closed without merging

Library / area: tombox-xshader (f16 operands of VOP instructions)

Exports changed (exports.txt rows): none

Source of the behaviour: LLVM AMDGPU getLit16Encoding for inline constants in 16-bit operands, and results an AMD Radeon RX 6800 (gfx1030) returned, published in the comments of the Leonida project's GPU test programs (GPL-3.0). Facts only (instruction, input bits, measured bits), no code copied; encodings from llvm-mc -mcpu=gfx1013. The Leonida line of THIRD_PARTY/CREDITS already covers tests/exec_vop/leonida.rs, where the tests are, so that file is not changed here.

Part of the split of #152: first of three small groups of translator fixes from the RX 6800 vectors. Based on c2a3522, 3 files, +116 / -5.

An inline float constant in an f16 operand is the f16 of that value in the low half and zero in the high half. Before this change:

  • v_pack_b32_f16 and v_cvt_f32_f16 read the f32 bit pattern of the constant;
  • OPSEL on a constant read the constant again instead of +0.0;
  • 1/2pi was taken as the f32 value, it is the f16 0x3118.

Tests (tests/exec_vop/leonida.rs): five tests, 45 measured cases (f16 unary, f16 binary, f16 inline constants, v_med3_f16 with OPSEL, single-rounding FMA). On c2a3522 without the fix, 6 cases fail, all in leonida_f16_inline_constants; the others already pass and are kept as regression vectors.

Results

WARP, --release, this branch alone on c2a3522:

  • cargo test -p tombox-xshader --test exec -- leonida: 8 passed, 0 failed, 1 ignored (the 3 existing Leonida tests and the 5 new ones).
  • The xshader branches of this split (mesh, opcode tables, f16 constants, v_med3_f32, SMEM) merged together on c2a3522, cargo test -p tombox-xshader, all targets: 0 failed. exec 115 passed (2 ignored), lib 90, mesh 26, opcodes 24, synthetic 24, isa_table 3, linkage 3, mixed_table 3, gcn_dims 3. isa_sweep: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations.
  • The branch merges into 2eda8b0 without conflict (git merge-tree); it was not rerun there.

Hardware: not rerun on this base, the GPU of my machine is busy for now. The same change passed on an RTX 5090 in #152 (2f1cfd0 on f10db75), and MiguelMatMar ran that branch on an RTX 40-series (results in #152). I will post a hardware run of this branch when the card is free.

No comment lines added (PR gate: 3 files checked, 0 problems). Not run against a title.

  • cargo test -p tombox-xshader passes on WARP
  • No game or console files and no binaries included
  • No fake success; anything not possible is left missing with a note

🤖 Generated with Claude Code

**@⁠QuentinDanblon** on GitHub · 2026-11-23 01:02 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/202) `QuentinDanblon:pr/hw-f16` → `main` · +116 −5 · 3 files · 1 commits · closed without merging **Library / area:** tombox-xshader (f16 operands of VOP instructions) **Exports changed (exports.txt rows):** none **Source of the behaviour:** LLVM AMDGPU `getLit16Encoding` for inline constants in 16-bit operands, and results an AMD Radeon RX 6800 (gfx1030) returned, published in the comments of the Leonida project's GPU test programs (GPL-3.0). Facts only (instruction, input bits, measured bits), no code copied; encodings from `llvm-mc -mcpu=gfx1013`. The Leonida line of `THIRD_PARTY/CREDITS` already covers `tests/exec_vop/leonida.rs`, where the tests are, so that file is not changed here. Part of the split of #152: first of three small groups of translator fixes from the RX 6800 vectors. Based on `c2a3522`, 3 files, +116 / -5. An inline float constant in an f16 operand is the f16 of that value in the low half and zero in the high half. Before this change: - `v_pack_b32_f16` and `v_cvt_f32_f16` read the f32 bit pattern of the constant; - OPSEL on a constant read the constant again instead of +0.0; - 1/2pi was taken as the f32 value, it is the f16 `0x3118`. Tests (`tests/exec_vop/leonida.rs`): five tests, 45 measured cases (f16 unary, f16 binary, f16 inline constants, `v_med3_f16` with OPSEL, single-rounding FMA). On `c2a3522` without the fix, 6 cases fail, all in `leonida_f16_inline_constants`; the others already pass and are kept as regression vectors. ### Results WARP, `--release`, this branch alone on `c2a3522`: - `cargo test -p tombox-xshader --test exec -- leonida`: 8 passed, 0 failed, 1 ignored (the 3 existing Leonida tests and the 5 new ones). - The xshader branches of this split (mesh, opcode tables, f16 constants, `v_med3_f32`, SMEM) merged together on `c2a3522`, `cargo test -p tombox-xshader`, all targets: 0 failed. exec 115 passed (2 ignored), lib 90, mesh 26, opcodes 24, synthetic 24, isa_table 3, linkage 3, mixed_table 3, gcn_dims 3. `isa_sweep`: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations. - The branch merges into `2eda8b0` without conflict (`git merge-tree`); it was not rerun there. Hardware: not rerun on this base, the GPU of my machine is busy for now. The same change passed on an RTX 5090 in #152 (`2f1cfd0` on `f10db75`), and MiguelMatMar ran that branch on an RTX 40-series (results in #152). I will post a hardware run of this branch when the card is free. No comment lines added (PR gate: 3 files checked, 0 problems). Not run against a title. - [x] `cargo test -p tombox-xshader` passes on WARP - [x] No game or console files and no binaries included - [x] No fake success; anything not possible is left `missing` with a note 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An inline float constant in an f16 operand is the f16 of that value in the
low half and zero in the high half (LLVM getLit16Encoding). v_pack_b32_f16
and v_cvt_f32_f16 read the f32 bit pattern, OPSEL on a constant read the
constant again instead of +0.0, and 1/2pi is the f16 0x3118, not the f32
value.

Tests (tests/exec_vop/leonida.rs): 45 f16 and FMA results an AMD Radeon
RX 6800 (gfx1030) returned, as published in the comments of the Leonida
project's GPU test programs (ItsNotRexed/Leonida, runtime/test/shaders/*.asm,
GPL-3.0). Facts only (instruction, input bits, measured bits), no code
copied; encodings from llvm-mc -mcpu=gfx1013. Six of them, all in
leonida_f16_inline_constants, disagreed with the translator before this
change. Credit: Leonida authors (THIRD_PARTY/CREDITS, existing line).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:13:41 +00:00
github-bot closed this pull request 2026-11-26 06:13:41 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-23 01:38 UTC · original

Applied in 8e4abb5 (merged in 24e6c10) with your authorship kept, thanks. The trailing comments on the new test vectors were dropped in f04f768 (the project keeps code comment-free).

**@⁠omonkeyz** on GitHub · 2026-11-23 01:38 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/202#issuecomment-7089303463) Applied in 8e4abb5 (merged in 24e6c10) with your authorship kept, thanks. The trailing comments on the new test vectors were dropped in f04f768 (the project keeps code comment-free).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.