compute: read a resource-heap descriptor at an added byte offset #3253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3253"
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 Not-Saii on 2026-11-28T01:57:55Z.
Refs #3224. Target branch
main.Gap. Some start-up compute shaders read a buffer descriptor from the resource heap in a waterfall loop over a lane-selected slot. They form the descriptor address by adding the slot's byte offset to the heap base, instead of passing the offset as the SGPR offset of the load:
The direct path refused the first add as a numeric use of the heap table (
unbound numeric SGPR sN). In the census on #3224, this is the largest group left in that family after #3006: 12 wave32 shaders.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl):s_add_u32 lo, <resource heap>, <non-constant SGPR>. Every other scalar ALU instruction clears it.s_add_u32 hi, 0, src_sccors_addc_u32 hi, 0, 0right after that add marks the high word as its carry.s_load_dwordx4with no SGPR offset from exactly that pair becomes the same indexed heap descriptor as the existing SGPR-offset form. It is lowered the same way, slot index = byte offset >> 5, and it goes through the same heap view contract (refuse_heap_contract).unbound numeric SGPR sN);heap descriptor address high word is not the carry of its offset add);s_load_dwordx4.What this does and doesn't do for the start-up shaders. A
.c67request has no view metadata, so these loads now stop atdirect resource-heap load requires the selected GPU slot and its view type. That's the resource-heap family of #3023 / #3063. The descriptor rewrite inside the loop would then meetheap byte window loaded inside a loop. None of the 12 compiles because of this PR alone.CBV_SRV_UAV_HEAP_DIRECTLY_INDEXEDand a single leftover user SGPR.maindoesn't bind the heap there; #3221 does. With #3221 they should take the same path. I haven't measured that.Tests. Dev build (Debug), NVIDIA GeForce RTX 4090 (driver 32.0.16.1088), Windows 11 build 26300, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled,
main8007a539plus this change.native_global_srv_heap_replay_hardware: passed, 118 assertions. The new section 11 oftests/native_global_srv_heap_replay_check.pycovers the container route with theraw_buffercontract:.viewsit is refused with the heap text;s_addc_u32compiles;s_mov_b32as the high word, ans_cmpbetween the adds and an immediate offset are each refused with their own text.native_heap_offset_add(new, compile-only): passed, 5 of 5. It writes a slot 67 request from source with the start-up shaders' entry layout: a table in s4, the resource heap in s5 and the sampler heap in s6, both heap flags, wave32.native_global_srv_heap_replay_warp: skipped (77). The in-box WARP has no 32-lane waves.8007a539, the replay fails at its first section 11 assertion (unbound numeric SGPR s2) andnative_heap_offset_addfails 3 of 5 (unbound numeric SGPR s5).heap_offset_address, the replay fails atadded_mov_highandnative_heap_offset_addfailsmov_highandscc_clobbered.Captured requests (counts only). I took the 156 slot 67 requests that stop first at
unbound numeric SGPRon7fcde81f, from a local start-up run (runtime2e12dd8e, 300 s). I rancompile_dxil --jobs 8 gfx1013-direct-cs@36 --requestson them with8007a539and with8007a539plus this change:unbound numeric SGPR s10todirect resource-heap load requires the selected GPU slot and its view type;A program that compiled before can't contain the heap add, because the add was refused, and SCC is only tracked after such an add. So already translated requests are unaffected by construction.
Overlap.
refuse_heap_contractand produces the same indexed descriptor symbol, so it should follow whichever contracts land. Both PRs add totests/native_global_srv_heap_replay_check.py(this one at the end), so a rebase conflict is possible there.docs/experiments/native-global-srv-heap-replay.mddescribes the new section and records these results.AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T03:20:45Z.
Review: COMMENTED
Review of head
fb071338(the PR's own change is the same asbc0d714a; the new head only merges currentmain).What I checked:
heap_offset_add/heap_offset_carry/heap_offset_addressinsrc/gfx1013_compute_native.cpp: SCC is tracked only as the carry ofs_add_u32 lo, <resource heap>, <non-constant SGPR>, it is cleared by every other SOP1/SOP2/SOPC/SOPK instruction, and a CFG join with a different SCC drops it. Anything that does not match stays refused, so the change can only widen what compiles in this exact shape.src/gfx1013_direct_compute.inl: the lowered slot index (low word >> 5) is the same as the existing SGPR-offset heap load next to it, and the new path goes through the samerefuse_heap_contract. The add itself writes the offset to the low word and0to SCC (write(128, ...)), so the followings_add_u32 hi, 0, src_scc/s_addc_u32 hi, 0, 0gives a high word of 0, as the slot-0 heap base needs.native_heap_offset_add(request-level refusals and controls) and section 11 ofnative_global_srv_heap_replay_check.py, a real D3D12 record/compile/replay with GPU readback for selections 0 and 1 plus the slot-1 mismatch control. The expected outputs are the fixture's slot data, not derived from the translator.Commands run:
python3 tests/docs_links_check.pyok,python3 tests/bidi_controls_check.pyok,git diff --check origin/main...HEADclean,python3 -m py_compileon both test files ok.-R '^native_(heap_offset_add|global_srv_heap_replay_warp|compute_clear|compute_raw_root|descriptor_scc_warp|direct_container|heap_handle_probe_warp|lane_spill_descriptor_warp)$': dev 8/8 passed, release 8/8 passed.native_global_srv_heap_replay_warpran (not skipped) on this WARP version.heap_offset_carryno longer acceptss_add_u32 hi, 0, src_scc):native_heap_offset_addfails atadded,native_global_srv_heap_replay_warpfails at the section 11 no-metadata assertion.>> 6instead of>> 5on the added address):native_global_srv_heap_replay_warpfails atrecord added select 1.No blocking findings. The receipt follows in a separate comment.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T03:21:03Z.
Win2025 WARP receipt for head
fb071338after updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
fb071338d4d82b0532b521b8c72bb8a740554840:--preset dev):cmake --build --preset dev --target compile_dxil native_global_srv_heap_replay native_store_replay native_heap_handle_probe -- -j 4):8.82s(configure1.84s)ctest --preset dev -R '^native_(heap_offset_add|global_srv_heap_replay_warp|compute_clear|compute_raw_root|descriptor_scc_warp|direct_container|heap_handle_probe_warp|lane_spill_descriptor_warp)$' --parallel 5 --no-tests=error --output-on-failure): 8/8 passed (16.03s:native_heap_handle_probe_warp0.32s,native_compute_clear0.44s,native_heap_offset_add0.85s,native_lane_spill_descriptor_warp1.00s,native_descriptor_scc_warp1.45s,native_compute_raw_root1.69s,native_global_srv_heap_replay_warp6.21s,native_direct_container15.40s)/O2(--preset release):cmake --build --preset release --target compile_dxil native_global_srv_heap_replay native_store_replay native_heap_handle_probe -- -j 4):34.68s(configure2.49s)ctest --preset release -R '^native_(heap_offset_add|global_srv_heap_replay_warp|compute_clear|compute_raw_root|descriptor_scc_warp|direct_container|heap_handle_probe_warp|lane_spill_descriptor_warp)$' --parallel 5 --no-tests=error --output-on-failure): 8/8 passed (12.34s:native_heap_handle_probe_warp0.17s,native_compute_clear0.25s,native_heap_offset_add0.30s,native_descriptor_scc_warp0.68s,native_compute_raw_root0.77s,native_lane_spill_descriptor_warp0.36s,native_global_srv_heap_replay_warp3.73s,native_direct_container11.89s)sccache: 39/70 hits; wall60.1stested:
fb071338via fetch (pull/3253/head, no patch)The new tests
native_heap_offset_addandnative_global_srv_heap_replay_warp(section 11) ran in both legs.AI-assisted; commands listed were executed locally.