Skip to content

shader: use named register codes in gfx1013_vertex_id.cpp - #3910

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:quality-item2-s4-vertex-id
Dec 3, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
Leyukaka:quality-item2-s4-vertex-id

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

src/gfx1013_vertex_id.cpp still writes operands as bare numbers: 128, 192, 193 and 208 for the inline integer bounds, 128 for the constant 0 source of a scalar move, 255 for the literal 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 and #3905 converted gfx1013_graphics_wqm.inl and gfx1013_sampled_pixel.cpp.

Change

This is the fourth slice. No behaviour change.

  • 2e895d17d uses the constants from gfx1013_registers.h in src/gfx1013_vertex_id.cpp (+16/-12, one file). The substitution is textual and the values and types are unchanged, so the emitted HLSL and the refusal text are unchanged.
  • As in shader: use named register codes in gfx1013_sampled_pixel.cpp #3905, the file is its own translation unit outside namespace x2w, so it includes the header and adds namespace gfx1013 = x2w::gfx1013; inside its anonymous namespace. The uses then read gfx1013::operand::....
  • Sites converted: vgpr_base for 256 as the first VGPR operand, zero / int_pos_last for the range 128..192, int_neg_first / int_neg_last for 193..208, literal for 255, and zero for the src == 128 source of a scalar move.
  • Two expressions that became longer than the file's existing lines are wrapped. Their operands and evaluation order are unchanged.
  • Left numeric:
    • reg != 128 in the disabled export check. gfx1013_vertex_id_disabled_export_mut uses that exact line as its string(REPLACE ...) source in tests/cmake/gfx1013_vertex_id.cmake, so renaming it would make the configure step fail on the lost anchor. It can follow together with the anchor in a later change.
    • the float constant range 240..247 and its table index selector - 240. The header's float_last is 248 (1/(2*pi)), which this translator refuses (refuse_unsupported_input_selector_248), so naming only the lower bound would leave the range half-converted.
    • 192u - selector, decode masks, opcodes and HLSL text.
  • The other four mutation anchors in tests/cmake/gfx1013_vertex_id.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 2e895d17d on main 7db6f1973. The targeted set passed:

  • gfx1013_vertex_id_all and the gfx1013_vertex_id_* cases, which pin the generated HLSL and the refusal reasons.
  • The five mutation controls among them (*_mut, WILL_FAIL) still fail as expected, so the anchors still apply.
  • native_buffered_vertex_warp, native_sampled_pixel_warp, native_sampled_replay and native_indexed_pixel_texture_warp.
  • native_translator_corpus_dxil and native_translator_corpus_ir.

Translator corpus: the TSV built from main 7db6f1973 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_vertex_id.cpp. The gfx1013_direct_*.inl frontends are still edited by many open PRs, so they will follow once that work lands.

Replace the magic operand numbers in src/gfx1013_vertex_id.cpp with the
constants from src/gfx1013_registers.h: the inline integer bounds (128,
192, 193, 208), the constant 0 source of a scalar move (128), the
literal operand (255) and the VGPR operand base (256). The file now
includes the header and aliases x2w::gfx1013 inside its anonymous
namespace. The substitution is textual and the values and types are
unchanged, so the generated HLSL and bindings are byte-identical. Left
as they are: reg != 128 in export_value, which is the anchor of the
gfx1013_vertex_id_disabled_export_mut control; the float constant range
240..247 and its table index (the header's float_last is 248);
192u - selector; the VGPR file size 256; decode masks, opcodes and HLSL
text. The other four 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 2e895d17 in a clean trial merge onto 9dfe168a. The named operand constants match the original selectors and unsigned arithmetic at each changed site. Selector 248 still refuses, and the disabled-export mutation anchor stays intact. MSVC Debug passed 66 targeted cases: all gfx1013_vertex_id_* checks including the five WILL_FAIL controls, the DXIL and IR translator corpora, and the sampled replay and three WARP cases. The buffered-vertex readback matched 24/24 components; sampled replay matched both cold and warm outputs and its three refusal controls. Both regenerated corpus TSVs are byte-identical to the main build (DXIL SHA-256 8c9a053ca0d0d4928654a46803675847099e013724ab2fe56159d7fbdb370ec5, IR c78e6c8b075bd114b360c87d9bbd0e2ce67a732f4ca62d25b0a7a3616cca9df6). No capability skips.

@R0Y00
R0Y00 enabled auto-merge (squash) December 3, 2026 05:11
@R0Y00
R0Y00 merged commit 2a280a9 into R0Y00:main Dec 3, 2026
5 checks passed
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