native: capture and replay view types for GPU-selected global SRV slots #2972
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2972"
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-27T00:46:22Z.
Fixes #2908. Continues #2912 (handed over by @tedin7 in https://github.com/R0Y00/Xbox2Windows/pull/2912#issuecomment-7204144181; his four commits are kept as they are, plus the 32-lane WARP skip from tedin7/Xbox2Windows#2). Target branch
cpp-migration.What
src/gfx1013_direct_compute.inl,src/gfx1013_compute_native.*,src/direct_compute_cache.*,src/native_compute_pipeline.*): the direct compute translation takesx2w::HeapViewContract(none,raw_buffer,other). An SMEM descriptor load from the resource heap is translated only withraw_buffer(then #2912'sResourceDescriptorHeap[slot]raw buffer read is used). Without a contract the existing refusal text stays ("direct resource-heap load requires the selected GPU slot and its view type"). A scalar buffer load from the heap base, a heap descriptor load with a constant index or an immediate offset (both could address another slot than the captured one) and a stride read of a GPU-selected slot in the direct path get their own refusals. The contract is in the frontend cache key when it is notnone. Heap-reading modules now also carry shader flag0x40000000, as DXC sets for the HLSL reference; without it the validator refuses the module ("Flags must match usage. Validation failed.", measured by removing the flag).src/startup_stubs/native_global_srv.h, from #2912): the slot line gains the buffer size (slot <n> <type> <stride> <bytes>); headerx2w-global-srv-views 2; the header is self-contained.tools/startup/compile_dxil.cpp):gfx1013-container-csreads an optionalreq_<key>.viewsnext to the.cdx, refuses a selection whose slot holds another view type thanneed(slot/type diagnostic), refuses aneedother thanraw_buffer, translates with the contract and printsglobal_srv select=<n> need=<type>. All refusals happen before the.csois published.native_global_srv_heap_replay(tests/native_global_srv_heap_replay.cpp,_check.py,tests/cmake/native_global_srv_heap_replay.cmake): source-built container that readsResourceDescriptorHeap[selector]with the selector in a GPU buffer; heap slots 0/1 raw buffers with different data, 2 Texture2D, 3 typed buffer.recordreads the selector back from the GPU before recording (one sync per recorded dispatch), captures{select, view types, sizes}intoreq_<key>.views, refuses incompatible slots beforeDispatch, and records withx2w_startup::NativeRecording+NativeDispatchStates.replayruns thecompile_dxiloutput on a heap rebuilt from the captured types.docs/experiments/native-global-srv-heap-replay.md."Native recording" / "runtime path" here: the issue's reproduction names
native_recording_checkandnative_dispatch_states_warp, which testNativeRecordingandNativeDispatchStates. Oncpp-migrationonly tests use these classes, so the fixture'srecordmode is the native recording path and its UAV sentinels are the runtime-path sentinels. The stand-in's native slot 67 path from #2958 callstranslate_computewithout a heap view contract, so a GPU-selected heap read stays refused there; passing captured views into it would be a follow-up. Please say if the issue meant more.How tested
native_global_srv_heap_replay_hardware: passed, 70 assertions:.views: refused with the heap text, no.cso;record0/1: fenced output equals the selected slot's 64 words, sentinels intact,.viewscaptured; 2/3: "global SRV slot 2 has view type texture, the shader needs raw_buffer" / "... slot 3 has view type typed_buffer ..." before the dispatch, nothing dispatched, sentinels intact;record --no-guardon slot 0 expecting a refusal sees the changed sentinels (exit 3);compile_dxil --requestson each capture: 0/1 compiled withglobal_srv select=<n> need=raw_buffer, 2/3 refused, no.cso;replayof the compiled.cso: 0/1 match the CPU reference, 2/3 refused with sentinels intact;compile_dxilandreplay: mismatched type, noneed, noselect, no line for the selected slot,select 7, missing.viewsfile — explicit diagnostic, no.cso, sentinels intact;native_global_srv_heap_replay_warp: skipped (77), "adapter has no 32-lane waves (4..4)" — the native module declaresWaveSize=32. Not evidence.^native_with-j 1: before (basec1933a61) 85/86 passed; after 87/88 passed. In both runs the only failure isnative_wave_request_hardware(#2915, fixed by #2928); skipsnative_comparison_pso_warp,native_heap_handle_probe_warp, and the new_warp.0x40000000the hardware test fails at validation.recordfor selection 0 exits 4 with "direct resource-heap load requires the selected GPU slot and its view type".python -B tests/docs_links_check.py: passed.Environment: NVIDIA GeForce RTX 3080, driver 32.0.16.2124, Windows 11 build 26200, MSVC toolset 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled.
Limits
.viewscaptures type, stride and size.heap_stride_srv(used bynative_compute_grid) is unchanged; only the direct path refuses a stride read of a GPU-selected slot.selectmust be the slot index the dispatch addresses; producing it from a title capture is outside this fixture.docs/experiments/native-global-srv-heap-replay.md(new notes go indocs/experiments/, per its README).AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-27T01:03:25Z.
Review: APPROVED
Review of head
7c955a09, tested merged ontocpp-migration7bcff286(after #2973). It auto-merges cleanly, and CI on the head is green. Approving and merging.Code read:
HeapViewContractgates the heap read. Withnone, the existing refusal text is kept, so #2958's in-runtime native path, which passes no contract, behaves as before.otheris refused by name, and onlyraw_bufferlowers toResourceDescriptorHeap[slot]with the0x40000000flag.heap_stride_srvin the HLSL path is unchanged.compile_dxilrefuses a.viewsslot type mismatch, or aneedother thanraw_buffer, before publishing.native_global_srv.his not included by any runtime source, so no start-up run is needed.Run on AMD: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release.
ctest --preset release --no-tests=error -R '^native_'gives 57 tests, 54 passed and 3 skipped (77:native_comparison_pso_warp,native_heap_handle_probe_warpandnative_global_srv_heap_replay_warp, because WARP has no 32-lane waves).native_heap_handle_probe_hardwareandnative_global_srv_heap_replay_hardwarepass. That matches @thepatrickworld's RX 9070 XT result on #2912 after the #2932 rebase.Mutation here: indexing the heap one slot off (
symbol.offset / 32 + 1) failsnative_global_srv_heap_replay_hardwarewithmismatch word 0: got 0xb0000000 expected 0xa0000000 (reference slot 0). With it restored, it passes.The follow-up you name, passing captured views into #2958's in-runtime path, is the natural next step for this to reach a start-up run. I will close #2908 by hand. Thanks to @tedin7 for #2912.
AI-assisted; the commands above were run locally.