shader: name gfx10 register codes in gfx1013_compute_native.cpp #3832

Manually merged
github merged 2 commits from github-bot/gh-3830 into gh-pr/3830/base 2026-12-02 18:52:48 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-12-02 07:34 UTC · original
Leyukaka:quality-2-gfx1013-registers → main · +299 −119 · 5 files · 2 commits · merged 2026-12-02 18:45 UTC

Problem

The gfx1013 translator writes scalar registers and operands as bare numbers (106, 107, 124 to 128, 255, 256...). The same integer means different things depending on where it appears:

  • a scalar register code, 0..127 (106/107 VCC, 124 M0, 125 NULL, 126/127 EXEC);
  • an ISA source operand, 0..511, where 128 is the constant 0 and 256 is the first VGPR;
  • a translator slot: some frontends keep SCC in slot 128 of their scalar state, the same number as operand 128.

Change

This is the first slice of replacing those numbers with named constants that keep the three meanings apart. No behaviour change.

  • 88541bca6 adds src/gfx1013_registers.h with x2w::gfx1013::reg and x2w::gfx1013::operand, and the gfx1013_registers_check test. static_asserts pin every value and one case per predicate checks its boundaries.
  • a65c80947 uses the constants in src/gfx1013_compute_native.cpp. The substitution is textual and the values are unchanged. Decode masks (& 127, & 255), HLSL text, VGPR counts and the remaining bounds (108, 104, < 105, < 127, 192u - code) are left as they are. The header joins the native shader revision inputs in CMakeLists.txt.

Only gfx1013_compute_native.cpp is converted here. Many open PRs edit the gfx1013_direct_graphics.inl, gfx1013_direct_compute.inl and gfx1013_direct_mesh.inl frontends, so those will follow in small slices once that work lands.

Validation

Built on Windows with MSVC, head a65c80947 on main f365f125b.

  • gfx1013_registers_check, native_compile_dxil_refusals, gfx1013_compute_ir_all, native_fixed_graphics_psi1 and native_direct_container pass.
  • Translator corpus from #3793 (tests/translator_corpus_hash.py, steps in docs/experiments/translator-corpus.md): the output built from main f365f125b and the output built from this branch have the same SHA-256, so the DXIL fingerprints and the refusal reasons are byte-identical.

Other open PRs

Several open PRs also edit gfx1013_compute_native.cpp. Since this is a mechanical rename, any conflict with them is textual only. If this lands first and an author would like help with the rebase, I am glad to do it.

**@⁠Leyukaka** on GitHub · 2026-12-02 07:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3830) `Leyukaka:quality-2-gfx1013-registers` → `main` · +299 −119 · 5 files · 2 commits · merged 2026-12-02 18:45 UTC ## Problem The gfx1013 translator writes scalar registers and operands as bare numbers (106, 107, 124 to 128, 255, 256...). The same integer means different things depending on where it appears: - a scalar register code, 0..127 (106/107 VCC, 124 M0, 125 NULL, 126/127 EXEC); - an ISA source operand, 0..511, where 128 is the constant 0 and 256 is the first VGPR; - a translator slot: some frontends keep SCC in slot 128 of their scalar state, the same number as operand 128. ## Change This is the first slice of replacing those numbers with named constants that keep the three meanings apart. No behaviour change. - `88541bca6` adds `src/gfx1013_registers.h` with `x2w::gfx1013::reg` and `x2w::gfx1013::operand`, and the `gfx1013_registers_check` test. `static_assert`s pin every value and one case per predicate checks its boundaries. - `a65c80947` uses the constants in `src/gfx1013_compute_native.cpp`. The substitution is textual and the values are unchanged. Decode masks (`& 127`, `& 255`), HLSL text, VGPR counts and the remaining bounds (`108`, `104`, `< 105`, `< 127`, `192u - code`) are left as they are. The header joins the native shader revision inputs in `CMakeLists.txt`. Only `gfx1013_compute_native.cpp` is converted here. Many open PRs edit the `gfx1013_direct_graphics.inl`, `gfx1013_direct_compute.inl` and `gfx1013_direct_mesh.inl` frontends, so those will follow in small slices once that work lands. ## Validation Built on Windows with MSVC, head `a65c80947` on `main` `f365f125b`. - `gfx1013_registers_check`, `native_compile_dxil_refusals`, `gfx1013_compute_ir_all`, `native_fixed_graphics_psi1` and `native_direct_container` pass. - Translator corpus from #3793 (`tests/translator_corpus_hash.py`, steps in `docs/experiments/translator-corpus.md`): the output built from `main` `f365f125b` and the output built from this branch have the same SHA-256, so the DXIL fingerprints and the refusal reasons are byte-identical. ## Other open PRs Several open PRs also edit `gfx1013_compute_native.cpp`. Since this is a mechanical rename, any conflict with them is textual only. If this lands first and an author would like help with the rebase, I am glad to do it.
Add src/gfx1013_registers.h with x2w::gfx1013::reg (VCC, M0, NULL, EXEC,
the last general SGPR and the internal SCC slot) and x2w::gfx1013::operand
(inline integer and float ranges, VCCZ, EXECZ, SCC, the literal and the
VGPR base). The header notes the three number spaces that share these
integers: scalar register codes, ISA operand encodings and translator
slots. static_asserts pin every value; gfx1013_registers_check covers the
predicate boundaries. Nothing includes the header yet.
Replace the magic register and operand numbers in
src/gfx1013_compute_native.cpp with the constants from
src/gfx1013_registers.h: VCC, M0, NULL, EXEC, the last general SGPR,
the SGPR count, the zero/inline integer/float/literal/SCC operands and
the VGPR operand base. The substitution is textual and the values are
unchanged, so the translator output is byte-identical (the
native_translator_corpus_* guard checks this). Decode masks such as
& 127 and & 255, HLSL text, VGPR counts and the remaining bounds
(108, 104, < 105, < 127, 192u - code) are left as they are. The header
joins the native shader revision inputs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 07:35:01 +00:00
github-bot changed target branch from main to gh-pr/3830/base 2026-12-02 18:52:46 +00:00
github manually merged commit a65c80947b into gh-pr/3830/base 2026-12-02 18:52:48 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 18:45 UTC · original · approved these changes

Reviewed a65c8094. I checked the numeric substitutions in the decoder, dataflow and emitter and verified that the SGPR, operand and VGPR constants retain their numeric values. Independent Windows/MSVC Debug cmake --build --preset dev --target gfx1013_registers_check compile_dxil and ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^gfx1013_registers_|^native_direct_mesh$' passed 5/5. Trial merge into 98f808d9 was clean.

**@⁠R0Y00** on GitHub · 2026-12-02 18:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3830#pullrequestreview-6156757232) · **approved these changes** Reviewed a65c8094. I checked the numeric substitutions in the decoder, dataflow and emitter and verified that the SGPR, operand and VGPR constants retain their numeric values. Independent Windows/MSVC Debug `cmake --build --preset dev --target gfx1013_registers_check compile_dxil` and `ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^gfx1013_registers_|^native_direct_mesh$'` passed 5/5. Trial merge into 98f808d9 was clean.
This discussion has been locked. Commenting is limited to contributors.
No description provided.