compute: lower root-UAV global DWORD stores in the direct path #3333
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3333"
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 SimSalabimse on 2026-11-28T10:06:37Z.
Part of #3224: the "direct global memory supports only DWORD loads with a scalar address pair" refusal (9 shaders, 19,528 untranslated dispatches in Not-Saii's census at
8007a539).What this covers. The census lists only the refusal text, not the opcodes per shader. At
8007a539,global_load_dwordthroughx4with a scalar address pair already passed the decoder, so my working assumption is that these keys fail on global stores. That is inferred, not checked against the 9 keys. If someone with those requests can rerun the census on this branch, that would confirm how many it actually recovers.Now lowered (direct compute path)
global_store_dword,dwordx2,dwordx3,dwordx4in thesaddrform, when the address is an unadvanced root UAV plus a 32-bit VGPR offset.glc,slcanddlcare accepted, and so is a signed immediate that's a multiple of 4.global_load_dwordthroughx4. Out-of-range stores are skipped and out-of-range loads return 0.Still refused, with a clear reason
The
offform (VGPR address pair), FLAT and scratch, an LDS result, byte and short ops, atomics,saddr127, a store through a root that isn't a UAV, an unaligned immediate, a data range pastv255, a mismatched or advanced SGPR pair, and scalar ALU on the root pair.Tests
tests/native_global_store_check.py(encodings plus negative controls) andtests/native_store_replay.cpp, registered asnative_global_store_encodings/native_global_store_hardware. Thenative_global_load_hardwarefixture now expects the root-SRV store refusal string.e519c57e,ctest -j 1with the audio device tests excluded:native_global_store_hardwareandnative_global_load_hardwarepassed twice each,native_passed 351/351 (332 passed, 19 WARP-only skips), andstartup_gfx2hlsl_passed 387/387.AI-assisted (Cursor)
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T19:00:57Z.
Review: CHANGES_REQUESTED
Reviewed
e519c57eby its diff. The lowering of the four store widths, the EXEC write mask, the signed 12-bit offset and the refusals (nosaddr,lds, flat/scratch, sub-DWORD, atomics) look correct. Three test gaps, a rebase point and a scope note:0xfffffff4offset 16; the widewraploads innative_global_load_check.pyall have their first DWORD out of range. Soconst int last_offset = offset;(dropping(count - 1) * 4, diff:284) would pass. Fix: an x4 (or x2) access whose first DWORD passes the guard and whose last would wrap; confirm it fails with the guard narrowed.u0. The only UAV load is the guarded one, stored toLOAD_SLOTand compared to 0; in-range loads are only checked through the root SRV. For example the load's handle classunsigned(uav)(diff:279) is not checked by a readback. Fix: after the stores ands_waitcnt,global_load_dworda DWORD a lane stored and store it to a free slot.const unsigned reg = analysis.srv++;(diff:272) still yieldsu0. Fix: a fixture with a root SRV and a root UAV, expectingt0andu0.mainaddedpacked_d16_x_uavandindexed_raw_srvafterfloat3_texture_uav, anddecode()'s bound is nowindexed_raw_srv(src/direct_compute_cache.cpp:138).root_buffer_uavhas to go after them, the bound has to follow, and the names list needspacked_d16_x_uavandindexed_raw_srvadded beforeroot_buffer_uav, otherwise kind 25 prints asroot_buffer_uavand 27 asunknown.root_buffer_uav(as forroot_buffer_srv), so programs that reach it move to aUAV kind root_buffer_uavrefusal rather than run. Worth stating in the body that this is translation only.Request changes for 1-4.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-28T20:52:20Z.
@Leyukaka Thanks for the review. All three test gaps are covered now, and the branch is rebased onto current main (head
a910514a).0xffffffe4 + (group << 2) + (lane & 3)) so the compiler can't fold the compare away. The test requires the bound2^32 - 1 - 28(or its signed form). If you narrowlast_offsettooffset, a different constant comes out and the test fails.s_waitcnt, each lane loads back the DWORD it wrote and stores it to a free slot, so the readback covers theunsigned(uav)load.t0,t1andu0.Windows test PC (RTX 4070 Ti plus WARP),
ctest -j 1 -R '^native_global_': 4 passed andnative_global_srv_heap_replay_warpskipped (77, as expected), ctest exit 0. Linux: python-linux passed 258/258.AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T07:34:43Z.
Review: CHANGES_REQUESTED
Re-reviewed at
a910514a(rebased onto8ecd30fe) bygit range-diffagainste519c57e. This replaces my earlier review.Fixed: 2 (after
s_mov_b32 exec_lo, -1ands_waitcnt, each lane reloads the DWORD at 48N throughu0and stores it to 6400+4N; the UAV load is no longerreadonly), 3 (theSRV(t0), SRV(t1), UAV(u0)program must reportt0 root=0,t1 root=1,u0 root=2), 4 (enum order, decode bound and names list,src/direct_compute_cache.cpp:138,:897) and 5 (scope stated indocs/experiments/native-direct-global-store.md).Point 1 is only partly fixed. The x4 store at offset 16 is there, but
wide_wrap_bound()searches the wholedxc -dumpbintext for4294967267|-29|4294967268|-28.X4_BASE = 0xffffffe4is 4294967268, which is -28 as an i32, one of the accepted values. Thev_add_nc_u32 v24, 0xffffffe4, v24that builds the address is emitted as anaddwith that constant, so the dump can match on the address add whatever bound the guard compares against, andconst int last_offset = offset;may still pass. This is by reading, not measured.Fix: match only the compare line (for example
icmp ule i32 %\S+, -29oricmp ult i32 %\S+, -28), or use a base that is not an accepted value; addadd i32 %a, -28to the samples that must not match; and post the matching dump line for the head and for thelast_offset = offsetmutant.Small: with
ulethe mutant's bound is 2^32-1-16 = 4294967279, i.e. -17; -16 is itsultform. The comments and the doc say-16.git merge-tree --write-treeontoorigin/main212d4b5f: clean.Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T12:41:28Z.
Review: COMMENTED
Head
2da1cc4c, rebased onto main77d1ba4d. Diff and source reading only, nothing built or run.git range-diffagainsta910514a: commits 2-4 are unchanged, commit 1 differs only by the rebase overheap_typed_srv(root_buffer_uavstays last in the enum, the decode bound and the names list,src/direct_compute_cache.cpp:138,:900-901).2da1cc4cis new (doc and test, +21/-10).Point 1 is fixed in the code.
wide_wrap_bound()(tests/native_global_store_check.py:145-153) now matches onlyicmp ule i32 %x, -29oricmp ult i32 %x, -28(or their unsigned spellings). The samples that must not match (:261-262) includeadd i32 %a, -28,icmp ule i32 %a, -17,icmp ult i32 %a, -16and the bare constants. By reading: the guard is emitted asuleagainst0xffffffff - last_offset(src/gfx1013_direct_compute.inl:636-638), the x4 at offset 16 is the only access in the program with a last offset of 28, and withlast_offset = offsetno guard compares against -29.The
-16/-17wording is corrected in the docstring (:38), the comments anddocs/experiments/native-direct-global-store.md:42-44.Still missing, as asked on
a910514a:dxc -dumpbinline for this head and for thelast_offset = offsetmutant;2da1cc4c. The last posted run is ona910514a, and PR CI does not runnative_global_store_*(not in theprtest filter, notests/checks/python-linuxentry), so the matcher samples inencodingsdo not run there either.ctest --preset dev -j 1 -R "^native_global_"on this head would cover it.I will approve once those are posted.
git merge-tree --write-treeontoorigin/main77d1ba4d: clean.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T12:55:25Z.
Review of head
2da1cc4c. Read only, nothing built or run.MUST
main. #3389 merged asaf1cab5c.git merge-tree --write-tree --name-only origin/main 2da1cc4cexits 1 withCONFLICT (content): Merge conflict in src/direct_compute_cache.cpp, in one hunk inview_kind_name.mainnow ends the list with"indexed_raw_srv"};and addsstatic_assert(std::size(names) == static_cast<size_t>(ComputeViewKind::indexed_raw_srv) + 1);. To resolve: keep this branch's"indexed_raw_srv", "heap_typed_srv", "root_buffer_uav"};and point the assert atComputeViewKind::root_buffer_uav, the last kind here. Drop the strayponytail:from its comment. Please rebase.a910514aand again at 12:41: thedxc -dumpbinline for the head and for thelast_offset = offsetmutant, and a run on this head. I agree with the reading thatwide_wrap_bound()now matches only the compare.SHOULD
native-direct-global-store.mdsays a program that reaches the manifest or native dispatch "is refused withUAV kind root_buffer_uav". Onlyformat_compute_runtime_manifestproduces that text, and onlycompile_dxilcalls it. Since #3449, default runs use the in-process route. There, the binding loop intranslate_compute_nativelythrows"view kind " + std::to_string(...) + " is not bound for a natively translated program"for any kind outside its accepted set, androot_buffer_uavis enum value 28 here (afterheap_typed_srv= 27). So in a default run, the 9 census shaders move fromdirect global memory supports only DWORD loads with a scalar address pairtoview kind 28 is not bound for a natively translated program. Please name both reasons, so a census reader can match them.NIT
index_mask = 1(bind_root_address(..., root_class)). The raw MUBUFbyte_boundstest still compares againstSymbol{Symbol::Type::root_address,low.value,1}without it. A rawbuffer_load_dwordthrough a root UAV is therefore refused asunsupported raw root buffer descriptor or offset. Onmainit getscompute root descriptor type or visibility. It is refused either way, so only the reason changes. I found this by reading.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:24:24Z.
Re-review of the delta
2da1cc4c→6128c25a, rebased onto mainaf1cab5c(read-only, on Linux; no build or run here). MUST 1 is resolved. Leyukaka's open request and SHOULD 3 still hold this PR, so I'm not merging it.Resolved
git range-diffshows commits 2–5 unchanged (=). Commit 1 (04252273) changes only as the rebase over #3389 requires:"indexed_raw_srv", "heap_typed_srv", "root_buffer_uav"};ends the list. The new6128c25apoints main'sstatic_assertatComputeViewKind::root_buffer_uav.git merge-tree --write-tree origin/main 6128c25aexits with rc 0 on current mainc04e0dd6. CI at6128c25a: Windows, Linux Python and gfx1013 fixtures pass.// ponytail:comment above that assert comes from main (git grep -c ponytail origin/main -- src/direct_compute_cache.cpp→ 1). It is not this branch's, so please ignore my "drop it".Still open
a910514aand 12:41 is unanswered. They asked for thedxc -dumpbinline for this head and for thelast_offset = offsetmutant, and for a run ofctest --preset dev -j 1 -R "^native_global_"on this head. The PR CI still doesn't runnative_global_store_*.docs/experiments/native-direct-global-store.mdstill says only that such a program "is refused withUAV kind root_buffer_uav". That text comes fromcompile_dxil's manifest formatter. On the default in-process route (#3449), the refusal isview kind 28 is not bound for a natively translated program. Please name both.NIT 4 (the reason change for a raw root-UAV
buffer_load) is unchanged and not blocking.This comment was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T13:40:39Z.
Run on head
6128c25a: Windows, a hardware adapter plus WARP,devpreset configured with-DX2W_WITH_OPUS=OFF, full build.ctest --preset dev --no-tests=error -R '^native_global_', exit 0:Output of
native_global_store_hardware:native_global_store_encodingsprints the first of those lines. The store test has no heap-slot case. In thenative_global_srv_heap_replay_hardwareoutput, thewindow_storecase oftests/native_global_srv_heap_replay_check.pyreports its expected refusal:Not covered:
dxc -dumpbinlines, for the head or for thelast_offset = offsetmutant. I did not produce them and did not run the mutant.native_global_srv_heap_replay_warpskipped withadapter has no 32-lane waves (4..4),-> exit 77,fixture capability skip (77). The heap replay ran on the hardware adapter only.UAV kind root_buffer_uavrefusal) is unchanged at this head.This answers the head-run part of my request. The dumpbin lines are still open.
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-29T18:43:20Z.
Windows test PC (
--preset dev,-j 1), at6128c25a49e082178934d487e26930ac52c31d52.This is the remaining
dxc -dumpbinevidence.native_global_store_check.pycompiledprogram()the same way the hardware test does (gfx1013-direct-cs@0), then randxc.exe -dumpbinon that.cso.At this head, unmodified, the compare
wide_wrap_boundaccepts is:wide_wrap_boundreturns true. That is the only accepted line. The address add ofX4_BASEis a different line and is not matched:The same dump also has other
icmp uleconstants (-17,-5,-13,-25,-45). Those are not the x4 wrap compare. There are noicmp ultlines.Local mutant, not committed. Only
src/gfx1013_direct_compute.inlline 636 changed, fromconst int last_offset = offset + static_cast<int>((count - 1) * 4);toconst int last_offset = offset;. The x4 compare becomes:wide_wrap_boundreturns false. Versus the head dump, the mutant also changes three other compares (-13to-9,-25to-17,-45to-33). The add of-28is unchanged.ctest --preset dev -j 1with-Rmatchingnative_global_store_:native_global_store_encodingsPassed,native_global_store_hardwarePassed, ctest exit 0.native_global_store_encodingsPassed.native_global_store_hardwareFailed withAssertionError: x4 wrap guard does not cover the last dword. ctest exit 8..inlfrom HEAD:git statusandgit diffempty, HEAD still6128c25a49e082178934d487e26930ac52c31d52. Rebuilt. Both store tests Passed again, ctest exit 0.This does not change SHOULD 3. Nothing was committed or pushed.
AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T19:06:31Z.
Review: APPROVED
Head
6128c25a, diff only. This replaces my change request.Delta from
2da1cc4cbygit range-diff: commits 2-5 unchanged, commit 1 differs only by the rebase over #3389, and6128c25apoints thestatic_assertatComputeViewKind::root_buffer_uav(src/direct_compute_cache.cpp:903).The
dxc -dumpbinlines posted by the author answer my last open point: at the head the matched compare isicmp ule i32 %t306, -29and theadd i32 -28, %t153is not matched; withlast_offset = offsetthe compare becomes-17andnative_global_store_hardwarefails withx4 wrap guard does not cover the last dword. That is the author's measurement, I did not reproduce the dump or the mutant; it is consistent with0xffffffff - last_offset(-29 = -1 - (16 + 12)).Still open, not blocking for me: the SHOULD from the other review,
docs/experiments/native-direct-global-store.md:22-23names onlyUAV kind root_buffer_uavand not the in-processview kind 28 is not bound for a natively translated program.Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T19:12:13Z.
Re-check at head
6128c25a(unchanged since my 13:24 comment). Read only, on Linux.Resolved
dxc -dumpbinevidence at this head. The accepted compare is%t307 = icmp ule i32 %t306, -29. Theadd i32 -28, %t153address add is not matched. Withlast_offset = offsetthe compare becomes-17, andnative_global_store_hardwarefails withx4 wrap guard does not cover the last dword. The earlier head run (ctest --preset dev --no-tests=error -R '^native_global_', 5/5, with the WARP heap replay skipped as a 77) covers the run part. Leyukaka's change request is replaced by an approval at6128c25a, so no review is still requesting changes.git merge-tree --write-tree origin/main 6128c25aexits 0 on current maind3e306a7. CI at the head: Windows, Linux Python and gfx1013 fixtures pass. The /O2 and coverage jobs are skipped, as they are for PRs. The new tests are registered through thetests/cmake/*.cmakeglob. The diff changes no launcher, preset or runtime default.Left as a follow-up (not blocking)
native-direct-global-store.mdstill names onlyUAV kind root_buffer_uav. On the default in-process route,d3d12_compute_dispatch.inlrefuses the same program withview kind 28 is not bound for a natively translated program. A one-line doc follow-up that names both reasons would let census readers match them.buffer_loadchanges) is unchanged.With 0 MUSTs, no change request standing and CI green, I'm merging at
6128c25a.This comment was AI-assisted.