Skip to content

test: native DXIL read of a GPU-selected descriptor heap slot (probe) - #2912

Closed
tedin7 wants to merge 4 commits into
R0Y00:cpp-migrationfrom
tedin7:native-global-srv-replay
Closed

tedin7 wants to merge 4 commits into
R0Y00:cpp-migrationfrom
tedin7:native-global-srv-replay

Conversation

@tedin7

@tedin7 tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Part of #870

Refs #2908. What this unblocks: reading a descriptor heap slot that the GPU selects (ResourceDescriptorHeap[index]) from a native DXIL compute module, the base for capturing and replaying the view type of such a slot.

This is cycle 1 of the work, a probe only. It does not yet capture or replay view types, and no guest shader is translated through a heap-indexed data read yet: that translation (a heap-indexed data SRV) is the follow-up in this same series.

What changed

  • DxilModule::heap_handle emits dx.op.createHandleFromHeap (opcode 218) plus annotateHandle with the view class the shader reads.
  • native_heap_handle_probe builds the same selection shader two ways (DXC HLSL reference and the native module), creates the pipeline with root flag CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED, and dispatches it twice with different selector words.
  • native_heap_handle_probe_check.py compiles the reference with the installed DXC, prints how DXC spells the heap handle and its shader flags, and passes those flags to the native module.

Tests

native_heap_handle_probe_warp and native_heap_handle_probe_hardware: each readback must equal the CPU reference of the selected slot, the two selectors must give different data, and a guard word past the copied range must stay intact. An adapter without shader model 6.6 or resource binding tier 3 skips (exit 77).

Verification:

  • Win2025 dev and release (WARP): pending.
  • No local build was run.

AI-assisted; commands listed were executed locally.

c1 and others added 4 commits November 26, 2026 20:25
…(ResourceDescriptorHeap probe)

Adds DxilModule::heap_handle (dx.op.createHandleFromHeap, opcode 218, annotated with the view class) and a probe that
compiles the same selection shader as DXC HLSL and as the native module, creates the pipeline with the heap-indexed root
flag, and dispatches it twice with different selector words: each readback must be the data of the selected slot and the
UAV guard word must stay intact. The adapter needs shader model 6.6 and resource binding tier 3, else the test skips.
…p slot as a raw buffer SRV

A buffer load through a descriptor loaded from the whole resource heap at a GPU-computed index used to be refused
(whole-heap buffer access needs a matching descriptor at the GPU-selected index). The direct DXIL lowering now emits
ResourceDescriptorHeap[slot] (createHandleFromHeap, annotated as a raw buffer) and records a heap_buffer_srv binding with
no table register; the pipeline then creates its root signature with the heap-indexed flag and sets the heap on the list.
Adds the view-type classification header (native_global_srv.h) that the dispatch guard will use; no guard yet.
@JB2WIN

JB2WIN commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Test results for this PR on top of current cpp-migration (ee76dfa, incl. #2914 and #2918) + #2917, PR head 432db95. No merge conflicts, dev preset builds.

  • native_heap_handle_probe_hardware: passed (NVIDIA GeForce RTX 3080, driver 32.0.16.2124).
  • native_heap_handle_probe_warp: failed, FAIL: pipeline state of the native shader (probe exit 5). The container diff the check prints shows why: the native module declares WaveSize=32, the DXC reference does not (MinimumExpectedWaveLaneCount: 0, MaximumExpectedWaveLaneCount: 4294967295). WARP only offers 4-lane waves, so CreateComputePipelineState refuses the native shader there.

Suggestion: skip like native_store_replay.cpp and native_recording_check.cpp already do when the adapter has no 32-lane waves, after the shader model / binding tier check in tests/native_heap_handle_probe.cpp:

// The native module declares WaveSize=32 (the guest wave), so an adapter without 32-lane waves cannot create it.
D3D12_FEATURE_DATA_D3D12_OPTIONS1 waves{};
if (FAILED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &waves, sizeof waves)) || !waves.WaveOps ||
    waves.WaveLaneCountMin > 32 || waves.WaveLaneCountMax < 32) {
    std::printf("adapter has no 32-lane waves (%u..%u)\n", waves.WaveLaneCountMin, waves.WaveLaneCountMax);
    return 77;
}

With that change locally: native_heap_handle_probe_warp is skipped (77) and native_heap_handle_probe_hardware still passes.

ctest --preset dev --no-tests=error -R "^native_heap_handle_probe_(warp|hardware)$" -V

Environment: Windows 11 build 26200, MSVC toolset 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled.

AI-assisted.

@JB2WIN

