shader: translate first-lane reads from a uniform buffer conversion #1215

Merged
R0Y00 merged 2 commits from upstream-pr/1222 into main 2026-11-24 04:54:32 +00:00
R0Y00 commented 2026-11-24 04:22:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T04:22:08Z.


Refs #1137

The startup shader translator can now emit a scalar assignment for a narrowly proven first-active-lane read. In straight-line code with the entry mask, a VGPR produced by a signed integer conversion of a scalar buffer load at a fixed offset has the same value in every active lane. A write to the VGPR invalidates that proof. Branching shaders and changed execution masks remain outside this profile.

On Windows, python -B tests/startup_uniform_lane_check.py at 65b0bb4 passed the positive case and five rejection controls. The source-built gfx1013 inputs exercise the binary decoder, stage translator and emitted HLSL assignments. The controls change the source, destination, VGPR definition, mask or branch. This PR covers translation and rejection only. It includes no application files.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6574554417 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1222). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T04:22:08Z. --- Refs #1137 The startup shader translator can now emit a scalar assignment for a narrowly proven first-active-lane read. In straight-line code with the entry mask, a VGPR produced by a signed integer conversion of a scalar buffer load at a fixed offset has the same value in every active lane. A write to the VGPR invalidates that proof. Branching shaders and changed execution masks remain outside this profile. On Windows, `python -B tests/startup_uniform_lane_check.py` at 65b0bb4 passed the positive case and five rejection controls. The source-built gfx1013 inputs exercise the binary decoder, stage translator and emitted HLSL assignments. The controls change the source, destination, VGPR definition, mask or branch. This PR covers translation and rejection only. It includes no application files.
tedin7 commented 2026-11-24 04:28:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:28:16Z.

Review: COMMENTED


Reviewed commit 65b0bb42 (CMakeLists.txt, docs/startup-runtime.md, tools/startup/gfx2hlsl.py, tests/startup_uniform_lane_check.py).

Findings

  • s_buffer_load_dword* & v_cvt_i32_f32 uniform tracking (tools/startup/gfx2hlsl.py):
    • op_s_buffer_load_dword tags destination SGPRs with ('fixed_buffer_word',) only when not mods and the offset operand is a literal (0x[0-9a-f]+|\d+). S() permits numeric reads of fixed_buffer_word, and any subsequent set_s without sym clears the tag via self.sym.pop(n, None).
    • op_v_cvt_i32_f32 keeps the prior VEC_U behavior (uint(int(F(...))), rejecting modifiers) and adds dst to self.uniform_v only when self.exec_known and src is an SGPR tagged ('fixed_buffer_word',).
    • set_v discards n from self.uniform_v on any VGPR write, and op_v_readfirstlane_b32 requires not mods, not self.has_branches, self.exec_known, an SGPR destination, and src in self.uniform_v.
  • Tests & docs: tests/startup_uniform_lane_check.py covers the positive path and five rejection controls (per-lane source, different VGPR, clobbered VGPR, modified exec_lo, and branch target). docs/startup-runtime.md is title-neutral and accurately describes the profile.

