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

Merged
Leyukaka merged 2 commits from upstream-pr/3830 into main 2026-12-02 18:45:23 +00:00
Leyukaka commented 2026-12-02 07:34:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T07:34:42Z.


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 #3791 (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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5601968824 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3830). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-02T07:34:42Z. --- ## 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 #3791 (`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.
R0Y00 commented 2026-12-02 18:45:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T18:45:13Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6156757232 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3830#pullrequestreview-6156757232). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T18:45:13Z. **Review:** APPROVED --- 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.
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!3830
No description provided.