Repository navigation
native: raw buffer loads through heap view tokens (#3023 stage 3, translator) - #3631
Conversation
…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>
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>
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed f4cc6a0e by reading the diff (the seven commits on top of #3544 cf0f40be); not built or run.
Verdict: approve. The buffer route is opt-out by construction: candidates are judged per load, ineligible ones keep today's path, the word-budget retry translates without the route, and dispatch still refuses every heaptok line, so nothing changes at runtime until PR 2. No MUST.
- SHOULD No CI has run at this head (no checks reported; the branch conflicts with main in
tests/native_compute_manifest_reasons.cpp, inherited from #3544). After the rebase,native_heap_token_texture_controlsneeds no GPU but is not in theprpreset filter, so CI still would not run the 130 rig assertions. Adding_controlsto the filter makes the eligibility rules (loop, mixed, word budget, mutations) a CI check. - SHOULD The dims table compares for equality (
gfx1013_direct_compute.inl:1240,== 0x20at:1303; docnative-heap-token-textures.md:97). #3619 (mesh, translator only) reads typed R32_UINT buffers through the same tokens with kind16. The codes do not clash, but with one code per id, a title buffer that compute reads raw and a mesh program reads typed would miss in one of the two routes. Both buffer codes are single bits, so testing(dims & 0x20) != 0here (and& 16in #3619) lets PR 2 mark one id as both. The doc line should also list16, so PR 2 writes one table for both translators. I'll change #3619 to match. - NIT The pre-pass comment says "raw MUBUF dword-family load" (
gfx1013_compute_native.cpp:2000), but the code takes onlybuffer_load_dword(:2070). x2/x3/x4 loads drop out as ineligible. That is safe, but the comment overstates it. - Checked, no finding: the
HeapTokenWordBudgettext matchesrefuse()for texture-only programs (rethrown unchanged); the retry cannot recurse (buffers_allowed=false); a cached oldheap_token_wordsvalue failsdecodeand is retranslated, not trusted (direct_compute_cache.cpp:380,:542); the s_add high-word-0 assumption is judged identically in the pre-pass and the lowering; the window's byte count is the title V#'s own num_records times stride, so A1 holds if PR 2 builds the view from the same descriptor.
Tests: _controls proves the per-load eligibility, the retry and the manifest words; _hardware (RTX 3080, author) proves rawbuf/sbuf reads and fails with the src reverted. CI ran neither (see above), and _warp skips (77).
The token guard compared the kind word with heap_token_r32_uint_buffer (16). A view id can carry other kind bits as well, such as the raw-buffer bit from R0Y00#3631, so test (kind & 16) != 0 instead. The fixture checks the and/icmp ne pair and that no equality test against 16 remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The token guard compared the kind word with heap_token_r32_uint_buffer (16). A view id can carry other kind bits as well, such as the raw-buffer bit from R0Y00#3631, so test (kind & 16) != 0 instead. The fixture checks the and/icmp ne pair and that no equality test against 16 remains. 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>
|
Friendly note: this is approved, but it currently conflicts with |
…n-buffers heap_token_word_count replaces heap_token_words in main's cache visitor, round-trip fixture and validate_shader (0, 5 or 7 words). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Leyukaka merged the updated #3544 (with Local, RTX 3080: AI-assisted. |
…n-buffers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eap-token-buffers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # src/direct_compute_cache.cpp # src/gfx1013_compute_native.h # src/gfx1013_direct_compute.inl # tests/native_compute_manifest_reasons.cpp # tests/native_direct_cache_check.cpp
|
@Leyukaka main moved again, including #3500, which adds its image field words at the same places as the heap token words. Merged in f7a54aa (#3544) and 26d1c53 (this PR). The b0 words are now root constants, stride words, image field words, then heap token words, in the translator, the manifest and the cache visitor. Both branches merge cleanly into Local, RTX 3080: If it conflicts again by the time you check, feel free to resolve it yourselves. We're fine with that, as you offered. AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
Reviewed the raw-buffer delta from #3544 f7a54aaa to 26d1c531. Independent MSVC Debug on Windows 11 build 26300 passed the heap-token controls, RTX 4060 Laptop hardware readback, manifest reasons and frontend cache round-trip (4 passes). The WARP heap-token fixture skipped with code 77 at the wave32 capability gate. The new manifest bindings still refuse live use until the runtime supplies them. This is ready for the dependency to land first. After #3544 merges, please refresh this branch and verify that the remaining diff is the buffer work.
R0Y00
left a comment
There was a problem hiding this comment.
#3544 is now in main. I reviewed 1b193f4d against 75759370; the remaining runtime integration still refuses the heap-token buffer manifest until the follow-up supplies the raw views and dimension table. The raw-buffer lowering, cache and fixture files are unchanged from the previously tested head. Independent MSVC Debug ctest --preset dev --no-tests=error -j 1 -V -R '^(native_heap_token_texture_(controls|warp|hardware)|native_compute_manifest_reasons|native_direct_cache_controls)$' gave four passes and one capability skip on Windows 11 build 26300. The translator rig held 130 assertions and the RTX 4060 Laptop (32.0.16.1656) run held 83. WARP reported wave size 4 and skipped the wave32 fixture with exit 77. The export census also passed all 476 cases and caught six mutations.
What
Raw buffer loads from the directly indexed resource heap at a GPU-selected offset, through the same view tokens as #3544 (stage 3 of #3023, translator side).
s_load_dwordx4/s_load_dwordx8(SMEM op 2/3) that reads a buffer V# through a heap token, followed by MUBUF loads, becomesResourceDescriptorHeap[baseraw + id]when the token names a raw buffer view (dimension table code0x20). Otherwise it reads the null raw view (reads zero) and counts one miss per wave with an active lane, as the texture route does.baseraw,nullraw).NativeComputeShader::heap_token_word_count(0/5/7) replaces the bool. Manifest:udsrc K heaptok baseraw|nullraw.native_compute_output_revision2 → 3 (doc: Revision).Why
The texture route (#3544) leaves buffer reads through the same tokens refused. The census shows them as the next block of heap refusals.
How
s_add_u32high word must be the constant 0 at translation time (no carry map, no runtime carry check; same heap-relative model as the heap_offset path).0x20dims entries.How tested
native_heap_token_texture_check.py): 130 assertions. They include loop, mixed loop, the mixed case (eligible texture plus ineligible buffer), a 25/26-stride word budget, mask/high-word/dims/slot mutations, and EXEC none/half from native: translate GPU-selected heap textures through view tokens in compute #3544.native_heap_token_texture.cpp, RTX 3080): 83 assertions;rawbuf,rawbuf_waterfall,sbufmodes. They fail with the src reverted.compile_dxilcompiled gives byte-identical output (revision line aside). Census on a local request set (counts only, no shader data in the repo): compiled 831 → 844, heap refusals 1323 → 1308.native_direct_mesh, fails the same way on main (077bff3).Risks / open
HeapViewContract::nonegate unchanged. The EXEC-gated miss count is shared with the texture route (heap_token_slot); no rig mode exercises it on a raw buffer load.X2W_D3D12_VIEW_CONTENT_TOKENS=1, buffer views are content tokens, which this route treats as misses (null view). PR 2 must refuse or decode them.Depends on #3544 (this branch contains it; review the last commits). Refs #3023, #3224.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
🤖 Generated with Claude Code