Skip to content

runtime: bind directly indexed sampler heap in native compute - #3779

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
R0D4X:runtime/native-compute-sampler-heap
Dec 2, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
R0D4X:runtime/native-compute-sampler-heap

Conversation

@R0D4X

@R0D4X R0D4X commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #3076
Refs #2935

Summary

Completes the remaining scope of #3076: binding the directly indexed sampler heap (ComputeViewKind::heap_sampler) on the in-process native compute translation route (translate_compute_natively), matching the published-manifest smpidx <bytes> path (#3540, #3626).

Changes

  • src/startup_stubs/d3d12_compute_dispatch.inl:
    • Reset tr.sampler_heap_bytes = 0 in refuse_native so a failed native translation cannot leave a stale span before a fallback manifest read.
    • Extract the single ComputeViewKind::heap_sampler binding before sorting and validating SRV/UAV registers, enforcing the same span invariants as format_compute_runtime_manifest and the manifest reader (compute_sampler_heap, register 0, array count 1, nonzero multiple of 16 bytes, <= 16 * 2047) and storing it in tr.sampler_heap_bytes.
  • tests/startup_compute_sampler_heap_check.py and tests/cmake/startup_compute_sampler_heap.cmake:
    • Add a native mode (X2W_NATIVE_SHADERS, X2W_NATIVE_SHADERS_ONLY=1, no published .cs.cso or <key>.txt) registered as startup_compute_dispatch_sampler_heap_native_{warp,hardware}.
    • Verifies live translation and readback of entry 67 across all 32 lanes, 4 decoy samplers at entry 67, views-only refusal, undersized heap refusal (67 entries), exact 68-entry boundary, a second program sampling entry 68 (span 1104: refused on 68 entries, passes on 69 entries), and native refusal of the reserved fallback entry 2047.
  • tests/standin_exports_check.py:
    • Resolve the exact line number of x2w_d3d12_compute_census in src/startup_stubs/d3d12_compute_dispatch.inl from the source file instead of hardcoding :1744, keeping the exact path:line assertion without breaking on edits to d3d12_compute_dispatch.inl.

Verification

  • Commit: 9e5a0947 (based on main 158ef794)
  • Environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK / DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), Microsoft Basic Render Driver (10.0.26100.9818), D3D12 debug layer enabled (no error messages).

Commands and results

ctest --preset dev --no-tests=error -R '^startup_compute_dispatch_sampler_heap' -V
ctest --preset release --no-tests=error -R '^startup_compute_dispatch_sampler_heap' -V
  • dev (Debug):
    • startup_compute_dispatch_sampler_heap_warp: Skipped (77) — adapter has no 32-lane waves (manifest and 6 reader refusals verified)
    • startup_compute_dispatch_sampler_heap_hardware: Passed (6.28 s, RTX 5080, debug layer clean)
    • startup_compute_dispatch_sampler_heap_native_warp: Skipped (77) — the adapter has no 32-lane waves
    • startup_compute_dispatch_sampler_heap_native_hardware: Passed (4.63 s, RTX 5080, debug layer clean)
  • release (/O2):
    • startup_compute_dispatch_sampler_heap_warp: Skipped (77) — adapter has no 32-lane waves
    • startup_compute_dispatch_sampler_heap_hardware: Passed (6.28 s, RTX 5080, debug layer clean)
    • startup_compute_dispatch_sampler_heap_native_warp: Skipped (77) — the adapter has no 32-lane waves
    • startup_compute_dispatch_sampler_heap_native_hardware: Passed (4.77 s, RTX 5080, debug layer clean)

Fail-first / mutation control

Reverting the d3d12_compute_dispatch.inl hunk and rebuilding d3d12_xs_shim fails startup_compute_dispatch_sampler_heap_native_hardware (exit 8) with:

x2w-draw compute pipeline 4eeb8b56930d15a4 not translated natively: view kind 20 is not bound for a natively translated program

Pure-Python checks

.\out\pe-env\Scripts\python.exe -B tests\standin_exports_check.py
.\out\pe-env\Scripts\python.exe -B tests\docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py
  • standin_exports: 470 cases, 6/6 mutations killed PASS
  • docs_links_check.py: Self-test passed. Checked 225 Markdown files and 874 links.
  • bidi_controls_check.py: Self-test passed. Checked 2877 tracked source, script and build/CI files: no bidirectional controls.

Scope note

This verifies source-built gfx1013 compute fixtures through the stand-in D3D12 runtime on the RTX 5080 and WARP; it does not establish full-title startup or frame rate.

AI-assisted.

@Leyukaka Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 9e5a09475. Thanks for the change. The skip at tests/startup_compute_sampler_heap_check.py:118 looks for root signature creation failed (adapter lacks directly indexed sampler heap). The runtime emits the device does not take a directly indexed sampler heap at src/startup_stubs/translated_sampler_bindings.h:186, so the skip never matches. An unsupported adapter can also reject the fixture's initial root signature at tests/startup_stream_consumer.cpp:1482, before native translation, and the test then fails instead of skipping. Please detect that capability before creating the fixture and return 77 for that case.

The entry-2047 case at tests/startup_compute_sampler_heap_check.py:170 reaches the existing frontend refusal at src/gfx1013_direct_compute.inl:892, so removing the new runtime span guard would still pass it. To test the guard, please exercise it with out-of-range binding metadata.

@R0D4X

R0D4X commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both review points in 63f63251:

  1. Capability skip & early probe:
    • Updated the capability skip substring in tests/startup_compute_sampler_heap_check.py to the device does not take a directly indexed sampler heap (matching src/startup_stubs/translated_sampler_bindings.h:186).
    • Added a sampler-heap-probe mode in tests/startup_stream_consumer.cpp that checks D3D_SHADER_MODEL_6_6 and D3D12_RESOURCE_BINDING_TIER_3 before create_slot67 runs and returns 77 on unsupported adapters instead of failing CreateRootSignature.
  2. Direct runtime span guard coverage:
    • Built a prepared frontend pack (compile_dxil --prepare-compute-pack) for the SAMPLE request and patched its heap_sampler binding metadata (required_bytes = 0, 20, 32768, and shader_register = 1), then ran startup_stream_consumer with X2W_NATIVE_COMPUTE_PACK and verified each is refused by translate_compute_natively with a sampler heap span that is not 16-byte entries below the fallback and leaves the output untouched. These 4 controls also run on WARP before the wave32 capability skip.

Re-verified on dev (Debug) and release (/O2) on Windows 11 (10.0.26300.9974), RTX 5080 (32.0.16.2140) + WARP (10.0.26100.9818):

  • startup_compute_dispatch_sampler_heap_native_hardware: Passed (dev 5.79 s / release 5.66 s, debug layer enabled, no error message)
  • startup_compute_dispatch_sampler_heap_native_warp: Skipped (77) after verifying all 4 runtime span guard controls.

@R0Y00
R0Y00 merged commit 7069dfe into R0Y00:main Dec 2, 2026
5 checks passed
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.

native: read sampler descriptors from the directly indexed sampler heap

3 participants