Skip to content

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

Draft
Leyukaka wants to merge 2 commits into
R0Y00:mainfrom
Leyukaka:quality-2-gfx1013-registers
Draft

Leyukaka wants to merge 2 commits into
R0Y00:mainfrom
Leyukaka:quality-2-gfx1013-registers

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

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 tooling: add a translator corpus hash check and an IR dump option #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.

Opened as a draft: six open PRs (#3792, #3717, #3631, #3544, #3527, #3320) also edit gfx1013_compute_native.cpp. I will rebase this after they land, so it does not force them to rebase.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant