xshader: write the cube helpers only into programs that call them #645

Merged
NickStallman merged 1 commit from upstream-pr/645 into main 2026-12-01 23:48:47 +00:00
NickStallman commented 2026-12-01 23:39:33 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T23:39:33Z.


Every translation carried tb_cubema, tb_cubesc, tb_cubetc, tb_cubeid and tb_cube_dir, used or not. They are now a block of their own, written only when the program calls one: v_cube*_f32 or a cube image's coordinates. The other small ALU helpers that shared the block (tb_perm, tb_cmp_class, tb_mull, tb_log2 and the rest) stay in every translation, now as ALU_HELPERS. Gating on the body follows tb_omod.

As #641 discussed, every program's HLSL changes, so the DXIL store recompiles each one once. #643 and brcly's latest translator commits already change every program, so landing this before users next prepare shaders costs no extra recompile. DXC already dropped the unused helpers, so the DXIL itself doesn't change.

On a seeded sample (measured on 89546024, before the rebase; the helper text is unchanged) of 300 recorded ProjectScarlett requests, 290 translate. 256 of them lose 1,171 bytes of HLSL each, and the other 34 call the helpers, so their HLSL is unchanged. The other 10 are refused by one build or both; I did not compare those refusals.

Tests

  • cube_helpers_come_only_with_cube_instructions (src/tests/hlsl/rdna2_alu_gaps.rs): a program without a cube instruction has no tb_cube in its HLSL, and one with v_cubeid_f32 still has the helpers. It fails on main. The existing cube image and v_cubeid_f32 tests pass.
  • host_profiles.txt re-recorded with TUXBOX_BLESS_PROFILES=1 (all 58 lines).
  • python tuxbox.py check --no-gpu: Evidence: TuxBox check of bf87edd73984, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run
  • Not run: GPU checks.

Refs #641, #643, #533.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5596695836 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/645). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T23:39:33Z. --- Every translation carried `tb_cubema`, `tb_cubesc`, `tb_cubetc`, `tb_cubeid` and `tb_cube_dir`, used or not. They are now a block of their own, written only when the program calls one: `v_cube*_f32` or a cube image's coordinates. The other small ALU helpers that shared the block (`tb_perm`, `tb_cmp_class`, `tb_mull`, `tb_log2` and the rest) stay in every translation, now as `ALU_HELPERS`. Gating on the body follows `tb_omod`. As #641 discussed, every program's HLSL changes, so the DXIL store recompiles each one once. #643 and brcly's latest translator commits already change every program, so landing this before users next prepare shaders costs no extra recompile. DXC already dropped the unused helpers, so the DXIL itself doesn't change. On a seeded sample (measured on `89546024`, before the rebase; the helper text is unchanged) of 300 recorded ProjectScarlett requests, 290 translate. 256 of them lose 1,171 bytes of HLSL each, and the other 34 call the helpers, so their HLSL is unchanged. The other 10 are refused by one build or both; I did not compare those refusals. ## Tests - `cube_helpers_come_only_with_cube_instructions` (`src/tests/hlsl/rdna2_alu_gaps.rs`): a program without a cube instruction has no `tb_cube` in its HLSL, and one with `v_cubeid_f32` still has the helpers. It fails on main. The existing cube image and `v_cubeid_f32` tests pass. - `host_profiles.txt` re-recorded with `TUXBOX_BLESS_PROFILES=1` (all 58 lines). - `python tuxbox.py check --no-gpu`: `Evidence: TuxBox check of bf87edd73984, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run` - Not run: GPU checks. Refs #641, #643, #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!645
No description provided.