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

Manually merged
github merged 2 commits from gh-pr/1222/head into gh-pr/1222/base 2026-11-26 22:50:06 +00:00
Owner

@⁠R0Y00 on GitHub · 2026-11-24 04:22 UTC · original
R0Y00:codex/startup-uniform-buffer-lane → main · +79 −2 · 4 files · 2 commits · merged 2026-11-24 04:54 UTC

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.

**@⁠R0Y00** on GitHub · 2026-11-24 04:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1222) `R0Y00:codex/startup-uniform-buffer-lane` → `main` · +79 −2 · 4 files · 2 commits · merged 2026-11-24 04:54 UTC 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:50:05 +00:00
github manually merged commit f84292e7d8 into gh-pr/1222/base 2026-11-26 22:50:06 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 04:26 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-24 04:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1222#issuecomment-7122026159) 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://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/1150) · [Descriptor fix](https://github.com/R0Y00/Xbox2Windows/commit/16ac9a22bdc73dd57cd3496d2c92665e0bb4d606). Blend decoding is already claimed in [#1216](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/1216).
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 04:28 UTC · original · reviewed

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.
**@⁠tedin7** on GitHub · 2026-11-24 04:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1222#pullrequestreview-6033654579) · **reviewed** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.