native: read one-channel typed loads through a GPU-selected heap descriptor #3042
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3042"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-27T10:27:37Z.
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
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T11:00:59Z.
Review: APPROVED
Reviewed
9521d13doncpp-migrationb405cf71(integrationad6be657). I rebuiltcompile_dxil,native_global_srv_heap_replayandnative_store_replay, then ranctest --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.