Skip to content

shader: use named register codes in gfx1013_compute_clear.cpp - #3913

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:quality-item2-s5-compute-clear
Dec 3, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:quality-item2-s5-compute-clear

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

src/gfx1013_compute_clear.cpp still writes registers and operands as bare numbers: 128 for the SGPR count and for the constant 0 operand, and 256 for the first VGPR operand. #3830 added src/gfx1013_registers.h to keep the register code, operand and translator slot meanings apart. #3901, #3905 and #3910 converted gfx1013_graphics_wqm.inl, gfx1013_sampled_pixel.cpp and gfx1013_vertex_id.cpp.

Change

This is the fifth slice. No behaviour change.

  • ea94df004 uses the constants from gfx1013_registers.h in src/gfx1013_compute_clear.cpp (+9/-6, one file). The substitution is textual and the values and types are unchanged, so the replayed clear and the refusals are unchanged.
  • Sites converted:
    • reg::sgpr_count for 128 as the size of the scalar state array (std::array<Value,128>) and as the source<128 bound that makes the v_mbcnt_lo source a scalar register.
    • operand::zero for 128 as the constant 0 source of s_mov_b32 (three uses).
    • operand::vgpr_base for 256 as the first VGPR operand in the v_mbcnt_hi source check and its index.
  • The file includes the header. Unlike the files in shader: use named register codes in gfx1013_sampled_pixel.cpp #3905 and shader: use named register codes in gfx1013_vertex_id.cpp #3910, it needs no namespace alias: replay_group_clear is defined as x2w::replay_group_clear, so gfx1013:: resolves inside x2w.
  • Two require expressions that became longer than the file's existing lines are wrapped. Their operands and evaluation order are unchanged.
  • Left numeric:
    • 102, the guest SGPR bound this replay accepts. It is not a register code, and the header has no constant for it.
    • 256 as the VGPR state size (std::array<Value,256>) and dst<255. These are counts, not operand codes.
    • (operands&0xfffc01ff)==193, a match on a whole masked VOP3 operand word, not a single operand field.
    • decode masks and opcodes.
  • The five mutation anchors (string(REPLACE ...) in tests/cmake/gfx1013_compute_clear.cmake) target lines this change does not touch.
  • No build change. gfx1013_registers.h is header-only and already in src.

Validation

Built on Windows with MSVC, head ea94df004 on main 8a2f84d1b. The targeted set passed:

  • gfx1013_compute_clear_all and the gfx1013_compute_clear_* cases, which cover the accepted clears and the refusals.
  • The five mutation controls among them (*_mut, WILL_FAIL) still fail as expected, so the anchors still apply.
  • native_translator_corpus_dxil and native_translator_corpus_ir.

Translator corpus: the TSV built from main 8a2f84d1b and the TSV built from this branch have the same SHA-256, so they are byte-identical.

Each replaced site was also read a second time against the header to confirm the same value, type and meaning.

Other open PRs

No open PR edits gfx1013_compute_clear.cpp. The gfx1013_direct_*.inl frontends are still edited by many open PRs, so they will follow once that work lands.

Replace the magic register and operand numbers in
src/gfx1013_compute_clear.cpp with the constants from
src/gfx1013_registers.h: the SGPR count (128, the scalar state size and
the register operand bound of v_mbcnt_lo), the constant 0 source of
s_mov_b32 (128) and the VGPR operand base (256). The file now includes
the header; replay_group_clear is defined as x2w::replay_group_clear, so
gfx1013:: resolves without an alias. The substitution is textual and
the values and types are unchanged, so the replayed clear is identical.
Left as they are: the 102-SGPR guest bound, the VGPR file size 256,
dst < 255, the encoded VOP3 operand word 193, decode masks and opcodes.
The five mutation anchors are on lines this change does not touch.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently reviewed ea94df0. The symbols resolve to the original operand values and preserve the scalar and vector bounds, short-circuit checks, and vector index. On Windows 11 with MSVC Debug, built all six gfx1013_compute_clear targets and ran ctest --preset dev --no-tests=error -j 1 -R '^gfx1013_compute_clear_': 44/44 passed, including all five mutation targets. This source-built replay fixture does not require a GPU.