Checks (Linux)

  • /root/.local/share/x2w-rev-venv/bin/python -B tests/startup_uniform_lane_check.py: passed (fixed scalar buffer value translated; five unproven reads rejected).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py: passed.
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: passed (form coverage checks passed).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (self-test passed; 16 Markdown files, 276 links).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (self-test passed; 1029 files).
  • git diff HEAD~1 --check: passed.
  • LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py: 129 tests run, 2 skipped, 10 failures, 1 error (environment lacks llvm-mc-15/llvm-objcopy-15 and LLVM 19 DPP output differs from LLVM 15 on v_cndmask_b32_dpp; unrelated to this PR).
  • Windows build and CTest suite were not run locally.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033654579 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1222#pullrequestreview-6033654579). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:28:16Z. **Review:** COMMENTED --- Reviewed commit `65b0bb42` (`CMakeLists.txt`, `docs/startup-runtime.md`, `tools/startup/gfx2hlsl.py`, `tests/startup_uniform_lane_check.py`). ### Findings - **`s_buffer_load_dword*` & `v_cvt_i32_f32` uniform tracking (`tools/startup/gfx2hlsl.py`)**: - `op_s_buffer_load_dword` tags destination SGPRs with `('fixed_buffer_word',)` only when `not mods` and the offset operand is a literal (`0x[0-9a-f]+|\d+`). `S()` permits numeric reads of `fixed_buffer_word`, and any subsequent `set_s` without `sym` clears the tag via `self.sym.pop(n, None)`. - `op_v_cvt_i32_f32` keeps the prior `VEC_U` behavior (`uint(int(F(...)))`, rejecting modifiers) and adds `dst` to `self.uniform_v` only when `self.exec_known` and `src` is an SGPR tagged `('fixed_buffer_word',)`. - `set_v` discards `n` from `self.uniform_v` on any VGPR write, and `op_v_readfirstlane_b32` requires `not mods`, `not self.has_branches`, `self.exec_known`, an SGPR destination, and `src` in `self.uniform_v`. - **Tests & docs**: `tests/startup_uniform_lane_check.py` covers the positive path and five rejection controls (per-lane source, different VGPR, clobbered VGPR, modified `exec_lo`, and branch target). `docs/startup-runtime.md` is title-neutral and accurately describes the profile. ### Checks (Linux) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_uniform_lane_check.py`: passed (`fixed scalar buffer value translated; five unproven reads rejected`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/pixel_aot_check.py`: passed. - `/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py`: passed (`form coverage checks passed`). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (self-test passed; 16 Markdown files, 276 links). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (self-test passed; 1029 files). - `git diff HEAD~1 --check`: passed. - `LLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/python -B tests/rdna2_tools_check.py`: 129 tests run, 2 skipped, 10 failures, 1 error (environment lacks `llvm-mc-15`/`llvm-objcopy-15` and LLVM 19 DPP output differs from LLVM 15 on `v_cndmask_b32_dpp`; unrelated to this PR). - Windows build and CTest suite were not run locally.
upstream-sync closed this pull request 2026-11-24 06:47:02 +00:00
R0Y00 commented 2026-11-24 06:50:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T04:26:46Z.


Rasptum has a working Windows 10 glyph branch on top of denn0x's wide-descriptor fix. Please reuse its root-signature handling and SDWA work. The overlap here is only v_readfirstlane_b32: that branch emits the current lane unconditionally, while this PR proves a uniform source and tests rejection of varying values, register clobbers, changed masks and branches. A single implementation with these controls would cover both contributions.

Author's branch at 95304976 · Windows 10 report · Descriptor fix. Blend decoding is already claimed in #1216.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122026159 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1222#issuecomment-7122026159). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T04:26:46Z. --- Rasptum has a working Windows 10 glyph branch on top of denn0x's wide-descriptor fix. Please reuse its root-signature handling and SDWA work. The overlap here is only `v_readfirstlane_b32`: that branch emits the current lane unconditionally, while this PR proves a uniform source and tests rejection of varying values, register clobbers, changed masks and branches. A single implementation with these controls would cover both contributions. [Author's branch at 95304976](https://github.com/rasptum/Xbox2Windows/commit/95304976b9fddf2b72529e170539c9ed162ce1a4) · [Windows 10 report](https://github.com/R0Y00/Xbox2Windows/issues/1150#issuecomment-7121735800) · [Descriptor fix](https://github.com/R0Y00/Xbox2Windows/commit/16ac9a22bdc73dd57cd3496d2c92665e0bb4d606). Blend decoding is already claimed in [#1216](https://github.com/R0Y00/Xbox2Windows/issues/1216#issuecomment-7122009849).
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
R0Y00/Xbox2Windows!1215
No description provided.