xshader: supply launch registers an instruction reads through its destination #624

Merged
NickStallman merged 4 commits from upstream-pr/624 into main 2026-12-01 20:32:02 +00:00
NickStallman commented 2026-12-01 15:08:49 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-12-01T15:08:49Z.


The translation sets a launch register (a pixel program's fragment position, a scalar argument) only when its entry-live analysis says the program reads it before writing it. That analysis took every decoded destination as a plain write, but several instructions also read their destination:

  • accumulators: v_fmac_f32, v_fmac_f16, v_pk_fmac_f16, v_dot2c_f32_f16, v_dot4c_i32_i8, the mac forms;
  • writes of part of a register: v_fma_mixlo/hi_f16, the 16-bit integer VOP3 forms, the compact v_rcp_f16, SDWA with UNUSED_PRESERVE, DPP16 without BOUND_CTRL, D16 loads, v_writelane_b32, v_interp_p2;
  • scalar forms that keep or change the destination in place: s_cmov, s_cmovk, s_bitset, s_addk, s_mulk, s_cmpk.

v_readlane_b32 also names the scalar it writes in its vector field, and s_cmpk writes nothing. A register whose first use is such an instruction kept its declared 0. In recorded requests of one title, 1,385 pixel programs first use the fragment position as the addend of v_fmac_f32 (a per-pixel hash for dithering and fades), so x and y read as 0 everywhere.

Also:

  • every register a scalar result clobbers now counts as written (a wave64 comparison's mask pair, a VOP3B carry);
  • position components follow SPI_PS_INPUT_ENA. When the enable and the signature disagreed, the old fallback put x, y, z or 1/w into registers that hold no position.

Refs #533.

Measured

Main 833e1217 and this head, side by side on every one of 55,257 recorded request/host translations from one title:

  • 2,043 change beyond the header: 2,038 pixel programs plus 5 recent requests without stage metadata. 1,424 now receive position components they read (x and y 1,024, y only 289, x only 110, w 1); 619 no longer receive one the input enable leaves out (x 614, others 5).
  • 7,684 change only in the entry-live comment line (pixel 7,335, compute 260, vertex 46, others 43); 44,094 are identical; 1,436 are refused by both.
  • No translation is newly refused or newly accepted; mesh programs are unchanged.
  • DXC (the runtime's profiles, -O3) and dxv accept all 2,043 changed translations.

Tests: the new tests in tests/hlsl/live_reads.rs fail without the change (checked by reverting each part). tools/check_pixel_interp.py gains a position case (16×16, expects (x+0.5, y+0.5, 0.5, 1.0) at every pixel).

  • GPU checks of fe4d8597 (GE-Proton11-15) on an AMD iGPU (1002:13c0, RADV) and an RTX 5090 (10de:2b85, 620.70.10):
    • pixel-interp passes on both (4 cases, 1,024 pixels, 0 wrong). Control (main plus only the check): fails on both, position at pixel [0,0] expected [0.5, 0.5, 0.5, 1.0], got [0, 0, 0, 0]; smooth, flat and half pass.
    • Full translator set: 68 pass, 1 fail on each card (pixel-link-slot86, an lld-link error linking the check's guest; it fails the same way on the control).
    • Lanes shader-cache, raster-tables, compute-root, compute-root-recovery, bindless-compute: 50 of 50 on both cards.
  • Evidence: TuxBox check of fe4d8597792d, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run

Not covered

  • High halves of 64-bit scalar sources, SMEM SOFFSET and multi-register vector operands are a follow-up; so is following control flow instead of program order (it would newly refuse mesh programs whose launch registers are written conditionally, which needs the mesh path's own proof first).

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5588491766 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/624). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-12-01T15:08:49Z. --- The translation sets a launch register (a pixel program's fragment position, a scalar argument) only when its entry-live analysis says the program reads it before writing it. That analysis took every decoded destination as a plain write, but several instructions also read their destination: - accumulators: `v_fmac_f32`, `v_fmac_f16`, `v_pk_fmac_f16`, `v_dot2c_f32_f16`, `v_dot4c_i32_i8`, the mac forms; - writes of part of a register: `v_fma_mixlo/hi_f16`, the 16-bit integer VOP3 forms, the compact `v_rcp_f16`, SDWA with `UNUSED_PRESERVE`, DPP16 without `BOUND_CTRL`, D16 loads, `v_writelane_b32`, `v_interp_p2`; - scalar forms that keep or change the destination in place: `s_cmov`, `s_cmovk`, `s_bitset`, `s_addk`, `s_mulk`, `s_cmpk`. `v_readlane_b32` also names the scalar it writes in its vector field, and `s_cmpk` writes nothing. A register whose first use is such an instruction kept its declared 0. In recorded requests of one title, 1,385 pixel programs first use the fragment position as the addend of `v_fmac_f32` (a per-pixel hash for dithering and fades), so x and y read as 0 everywhere. Also: - every register a scalar result clobbers now counts as written (a wave64 comparison's mask pair, a VOP3B carry); - position components follow `SPI_PS_INPUT_ENA`. When the enable and the signature disagreed, the old fallback put x, y, z or 1/w into registers that hold no position. Refs #533. ## Measured Main 833e1217 and this head, side by side on every one of 55,257 recorded request/host translations from one title: - 2,043 change beyond the header: 2,038 pixel programs plus 5 recent requests without stage metadata. 1,424 now receive position components they read (x and y 1,024, y only 289, x only 110, w 1); 619 no longer receive one the input enable leaves out (x 614, others 5). - 7,684 change only in the entry-live comment line (pixel 7,335, compute 260, vertex 46, others 43); 44,094 are identical; 1,436 are refused by both. - No translation is newly refused or newly accepted; mesh programs are unchanged. - DXC (the runtime's profiles, -O3) and dxv accept all 2,043 changed translations. Tests: the new tests in `tests/hlsl/live_reads.rs` fail without the change (checked by reverting each part). `tools/check_pixel_interp.py` gains a `position` case (16×16, expects (x+0.5, y+0.5, 0.5, 1.0) at every pixel). - GPU checks of fe4d8597 (GE-Proton11-15) on an AMD iGPU (`1002:13c0`, RADV) and an RTX 5090 (`10de:2b85`, 620.70.10): - `pixel-interp` passes on both (4 cases, 1,024 pixels, 0 wrong). Control (main plus only the check): fails on both, position at pixel [0,0] expected [0.5, 0.5, 0.5, 1.0], got [0, 0, 0, 0]; smooth, flat and half pass. - Full translator set: 68 pass, 1 fail on each card (`pixel-link-slot86`, an lld-link error linking the check's guest; it fails the same way on the control). - Lanes `shader-cache`, `raster-tables`, `compute-root`, `compute-root-recovery`, `bindless-compute`: 50 of 50 on both cards. - `Evidence: TuxBox check of fe4d8597792d, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run` ## Not covered - High halves of 64-bit scalar sources, SMEM `SOFFSET` and multi-register vector operands are a follow-up; so is following control flow instead of program order (it would newly refuse mesh programs whose launch registers are written conditionally, which needs the mesh path's own proof first). 🤖 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!624
No description provided.