@R0Y00
R0Y00 enabled auto-merge (squash) December 3, 2026 07:09
@R0Y00
R0Y00 merged commit 66d97a7 into R0Y00:main Dec 3, 2026
5 checks passed
Leyukaka added a commit to Leyukaka/Xbox2Windows that referenced this pull request Dec 3, 2026
The source-contract checks still looked for the numeric spellings that
the register-name slices replaced:

- gfx1013_isa_meta_check.py: the ext_src255 and vop3_literal model
  anchors and two contract needles now use operand::literal, the SOP1,
  SOPC and SOP2 literal checks are pinned too, and the header include is
  required.
- gfx1013_pixel_meta_check.py: the literal_255 model anchor and the
  contract needle now use gfx1013::operand::literal; the named inline
  integer ranges, the include and the namespace alias are pinned.
- gfx1013_compute_clear_meta_check.py: the mbcnt_hi_src model anchor
  uses gfx1013::operand::vgpr_base after R0Y00#3913, and the four renamed
  sites and the include are pinned.

Each script now also reads src/gfx1013_registers.h and checks the
numeric values behind the names it relies on (literal 255; zero 128,
int_pos_last 192, int_neg_first 193, int_neg_last 208; sgpr_count 128,
vgpr_base 256), so the encodings stay covered. The test cases, the
models and the CMake mutation anchors are unchanged.
R0Y00 pushed a commit that referenced this pull request Dec 3, 2026
…cpp (#3916)

* shader: use the named literal operand in gfx1013_isa.cpp

Replace the nine 255 comparisons in probe_instruction with
operand::literal from src/gfx1013_registers.h. They test whether a
VOP1/VOP2/VOPC, SOP1, SOPC, SOP2, VOP3 or VOP3P source field selects the
trailing literal dword, which adds one word to the instruction size.
The file is inside namespace x2w::gfx1013, so operand:: needs no
qualifier. The values and types are unchanged, so every decoded size
is identical. Left as they are: the DPP and SDWA selectors 233, 234,
249 and 250 (the header has no names for them), field masks and
opcodes. The five mutation anchors are on other lines.

* shader: use named operand codes in gfx1013_pixel.cpp

Name the literal operand (255) and the inline integer bounds (128, 192,
193, 208) in the v_mov_b32 source decode of decode_color with the
constants from src/gfx1013_registers.h. The function is a file-static
outside namespace x2w, so the file aliases x2w::gfx1013. The values and
types are unchanged, so the decoded colour is identical. The lines that
tests/cmake/gfx1013_pixel.cmake uses as mutation anchors stay numeric:
src >= 256 && vgpr[src - 256] with its body, dst = src - 128,
dst = 192u - src and the float table. The 240..247 float range is
also left as is.

* tests: match the named operand codes in the gfx1013 meta checks

The source-contract checks still looked for the numeric spellings that
the register-name slices replaced:

- gfx1013_isa_meta_check.py: the ext_src255 and vop3_literal model
  anchors and two contract needles now use operand::literal, the SOP1,
  SOPC and SOP2 literal checks are pinned too, and the header include is
  required.
- gfx1013_pixel_meta_check.py: the literal_255 model anchor and the
  contract needle now use gfx1013::operand::literal; the named inline
  integer ranges, the include and the namespace alias are pinned.
- gfx1013_compute_clear_meta_check.py: the mbcnt_hi_src model anchor
  uses gfx1013::operand::vgpr_base after #3913, and the four renamed
  sites and the include are pinned.

Each script now also reads src/gfx1013_registers.h and checks the
numeric values behind the names it relies on (literal 255; zero 128,
int_pos_last 192, int_neg_first 193, int_neg_last 208; sgpr_count 128,
vgpr_base 256), so the encodings stay covered. The test cases, the
models and the CMake mutation anchors are unchanged.
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.

2 participants