shader: lower root-pointer global_load_dword in the direct C++ compute path #2966
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2966"
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 legacy-code-archaeologist on 2026-11-27T00:07:30Z.
Change
The direct C++ compute frontend now lowers
global_load_dwordin thesaddrform. Before, it refused it withunsupported instruction global_load_dword. Refs #2962 (part of the "global loads" item in #2935).root_buffer_srvbinding the scalar root loads inmemory()already use. The load becomes a raw buffer load from that view.gfx2hlsl.pyop_global_load_dworduses. A VADDR near 2^32 plus a positive offset reads 0 instead of wrapping into an in-bounds word.buffer_load_dwordin this path (DWORD alignment mode).gfx2hlsl.pyrefuses an unproven alignment instead; the console'sALIGNMENT_MODEis not measured.offform, the FLAT and scratch segments, other opcodes (wider loads, stores, atomics), theldsform, a non-root SADDR, a replaced high half, and an unaligned immediate offset. A pointer advanced by scalar arithmetic is refused earlier, as an unbound numeric SGPR.gfx2hlsl.pyaccepts a pointer advanced by a known literal; that is not done here.Files:
src/gfx1013_compute_native.cpp(decode),src/gfx1013_direct_compute.inl(global_load),tests/native_global_load_check.py,tests/cmake/native_global_load.cmakeanddocs/experiments/native-direct-global-load.md.Verification
Run on
cpp-migrationf934df52plus this commit, Windows 10.0.26100.9711,devpreset, NVIDIA Quadro M1000M (driver 32.0.15.7371), debug layer unavailable.ctest --preset dev --no-tests=error -R '^native_global_load_hardware$' -Vreports a skip (77). The 11 refusals and thedxc -dumpbinmodule checks passed: 6 raw buffer loads, 2 upper-bound guards and 1 lower-bound guard. The dispatch readback is not measured.native_store_replayneeds shader model 6.6 with wave32, which this Maxwell GPU lacks;native_scalar_lds_hardwareandnative_shift64_hardwareskip here for the same reason. A run on an SM 6.6 wave32 adapter would be very welcome.unsupported instruction global_load_dword.ctest --preset dev -R '^native_' -j 2one3670100plus the change: 97/99 passed, 9 skipped (77). The two failures are graphics PSO creations that return0x80070057on this adapter:native_graphics_vertex_vcc_join_hardware(it failed the same way before the change one97c5c7c) andnative_startup_request_cache_hardware(a desktop graphics pipeline; not compared against a baseline). This change only adds a compute-stage decode.f934df52,native_direct_container,native_shift64_controlsandnative_global_load_hardware(skip) were rerun.python -B tests/docs_links_check.py: ok.Evidence and follow-up
Fixture. All words are source-built and assembled with LLVM 15.0.7 (
clang -cc1as -triple amdgcn -target-cpu gfx1013 -filetype asm -show-encoding). The dispatch has two groups of 32 lanes. It reads the root SRV thatnative_store_replayfills with 0x51aa0000 + dword index, sized to 64 dwords by a scalar load at byte 252. Each lane stores five words:References with the offset dropped or the upper guard dropped must differ from the readback. The lower guard is not observable under a view below 4 GiB: the wrapped value lies outside the view either way.
Limits:
gfx2hlsl.pyhas the same limit. I did not check how the runtime sizes the root view on this branch.Checklist
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T00:34:18Z.
Review: APPROVED
Review of head
c5776536, tested merged ontocpp-migration8946fb16(after #2964). It auto-merges cleanly, and CI on the head is green. This is the dispatch readback you asked for, on an SM 6.6 wave32 adapter. Approving and merging.Code read:
0x37in [31:26], SEG = 2, opcode 12, the LDS bit refused, SADDR 125 (off) refused, a 12-bit signed offset, VADDR in word 1 [7:0] and VDST in [31:24].root_buffer_srv, andrequired_byteswidened to the positive offset.gfx2hlsl.op_global_load_dword, but only when the offset is non-zero, which is the only case that can wrap.Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release.
native_global_load_hardwarepassed:global_load_dword: 320 words of two groups matched (offsets 0, 16, -8, the 2^32 guard and an unaligned address); the offset-dropped and wrap-guard-dropped references differ;off, a table pointer, offset:2, dwordx2, store, a replaced high half, an advanced pointer, lds, flat and scratch segments, an atomic.ctest --preset release --no-tests=error -R '^native_': 48 tests, 47 passed and 1 skipped (77,native_comparison_pso_warp). The two graphics PSO failures you saw on the Quadro M1000M (0x80070057) do not happen here:native_graphics_vertex_vcc_join_hardwareandnative_startup_request_cache_hardwareboth pass. So they look specific to that adapter or driver.Mutation here: ignoring the immediate offset (
addr = vaddr) fails the readback, for example(9, '0x51aa0000', '0x51aa0004'). With it restored, it passes.Open, as you note, not blocking: dropping the low two address bits assumes DWORD alignment mode for global loads. The console's
SH_MEM_CONFIG.ALIGNMENT_MODEis not measured, andgfx2hlsl.pyrefuses an unproven alignment instead. The fixture's unaligned case pins the current choice, so a later measurement will show up as a fixture change.AI-assisted; the commands above were run locally.