JB2WIN commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@tedin7 I opened tedin7#2 against your native-global-srv-replay branch with the WARP skip from my comment above (one commit, tests/native_heap_handle_probe.cpp only). Merging it there brings the fix into this PR: native_heap_handle_probe_warp then skips (77, adapter has no 32-lane waves (4..4)) and native_heap_handle_probe_hardware still passes on an RTX 3080. AI-assisted.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @JB2WIN for testing on the 3080 and for the WARP skip.

We're stepping back from this one so your person can take it from here. State of the branch (native-global-srv-replay, head 432db95):

"Allow edits by maintainers" is on, so you can push straight to this branch or open a new PR from it, whichever you prefer. We're also releasing the claim on #2908.

AI-assisted; commands listed were executed locally.

@SimSalabimse

Copy link
Copy Markdown
Contributor

Hardware and WARP result for head 432db950e4782119b144a4f3f743a99c5563e1a2 (base 40365770). The hardware test passes on an RTX 4070 Ti. The WARP test fails because the pipeline state for the native shader is refused; the reference shader's pipeline is accepted.

Environment: Windows 11 25H2 (26200), MSVC 19.42, Windows SDK 10.0.26100 DXC, NVIDIA GeForce RTX 4070 Ti, driver 621.35 (32.0.16.2135). Clean worktree at the PR head, fresh out/pe-env, dev preset. Tests run serially. The probe does not enable the D3D12 debug layer, so there is no debug-layer status to report.

Commands

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R "^native_heap_handle_probe_(warp|hardware)$" -V --output-on-failure -j 1 --timeout 300

Result (measured, 2 runs, same both times): 2 tests: 1 passed, 1 failed. ctest exit 8. No skips.

  • native_heap_handle_probe_hardware passed (0.41 s and 0.43 s):
reference selector 0: data matches the CPU reference, guard intact
reference selector 1: data matches the CPU reference, guard intact
native selector 0: data matches the CPU reference, guard intact
native selector 1: data matches the CPU reference, guard intact
native_heap_handle_probe: PASS
  • native_heap_handle_probe_warp failed (0.29 s and 0.22 s), probe exit 5:
FAIL: pipeline state of the native shader
AssertionError: probe exit 5

WARP did not skip: the adapter check passed, so WARP reports shader model 6.6 and resource binding tier 3 here. The failure is CreateComputePipelineState for the native module, after the reference module's pipeline was created. The container diff the check prints shows the native module declares WaveSize=32, which the DXC reference does not. src/dxil_module.h already emitted i32 32 as the wave size at 40365770, so this is not from this PR. WARP reported 4 lanes on #2915, so my guess is that WARP refuses a required wave size of 32, but I did not confirm that: I did not capture the HRESULT or try without the wave size.

