Repository navigation
shader: use named register codes in gfx1013_vertex_id.cpp - #3910
Conversation
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
left a comment
There was a problem hiding this comment.
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.
Problem
src/gfx1013_vertex_id.cppstill 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 addedsrc/gfx1013_registers.hto keep the register code, operand and translator slot meanings apart. #3901 and #3905 convertedgfx1013_graphics_wqm.inlandgfx1013_sampled_pixel.cpp.Change
This is the fourth slice. No behaviour change.
2e895d17duses the constants fromgfx1013_registers.hinsrc/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.namespace x2w, so it includes the header and addsnamespace gfx1013 = x2w::gfx1013;inside its anonymous namespace. The uses then readgfx1013::operand::....vgpr_basefor 256 as the first VGPR operand,zero/int_pos_lastfor the range 128..192,int_neg_first/int_neg_lastfor 193..208,literalfor 255, andzerofor thesrc == 128source of a scalar move.reg != 128in the disabled export check.gfx1013_vertex_id_disabled_export_mutuses that exact line as itsstring(REPLACE ...)source intests/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.240..247and its table indexselector - 240. The header'sfloat_lastis 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.tests/cmake/gfx1013_vertex_id.cmaketarget lines this change does not touch.gfx1013_registers.his header-only and already insrc.Validation
Built on Windows with MSVC, head
2e895d17donmain7db6f1973. The targeted set passed:gfx1013_vertex_id_alland thegfx1013_vertex_id_*cases, which pin the generated HLSL and the refusal reasons.*_mut,WILL_FAIL) still fail as expected, so the anchors still apply.native_buffered_vertex_warp,native_sampled_pixel_warp,native_sampled_replayandnative_indexed_pixel_texture_warp.native_translator_corpus_dxilandnative_translator_corpus_ir.Translator corpus: the TSV built from
main7db6f1973and 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. Thegfx1013_direct_*.inlfrontends are still edited by many open PRs, so they will follow once that work lands.