runtime: bind heap view tokens for translated compute (#3023 stage 3, opt-in) #3719
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!3719
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3717"
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?
@JB2WIN on GitHub · 2026-12-01 10:07 UTC · original
JB2WIN:native/heap-token-runtime→main· +5845 −142 · 43 files · 26 commits · draft#3023 stage 3, runtime side. Stacked on #3633 (which contains #3546): please review only the commits after
f4cc6a0e(d2805e70onward). Draft, opt-in, default behaviour unchanged.The plan in #3023 has not been approved yet. I'm opening this so it can be looked at. If the direction doesn't fit, say so and I'll change or close it.
What it does
With
X2W_D3D12_HEAP_TOKENS=1, a translated compute program that has heap token lines (#3546 textures, #3633 raw buffers) is bound instead of refused:note_lock. The ring shrinks to 196,603 only with the opt-in.era_gpu_alias. Title-supplied memory or a view stride other than 32 is refused with "heap tokens need a GPU-visible view heap".heap_token_dims_srv(1D 1, 2D 2, 2D array 6, raw 0x20). Dirty spans are uploaded in the dispatching list.CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED, with heaps bound before the root signature. There is a capability refusal on adapters without it.d2805e70): one null word per dimension (null1d,null2d,null2da), because a null read through the wrong dimension is undefined. Revision 3 → 4.X2W_D3D12_HEAP_TOKENS=1together withX2W_D3D12_VIEW_CONTENT_TOKENS=1is refused ("heap tokens need id tokens").Tests
heap_token_kinds_check,heap_token_binding_check,startup_compute_heap_token_check, andstartup_compute_heap_token_dispatch_hardware(texels for 1D/2D/2D array, raw words, miss counts, debug layer clean, alias kept alive by the recording).native_|startup_compute|heap|manifest|direct_compute|sampler|compute_, 1312 tests) after merging current main: everything green exceptstartup_compute_gather_l_hardwareandstartup_compute_gather_l_warp(D3D12 error 660, SV_Position register mismatch). Those two fail the same way on plain main.Known limits / not done yet
AI-assisted.
🤖 Generated with Claude Code
- Count a token miss only when the wave has an active guest lane (ballot of EXEC), not for a wave that reaches the instruction with EXEC = 0. The hardware fixture gains two modes: EXEC limited to the upper 16 lanes (lane 0 inactive) and EXEC = 0. - The native-only route refuses a program with token words with the manifest reader's text ("heap token textures are not bound yet") instead of "view kind N is not bound". Covered by startup_compute_dispatch_native. - conservative_sgpr_reads: encodings without a case now read every SGPR (control flow, LDS, export and interpolation are listed as reading none), and the v_cndmask_b32 lane mask counts as a pair. Control in native_heap_token_texture_controls (mask_pair vs. a mask clear of the T#). - Say why native_compute_output_revision is 2 (header and doc). AI-assisted. Co-Authored-By: Claude Opus 5.5 <[email protected]>Draw heap: the top of the heap becomes a fixed region for heap view tokens, 65,536 mirror slots plus 5 typed nulls (1D, 2D, 2D array, raw, R32_UINT typed; written once at heap creation, only with X2W_D3D12_HEAP_TOKENS). The heap keeps 1 << 18 slots; the ring of per-draw and per-dispatch tables shrinks from 262,144 to 196,603 slots (draw_ring_size = draw_heap_size - 65,536 - 5), also without the opt-in. Both ring sites go through one reservation (modulus and wrap check), so the ring never writes a region slot. Alias: with the opt-in, every shader-visible CBV/SRV/UAV descriptor heap gets a heap from OpenExistingHeapFromAddress on its memory (era_gpu_alias, never the existing-heap cache of unplaced_memory_buffer) with a buffer placed over it; the raw SRV is FirstElement 0, NumElements = entries * 8, checked against the allocation. Memory that is not an allocation base, or a refused alias, gives no alias and heap token programs keep a named refusal ("heap tokens need a GPU-visible view heap"). No upload fallback. Root: adapter_lacks_directly_indexed_resource_heap (shader model 6.6, tier 3) with its own refusal texts; compute_root_flags ORs CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED with the sampler flag for a program that reads heap tokens. Nothing sets that yet: the reader still refuses heaptok lines. Tests: heap_token_binding_check (ring, layout, nulls, alias view, root flags, refusal text; six mutation controls), resource-heap rows and a control in startup_translated_sampler_bindings, and the WARP fixture startup_compute_heap_token_check.py (layout, nulls, ring reservations, alias on VirtualAlloc memory and refusal for an interior pointer, refusal text). AI-assisted. Co-Authored-By: Claude Opus 5.5 <[email protected]>@JB2WIN on GitHub · 2026-12-01 11:31 UTC · original
@R0Y00 @Leyukaka @tedin7 @JohnConnorNPC review welcome on this draft: the runtime side of #3023 stage 3 (opt-in
X2W_D3D12_HEAP_TOKENS=1, default behaviour unchanged). It is stacked on #3633/#3544, so only the commits afterf4cc6a0eare new here.The main thing I'd like a view on before I build the fenced release on top: the binding approach (mirror region carved from the draw heap, zero-copy token SRV alias over the runtime-allocated view heap, kinds table). If the direction doesn't fit, tell me and I'll change it.
The Windows check was red because the pr preset did not build
native_heap_token_texture;4bc3d4adadds it. Not asking for a merge yet: the release step and the state handling are still to come (listed under known limits).AI-assisted.
@JB2WIN on GitHub · 2026-12-01 14:03 UTC · original
Measurement update, and a design question before anyone spends time reviewing the binding details.
I did a launcher run with
X2W_D3D12_HEAP_TOKENS=1(RTX 3080, 900 s, boot/menus/early scenes only; no gameplay was reached, so no heaptok program ran yet).What holds:
What breaks the current design:
extra[0]). This PR only aliases runtime-allocated view heap memory, so every heap-token dispatch would be refused with "heap tokens need a GPU-visible view heap".MEM_MAPPEDviews, the physical-page mapping inxmem_mapped_pages.cpp.OpenExistingHeapFromAddressworks on one view (S_OK in a trial), but there is no single heap or raw SRV over the whole span.X2W_D3D12_VIEW_CONTENT_TOKENS=1: this PR refuses heap tokens under it ("heap tokens need id tokens").Options I see for (1)/(2), none built yet:
ResourceDescriptorHeap[base + (slot >> 11)]at offset(slot & 2047) * 32. This needs a remap hook so a view that is unmapped or remapped drops its alias.OpenExistingHeapFromHandle) plus a page table. This is independent of the VA layout, but bigger.My preference is A, since it is the smallest change and the runtime already owns the mapping. I'd rather hear from whoever knows the xmem mapping and the content-token plans before choosing. Until then the PR stays a draft and I won't build the release step on top.
AI-assisted.
github-bot referenced this pull request2026-12-02 07:35:00 +00:00
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.