shader: use named register codes in gfx1013_sampled_pixel.cpp #3905

Merged
Leyukaka merged 2 commits from upstream-pr/3905 into main 2026-12-03 01:55:00 +00:00
Leyukaka commented 2026-12-03 00:53:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-03T00:53:57Z.


Problem

src/gfx1013_sampled_pixel.cpp still writes operands as bare numbers: 128, 192, 193 and 208 for the inline integer bounds, 255 for the literal, 256 for the first VGPR operand and 124 for M0. #3830 added src/gfx1013_registers.h to keep the register code, operand and translator slot meanings apart, and #3901 converted gfx1013_graphics_wqm.inl.

Change

This is the third slice. No behaviour change.

  • a206c48b9 uses the constants from gfx1013_registers.h in src/gfx1013_sampled_pixel.cpp (+14/-11, one file). The substitution is textual and the values and types are unchanged, so the emitted HLSL and the refusal text are unchanged.
  • 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::... and gfx1013::reg::m0, as in the earlier slices.
  • Left numeric:
    • the float constant range 240..247 and its table index index-240. The header's float_last is 248 (1/(2*pi)), which this translator does not accept, so naming only the lower bound would leave the range half-converted.
    • 256 as the VGPR file size (the array size and the destination bound) and addr<255. These are counts, not operand codes.
    • the 256+addr / 257+addr coordinate pair, 192u-index, decode masks, opcodes and HLSL text.
  • The five mutation anchors in tests/cmake/gfx1013_sampled_pixel.cmake (the string(REPLACE ...) sources) 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 a206c48b9 on main b6171650f. The targeted set passed 68/68:

  • gfx1013_sampled_pixel_all and the gfx1013_sampled_pixel_* 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_sampled_replay, native_sampled_pixel_warp and native_indexed_pixel_texture_warp.
  • native_translator_corpus_dxil and native_translator_corpus_ir.

Translator corpus: the TSV built from main b6171650f 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_sampled_pixel.cpp. The next files in the plan, the gfx1013_direct_*.inl frontends (graphics, compute, mesh), are each edited by 12 to 15 open PRs, so they will follow once that work lands.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5617551922 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3905). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-03T00:53:57Z. --- ## Problem `src/gfx1013_sampled_pixel.cpp` still writes operands as bare numbers: 128, 192, 193 and 208 for the inline integer bounds, 255 for the literal, 256 for the first VGPR operand and 124 for M0. #3830 added `src/gfx1013_registers.h` to keep the register code, operand and translator slot meanings apart, and #3901 converted `gfx1013_graphics_wqm.inl`. ## Change This is the third slice. No behaviour change. - `a206c48b9` uses the constants from `gfx1013_registers.h` in `src/gfx1013_sampled_pixel.cpp` (+14/-11, one file). The substitution is textual and the values and types are unchanged, so the emitted HLSL and the refusal text are unchanged. - 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::...` and `gfx1013::reg::m0`, as in the earlier slices. - Left numeric: - the float constant range `240..247` and its table index `index-240`. The header's `float_last` is 248 (1/(2*pi)), which this translator does not accept, so naming only the lower bound would leave the range half-converted. - `256` as the VGPR file size (the array size and the destination bound) and `addr<255`. These are counts, not operand codes. - the `256+addr` / `257+addr` coordinate pair, `192u-index`, decode masks, opcodes and HLSL text. - The five mutation anchors in `tests/cmake/gfx1013_sampled_pixel.cmake` (the `string(REPLACE ...)` sources) 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 `a206c48b9` on `main` `b6171650f`. The targeted set passed 68/68: - `gfx1013_sampled_pixel_all` and the `gfx1013_sampled_pixel_*` 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_sampled_replay`, `native_sampled_pixel_warp` and `native_indexed_pixel_texture_warp`. - `native_translator_corpus_dxil` and `native_translator_corpus_ir`. Translator corpus: the TSV built from `main` `b6171650f` 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_sampled_pixel.cpp`. The next files in the plan, the `gfx1013_direct_*.inl` frontends (graphics, compute, mesh), are each edited by 12 to 15 open PRs, so they will follow once that work lands.
R0Y00 commented 2026-12-03 01:54:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:54:56Z.

Review: APPROVED


Independently reviewed e9d9b967. Each named register/operand code matches the previous numeric boundary and the scalar, literal, and VGPR paths keep the old behavior. MSVC Debug ctest --preset dev --no-tests=error -j 1 -R '^(gfx1013_sampled_pixel_all|shader_compile_sampled_pixel_cli_check|native_sampled_pixel_(warp|hardware))$' passed 4/4 in two serial selections on Windows 11 build 26300, WARP and RTX 4060 Laptop (616.56). Changing the lower negative bound to exclusive survived the default tests. With the existing dead scalar move changed locally from selector 200 to the first negative selector 193, the head passed and the mutant refused at byte 60. Both local edits were reverted and the original unit suite passed again.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6162366315 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3905#pullrequestreview-6162366315). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T01:54:56Z. **Review:** APPROVED --- Independently reviewed e9d9b967. Each named register/operand code matches the previous numeric boundary and the scalar, literal, and VGPR paths keep the old behavior. MSVC Debug `ctest --preset dev --no-tests=error -j 1 -R '^(gfx1013_sampled_pixel_all|shader_compile_sampled_pixel_cli_check|native_sampled_pixel_(warp|hardware))$'` passed 4/4 in two serial selections on Windows 11 build 26300, WARP and RTX 4060 Laptop (616.56). Changing the lower negative bound to exclusive survived the default tests. With the existing dead scalar move changed locally from selector 200 to the first negative selector 193, the head passed and the mutant refused at byte 60. Both local edits were reverted and the original unit suite passed again.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3905
No description provided.