startup: translate the SMEM offset 'off' as the literal 0 in gfx2hlsl #1669
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1676"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T16:56:24Z.
Fixes #1674.
Change
tools/startup/gfx2hlsl.py: the SMEM offset operandoffnames no offset, so the byte offset is zero. A smallsmem_offset()helper mapsoffto the literal0before the existing handling in both load families:s_buffer_load_dword*used to refuse it withoperand 'off'. It now emits exactly what the literal0emits,rN.Load(0x00000000u + 4 * i), and marks the result as a fixed buffer word in the same way.s_load_dword*used to fail inint(ops[2], 0)and report the misleadings_load with a register offset through .... It now takes offset 0:rN.Load(0)from a root buffer, or descriptor offset 0 from a table.s_buffer_load_dword*s_load_dword*offm0Out of scope, as the issue says: an
m0register offset fors_load_dword*, and the count of locally refused shaders.Test
tests/startup_gfx2hlsl_smem_offset_check.pyfollowsstartup_translator_check.py. It drives the handlers on a scalar symbol state with no machine code and checks:offagainst the literal0. Emitted lines and the resulting symbols must be equal fors_buffer_load_dword,_dwordx2and_dwordx4, fors_load_dwordand_dwordx2from a root buffer, and fors_load_dwordx8from a descriptor table, where all eight registers must be('desc', table, 0, i).m0forms keep their behaviour:0x4and0x8are unchanged,s_buffer_load_dword ... m0givesr0.Load(m0 + 0)and is not marked as a fixed word, ands_load_dword ... m0is still refused.of,OFF,offset,null,off:0) are refused by both kinds of load. Sooffis not loosened into "anything means zero".smem_offsetreplaced by the identity in-process, bothoffforms must be refused again with the old messages.The test is registered as
startup_gfx2hlsl_smem_offsetand added to the platform-independent Python job and the list inAGENTS.md.docs/experiments.mdgets a short section with the operand table.Results
Commit
04711708onf121513e, Windows 11 26300.9974, Python 3.12:On
f121513ewithout the change, the same file fails at the first check (s_buffer_load_dword: off accepted: MISMATCH "operand 'off'") and exits non-zero.These also still pass:
startup_translator_check.py,startup_uniform_lane_check.py(whose fixed-element read depends on the fixed-word marking),startup_gfx2hlsl_sdwa_check.py,startup_sampler_heap_check.py,startup_gfx2hlsl_capture_check.py,startup_inline_sampler_check.py,startup_flat_param_check.py,startup_image_load_mip_check.py,docs_links_check.pyandbidi_controls_check.py.Not measured: whether the locally refused loading-screen shaders now translate. That needs the local cache, as the issue notes.
AI-assisted (Claude Code).