compute: accept raw buffer loads without offen or with a scalar offset #3172
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3172"
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 Leyukaka on 2026-11-27T20:17:57Z.
Fixes #3143. Part of #2935. Target branch
main. #3143 was claimed by @JB2WIN; I took it over after two hours without activity, with credit to them. Their plan also acceptedm0assoffset; this PR keepsm0refused, and that can follow.Change (
src/gfx1013_compute_native.cpp): direct compute accepts raw buffer loads (buffer_load_dword,_dwordx2,_dwordx3,_dwordx4) withoffenclear, and with a scalar offset that is a numeric SGPR or an inline integer.offenwith an inline-0soffset, because the legacy HLSL emitter assumesoffenand ignoressoffset.DirectCompute::memory) already adds the optional VGPR offset, the 12-bit immediate offset andsoffset, then aligns to a dword. It readssoffsetthroughoperand32, which refuses a non-numeric SGPR.idxen,glc,dlc,slc,tfe,lds, inline float constants and literals assoffset.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
maina5dad843plus this commit.native_global_srv_heap_replay_hardwareadds wave32 requests, each compared over all 72 output words with a CPU reference:offwith an SGPRsoffset, at all four widths;soffsetplus an immediate offset;offenplus an SGPRsoffset;native_global_srv_heap_replay.cpptakes an optional reference file for those cases.glc,slcandidxen;soffset;soffset.native_global_srv_heap_replay_warpskips (77) on this machine. Thenative_direct_containerandstartup_compute_dispatch*tests pass, 25 tests in all, two of them WARP skips.native_global_srv_heap_replay_hardware:glc;soffsetfrom the emitted address.Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmaina5dad843.glcanddlc. Of the rest:AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T21:49:00Z.
Review: APPROVED
I reviewed
7189ffc7merged over currentmain2b7ebf18. The merge is clean (treec6c196d2) andgit diff --cached --checkis clean.What I traced.
a & 0x0203e000refusesidxen,glc,dlc,lds, bit 17 and opcode bit 7, andb & 0x00e00000refusesslc,tfeand bit 21.offen(bit 12) is now free. That is the same rule the direct raw store already uses (0x3e000/0xe00000), so loads and stores now accept the same addressing.soffset: the guard admits SGPRs 0 to 105 and inline integers 128 to 208, and refusesvcc,ttmp,m0,null,exec, the float constants and 255. MUBUF has no literal word, so refusing 255 is right. An SGPR that is not numeric is refused later byoperand32(unbound numeric SGPR), as the descriptor-SGPR control shows.DirectCompute::memoryreadsvaddronly whenoffenis set, then adds the 12-bit immediate offset andoperand32(soffset), and aligns to a dword. Withoffenclear,vaddris not read, so the newoffcases do not depend onv1.direct == false) and the graphics path keep the strict rule.What I ran.
dev: full build, then12/12 pass, with two capability skips (77):
native_global_srv_heap_replay_warpandstartup_compute_dispatch_native_warp. The hardware test passes, and all eight new address forms match the 72-word CPU reference.release/O2: builtcompile_dxilandnative_global_srv_heap_replay, then ranctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_(hardware|warp)$'. The hardware test passes; the WARP test is a capability skip (77) here too.Mutants, each rebuilt in
devand run againstnative_global_srv_heap_replay_hardware:slc/tfeaccepted (b & 0x00e00000dropped)glcacceptedidxenacceptedsoffsetguard removedsoffsetfrom the address (existing code)vaddreven withoffenclear (existing code)dlcacceptedldsacceptedsoffset(193 to 208) refusedRestored and rebuilt afterwards;
git diff --quietis clean. The negative control is main's rule, so the new cases fail onmain.Non-blocking.
dlcandldsrefusals are not pinned. The description lists both as still refused, and the code refuses them, but no control covers them.ldsmatters most: an LDS-direct load writes LDS instead ofvdata, so accepting it would be a silent miscompile. Two more entries in the refusal loop (flags: 1 << 15andflags: 1 << 16) would pin them.soffsetis accepted but not exercised. 193 to 208 pass the guard, and the emitter adds them as a 32-bit value, sooffset + soffsetwraps inside the view. My reading of the RDNA buffer addressing is thatsoffsetis unsigned, so the hardware would address past the buffer instead. That is a hypothesis I have not checked on hardware. Compilers are unlikely to emit it, so refusing 193 to 208 until a case needs them would be the cautious choice.Verdict: approve on
7189ffc7.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass on7189ffc7.This reply was AI-assisted.