Repository navigation
native: read one-channel typed loads through a GPU-selected heap descriptor - #3042
Conversation
…riptor A formatted MUBUF load (buffer_load_format_x, idxen) through a heap descriptor was refused: only the raw_buffer heap view contract existed. HeapViewContract::typed_dword now covers programs whose heap reads are one-channel typed loads of 32-bit typed buffer slots. heap_resource annotates ResourceDescriptorHeap[slot] as a typed buffer of one U32 component and records the new binding kind heap_typed_srv; raw loads, byte windows and multi-channel loads stay refused under it. The cache identity and the cache decoder know the new kind, and compile_dxil's heap-read re-check uses compute_heap_binding. .views records the 32-bit channel count of each typed buffer slot in a "dword <slot> <channels>" line. global_srv_contract derives the contract from the request: need raw_buffer -> raw_buffer, need typed_buffer with every captured typed slot a one-channel 32-bit buffer -> typed_dword. The fixture's record mode takes --need typed_buffer. The guest descriptor fields (stride 4, 32-bit format, identity dst_sel, no swizzle, num_records = element count) stay the caller's guarantee; the doc lists them. Tests: native_global_srv_heap_replay_check.py section 10 records, compiles (twice, frontend cache hit) and replays the typed load on the R32_UINT slot, checks the cross-slot mismatch and two refused selections, and ten compile refusals. Refs R0Y00#3023 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R0Y00
left a comment
There was a problem hiding this comment.
Reviewed 9521d13d on cpp-migration b405cf71 (integration ad6be657). I rebuilt compile_dxil, native_global_srv_heap_replay and native_store_replay, then ran ctest --preset <dev|release> --no-tests=error -V -R '^(native_global_srv_heap_replay_(hardware|warp)|native_mtbuf_hardware|native_direct_container|compute_load_format_controls)$'. Each preset gave four passes and one WARP 77 skip for four-lane waves. RTX 4060 Laptop, driver 32.0.16.1656, Windows 11 26200.9974, SDK 10.0.26100, WARP 10.0.26100.9818, heap replay debug layer off. Typed slot 3 matched the captured data on the GPU and in offline replay, the warm frontend cache hit, and the wrong-slot comparisons and malformed metadata controls refused or mismatched as expected. Hosted Windows, Linux and gfx1013 passed. Scope is the single-channel R32_UINT fixture and the documented offline contract. Mixed selection and the runtime view validation stay in #3023.
Change
Target branch
cpp-migration. Refs #3023. Follow-up to #3034 (merged asb405cf71).The direct compute path translated GPU-selected heap reads only under the
raw_bufferview contract, so a formatted MUBUF load (buffer_load_format_xwith anidxenelement index) through a heap descriptor was refused ("a GPU-selected heap slot is read as a raw buffer SRV only"). This adds a second contract class for one-channel 32-bit typed buffer slots.src/gfx1013_compute_native.h:HeapViewContract::typed_dwordwith its caller guarantee in the comment; binding kindComputeViewKind::heap_typed_srv;compute_heap_bindingcovers both heap kinds.src/gfx1013_direct_compute.inl,heap_resource: undertyped_dwordonlytyped_buffer_srvwith one channel is accepted. The handle isResourceDescriptorHeap[slot]annotated as a typed buffer of one U32 component (annotateHandlekind 10, props5 + 1 * 256), module flag0x40000000only. Raw loads, byte windows,tbufferloads ("… read as a typed dword buffer SRV only") and 2-4 channel loads ("typed heap load reads one channel only") are refused.raw_bufferbehaviour is unchanged.src/direct_compute_cache.cpp: cache identity/heap-view/typed_dword; the binding decoder's kind bound moves to the new last kind.src/startup_stubs/native_global_srv.h:GlobalSrvView::dword_channels(fromtyped_dword_channels);.viewsgains adword <slot> <channels>line after the slot lines (header stays version 2; the decoder accepts it only for an earlier typed buffer slot, once, 1-4 channels);global_srv_contract()mapsneed raw_buffer→raw_bufferandneed typed_buffer→typed_dwordwhen every captured typed buffer slot is a one-channel 32-bit buffer.tools/startup/compile_dxil.cpp:read_captured_viewsuses the helper; the heap-read re-check usescompute_heap_binding.tests/native_global_srv_heap_replay.cpp:record … [--no-guard] [--need typed_buffer]; record and replay build the request first and pass the helper's contract to the pipeline.Why this step: on a local start-up capture (
compile_dxil --refusals, 2,689 slot 67 requests, counts only, raw contract forced by an uncommitted switch), 906 requests stopped first at the typed heap load, and all 906 are this one-channelidxenshape. No additional request compiles from this alone: withtyped_dwordforced instead, 895 of them then stop at a raw read of another heap slot. Those programs read the heap both ways, which one captured selection does not cover (the existing contract comment already says so for two selectors). That mixed case is the next step.Verification
Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), MSVC 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled. Measured on
e67f1017(#3034 before its merge);cpp-migrationb405cf71has the same tree.native_global_srv_heap_replay_hardware: 122 assertions (94 before), 9 s.buffer_load_format_x v2, v0, s[20:23], 0 idxenrecorded with--need typed_bufferfor slot 3 (R32_UINT) → output equals the slot 3 data;.viewshasneed typed_bufferanddword 3 1. Selections 0 (raw) and 2 (texture) are refused before the dispatch.compile_dxil --requestscompiles it; a second run reportsfrontend_cache_hit=1and the same.cso(the new binding kind decodes). Replay equals the slot 3 data; replay against slot 0 data reports a mismatch..cso: a two-channel typed load; the raw program and atbufferload under the typed contract; the typed load under the raw.views;.viewswithout thedwordline ("… (no 32-bit channel metadata)"), withselect 0, withdword 3 5, with adwordline for a raw slot, twice, or before the slot lines.compile_dxiland the fixture built ate67f1017passes the 94 earlier assertions and fails at the first typed record (the old fixture has no--need). The oldcompile_dxilgiven the typed request refuses it with "GPU-selected heap slot view type typed_buffer is not raw_buffer; only raw buffer heap reads are translated"; the new one compiles it.native_cvt_pk_u8_hardware(known), andnative_sdwa_f16_ir/native_sdwa_f16_hardware, which fail ate67f1017as well. On this machinenative_sdwa_f16_irasserts(0, 'add', '0xa55a4200', '0xa55a4200'): the printed values are equal, but the match fails.compile_dxil --refusalson the local capture without a contract: identical before and after.tests/compute_heap_view_check.py,tests/startup_gfx2hlsl_heap_record_check.py,tests/docs_links_check.py,tests/bidi_controls_check.pypass.Evidence and follow-up
clang -cc1as -triple amdgcn-amd-amdhsa -target-cpu gfx1013 -show-encoding); fixtures are source-built.docs/experiments/native-global-srv-heap-replay.md): the translator sees no descriptor values. Every selectable slot must be anR32_UINT,R32_SINTorR32_FLOATview bound asR32_UINTover the same element range, and the guest descriptor must have stride 4, a 32-bit format, identitydst_sel_x, swizzle/add_tidoff andnum_recordsequal to the view's element count..viewsrecords resource sizes, soglobal_srv_contractchecks necessary conditions only. OnlyR32_UINTis exercised. No runtime binds a typed heap slot yet.Checklist
AI-assisted.
🤖 Generated with Claude Code