shader: use named register codes in gfx1013_vertex_id.cpp #3912

Manually merged
github merged 1 commit from github-bot/gh-3910 into gh-pr/3910/base 2026-12-03 05:15:13 +00:00 AGit
Owner

@⁠Leyukaka on GitHub · 2026-12-03 05:00 UTC · original
Leyukaka:quality-item2-s4-vertex-id → main · +16 −12 · 1 files · 1 commits · merged 2026-12-03 05:13 UTC

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. #3832 added src/gfx1013_registers.h to keep the register code, operand and translator slot meanings apart. #3903 and #3907 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 #3907, 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.

**@⁠Leyukaka** on GitHub · 2026-12-03 05:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3910) `Leyukaka:quality-item2-s4-vertex-id` → `main` · +16 −12 · 1 files · 1 commits · merged 2026-12-03 05:13 UTC ## 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. #3832 added `src/gfx1013_registers.h` to keep the register code, operand and translator slot meanings apart. #3903 and #3907 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 #3907, 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 05:05:25 +00:00
github-bot changed target branch from main to gh-pr/3910/base 2026-12-03 05:14:45 +00:00
github manually merged commit 2e895d17d7 into gh-pr/3910/base 2026-12-03 05:15:12 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 05:10 UTC · original · approved these changes

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** on GitHub · 2026-12-03 05:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3910#pullrequestreview-6164039111) · **approved these changes** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.