xshader: keep tb_cubeid's face numbers in float #643

Merged
NickStallman merged 1 commit from upstream-pr/643 into main 2026-12-01 23:13:13 +00:00
NickStallman commented 2026-12-01 21:44:26 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T21:44:26Z.


tb_cubeid (the v_cubeid_f32 helper) chose its face number with select(z < 0.0, 5.0, 4.0) and the like. HLSL types a select of two untyped literals as double, so DXC computed the face in doubles, converted it to float, and marked the program as using double-precision floating point, at -O0 and -O3 alike. A host without doubles (vkd3d-proton reports none without f64 denormal support; Metal has none) refuses every such pipeline. Results were unchanged: 0 to 5 convert exactly.

The literals are now f floats. Of the translator's helpers this was the only select with two literals; the ?: forms elsewhere stay float.

Every translation changes. push_helpers writes the cube helpers (tb_cubeid with tb_perm_byte, tb_cubema and the rest) into every program, whether it uses them or not, so this edit changes the HLSL of every program, and host_profiles.txt is re-recorded (all 58 lines). DXC drops the unused helper, so only programs with v_cubeid_f32 get different DXIL, but the DXIL store is keyed by HLSL, so every cached shader recompiles once. If that cost needs to wait, this can ride along with the next change that touches every translation. Emitting the cube helpers only for the instructions that call them would be a separate change; it changes every program's HLSL too.

Tests

  • cube_face_ids_need_no_doubles (src/tests/hlsl/rdna2_alu_gaps.rs) translates a v_cubeid_f32 program, checks the literals, and with DXC set compiles it and checks that DXC declares no double-precision use. It fails on main.
  • host_profiles.txt re-recorded with TUXBOX_BLESS_PROFILES=1, as the test asks.
  • python tuxbox.py check --no-gpu: Evidence: TuxBox check of e4e3d44d0974, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run
  • Not run: GPU checks. The emitted code computes the same numbers in float.

Proposal and discussion: #641. Draft until that is agreed. Refs #533.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5595113394 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/643). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T21:44:26Z. --- `tb_cubeid` (the `v_cubeid_f32` helper) chose its face number with `select(z < 0.0, 5.0, 4.0)` and the like. HLSL types a `select` of two untyped literals as `double`, so DXC computed the face in doubles, converted it to float, and marked the program as using double-precision floating point, at `-O0` and `-O3` alike. A host without doubles (vkd3d-proton reports none without f64 denormal support; Metal has none) refuses every such pipeline. Results were unchanged: 0 to 5 convert exactly. The literals are now `f` floats. Of the translator's helpers this was the only `select` with two literals; the `?:` forms elsewhere stay float. **Every translation changes.** `push_helpers` writes the cube helpers (`tb_cubeid` with `tb_perm_byte`, `tb_cubema` and the rest) into every program, whether it uses them or not, so this edit changes the HLSL of every program, and `host_profiles.txt` is re-recorded (all 58 lines). DXC drops the unused helper, so only programs with `v_cubeid_f32` get different DXIL, but the DXIL store is keyed by HLSL, so every cached shader recompiles once. If that cost needs to wait, this can ride along with the next change that touches every translation. Emitting the cube helpers only for the instructions that call them would be a separate change; it changes every program's HLSL too. ## Tests - `cube_face_ids_need_no_doubles` (`src/tests/hlsl/rdna2_alu_gaps.rs`) translates a `v_cubeid_f32` program, checks the literals, and with `DXC` set compiles it and checks that DXC declares no double-precision use. It fails on main. - `host_profiles.txt` re-recorded with `TUXBOX_BLESS_PROFILES=1`, as the test asks. - `python tuxbox.py check --no-gpu`: `Evidence: TuxBox check of e4e3d44d0974, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run` - Not run: GPU checks. The emitted code computes the same numbers in float. Proposal and discussion: #641. **Draft** until that is agreed. Refs #533. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!643
No description provided.