Repository navigation
Conversation
…ompute A compute program that loads a texture with s_load_dwordx8 from the directly indexed resource heap at an SGPR offset chosen by GPU data is now translated when every use of the eight words is the T# of a supported image instruction (1D, 2D or 2D-array load, load_mip, sample_l, sample_lz, 2D gather4_lz, get_resinfo). The shader reads the 32-byte view token at the guest byte address, checks the magic, the view id range and the dimension recorded for the id, and samples ResourceDescriptorHeap[base(dimension) + id] (a null slot otherwise, counting one miss per wave). The manifest names the runtime- provided views and words (heaptok, heaptokdims, heaptokmiss, five heaptok words); the runtime reader still refuses them by name, so dispatch behaviour is unchanged. Not independently design-approved: see the PR description. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n compute Refs R0Y00#3023 R0Y00#3224. Builds on the heap token textures of R0Y00#3544. A raw buffer V# loaded with s_load_dwordx4 from the directly indexed resource heap at a GPU-selected byte offset (an SGPR offset, or an address formed by s_add_u32) is read through the view token the title keeps at that address, like the token textures. Reads of that V# in the byte-window form (buffer_load_dword{,x2,x3,x4} with OFFEN, the s_bfe/s_max/s_mul/s_and/s_or rewrite) and scalar buffer loads from it are translated; every other use keeps today's path and refusal text. - Each s_load_dwordx4 candidate is judged on its own; a candidate that fails is dropped and does not take the texture route off the program. An s_add_u32 heap address that is not an eligible candidate keeps the old rejection. - The shader checks magic, id range and the dimension table entry 0x20 (raw buffer view) on every execution and reads ResourceDescriptorHeap[baseraw + id], or the null raw view with one counted miss per wave. - A program with an eligible buffer load publishes seven token words (baseraw and nullraw after the five of the textures): NativeComputeShader:: heap_token_word_count replaces heap_token_words. Texture-only programs keep five words and byte-identical modules and manifests (revision line aside). - native_compute_output_revision 2 -> 3. - The dispatch reader names baseraw and nullraw and still refuses every heaptok line: programs of this change stay refused at dispatch until the runtime binds the views (PR 2). Tests: native_heap_token_texture_controls (eligible forms, controls with today's text, address shapes, loop, mixed texture and buffer), native_heap_token_texture_{warp,hardware} (rawbuf, rawbuf_waterfall, sbuf), native_compute_manifest_reasons, startup_compute_dispatch_texture. The design was frozen by the owner without independent approval (see the PR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for the heap token buffer route. - heap_token_buffer_eligible now checks the address the lowering needs, on the state at the load: heap pointer high word is the constant 0, imm % 32 == 0, proven 32-byte aligned SGPR offset, no offset + imm overflow; on an added address imm == 0 and a masked offset. It also compares the V# words symbol for symbol as heap_token_buffer does. A candidate that fails is dropped (an added address keeps the old program-wide rejection) and keeps today's text. The lowering refusals stay as a safeguard. - When no buffer load is eligible, the textures are judged again on the analysis without the byte window, as before the route knew buffers. - Document the carry assumption of an added address (heap-relative model of the existing heap_offset path, no runtime carry check). - Tests: address-shape controls expect the heap contract text of the dropped load; new controls for overflow, a non-constant high word, an unread candidate next to a texture, and an accepted wide mask. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…word budget) Review fixes, round 2. - A byte window load inside a loop is dropped by the analysis with the same query the lowering uses, instead of failing the whole program (textures included) at lowering. - When the seven token words do not fit the 32-word entry layout next to the descriptor strides and root constants (the strides are known only while lowering), the program is translated again with the buffer route off, so the buffer loads keep today's path and text. - Document that words 2 and 3 of the title's V# are not read and that PR 2 must make the raw view's range equal it (A1). - Tests: loop and texture + loop controls now expect today's text; 25 strides compile next to seven token words, 26 are refused with today's text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ments - The budget retry in translate_program catches HeapTokenWordBudget (thrown by prepare_heap_tokens with the same text) instead of matching the message. - Exact root signature match for the user SGPR count in the test, comments wrapped to 120 columns, doc line for the seven-word form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e-only refusal, SGPR reads)
- 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 <noreply@anthropic.com>
Conflicts in src/direct_compute_cache.cpp (token words before the sampler heap line), tests/native_compute_manifest_reasons.cpp and tests/startup_compute_dispatch_native_check.py: both sides kept. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Takes the R0Y00#3544 review fixes: the EXEC-gated miss count now applies to the raw buffer route as well, the native-only refusal reads heap_token_word_count, the revision comment explains both bumps (2 textures, 3 raw buffers), the manifest test keeps the seven-word case next to the sampler cases, and the hardware rig keeps both first_active and scalar modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The heap token word set becomes base1d, base2d, base2da, count, null1d, null2d, null2da (7 words), plus baseraw, nullraw (9 words) for programs with a raw buffer token load. The null slot of a texture load of dimension index d (1D 0, 2D 1, 2D array 2) is word 4 + d; baseraw and nullraw move to words 7 and 8. A null descriptor read with another dimension is undefined in D3D12, so the runtime has to provide one null view per dimension. native_compute_output_revision 3 -> 4 (the word layout of every token program changed). The cache decoder, the manifest writer, the manifest reader's known names, the documentation and the tests move to 7/9 words; the word budget test now has 23 strides next to nine words. The rig creates three distinct null views (1D, 2D, 2D array). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
X2W_D3D12_HEAP_TOKENS=1 (opt-in, read once, next to view_content_tokens) is the switch for binding the heap view tokens of translated compute programs. Binding itself is not implemented yet, so the manifest reader and the native-only route refuse a program with heaptok lines in three cases, with one text shared by both routes (heap_token_refusal): - opt-in unset: "heap token textures are not bound yet" (unchanged); - opt-in together with X2W_D3D12_VIEW_CONTENT_TOKENS: "heap tokens need id tokens"; - opt-in alone: "heap tokens are not bound yet (runtime binding in progress)". Tests cover all three cases on the manifest reader and on the native-only route, plus the content-token-only control. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…yet) Adds heap_token_kinds.h (kinds table codes: texture 1 + SQ dimension, raw buffer 0x20, R32_UINT typed buffer 16 reserved for R0Y00#3619 and never accepted by the compute route; a pure function from a desktop SRV desc), and heap_token_pending.h (bookkeeping of ids that need a mirror descriptor, with a backfill of existing ids and a generation per reassigned id). note_view only appends ids under note_lock when X2W_D3D12_HEAP_TOKENS is on; nothing creates a descriptor yet. Test hooks: x2w_d3d12_create_srv (real device slot 18 path) and x2w_d3d12_heap_mirror_queue. Tests: heap_token_kinds_check with four mutation controls, and a WARP skeleton startup_compute_heap_token_check.py (records, ids, queue, controls; no dispatch checks yet). AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cation A reassigned id whose generation could not be stored (bad_alloc) kept its old generation, so an entry for the old record looked current. The generation is now epoch + per-id count; a failed count grows the epoch (allocation-free), which changes every generation. note_view calls invalidate(id) when store_view fails after take_parked_record emptied the record. take() accepts an eligibility predicate so the consumer drops ids that are no longer materialized SRVs, and returns nothing (queue intact) if its result cannot be allocated. The lost-queue log moves after note_lock is released. compute_token_accepts is a helper for the mirror flush in a later commit; the runtime does not call it yet (the earlier message said otherwise). Tests: failure injection compiled only with X2W_HEAP_TOKEN_PENDING_TEST_HOOKS (test target only, no cost in the runtime), cases for generation, queue, backfill and take failures, and the mutation generation-kept-on-alloc-failure. Mutation controls now pass only on the "mutation <name>: caught" line instead of WILL_FAIL, so a crash or unknown name no longer passes. Note: the Python skeleton startup_compute_heap_token_check.py does not check the backfill. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…escriptors yet)
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 <noreply@anthropic.com>
…ing carve-out, ring guards) Alias lifetime (blocker): the GPU alias of a view heap is released when its descriptor heap is finally released (before anything of its memory can be freed), not only on the creation failure path. HeapTokenAliases keeps at most one entry per address: open() drops an existing entry first, and a duplicate found at store time replaces the old one. Only memory the runtime allocated itself is aliased; a shader-visible view heap over memory the title supplied (extra[0]) gets no alias, is counted, and heap token programs keep the refusal "heap tokens need a GPU-visible view heap". The title descriptor stride must be 32 bytes (one record), else the same refusal. Ring: the 65,536 + 5 region is carved out only with X2W_D3D12_HEAP_TOKENS=1. Without the opt-in the ring is the whole 262,144-slot heap, as on main. A reservation larger than the ring is refused (draw: refusal reason, dispatch: "the descriptor table is larger than the ring") and never writes the region. The translated draw sets the descriptor heaps before its root signature, as a translated Dispatch does. Tests: heap_token_binding_check (opt-in ring, oversize, stride) with ten mutation controls that now build the unchanged check against a copy of heap_token_binding.h with one real source edit; startup_compute_heap_token (own-memory alias, supplied memory, drop to 0 live, duplicate and reopen at one address, stride and size refusals, oversize reservations, ring with the switch off); startup_compute_dispatch_ring and startup_draw_depth_target_ring (production Dispatch and draw sites reserve through the ring function with the cursor past the ring, opt-in on and off); triage allowlist and scanner for the heap token gate texts and the new ring reason. Not covered by a device: the successful alias through CreateDescriptorHeap on WARP (its descriptor stride is 64; the stride-32 path is covered by the direct open and by the hardware dispatch run), the note_view invalidate path (class test only), the draw heap-before-root-signature order (no program takes the directly indexed flag yet). AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions, pinned mutant controls, refusal path) - Dispatch native/texture checks derive the expected refusal from the adapter's view descriptor stride (now logged by the alias open): stride != 32 expects the view heap refusal, stride 32 requires the alias to have succeeded. - Each heap_token_binding mutant control pins its own FAIL line. - Draw ring refusal text is in the triage allowlist; the scanner also scans draw_translated. Dispatch oversize refusal now goes through the reason path (checked before reserving). - Fix a misleading label in heap_token_binding_check. Sites without a header mutant are caught by device tests (mutation-checked by hand): alias release on final heap release and duplicate replace by startup_compute_heap_token; draw/dispatch oversize have no device test (unreachable in production). AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With X2W_D3D12_HEAP_TOKENS=1 a translated compute program with heaptok lines (manifest or in-process native route) now runs with the views its tokens name instead of being refused, when the runtime can bind them: - heap_token_mirror.inl: at a heap token Dispatch the ids queued by note_view get one desktop SRV each in the mirror region of the draw heap (slot ring + id), made from the title's own description through the new translate_srv_desc/check_view helpers that view_slot<18> shares. Only 1D, 2D, 2D array textures and raw buffer views are named; anything else gets kind 0. The mirror holds its own COM reference on each desktop resource. - The kinds table (heaptokdims) is a default-heap buffer; the span of it that changed is copied from the upload ring in the same command list before the Dispatch, after the descriptor was written. - The token SRV is a raw view over the GPU alias of the list's view heap, the miss UAV a persistent counter (read back and logged every 4096 heap token Dispatches); the three take table registers, no new root parameter, and the root takes the directly indexed resource heap flag. - Entry words (base/count/null per dimension) are computed per Dispatch (heap_token_word_value); count follows the current record count. - The gate text "heap tokens are not bound yet (runtime binding in progress)" is gone. A manifest whose token lines are not the translator's complete set is refused as such; no alias for the bound view heap keeps "heap tokens need a GPU-visible view heap". - Tests: startup_compute_heap_token_dispatch (hardware: texels of 1D, 2D, 2D array views, raw words, misses per wave, debug layer, published manifest, 4096-dispatch readback; WARP: the named refusal), mirror, kinds, refs and words in startup_compute_heap_token, unit checks and mutant controls in heap_token_binding. Known limits, left to the next commit: a mirror entry is never released (the resource stays alive, nothing is written to the slot again); resources a list tracks in a write state are not transitioned for a token read; the kinds copy is recorded in the first Dispatch list that sees the change. Default behaviour without the opt-in is unchanged. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the heap token binding commit: - The token dispatch holds COM references: HeapMirrorBinding keeps the alias buffer, kinds table and miss counter as ComPtrs, and heap_mirror_prepare retains the alias buffer and its heap with the recording (retain_with_recording, new heap overload and allocator holds), so a title releasing its view heap between recording and execution cannot free what the list reads. The reference is taken before anything else in prepare, closing the CPU window until the view is written. - The mirror takes its own reference on a desktop resource with the liveness check and the AddRef as one step (retire_acquire_desktop, under retire_lock), before CreateShaderResourceView. - The miss readback logs a delta of 0 for a copy older than the last one and never moves the logged mark back (heap_token_miss_advance). - An id whose resource wrapper is alive but has no desktop object yet is queued again at the next flush. Known limit, not changed: the kinds copy recorded in a list that is never submitted or is reset is not re-recorded; its ids read kind 0 (a counted miss, never a wrong view), because the list bookkeeping has no cheap per-list span to re-dirty. - heap_token_gate_text no longer looks at the view heap alias (the answer is cached per program); heap_mirror_prepare refuses a Dispatch whose list has no alias with the same "heap tokens need a GPU-visible view heap" through the normal reason path. - Ring cursor stays inside the ring (no jump at the 32-bit wrap with the 196,603-slot ring); the mirror's entry table is allocated before the queue is taken, so flush cannot throw under draw_lock (named refusal). - Tests: the Dispatch-time alias refusal and a release-before-execute run on hardware (recording holds one heap), exact Dispatch outcome in the native check's bound branch, counter read after the fence before the logged dispatch, unit checks and mutation controls for the ring cursor and the miss delta. On WARP the program is refused for its 32-lane waves before any Dispatch can bind it. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…untime Conflicts and how they were resolved: - src/startup_stubs/d3d12_compute_dispatch.inl: create_compute_pipeline keeps the heap token root flags and refusal (compute_root_flags, token_views) and takes upstream's explicit ID3D12Device parameter; the resource heap capability check and heap_token_refusal now take the device too (no the_device read on the worker). install_compute_translation also installs heap_token_views, which upstream's candidate install did not know about. - src/startup_stubs/d3d12_xs_device.cpp: CreateDescriptorHeap keeps upstream's CPU-only mirror of a shader-visible heap and then the heap token alias; the view slots keep check_view/translate_srv_desc (shared with the heap token mirror) and read the view descriptions at the title's record width (upstream R0Y00#3552) in check_view and translate_srv_desc; slots 19-21 keep upstream's desc_copied copy. - tests/native_compute_manifest_reasons.cpp: both new manifest tests kept (heap token views and words, root buffer SRV). - tests/startup_stream_consumer.cpp: record-at-32 mode list is the union of both sides. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wrapper the retire drain dropped has a negative refs count; the mirror treated it as alive and queued its id again at every flush. Alive is now refs > 0. Test: a released and drained texture is counted once and not queued again. Comments state the reassignment limit honestly; a check message in heap_token_binding_check matches its expectation. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pr test filter runs native_.*_controls, so native_heap_token_texture_controls was selected without its executable and reported Not Run. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@R0Y00 @Leyukaka @tedin7 @JohnConnorNPC review welcome on this draft: the runtime side of #3023 stage 3 (opt-in 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 AI-assisted. |
…extures Conflicts and how they were resolved: tests/native_compute_manifest_reasons.cpp kept both new cases (our heap token views and words, upstream's root buffer SRV) and the summed case count (+9). CMakePresets.json: native_heap_token_texture added to the pr build preset so the native_.*_controls test filter finds its executable. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts and how they were resolved: tests/native_compute_manifest_reasons.cpp kept the token-buffer seven-word case and upstream's root buffer SRV case, and the summed case count (+10). The CI preset line comes in with the textures branch. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts and how they were resolved: src/startup_stubs/d3d12_xs_device.cpp kept both forward declaration groups (HeapMirrorBinding and its functions from this branch, existing_memory_buffer from the buffers branch). tests/native_compute_manifest_reasons.cpp kept this branch's nine-word token buffer case (the buffers branch's seven-word text is the older form) and the case count of the buffers branch (+10, same 11 case blocks on both sides). The CI preset line is identical on both sides. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Measurement update, and a design question before anyone spends time reviewing the binding details. I did a launcher run with What holds:
What breaks the current design:
Options I see for (1)/(2), none built yet:
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. |
#3023 stage 3, runtime side. Stacked on #3631 (which contains #3544): please review only the commits after
f4cc6a0e(d2805e7 onward). 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 (#3544 textures, #3631 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.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