Repository navigation
shader: use named register codes in gfx1013_sampled_pixel.cpp - #3905
Conversation
Replace the magic register and operand numbers in src/gfx1013_sampled_pixel.cpp with the constants from src/gfx1013_registers.h: M0 (124), the inline integer bounds (128, 192, 193, 208), 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: the float constant range 240..247 and its table index (the header's float_last is 248), 192u - index, the VGPR file size 256 (array size and destination bound), addr < 255, the 256 + addr / 257 + addr coordinate pair, decode masks, opcodes and HLSL text. The mutation anchors in tests/cmake/gfx1013_sampled_pixel.cmake are untouched.
R0Y00
left a comment
There was a problem hiding this comment.
Independently reviewed e9d9b96. 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.
Problem
src/gfx1013_sampled_pixel.cppstill 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 addedsrc/gfx1013_registers.hto keep the register code, operand and translator slot meanings apart, and #3901 convertedgfx1013_graphics_wqm.inl.Change
This is the third slice. No behaviour change.
a206c48b9uses the constants fromgfx1013_registers.hinsrc/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.namespace x2w, so it includes the header and addsnamespace gfx1013 = x2w::gfx1013;inside its anonymous namespace. The uses then readgfx1013::operand::...andgfx1013::reg::m0, as in the earlier slices.240..247and its table indexindex-240. The header'sfloat_lastis 248 (1/(2*pi)), which this translator does not accept, so naming only the lower bound would leave the range half-converted.256as the VGPR file size (the array size and the destination bound) andaddr<255. These are counts, not operand codes.256+addr/257+addrcoordinate pair,192u-index, decode masks, opcodes and HLSL text.tests/cmake/gfx1013_sampled_pixel.cmake(thestring(REPLACE ...)sources) target lines this change does not touch.gfx1013_registers.his header-only and already insrc.Validation
Built on Windows with MSVC, head
a206c48b9onmainb6171650f. The targeted set passed 68/68:gfx1013_sampled_pixel_alland thegfx1013_sampled_pixel_*cases, which pin the generated HLSL and the refusal reasons.*_mut,WILL_FAIL) still fail as expected, so the anchors still apply.native_sampled_replay,native_sampled_pixel_warpandnative_indexed_pixel_texture_warp.native_translator_corpus_dxilandnative_translator_corpus_ir.Translator corpus: the TSV built from
mainb6171650fand 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, thegfx1013_direct_*.inlfrontends (graphics, compute, mesh), are each edited by 12 to 15 open PRs, so they will follow once that work lands.