shader: lower multi-DWORD GLOBAL loads in direct Compute #3166
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3166
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3164"
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?
@RonLogic on GitHub · 2026-11-27 19:24 UTC · original
RonLogic:shader/native-global-vector-load→main· +137 −44 · 5 files · 2 commits · merged 2026-11-27 21:55 UTCChange
Fixes #3165. Refs #2935 and #2962. The direct Compute frontend now lowers
global_load_dwordx2,global_load_dwordx3, andglobal_load_dwordx4through a proven root SRV address. At88cddb09, all three source-built requests stopped at guest+0x38on the scalar-only decoder restriction.The lowering reuses the existing DWORD alignment and signed immediate contract. It reads the address before writing the tuple, covers the full transfer width in the view size and range guard, and writes consecutive VGPRs under EXEC. Unsupported segments, pointers and destination tuples still give named refusals. This is the scalar-address GLOBAL form. #3145 is the separate raw MUBUF task.
Verification
Tested
90fe9b5cdf869d66a8ac2873017bbee1f27ebf34on88cddb0919fd4044ff45211c0919c3aefda73c35. Windows 1126300.10075, Visual Studio 2026 18.12.1, SDK 10.0.26100, DXC 1.9.2602.17, RTX 407032.0.16.2124. Native replay used the default D3D12 device and its normal configuration without the debug layer.Evidence and follow-up
The experiment note documents the source-built fixture and the public ISA references. The native replay requires wave32, which the local WARP adapter does not expose. Guest accesses outside the bound root view remain subject to the documented root-view limit.
I used Codex to prepare the change and ran verification locally.
github-bot referenced this pull request2026-11-27 19:38:56 +00:00
@KelboLive on GitHub · 2026-11-27 20:59 UTC · original
LGTM! The multi-DWORD GLOBAL load lowering is solid:
Key improvements:
global_load_dwordx2/x3/x4now properly compute the address once before writing any destination VGPRs, even when destinations alias VADDR.min_size = offset + width * 4).Minor note: The test fixture
wide_programcorrectly reverses destination ordering when testing aliasing, which matches the hardware behavior where consecutive VGPRs are written in order. This is important for games that use overlapping register allocations.This significantly expands direct compute coverage for games using large global memory loads.
@pigalot on GitHub · 2026-11-27 21:55 UTC · original · approved these changes
I reviewed
72141fd0(themainmerge on top of90fe9b5c) merged overmainc45bf9ab. The merge is clean (tree94b6afed) andgit diff --cached --checkis clean. The source change is the same as in90fe9b5c.What I traced.
global_load_dword,dwordx2,dwordx4anddwordx3(gfx1013_isa_tables.inl:713).widths[]{1, 2, 4, 3}matches, andi.namenow comes from the table.vaddrbefore any destination write, so an alias of VADDR (thealiascase) reads the original address. The low two bits are dropped as before.addof a negative constant, the same modulo 2^32 as the oldsub.count * 4.vector_writeunder EXEC.global_load_dwordmatch insrc/is in #3163'sclear_vector_spills(merged asc45bf9ab). It still clears one register and only for the exactglobal_load_dwordname. That is safe, becauseDirectCompute::write()refuses any write to a VGPR that holds symbolic lanes before the analysis clear matters. Widening that match is a possible follow-up, not a blocker for this PR.What I ran. I built
compile_dxil native_store_replayindevandrelease, then ran/O2, with no skips. I also rannative_lane_spill_descriptor_hardwareindev; it passes.main28e4a025, the PR's version ofnative_global_load_check.pyfails at the first refusal.mainstill refuses the GLOBAL encodings with "direct global memory supports only global_load_dword with a scalar address pair", and its own test listsdwordx2among the refusals.Mutants in
src/gfx1013_direct_compute.inl. For each, I rebuilt indevand rannative_global_load_hardware:widths[]{1, 2, 3, 4}(x3 and x4 swapped)+ 4)selectapplied to component 0 only0x51aa0001..4instead of 0)last_offset = offset)Restored and rebuilt afterwards;
git diff --quietis clean.For the survivor, I added a probe: an x4 load from v2 (
0xfffffff0 + 4 * (lane & 3)) at offset 0, so lanes 1..3 cross 2^32 partway through the tuple. On this head every component reads 0. Under the mutant every component also reads 0, because this driver bounds-checks the unwrapped component offsets. So the last-DWORD guard is not observable here. It would matter on a driver that wraps component offsets.Non-blocking. If you want the last-DWORD guard pinned on every driver, an IR-level assert would do it: check that the x4 module's upper bound is
0xffffffff - (offset + 12), not0xffffffff - offset.Verdict: approve on
72141fd0.Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off.
CI:
Build and test on Windowspasses on72141fd0.This reply was AI-assisted.
@tedin7 on GitHub · 2026-11-27 22:17 UTC · original
Windows Server 2025 verification of
72141fd0b859a07eb6115a769dc6092c3ba14ede(D3D12 WARP, MSVC 14.44.35207):cmake --build --preset dev --target compile_dxil native_store_replay native_compute_ir_dump;ctest --preset dev -R <native sweep>: 100% tests passed out of 158 (91 passed, 67 skipped;native_global_load_hardwareskips here, it needs a wave32 adapter)--preset release;ctest --preset release -R <native sweep>: 100% tests passed out of 158 (91 passed, 67 skipped)cpp-migration(a0f67731) with only this PR's own change applied, dev and release: 70 of 71 native tests passed or skipped. The one failure,native_sdwa_f16_ir, fails the same way oncpp-migrationwithout this PR, so it is not caused by this change.<native sweep>= everynative_*test exceptnative_startup_request_cache_hardware, which fails on WARP-only hosts with or without this PR.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-27 22:17 UTC · original · reviewed
Review of
72141fd0b8(updated with main). Comment only.The direct GLOBAL path now handles all four GFX10 DWORD load opcodes, 12 to 15 (
global_load_dword,_dwordx2,_dwordx4,_dwordx3; the width table{1, 2, 4, 3}matches that opcode order). It still accepts only the saddr form,ADDR = SADDR + zext(VADDR) + sext(OFFSET). The native decode refuses other segments, the LDS bit (bit 13), a null or EXEC_HI saddr (125, 127), and opcodes outside 12 to 15. The destination range is checked against v255. The wrap guard covers both the first DWORD (negative offset) and the last DWORD (positive offset plus the width), and an out-of-range lane reads 0 for every component. The low two address bits are dropped, asbuffer_load_dworddoes in this path.Coverage note: the only test of this path is
native_global_load_hardware, which needs a wave32 adapter and skips on our WARP host and in CI. The multi-DWORD readback therefore rests on the RTX 4070 run in the description. A no-GPU IR check like thenative_*_irtests, for onedwordx3load with an aliased destination, would keep the address-before-write order covered everywhere.On
cpp-migration: main itself no longer merges cleanly with that branch, since #3142; the conflicting files are ones this PR does not touch. So I applied only this PR's own change ontocpp-migrationand ran the native sweep there (comment below).Commands:
git diff origin/main...pull/3164/head(read),git merge-tree --write-tree origin/cpp-migration pull/3164/head,git apply --3wayof the PR's own diff ontoorigin/cpp-migration, plus the Windows commands in the comment below.AI-assisted; commands listed were executed locally.