Repository navigation
compute: read a resource-heap descriptor at an added byte offset - #3253
Merged
Merged
Conversation
A waterfall loop over a lane-selected heap slot forms the descriptor
address as s_add_u32 lo, <resource heap>, <offset>; s_add_u32 hi, 0,
src_scc (or s_addc_u32 hi, 0, 0); s_load_dwordx4 ..., s[lo:hi], 0x0.
The direct path refused the add as a numeric use of the heap table
("unbound numeric SGPR sN").
Track SCC as the carry of such an add and treat the load from that
exact pair as the indexed heap descriptor of the SGPR-offset form, read
under the same heap view contract. A constant offset, a high word that
is not the add's carry, SCC clobbered between the adds and an immediate
offset on the load stay refused.
Refs R0Y00#3224
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs R0Y00#3224 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
reviewed
Nov 28, 2026
tedin7
left a comment
Collaborator
There was a problem hiding this comment.
Review of head fb071338 (the PR's own change is the same as bc0d714a; the new head only merges current main).
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.- Tests:
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. - No other open or merged PR covers this slice in the direct compute path (#2861 is the gfx2hlsl path).
Commands run:
- Linux:
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. - Windows Server 2025, D3D12 WARP 1.0.22,
-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. - Mutation 1 (
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. - Mutation 2 (slot index
>> 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.
Collaborator
|
Win2025 WARP receipt for head fb07133 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
The new tests AI-assisted; commands listed were executed locally. |
Leyukaka
added a commit
to Leyukaka/Xbox2Windows
that referenced
this pull request
Nov 28, 2026
Direct wave64 compute now gives scalar loads the same SGPR bound as wave32 since R0Y00#3180: destination ranges may end at s107 (VCC_HI), and VCC_LO/VCC_HI may be the SGPR offset. In the direct wave64 model VCC is two scalar words that both host wave32 halves hold identically (ballot writers publish both words through the exchange), so a uniform numeric load into s106/s107 is read back the same way by s_mov, v_cndmask and the VCC branches. Table descriptor loads and resource-heap loads at an added byte offset (R0Y00#3253), which track descriptor identity or a slot index instead of payload bits, still refuse when their destination overlaps VCC in wave64. Graphics and ranges past s107 keep their refusals. New test native_smem_vcc_wave64 (controls, hardware): x4 and x8 loads ending at s107, VCC_LO and VCC_HI offsets, and a 64-bit mask loaded into VCC driving v_cndmask in both host halves under a patterned EXEC. native_direct_container replaces the wave64 VCC refusals it had with a symbolic-destination refusal. native_heap_offset_add gains a wave64 control: an added-offset heap address loaded into s[104:107] refuses with the overlap message.
R0Y00
pushed a commit
that referenced
this pull request
Nov 28, 2026
Direct wave64 compute now gives scalar loads the same SGPR bound as wave32 since #3180: destination ranges may end at s107 (VCC_HI), and VCC_LO/VCC_HI may be the SGPR offset. In the direct wave64 model VCC is two scalar words that both host wave32 halves hold identically (ballot writers publish both words through the exchange), so a uniform numeric load into s106/s107 is read back the same way by s_mov, v_cndmask and the VCC branches. Table descriptor loads and resource-heap loads at an added byte offset (#3253), which track descriptor identity or a slot index instead of payload bits, still refuse when their destination overlaps VCC in wave64. Graphics and ranges past s107 keep their refusals. New test native_smem_vcc_wave64 (controls, hardware): x4 and x8 loads ending at s107, VCC_LO and VCC_HI offsets, and a 64-bit mask loaded into VCC driving v_cndmask in both host halves under a patterned EXEC. native_direct_container replaces the wave64 VCC refusals it had with a symbolic-destination refusal. native_heap_offset_add gains a wave64 control: an added-offset heap address loaded into s[104:107] refuses with the overlap message.
tedin7
added a commit
to tedin7/Xbox2Windows
that referenced
this pull request
Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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; native: bind a single directly indexed heap flag as a descriptor table #3221 does. With native: bind a single directly indexed heap flag as a descriptor table #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