Wider check, once: I ran ctest --preset dev --no-tests=error -R "native_" -j 1 on this head. That regex also matched cpu_native_*, so it ran 82 tests: 79 passed, 1 skipped (native_comparison_pso_warp), 2 failed (native_wave_request_hardware, which also fails at 40365770 per #2915, and native_heap_handle_probe_warp). ctest exit 8. Nothing else regressed.

Control: The test does not exist at 40365770, so I could not run it against the base. The probe's own assertions are the only control I ran: each selector's readback must match the CPU reference and the guard word must stay intact.

AI-Assisted

@thepatrickworld

Copy link
Copy Markdown
Contributor

Independent Windows / AMD run of both entries on this head merged with cpp-migration ea07313b, plus the WARP measurement left open above: the card entry passes, and WARP refuses wave size 32 because its reported range on this machine is 4..4. Not a code change; measurements only.

Environment

Windows 10.0.26200.9974, MSVC cl 19.44.35230 with BuildTools 14.44.35207, DXC 1.9.2602.17 from SDK 10.0.26100.0, AMD Radeon RX 9070 XT (vendor 1002 device 7550, driver 32.0.32029.2010), preset dev, no D3D12 debug layer. Measured tree: 432db950e4 merged with origin/cpp-migration ea07313b → merge commit 34febbd6b181516544e7d6502ae34cd3937b4737, git status --porcelain --untracked-files=no empty.

Commands

ctest --preset dev --no-tests=error -R "^native_heap_handle_probe_warp$" -V
ctest --preset dev --no-tests=error -R "^native_heap_handle_probe_hardware$" -V

Observed, merged tree

native_heap_handle_probe_hardware: Passed, 0.31 s:

reference selector 0: data matches the CPU reference, guard intact
reference selector 1: data matches the CPU reference, guard intact
native selector 0: data matches the CPU reference, guard intact
native selector 1: data matches the CPU reference, guard intact
native_heap_handle_probe: PASS

native_heap_handle_probe_warp: Failed, ctest exit 8 — FAIL: pipeline state of the native shader, printed right before return 5 (tests/native_heap_handle_probe.cpp:193-195). The probe's adapter gate passed (this WARP reports shader model 6.6 and resource binding tier 3), so this is a refused pipeline state, not a skip.

The WARP refusal, measured

The guess in the report above (a required wave size of 32 against WARP's 4 lanes) holds, and the property can be named:

  • Instrumentation (unpushed; prints and the HRESULT around both PSO creations): PROBE pso reference hr=00000000, then PROBE pso native hr=80070057 (E_INVALIDARG).
  • Capability range, per adapter on this machine:
enum 2: Microsoft Basic Render Driver vendor=1414 device=008c flags=0002   → shader_model=0066 waveops=1 lanes=4..4 total=128
enum 0: AMD Radeon RX 9070 XT         vendor=1002 device=7550 flags=0000   → shader_model=0066 waveops=1 lanes=32..64 total=4096
  • The same probe compiled the DXC reference with a pinned width: [WaveSize(4)] → WARP creates the reference PSO (hr=00000000) and still refuses the native one, which is pinned to 32; [WaveSize(32)] → WARP refuses the reference PSO itself (PROBE pso reference hr=80070057) before the native one is tried. So the rejection is not about how the property is spelled, and not about the native generator: it is 32 being outside WARP's range.
  • Removing the compute entry-point property i32 11, !{i32 32} that the generator appends to every compute module (src/dxil_module.h:218 at this head, :207 on cpp-migration) makes both PSOs be created and the probe pass on both adapters, four selector checks included.

Recorded dead end: taking createHandleFromHeap out of the native module makes the validator refuse it (Flags must match usage. Flags declared=1073741840, actual=16 — only the 0x40000000 heap-indexed bit differs), because the flag word handed to the module is the reference's. The flags are not a suspect.

For the record, not this probe

On the head as pushed (432db950e4, base 40365770, which predates e97c5c7c) the hardware entry dies with 0xC0000005 on this card inside CreateComputePipelineState: NULL_CLASS_PTR_READ_c0000005_amdxc64.dll, amdxc64.dll 8.18.10.0514, faulting RVA 0x1AB2CB7. After merging cpp-migration the same entry passes. That is consistent with #2932 ("emit !llvm.ident in direct DXIL modules for AMD PSO creation") and with the merge turning red into green, but I did not A/B the merge minus that one commit and did not decode the modules' metadata, so it is a match, not a proven cause. Worth a rebase before testing on AMD.

What would make the _warp entry meaningful

Either mark native_heap_handle_probe_warp as an expected skip keyed on the adapter's reported lane range, or give it a real 4-lane path. Dropping the property globally is not a fix: the emitted HLSL hardcodes [WaveSize(32)] (src/gfx1013_compute_native.cpp:1545) and the guest mapping is guestIndex = wave*32u + lane (:1560, both read at ea07313b; this PR does not touch that file), so the pin is deliberate — removing it for this test would run WARP in 4-lane waves against a model that assumes 32.

Limits

  • One machine, one GPU, one driver, one Windows build. The HRESULT instrumentation, the capability dump, the property ablation and the [WaveSize(4)] / [WaveSize(32)] reference builds were local and unpushed; each was restored (file sha256 back to the original, git status empty, and the same run returns to green).
  • Both containers were only exercised with the flag word DXC printed for the reference; another flag set was not tried.

AI-assisted.

@JB2WIN

JB2WIN commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

@SimSalabimse thanks, that matches what I saw on an RTX 3080. Your guess is right: with a D3D12_FEATURE_D3D12_OPTIONS1 check the probe reports adapter has no 32-lane waves (4..4) on WARP, so the native module's WaveSize=32 cannot be created there. The fix (return 77 in that case, as native_store_replay and native_recording_check already do) is in tedin7#2; with it native_heap_handle_probe_warp skips and _hardware still passes. #2908 is now continued from this branch (claim on the issue). AI-assisted.

@JB2WIN

JB2WIN commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Continued in #2972 (Fixes #2908): it keeps the four commits of this PR, adds the 32-lane WARP skip, the view contract for the heap read, .views handling in compile_dxil and the native_global_srv_heap_replay fixture. AI-assisted.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #2912 by @tedin7 -- test: native DXIL read of a GPU-selected descriptor heap slot (probe)

What works

  • Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
  • The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
  • supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
  • Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
  • Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms

Issues

  • supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
  • The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help

Recommendations

  • Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
  • Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib

Overall

A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.

@tedin7

tedin7 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

Closing this one: the work continued and was merged in #2972, which includes the 4 commits from this branch. Thank you @JB2WIN for carrying it to the finish.

AI-assisted; commands listed were executed locally.

@tedin7 tedin7 closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants