Repository navigation
shader: use named register codes in gfx1013_compute_clear.cpp - #3913
Merged
Merged
Conversation
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
approved these changes
Dec 3, 2026
R0Y00
left a comment
Owner
There was a problem hiding this comment.
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
enabled auto-merge (squash)
December 3, 2026 07:09
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
src/gfx1013_compute_clear.cppstill 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 addedsrc/gfx1013_registers.hto keep the register code, operand and translator slot meanings apart. #3901, #3905 and #3910 convertedgfx1013_graphics_wqm.inl,gfx1013_sampled_pixel.cppandgfx1013_vertex_id.cpp.Change
This is the fifth slice. No behaviour change.
ea94df004uses the constants fromgfx1013_registers.hinsrc/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.reg::sgpr_countfor 128 as the size of the scalar state array (std::array<Value,128>) and as thesource<128bound that makes thev_mbcnt_losource a scalar register.operand::zerofor 128 as the constant 0 source ofs_mov_b32(three uses).operand::vgpr_basefor 256 as the first VGPR operand in thev_mbcnt_hisource check and its index.replay_group_clearis defined asx2w::replay_group_clear, sogfx1013::resolves insidex2w.requireexpressions that became longer than the file's existing lines are wrapped. Their operands and evaluation order are unchanged.102, the guest SGPR bound this replay accepts. It is not a register code, and the header has no constant for it.256as the VGPR state size (std::array<Value,256>) anddst<255. These are counts, not operand codes.(operands&0xfffc01ff)==193, a match on a whole masked VOP3 operand word, not a single operand field.string(REPLACE ...)intests/cmake/gfx1013_compute_clear.cmake) target lines this change does not touch.gfx1013_registers.his header-only and already insrc.Validation
Built on Windows with MSVC, head
ea94df004onmain8a2f84d1b. The targeted set passed:gfx1013_compute_clear_alland thegfx1013_compute_clear_*cases, which cover the accepted clears and the refusals.*_mut,WILL_FAIL) still fail as expected, so the anchors still apply.native_translator_corpus_dxilandnative_translator_corpus_ir.Translator corpus: the TSV built from
main8a2f84d1band 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. Thegfx1013_direct_*.inlfrontends are still edited by many open PRs, so they will follow once that work lands.