Skip to content

d3d12: forward compute root bindings and Dispatch on console lists - #2491

Open
Holastor wants to merge 9 commits into
R0Y00:mainfrom
Holastor:d3d12/compute-dispatch-root-bindings
Open

Holastor wants to merge 9 commits into
R0Y00:mainfrom
Holastor:d3d12/compute-dispatch-root-bindings

Conversation

@Holastor

@Holastor Holastor commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Rebased onto current main and updated to match the existing shared dispatch and compute root infrastructure (#1974, #1975, #2532):

  • Root Constants (slots 37 / 39): Extended x2w_root_constants::Store to support capacity up to 32 words per parameter for native slot 86 roots while preserving the 8-word default for translated compute. Forward valid 32-bit root constants to the desktop command list when desktop_compute_root is bound.
  • Root UAV (slot 45): Implemented list_compute_root_uav with placed buffer subrange offset translation to desktop GPU virtual addresses, routed through bind_compute_root_view so restore_compute_root replays it after shim passes.
  • Dispatch (slot 14) & Root Signature (slot 33): Kept main's canonical list_dispatch with decide_dispatch validation, updating parameter forwarding classification in Device::CreateRootSignature and checking that all declared compute parameters (SRV, UAV, constants) are bound prior to forwarding.
  • Fixture: Added synthetic fixture tests/startup_compute_dispatch.cpp (startup_compute_dispatch_root_<backend>) testing WARP and hardware backends, verifying 32-word native root constants with range checking, placed buffer subrange UAV dispatch, sentinel preservation at byte 0, readback of 57 at byte 256, and zero debug layer errors.

Verification & Evidence

Unit tests and linters:

python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
git diff --check upstream/main..HEAD
  • Markdown links: 27 files, 541 links checked, all passed.
  • Bidirectional controls: 2035 tracked files checked, no issues.
  • Git whitespace/diff check: clean.

dev preset test results:

ctest --preset dev --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root|startup_list_dispatch)' -V
The following tests passed:
	startup_root_constant_store
	startup_compute_dispatch_root_warp
	startup_compute_dispatch_root_hardware
	startup_list_dispatch
	startup_list_dispatch_no-limit_control
	startup_list_dispatch_no-state_control
	startup_list_dispatch_no-root-args_control
	startup_list_dispatch_no-pairing_control
	startup_list_dispatch_no-bound_control
	startup_list_dispatch_native_warp
	startup_list_dispatch_native_hardware
	startup_list_dispatch_native_skip_srv_warp_control

100% tests passed, 0 tests failed out of 12

release preset test results:

ctest --preset release --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root)' -V
The following tests passed:
	startup_root_constant_store
	startup_compute_dispatch_root_warp
	startup_compute_dispatch_root_hardware

100% tests passed, 0 tests failed out of 3
  • WARP: readback 57, sentinel 0x11111111, debug errors: 0, removed: S_OK.
  • Hardware (AMD Radeon RX 6600M, driver 32.0.12033.1030, Windows 10.0.26100, D3D12 debug layer enabled): readback 57, sentinel 0x11111111, debug errors: 0, removed: S_OK.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This branch also carries the three slot 70 backing commits from #2395, which the slot 86 native compute fixture does not need. Please put the final compute commit on current main or name the actual dependency if one exists. #2470 and #2490 work on translated slot 67 pipelines, while this fixture uses a real slot 86 compute PSO. Please coordinate the common command-list slots and test both paths after choosing the order. Keep the 57 readback and no-bound-pipeline controls on the native path.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from f90ed35 to 9ad7cb3 Compare November 25, 2026 19:24
@Holastor

Copy link
Copy Markdown
Contributor Author

Done — the branch now carries only the single compute dispatch commit (9ad7cb3f) on top of current main (6d2d3bed). The three slot 70 backing commits are no longer present.

On coordination with #2470 and #2490: those PRs operate on a translated slot 67 (placeholder) compute pipeline through dispatch_translated, which is called at the top of list_dispatch before the native path runs. This PR handles the native path only: a slot 86 desktop compute PSO is bound via list_pipeline (slot 25), which sets pass.compute_pipeline = true, and list_dispatch then calls list->Dispatch() directly. The two paths share the same argument-binding slots (14/35/37/39/45) but are entirely independent in execution — the translated path refuses when dispatch_translated returns true regardless of a native pipeline being present, and the native path runs only when no translated dispatch was recorded. No ordering dependency exists between the two PRs for these shared slots; whichever merges first, the other's handlers remain intact.

The 57 readback and no-bound-pipeline controls are both present on the native path:

startup_compute_dispatch_warp     Passed
startup_compute_dispatch_hardware Passed   adapter=AMD Radeon RX 6600M
read back value: 57 (expected 57)
compute stats: dispatches=1, skipped=1
device removed reason: 0x00000000, debug layer errors: 0

Command: ctest --preset dev --no-tests=error -R '^startup_compute_dispatch' -V

@ChazY11

ChazY11 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Built and run here: both cases pass, and four mutations separate into the two that matter and the two the fixture never reaches

ctest --preset dev -R 'compute_dispatch_(warp|hardware)'
    1/2 startup_compute_dispatch_warp .......  Passed   0.67 sec
    2/2 startup_compute_dispatch_hardware ...  Passed   3.66 sec
    100% tests passed, 0 tests failed out of 2

startup_compute_dispatch built from this branch with cmake --build --preset dev --target startup_compute_dispatch
(individual targets build here; the full target set stops in DXC on this host).

Four mutations of src/startup_stubs/d3d12_xs_device.cpp

mutation result
zero-sized Dispatch no longer rejected (if (!x || !y || !z) return; → if (false) return;) caught
if (parameter >= 16) return; → >= 17 survived
heap-type test relaxed (if (heap.type != … CBV_SRV_UAV) continue; → if (false) continue;) survived
dispatch whenever a pass exists (pass.pipeline_real && pass.compute_pipeline → true) caught

The two caught ones are exactly the halves I would want asserted. Zero-sized dispatches are illegal in D3D12 and must
not reach ID3D12GraphicsCommandList::Dispatch; and "only dispatch through a real compute pipeline" is the entire
point of the change — making it unconditional would dispatch through a placeholder and the fixture notices.

The two survivors are invalid-input guards the fixture never feeds

  • parameter >= 16: the fixture builds a two-entry root signature and touches parameters 0 and 1
    (root_params[0] UAV, root_params[1] 32-bit constants), so index 16 is never presented. A call with parameter = 16
    should be dropped without touching compute_root_address[16]; one case would pin it.
  • heap type: the fixture creates D3D12_HEAP_TYPE_DEFAULT and READBACK committed resources and registers a
    CBV/SRV/UAV heap, so a SAMPLER or RTV heap never reaches the descriptor-table path. A call with a SAMPLER heap
    should be ignored rather than resolved against a descriptor range it does not own.

Neither survivor is a defect I can demonstrate — both guards look correct, they simply have no case whose behaviour
would change if they were removed. Both are cheap to add and both protect against an index or heap-kind mistake from
the title side, which is precisely the sort of thing a stand-in has to get right.

One thing I checked while reading

x2w_d3d12_compute_stats reports render_dispatches and render_dispatches_skipped separately, and the counters are
bumped before the early-return branches (if (n <= 3) log(...)). That means a skipped dispatch is countable without a
log line, which is what lets a fixture assert "one recorded, one skipped" rather than parsing logs. Worth keeping.

Environment

Windows 11 build 26300.9974; WARP (Microsoft Basic Render Driver) and the installed physical GPU; two cases as
registered in the branch's CMakeLists.txt. Each mutation was built, run, reverted and rebuilt; final state 2/2 green.

AI-assisted.

@tedin7 tedin7 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.

Comment review of head 9ad7cb3 (code read against origin/main, no Windows run by me).

Checked on Linux: git diff --check origin/main...HEAD, python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py all clean. I could not build the C++ fixture here, so I did not run the code mutations; the mutation results already posted in this thread by ChazY11 are the only mutation evidence.

What looks right:

  • src/startup_stubs/d3d12_xs_device.cpp: slots 14, 35, 37, 39, 45 are forwarded only when a real compute pipeline / desktop compute root is bound, and the root-parameter type is checked before forwarding. Zero-size Dispatch is ignored and counted as skipped.
  • The fixture tests/startup_compute_dispatch.cpp reads back the UAV value (57) and has two negative controls, registered for warp and hardware in CMakeLists.txt.

Open question for @R0Y00 (design, not a bug):

  • Several open PRs edit the same compute slots in the same file: #1975 (slots 37 and 39 root constants), #2470 and #2490 (translated compute Dispatch), #1441 (draft, desktop DXIL compute). This PR adds list_dispatch (slot 14) and the compute root constant handlers (37, 39) too, so whichever lands second will conflict and may register a second handler for the same slot.
  • Please pick the order or the one owner of each slot. I am not merging this while the overlap is open.
  • Also: the diff moves some existing list_typed[...] lines (13, 36, 40, 42), which is churn unrelated to compute; consider leaving those lines where they were to ease the rebase.

Merge stays with @R0Y00 / MasterDomino. Win2025 WARP receipt for this head is still missing.

AI-assisted; commands listed were executed locally.

@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Hardware run and Windows 11 MSVC build at head 9ad7cb3f.

Environment: Windows 11 Pro build 26300.9974, Debug (dev preset), MSVC toolset 14.44.35207 (cl 19.44.35230.0). The hardware test prints adapter=NVIDIA GeForce RTX 3070 Ti and device removed reason: 0x00000000, debug layer errors: 0 (x2w-d3d12 debug layer: 0x00000000 enabled). Driver 32.0.16.2101 (not printed by this test; from the other hardware logs of this session on the same machine). The runs were serial (-j1).

Build: cmake --build --preset dev exited 0 (this PR changes C++ in src/startup_stubs/ and tests/, so the build was rerun at this head).

Tests:

  • ctest --preset dev --no-tests=error -j1 -R '^startup_compute_dispatch_warp$' -E hardware -V: 1/1 passed (startup_compute_dispatch_warp).
  • ctest --preset dev --no-tests=error -j1 -R '^startup_compute_dispatch_hardware$' -V: 1/1 passed. 0 capability skips (77).

Both tests print read back value: 57 (expected 57) and compute stats: dispatches=1, skipped=1. The log shows the first Dispatch(1, 1, 1) as skipped (pipeline_real=0 compute=0) and the second as recorded, after compute root UAV 0 was forwarded from the title address to a desktop address. The WARP run uses adapter=Microsoft Basic Render Driver and also reports debug layer errors: 0.

On the PR so far: the hardware run in the author's comment names AMD Radeon RX 6600M. A further comment reports a run on "the installed physical GPU" without naming the adapter. I found no run that names an NVIDIA adapter on this head.

Not covered by this run: NVIDIA only (RTX 3070 Ti); no AMD or Intel GPU; no Release build; the wider ctest -R '^startup_' suite was not run; the code mutations reported earlier in the thread were not rerun here; the fail-first run on main was not repeated; no negative control for this test appears in the log.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from 9ad7cb3 to 8cdc558 Compare November 25, 2026 20:42
@Holastor

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (99af3da0), resolving the CMakeLists.txt conflict with merged #2473.

Verified on Windows 11 x64 (AMD Radeon RX 6600M & WARP):

  • Build commit: 8cdc5589
  • ctest --preset dev --no-tests=error -R '^startup_compute_dispatch' -V: 2/2 passed
  • ctest --preset release --no-tests=error -R '^startup_compute_dispatch' -V: 2/2 passed
read back value: 57 (expected 57)
compute stats: dispatches=1, skipped=1
device removed reason: 0x00000000, debug layer errors: 0

PR is mergeable.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Re-reviewed 8cdc5589 after the branch was narrowed to the native slot 86 path. The exact 57 readback and the missing-pipeline case are useful. Two root-binding cases still need coverage before this can merge.

  • Slot 45 finds the owning placed buffer for an interior guest address and binds the desktop resource's base GPU VA in both branches. A valid subrange therefore writes the beginning of the buffer. Reuse the validated placement and add the guest byte offset to the desktop GPU VA. Check reject before considering any desktop-address path. Please dispatch into a nonzero aligned subrange and read back both it and the sentinel before it.
  • Slot 39 uses the original count in 1u << count after storing only the first eight words, and forwards the original count to the desktop root. A legal native root with 32 DWORDs can reach a shift outside the width, and a count past the bound of the active parameter gets forwarded. Keep the native and translated constant capacity explicit and check the active parameter's declared range. Exercise a native root with 32 constants and an out-of-range write.

Please also add a real slot-35 descriptor-table readback if keeping slot 35 in this PR. The current fixture uses root constants and a root UAV only. The handler resolves a view table but sends the original handle to D3D12, so a distinct guest and desktop handle is the useful comparison. This is a source review finding; I did not run those three new cases.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from 8cdc558 to cc447ed Compare November 25, 2026 20:56
@Holastor

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (e9ae884f), resolving the CMakeLists.txt conflict with merged #2451.

  • Build commit: cc447ed4
  • ctest --preset dev --no-tests=error -R '^startup_compute_dispatch' -V: 2/2 passed (0.22s)
read back value: 57 (expected 57)
compute stats: dispatches=1, skipped=1
device removed reason: 0x00000000, debug layer errors: 0

PR is mergeable.

@Holastor

Copy link
Copy Markdown
Contributor Author

Updated in commit d037e27 against upstream/main (e9ae884f):

1. Slot 45 (list_compute_root_uav)

  • Placed buffer subrange translation: When placed_buffer_range resolves an owning placed allocation (owner), computes offset = address - base where base = reinterpret_cast<u64>(owner->own().title_memory) and adds the offset to the desktop resource virtual address: desktop = res->GetGPUVirtualAddress() + offset.
  • Rejection check: Checks !placed.reject before considering any desktop-address path, ensuring rejected placed subranges do not fall through to raw desktop GPU VAs.
  • Fixture verification: Allocates a 512-byte placed buffer, initializing byte 0 with sentinel 0x11111111 and byte 256 with 0x22222222. Dispatches into the nonzero aligned subrange at offset 256 (guest_mem + 256). Verified readback asserts that offset 0 sentinel 0x11111111 remains untouched and offset 256 is updated to 57.

2. Slots 37 & 39 (list_compute_root_constant and list_compute_root_constants)

  • Capacity separation: Explicitly separates translated constants limits (translated_compute_constant_parameters = 16, translated_compute_constant_words = 8) from native parameter bounds (max_native_root_constants = 64).
  • Declared range validation: When pass.compute_params is active, checks p.type == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, offset < p.constants_count, and count <= p.constants_count - offset, dropping out-of-range writes before forwarding to the desktop list.
  • Bit shift overflow guard: Bounds translated storage masking to bound = std::min(count, 8 - offset) with ((1u << bound) - 1u) << offset, preventing shifts outside 32-bit width.
  • Fixture verification: Shader and root signature declare 32 root DWORD constants (scale, bias, pad[29], extra). Includes negative controls verifying out-of-range writes are dropped (count = 33, offset = 32, and offset = 31, count = 2). Writes full 32 constants via slot 39, followed by slot 37 updating offset 0 (scale = 5), yielding 5 * 10 + 7 + 0 = 57.

3. Slot 35 (list_compute_table)

  • Dropped slot 35 and related tables/state from this PR. Resolving guest and desktop descriptor tables requires command list descriptor heap binding (SetDescriptorHeaps, slot 32) and descriptor table virtualization, which will be covered together with table fixtures rather than in direct root binding dispatch.

Test Receipts

ctest --preset dev --no-tests=error -R '^startup_compute_dispatch' -V
  • WARP: Passed (readback 57, sentinel 0x11111111, dispatches=1, skipped=1, debug_errors=0, removed=S_OK)
  • Hardware (AMD Radeon RX 6600M, driver 32.0.12033.1030, Windows 10.0.26100, D3D12 debug layer enabled): Passed (readback 57, sentinel 0x11111111, dispatches=1, skipped=1, debug_errors=0, removed=S_OK)
ctest --preset release --no-tests=error -R '^startup_compute_dispatch' -V
  • WARP & Hardware: Passed (2/2)
ctest --preset dev --no-tests=error -R 'desktop_root_signature|era_heap_allocation|offscreen_warp' -V
  • Regression suite: Passed (3/3)

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

I reran d037e277 in Windows Release. WARP and RTX 4060 Laptop both kept 0x11111111 at byte 0 and wrote 57 at byte 256 using the 32-DWORD native root. The range guards passed and slot 35 is out of this diff. That addresses the native binding findings on the prior head. I also checked the current #2470 stack; the two candidates conflict in d3d12_xs_device.cpp over the compute slot and root-state wiring. Keep the native subrange fixture and reapply the native forwarding delta on the shared compute root/dispatch base after its existing prerequisites land.

@tedin7 tedin7 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.

Comment review of head d037e277, as @R0Y00 asked: what this PR still adds after #1974, #1975 and the #2470 work that landed through #2532. Code read against current main. I did not build it.

The branch conflicts with main in src/startup_stubs/d3d12_xs_device.cpp (git merge-tree --write-tree origin/main d037e277). Most of it is now on main in a different shape:

  • Slot 14 Dispatch: already on main (#1974). list_dispatch first tries the translated slot 67 path (dispatch_translated). Then it forwards only after x2w_startup::decide_dispatch accepts the bound desktop compute pipeline and root, the root/pipeline match and the bound root arguments, and it logs a reason when it refuses. The PR's list_dispatch (pipeline_real / compute_pipeline plus a skip counter) duplicates this and should be dropped.
  • Slots 37 / 39 compute root constants: on main (#1975), with one difference. list_compute_constant(s) store the words in pass.compute_constants through store_root_constants. That keeps 16 parameters of 8 words and logs anything dropped or truncated. The 32-DWORD native root that R0Y00 verified on d037e277 (57 at byte 256) would be truncated to 8 words on main. So the PR's real remaining delta here is native capacity: a native slot 86 root needs its declared constants_count (up to 32), not the translated store's 8. That fits best as an extension of store_root_constants / x2w_root_constants::Store, checked against the active parameter's declared range, not as a second handler.
  • Slot 45 compute root UAV: not on main. main records root UAVs only from the fixture hook x2w_d3d12_fixture_compute_root_uav, and its comment at bind_compute_root_view says slot 45 is not forwarded. The PR's slot 45 forwarding, with the placed-buffer subrange offset that R0Y00 checked (byte 0 kept at 0x11111111, 57 at byte 256), is new. It should go through bind_compute_root_view so restore_compute_root replays it after a shim compute pass.
  • Fixture tests/startup_compute_dispatch.cpp (native slot 86 path): new and still useful. Keep the subrange and the 32-DWORD cases. They are the only device evidence for the two deltas above.

Suggested shape after updating to main: drop the PR's slot 14 / 37 / 39 handlers, raise the native constant capacity in the shared store, add slot 45 through bind_compute_root_view, and keep the fixture. R0Y00's changes-requested stays until R0Y00 clears it. No merge from our side.

Commands: git merge-tree --write-tree origin/main d037e277 (1 conflict, d3d12_xs_device.cpp), git show origin/main:src/startup_stubs/d3d12_xs_device.cpp and git show origin/main:src/startup_stubs/d3d12_draw.inl (list_dispatch, list_compute_constant(s), store_root_constants, bind_compute_root_view), git log -S decide_dispatch / -S list_compute_constants (#1974, #1975).

AI-assisted; commands listed were executed locally.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from d037e27 to 61f0e76 Compare November 26, 2026 11:52
@Holastor

Copy link
Copy Markdown
Contributor Author

Updated head to 61f0e76e following @tedin7's review and rebased onto current main (410f6004):

  1. Dropped redundant slot 14 / 37 / 39 handlers and skip counters: Aligned with main's canonical list_dispatch and decide_dispatch path from startup: implement command-list slot 14 Dispatch (Part of #870) #1974.
  2. Extended root constant capacity: x2w_root_constants::Store now supports capacity up to 32 words per parameter for native slot 86 roots while preserving the 8-word default for translated compute. In list_compute_constant and list_compute_constants, forwarded calls reach list->SetComputeRoot32BitConstant(s) when desktop_compute_root is bound. Added unit test cases for 32-word capacity in tests/startup_root_constant_store.cpp.
  3. Implemented slot 45 compute root UAV: Bound through bind_compute_root_view with placed buffer subrange offset translation so restore_compute_root replays it after shim passes.
  4. Compute dispatch verification: list_dispatch validates that all declared compute parameters (SRV, UAV, constants) are bound. Renamed fixture tests to startup_compute_dispatch_root_<backend> to avoid test name collision with startup_compute_dispatch_<adapter> from startup: compute input named by a resource heap record a root constant indexes #2532.

Receipts

ctest --preset dev --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root|startup_list_dispatch)' -V
  • 12/12 passed (100%): startup_root_constant_store, startup_compute_dispatch_root_warp, startup_compute_dispatch_root_hardware, plus all 9 startup_list_dispatch canonical and mutation checks.
ctest --preset release --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root)' -V
  • WARP & Hardware (AMD Radeon RX 6600M): Passed. Sentinel at byte 0 preserved (0x11111111), 32-DWORD root constant update correctly evaluated to 57 at byte 256, 0 debug layer errors, device removed reason S_OK.

@Holastor
Holastor requested a review from tedin7 November 26, 2026 11:53
@Holastor

Copy link
Copy Markdown
Contributor Author

@R0Y00 — gentle ping on this PR. Main is merged cleanly and all CI / Win2025 WARP checks (dev & release) are green; it's just waiting on the matched baseline/candidate title run when one of you has a window.

@pigalot pigalot 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.

Independently reviewed 61f0e76e integrated over main c1de64a5 (tree 337e949c). The merge is clean (CMakeLists.txt, d3d12_draw.inl and d3d12_xs_device.cpp auto-merged) and git diff --cached --check origin/main is clean.

Earlier findings.

  • R0Y00 on 8cdc5589: the slot 45 subrange offset, the reject check and the 32-word native capacity are in the code. The subrange is pinned: dropping + offset fails the fixture with sentinel at offset 0: 0x00000039. R0Y00's last comment, on d037e277, asked to reapply the native delta on the shared root/dispatch base. This head does that in the shape tedin7 suggested: no second slot 14/37/39 handler, a wider x2w_root_constants::Store, and slot 45 through bind_compute_root_view.
  • What did not carry over: d037e277 forwarded slot 37/39 only after checking the active parameter's type and declared range. In this head, that check now decides only the store's capacity. The forward to the desktop list happens whenever a desktop compute root is bound. That is the finding below.

What I ran. Full dev and release builds of the trial merge, then:

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -E hardware -R '^(startup_root_constant_store|startup_compute_dispatch_root_warp|startup_list_dispatch.*|startup_compute_root|compute_root_warp|startup_indirect_root_constants_warp|startup_compute_binding_trace_warp|startup_compute_dispatch_.*_warp|startup_compute_dispatch_warp|startup_compute_root_srv_dispatch_warp)$'
python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_compute_dispatch_root_hardware|startup_list_dispatch_native_hardware|startup_compute_dispatch_hardware|startup_compute_dispatch_native_hardware|startup_compute_root_srv_dispatch_hardware|startup_indirect_root_constants_hardware|compute_root_hardware)$'
  • WARP: 23 of 25 pass in each preset.
    • startup_compute_dispatch_native_warp is the existing capability skip ("the adapter has no 32-lane waves").
    • startup_compute_dispatch_warp fails in Debug and Release, 3 of 3 runs: RuntimeError: dispatch-wrong-root: consumer exit 3221225477 (0xC0000005).
    • On main c1de64a5, with the same build directory rebuilt, it passes 3 of 3.
  • Hardware: 7 of 7 pass in each preset, including the PR's startup_compute_dispatch_root_hardware.

Finding 1: slots 37, 39 and 45 forward to root parameters that the bound desktop root does not declare.

list_compute_constant(s) start from the translated default capacity = 8. They raise it only when compute_params names a 32-bit constants parameter at that index. They then call SetComputeRoot32BitConstant(s) whenever pass.desktop_compute_root is set, parameter < 16 and the range fits that capacity. A parameter past NumParameters, or one of another type, therefore still reaches D3D12. list_compute_root_uav checks the type only when parameter < compute_params->size(), so a parameter past the end is bound too.

  1. An existing test from main crashes. startup_compute_dispatch_warp dispatch-wrong-root sets slot67_other_root, a root with no parameters, then calls slot 37 for parameter 0. The bisect: with the two new forwarding blocks in list_compute_constant(s) removed, and everything else the same, the test passes again. Reverting the root_srv_only widening or the slot 45 registration instead leaves it failing. I didn't check which tests CI runs. The PR body's ctest filter does not include this one.
  2. Probes on the PR's own fixture (WARP, debug layer on). One call was added after the slot 37 write, the fixture rebuilt, then restored:
Added call Result
none exit 0, 57 at byte 256, sentinel kept, 0 debug errors
slot 39, parameter 0 (the root UAV), 1 word exit 70. SetComputeRoot32BitConstants: The currently set root signature declares parameter [0] with type UAV, so it is invalid to set root constants here.
slot 37, parameter 0 exit 70, the same error for SetComputeRoot32BitConstant
slot 39, parameter 2 (the root has 2) exit 0xC0000005
slot 45, parameter 2, the valid subrange log compute root UAV 2: title … -> desktop 0x200000100, then exit 0xC0000005

Suggested direction (unconfirmed): forward only when compute_params is set, parameter < compute_params->size(), the parameter has the slot's type, and (for 37/39) offset/count fit its constants_count. The d037e277 version did this for 37/39. Graphics list_root_srv does the same before it forwards. A fixture call for each of the cases above would pin it, for example one with no debug error and the 57 readback unchanged.

Finding 2: slot 45 binds title memory that no placed buffer covers as a desktop GPU address. If list_upload_gpu misses and placed_buffer_range returns no owner and no reject, the branch else if (!placed.owner && …) desktop = address; passes the title CPU address to SetComputeRootUnorderedAccessView. Probe: one extra slot 45 call on parameter 0 with a fresh 64 KiB VirtualAlloc, before the fixture's valid bind.

  • With the debug layer off, the log shows compute root UAV 0: title 0x298e4850000 -> desktop 0x298e4850000. Then the valid bind replaces it and the readback is still 57.
  • With X2W_D3D12_DEBUG=1, the process ends inside that slot 45 call with exit code 2173, before the shim's log line. I did not find what ends it.

A title address is not a desktop GPU virtual address. I suggest refusing (and logging) this case, as the slot 67 output path does for "an output is not an aliased placed buffer range", rather than binding it.

Mutants (each applied alone, full dev build, the WARP set above minus the failing startup_compute_dispatch_warp, sources restored from their raw bytes, git diff --quiet clean afterwards):

Mutant Result
slot 45 binds the base VA (offset dropped) killed: startup_compute_dispatch_root_warp, sentinel at offset 0 is 0x39
slot 39 forward range check dropped killed: debug-layer error on SetComputeRoot32BitConstants
slot 37 forward range check dropped killed: debug-layer error on SetComputeRoot32BitConstant
slot 39 stores at the translated 8-word capacity killed: startup_compute_dispatch_root_warp
dispatch treats an unset root SRV as bound killed: startup_list_dispatch_native_warp
root_srv_only widening reverted killed: startup_compute_dispatch_root_warp
store: 32-word mask without the full-width case killed: startup_root_constant_store ("all 32 words bound with capacity 32") and startup_compute_dispatch_root_warp
slot 45 ignores placed.reject survives
slot 45 parameter type check dropped survives
slot 45 alignment check dropped survives
dispatch treats an unset root UAV as bound survives
dispatch treats unset root constants as bound survives

7 of 12 are killed. The five survivors are new checks with no fixture that reaches them: a rejected placed range, a slot 45 bind to a non-UAV parameter, a misaligned slot 45 address, and a dispatch with a declared root UAV or constants parameter left unset. Each needs one fixture call plus an assertion that the dispatch is refused or the bind is dropped. The all_bound refusal is new behaviour in this PR, so its UAV and constants arms should be pinned like the SRV arm already is.

Non-blocking.

  • Several comments still describe slot 45 as not forwarded: bind_compute_root_view's header, the fixture-hook comment above x2w_d3d12_fixture_compute_root_uav, and startup_list_dispatch_check.cpp:61. The root_srv_only field comment ("every parameter a root SRV") now also covers root UAVs and constants.
  • render_dispatches / render_dispatches_skipped are declared and never used. Pass::compute_root_address is written by slot 45 and never read.
  • The fixture's three out-of-range controls check only that nothing reaches D3D12 (no debug error). The store still keeps the truncated words. That is fine for dispatch, but no assertion reads them.

Verdict: changes requested on 61f0e76e, for finding 1 (it breaks startup_compute_dispatch_warp from main), finding 2 and the five surviving mutants. R0Y00's changes-requested review on 8cdc5589 also still stands.

Environment: AMD Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 driver 32.0.16.1088, WARP 10.0.26100.9818, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, D3D12 debug layer on (X2W_D3D12_DEBUG=1, as registered) except in the one probe marked off.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 61f0e76e.

This reply was AI-assisted.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from 61f0e76 to 9829040 Compare November 28, 2026 06:39
@Holastor

Holastor commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated head to 9829040d and rebased onto current main (db28a796), resolving all findings and coverage gaps from @pigalot's review:

1. Root Parameter Type and Range Gating (Finding 1)

  • In list_compute_constant and list_compute_constants, forwarding to list->SetComputeRoot32BitConstant(s) is now strictly gated on compute_params matching parameter < compute_params->size(), parameter type D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, and declared constants_count bounds. Calls targeting out-of-range parameters or parameters of other types (e.g. parameter 0 on empty root slot67_other_root) no longer forward to D3D12.
  • Verified that startup_compute_dispatch_warp now passes cleanly in both dev (1.34s) and release (1.25s), resolving the previous dispatch-wrong-root 0xC0000005 crash.

2. Disallow Unplaced Host Memory as GPU VA (Finding 2)

  • In list_compute_root_uav, dropped the fallback branch that assigned raw unplaced CPU addresses (!placed.owner) to desktop = address. Unplaced host memory is refused, logged, and clears any previously bound desktop UAV (desktop_compute_root_uavs[parameter] = 0).

3. Mutant Coverage in Synthetic Fixture

Added negative controls and assertions in tests/startup_compute_dispatch.cpp killing all 5 surviving mutants identified:

  • placed.reject handling: Slot 45 call with wrapping/rejected address (~0u64) clears the binding; subsequent Dispatch is refused.
  • Slot 45 parameter type & bounds: Slot 45 calls targeting parameter 1 (32BIT_CONSTANTS) and parameter 2 (past NumParameters) are dropped without reaching D3D12 (0 debug errors).
  • Slot 45 alignment guard: Slot 45 call with misaligned address (+1) clears the binding; subsequent Dispatch is refused.
  • Unset root UAV: Calling Dispatch when constants are bound but root UAV is unset is refused.
  • Unset root constants: Calling Dispatch when root UAV is bound but root constants are unset is refused.
  • Slot 37/39 parameter type & bounds: Slot 37/39 calls targeting parameter 0 (UAV) and parameter 2 (out of bounds) are dropped without reaching D3D12.

4. Non-blocking Cleanups

  • Removed unused declarations render_dispatches, render_dispatches_skipped, and Pass::compute_root_address.
  • Updated stale comments in bind_compute_root_view, x2w_d3d12_fixture_compute_root_uav, root_srv_only, and tests/startup_list_dispatch_check.cpp.

Test Receipts

ctest --preset dev --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root|startup_list_dispatch.*|startup_compute_root|compute_root_warp|startup_indirect_root_constants_warp|startup_compute_binding_trace_warp|startup_compute_dispatch_warp|startup_compute_root_srv_dispatch_warp)$' -V
  • 16/16 passed (100%): all WARP/CPU checks including startup_compute_dispatch_warp (PASS on warp, 1.34s) and startup_compute_dispatch_root_warp (readback 57, sentinel 0x11111111, debug errors: 0).
ctest --preset dev --no-tests=error -R '^(startup_compute_dispatch_root_hardware|startup_list_dispatch_native_hardware|startup_compute_root_srv_dispatch_hardware|startup_indirect_root_constants_hardware|compute_root_hardware)$' -V
  • 5/5 passed (100%): on AMD Radeon RX 6600M (driver 32.0.21045.11001, Windows 10.0.26100, D3D12 debug layer enabled).
ctest --preset release --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root|startup_compute_dispatch_warp)' -V
  • Release: Passed.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Thanks for the update to 9829040d. I reviewed it statically against main c3204a9c and did no Windows build, WARP or GPU run. The trial merge is clean: git merge-tree --write-tree origin/main 9829040d exits 0. In the code, the earlier requests on 8cdc5589 and F1/F2 from the 61f0e76e review look addressed. valid_param gates slots 37/39, slot 45 returns for parameter >= params->size() or a type other than UAV, and the desktop = address fallback is gone. I think two things still need a fix before merge:

1. Root constants are not set again after a shim compute pass. restore_compute_root sets the title root again but replays only desktop_compute_upload_srvs and desktop_compute_root_uavs. Before it runs, validate_indexed_arguments (the if (indirect && indexed) path in draw_translated) calls list->SetComputeRootSignature(compute.root.Get()), and the split indirect Dispatch also replaces the compute root. pass.compute_constants still reports those words as bound, so the next slot 14 Dispatch is forwarded with the title's constants unset. On main, that root is refused with compute root arguments are not forwarded (list_dispatch.h). A fix could replay the bound words in restore_compute_root, with a fixture case: constants, then an indirect indexed draw, then Dispatch, then read back 57. Source: git show 9829040d:src/startup_stubs/d3d12_xs_device.cpp and .../d3d12_draw.inl.

2. The five mutants that survived the previous review still look unpinned. The all_bound loop is the same as on 61f0e76e; only the fixture changed.

  • Unset root UAV treated as bound: the clears zero only pass.desktop_compute_root_uavs[...], so the desktop list keeps UAV-A's guest_subrange_va binding. The "constants bound, UAV unset" Dispatch would then write 57 at +256, the same value as the final Dispatch.
  • Unset root constants treated as bound: the UAV-A Dispatch would write at +256 before the final 57 overwrites it. d3d12sdklayers.h (SDK 26100) has NOT_SET message IDs only for descriptor tables and root CBV/SRV/UAV: grep -o 'D3D12_MESSAGE_ID_[A-Z0-9_]*NOT_SET' d3d12sdklayers.h.
  • placed.reject is equivalent: placed_buffer_range returns a reject only as {nullptr, nullptr, true}, so res && placed.owner already fails.
  • Alignment: the UAV-D binding is replaced before any Dispatch that the constants arm doesn't already refuse. Only a debug-layer error at set time could catch it, which I couldn't measure.
  • To pin these, the refused-Dispatch cases could bind their own aligned subrange (for example +128 with its own sentinel) that is read back, or the test could assert the Dispatch(...) refused: log lines. A posted mutation table would help too.

Two smaller points:

  • In the fixture shader, HLSL pads each pad[29] element to 16 bytes. extra therefore sits at DWORD 117, outside the 32-DWORD root, and word 31 is never read: dxc -T cs_6_0 -E cs_main -Fc shows uint extra; ; Offset: 468 and Size: 472. Writing uint2 pad2; uint4 pad4[6]; uint3 pad3; instead gives Offset: 124 and Size: 128, and a nonzero extra would show that the word arrives.
  • The slot 14 paragraph in docs/experiments.md still says slots 37, 39 and 45 have no handler.

CI ran ctest --preset pr (100% tests passed out of 70), but none of the new tests: grep -c startup_compute_dispatch_root on the Windows job log gives 0.

This comment was AI-assisted.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from 9829040 to d0ccda2 Compare November 28, 2026 08:00
@Holastor

Copy link
Copy Markdown
Contributor Author

Thanks @JohnConnorNPC for the detailed and thorough review! I have addressed all points and rebased the branch on current main (bbf4687b) at commit d0ccda2f.

Changes Summary

  1. Root constants restored after shim compute pass (src/startup_stubs/d3d12_xs_device.cpp):

    • Updated restore_compute_root to inspect declared parameters in pass.compute_params and replay all bound 32-bit root constants from pass.compute_constants in contiguous spans via list->SetComputeRoot32BitConstants:
      if (const auto* params = pass.compute_params) {
          for (UINT parameter = 0; parameter < params->size() && parameter < 16; ++parameter) {
              const auto& p = (*params)[parameter];
              if (p.type == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS) {
                  const UINT declared = (std::min)(p.constants_count, x2w_root_constants::max_words_per_parameter);
                  UINT offset = 0;
                  while (offset < declared) {
                      if (!(pass.compute_constants.bound[parameter] & (1u << offset))) {
                          ++offset;
                          continue;
                      }
                      UINT count = 0;
                      while (offset + count < declared && (pass.compute_constants.bound[parameter] & (1u << (offset + count)))) {
                          ++count;
                      }
                      list->SetComputeRoot32BitConstants(parameter, count, &pass.compute_constants.words[parameter][offset], offset);
                      offset += count;
                  }
              }
          }
      }
    • Exported fixture helper x2w_d3d12_fixture_restore_compute_root(guest_list).
    • In tests/startup_compute_dispatch.cpp, added explicit test case: binds 32-word root constants and UAV, clobbers the desktop compute root signature with a dummy root (simulating an intervening shim compute pass such as validate_indexed_arguments or split indirect Dispatch), calls x2w_d3d12_fixture_restore_compute_root, executes Dispatch(1, 1, 1), and verifies full execution.
  2. HLSL constant buffer vector padding (tests/startup_compute_dispatch.cpp):

    • Replaced pad[29] with uint2 pad2; uint4 pad4[6]; uint3 pad3; uint extra;, packing vectors 0 through 7 without HLSL 16-byte scalar array padding.
    • extra now sits exactly at byte offset 124 (DWORD 31). Setting constants_32[31] = 2 yields val = 5 * 10 + 7 + 2 = 59, proving that word 31 arrives at the shader.
  3. Pinning the surviving mutants with dedicated sentinels (tests/startup_compute_dispatch.cpp):

    • Configured separate sentinel regions in the placed buffer to catch any stale desktop binding dispatches:
      • +0: Sentinel 0x11111111 (guards base memory).
      • +128: Sentinel 0x33333333 (pins unset constants mutant): binds UAV to +128 while constants are unset, calls Dispatch(1, 1, 1) -> refused. If a mutant treats constants as bound, +128 is corrupted.
      • +256: Destination for valid dispatch after root restore -> asserted strictly for 59.
      • +384: Sentinel 0x44444444 (pins unset UAV, alignment, and placed.reject mutants): binds UAV to +384, binds constants, then calls slot 45 with a misaligned address +384 + 1 or ~0u64 (clearing desktop_compute_root_uavs[0] = 0 in pass while the desktop list holds the stale +384 hardware binding). Calls Dispatch(1, 1, 1) -> refused. If a mutant ignores the UAV check, alignment, or reject, +384 is corrupted.
    • Added parameter 16 out-of-bounds guards for slots 37, 39, and 45.
Mutation Caught By
Zero-sized dispatch check relaxed Refused at dispatch; 0 threads
Dispatch without compute pipeline Refused at dispatch; no PIs recorded
Unset root constants treated as bound Corrupts sentinel 0x33333333 at +128 (caught by sentinel_128 == 0x33333333)
Unset root UAV treated as bound Corrupts sentinel 0x44444444 at +384 (caught by sentinel_384 == 0x44444444)
Misaligned UAV address ignored Corrupts sentinel 0x44444444 at +384 (caught by sentinel_384 == 0x44444444)
Rejected placed buffer range ignored Corrupts sentinel 0x44444444 at +384 (caught by sentinel_384 == 0x44444444)
parameter >= 16 guard relaxed Tested explicitly on slots 37, 39, 45 with param 16
Root constants not restored across shim pass Target +256 reads wrong value / fails result_256 == 59
DWORD 31 truncation / misalignment Target +256 reads 57 instead of 59 (extra = 2)
  1. Documentation and CI configuration:
    • Updated docs/experiments.md:17160 to reflect that slots 37, 39, and 45 forward to the desktop list.
    • Added "startup_compute_dispatch" to targets and startup_compute_dispatch_root_warp to the pr test filter regex in CMakePresets.json.

Test Receipts

ctest --preset dev --no-tests=error -R '^startup_compute_dispatch_root_' -V
354: adapter=Microsoft Basic Render Driver
354: sentinel at offset 0: 0x11111111 (expected 0x11111111)
354: sentinel at offset 128: 0x33333333 (expected 0x33333333, pins unset constants mutant)
354: subrange value at offset 256: 59 (expected 59, scale=5, bias=7, extra=2)
354: sentinel at offset 384: 0x44444444 (expected 0x44444444, pins unset UAV / alignment mutant)
354: device removed reason: 0x00000000, debug layer errors: 0
1/2 Test #354: startup_compute_dispatch_root_warp ....... Passed 0.06 sec

355: adapter=AMD Radeon RX 6600M
355: sentinel at offset 0: 0x11111111 (expected 0x11111111)
355: sentinel at offset 128: 0x33333333 (expected 0x33333333, pins unset constants mutant)
355: subrange value at offset 256: 59 (expected 59, scale=5, bias=7, extra=2)
355: sentinel at offset 384: 0x44444444 (expected 0x44444444, pins unset UAV / alignment mutant)
355: device removed reason: 0x00000000, debug layer errors: 0
2/2 Test #355: startup_compute_dispatch_root_hardware ... Passed 0.18 sec
ctest --preset dev --no-tests=error -R '^(startup_root_constant_store|startup_compute_dispatch_root|startup_list_dispatch.*|startup_compute_root|compute_root_warp|startup_indirect_root_constants_warp|startup_compute_binding_trace_warp|startup_compute_dispatch_warp|startup_compute_root_srv_dispatch_warp)$' -V
  • 16/16 passed (100%)
ctest --preset dev --no-tests=error -R '^(startup_compute_dispatch_root_hardware|startup_list_dispatch_native_hardware|startup_compute_root_srv_dispatch_hardware|startup_indirect_root_constants_hardware|compute_root_hardware)$' -V
  • 5/5 passed (100%) on AMD Radeon RX 6600M (driver 32.0.21045.11001, Windows Build 26100, D3D12 debug layer enabled).
ctest --preset release -R '^startup_compute_dispatch_root_' -V
  • Release /O2: Passed on both WARP and hardware.

@Holastor
Holastor requested a review from pigalot November 28, 2026 08:03

@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.

Review of head aa7a96b5, by reading only (not built or run). git merge-tree --write-tree origin/main aa7a96b5 exits 0 on main 212d4b5f, and main still has no slot 45 handler and only stores slots 37/39, so the change is not covered there. Line numbers below are at the PR head.

Three cases the fixture does not reach:

  1. Slot 45 binds list upload memory as a root UAV. list_compute_root_uav takes a list_upload_gpu hit as the desktop address (d3d12_xs_device.cpp:4455-4456). Those pages are created in an UPLOAD heap in GENERIC_READ (list_upload_pages.h:19-27), which cannot be a UAV write target. Slot 43 uses the same lookup, but for reads. Refusing that branch in slot 45 would be safer.
  2. Slot 45 binds placed buffers that the translated path refuses. The placed branch (:4458-4469) uses owner->own().real when placed.alias is null, and never checks D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS. placed_buffer_range sets alias only for Placement::aliased_buffer (d3d12_capture.inl:350-351). The translated output path refuses both cases (d3d12_compute_dispatch.inl:641 and :645), and the translated root SRV path refuses a non-aliased range unless it was copied in this recording (:378).
  3. Two paths set the desktop compute root again without restore_compute_root.
    • After a translated slot 67 dispatch, d3d12_compute_dispatch.inl:774-778 sets the root and replays root SRVs only. The root UAVs and constants this PR forwards are gone from the desktop list, while desktop_compute_root_uavs and compute_constants still report them bound.
    • The rect-list conversion (d3d12_xs_device.cpp:3899) sets the root with no arguments. has_compute_root_views (:3887) refuses it while a root SRV or UAV is live, but it does not look at constants, so a root with only constants bound loses them.
    • In both cases a later native Dispatch on the same list passes the all_bound check (:4574-4590) and is forwarded with those arguments unset. Calling restore_compute_root in both places would cover it.

Minor:

  • list_typed[37] and [39] are assigned twice in build_tables: :7765-7766 (added here) and :7776-7777 (already there).
  • The comments at :3373, :3380 and :3944 still say that only root SRVs are forwarded.

CI passes on aa7a96b5. The pr preset gains only startup_compute_dispatch_root_warp; startup_root_constant_store, startup_list_dispatch* and startup_compute_dispatch_warp are not in its filter, so CI does not run them.

@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed the three findings and the minor points in aa7a96b5..de6392e0 (three commits). @Leyukaka, thanks for the read-through — all three reproduce from the code.

1. Root UAV validation (slot 45)

  • The upload lookup is gone: list_compute_root_uav no longer accepts list_upload_gpu addresses. Upload pages are created in an UPLOAD heap in GENERIC_READ (list_upload_pages.h:17-27), so they cannot be UAV targets.
  • A placed buffer is forwarded only when it aliases title memory and its desktop resource has D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, matching the translated output rules (d3d12_compute_dispatch.inl:641/:645).
  • The refusal log is now ... is not an aliased placed buffer range with unordered access.

The fixture adds three negative controls: upload memory from slot 148, a placed buffer created without the UAV flag, and a placed buffer forced to the non-aliased committed fallback (128 KiB allocation, address at +0x100; the committed resource is read back). Each check is pinned by a mutation below.

2. Restore after root-replacing paths

  • record_translated_dispatch now calls restore_compute_root instead of replaying only root SRVs (d3d12_compute_dispatch.inl:773).
  • The rectangle-list conversion does the same instead of only setting the signature (d3d12_xs_device.cpp:3899), so a root with only constants bound no longer loses them.
  • restore_compute_root already replays root SRVs, root UAVs and constant spans.

3. Minor points

  • Removed the duplicate list_typed[37]/[39] pair added in this PR; the pre-existing pair stays.
  • Updated the stale comments at the slot 33 path, the split-dispatch comment and the compute_root_has_arguments field comment.
  • The pr preset now builds and runs startup_root_constant_store, startup_list_dispatch* and startup_compute_dispatch_warp (plus startup_stream_consumer). This is exactly the regression pigalot found and CI did not run at 61f0e76e.

Mutation evidence

Each mutation applied alone on de6392e0, dev build, WARP, fixture run directly:

Mutation Result
slot 45 accepts upload memory again killed: exit 22 (the upload page was written with 59)
slot 45 drops the ALLOW_UNORDERED_ACCESS check killed: exit 23 (the refused target was written)
slot 45 drops the alias requirement killed: exit 24 (the non-aliased committed buffer was written with 59)

Earlier mutants still hold: removing the constants replay leaves 0 at +256; removing the UAV replay writes at +384; forwarding a cut span produces the two debug-layer errors.

Test receipts

ctest --preset dev --no-tests=error -R '^(startup_compute_dispatch_root_(warp|hardware)|startup_compute_dispatch_warp|startup_root_constant_store|startup_list_dispatch[a-z_-]*)$'
    13/13 passed

WARP (Microsoft Basic Render Driver, debug layer on) and AMD Radeon RX 6600M, driver 32.0.21045.11001, Windows 11 10.0.26300, debug layer on.

cmake --build --preset pr
ctest --preset pr --no-tests=error
    84/85 passed

The one failure is startup_launch on this host: its control never saw a block above 2^40 (startup_launch_check.py:263), which is a host memory-layout condition unrelated to this diff. All compute/list/store tests in the pr preset pass.

#3343

#3343 is a duplicate submission of this branch plus an assert compute binding refusals commit. That commit expects the old slot-45 message and the old refusal counts; the three new controls add dropped UAV binds, so its strings and counts no longer match this head. Please keep this PR and close #3343 as superseded.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from de6392e to fc0c862 Compare November 29, 2026 12:31
@Holastor

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (77d1ba4d); the conflict was in CMakePresets.json with #3378/#3450. The resolution keeps both upstream's new pr targets (startup_inline_retire, startup_resource_retire_title, startup_table_lock, the inline indirect tests) and this PR's additions.

New head: fc0c862b. The three commits are unchanged in content.

Re-ran on the new base:

  • targeted set (startup_compute_dispatch_root_(warp|hardware), startup_compute_dispatch_warp, startup_root_constant_store, startup_list_dispatch*): 13/13 passed;
  • cmake --build --preset pr + ctest --preset pr: 92/93 passed, with the same host-only startup_launch failure (the memory-block control never saw a block above 2^40 on this machine).

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

I re-reviewed fc0c862b (rebased on main 77d1ba4d, 0 behind) by reading it, and ran the store test on Linux. I did no Windows build, WARP or GPU run.

Nothing blocking from me. The point from my d0ccda2f review is fixed: before x2w_d3d12_fixture_restore_compute_root, the restore case now has a same-layout root write zero constants and a UAV at +384. Leyukaka's three points from the aa7a96b5 review are fixed in the code:

  • slot 45 no longer takes list_upload_gpu hits;
  • slot 45 needs placed.alias with D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
  • both record_translated_dispatch and the rectangle-list conversion now call restore_compute_root.

git grep -n 'SetComputeRootSignature' fc0c862b -- src/startup_stubs finds no other path that replaces the title's desktop compute root without a restore. The builder gate sets the same root again, which keeps its arguments. The translated Dispatch now replays root UAVs and constants after each translated dispatch as well. It replays only what slots 37, 39 and 45 forwarded under a decoded title root, so translated results shouldn't change.

CI at this head reports 100% tests passed out of 93, and the log has startup_compute_dispatch_root_warp ... Passed, startup_root_constant_store ... Passed, startup_list_dispatch_native_skip_srv_warp_control ... Passed and startup_compute_dispatch_warp ... Passed.

I built tests/startup_root_constant_store.cpp with g++ 14 on Linux (-std=c++17 -fsanitize=address,undefined) and it prints root constant store ok. Each of these mutants fails it: either capacity > max_words_per_parameter guard removed (FAIL: a capacity above 32 is refused), the n >= 32 ? ~0u branch in set removed (FAIL: all 32 words bound with capacity 32), or word() limited to 8 words (FAIL: last word reads back).

The two older change requests still block the merge: R0Y00's on 8cdc5589 and pigalot's on 61f0e76e. As far as I can tell, every point in both is now addressed in the code. So this needs their re-review, not more changes.

SHOULD

  1. One mutant of the new all_bound constants check still survives, by reading. Leyukaka found it on d3d12: compute dispatch root-binding review follow-up #3343, and the same code is here: is_bound(i, 0, p.constants_count, cap) → is_bound(i, 0, 1, cap). Every Dispatch in tests/startup_compute_dispatch.cpp sees parameter 1 with either no words set or all 32. The first one forwarded follows SetComputeRoot32BitConstants(1, 33, ...), and the earlier refused ones come before any write to parameter 1. So checking only word 0 gives the same results. A Dispatch after a write of words 0-1 only, which must be refused and leave a sentinel untouched, would pin it.

NIT
2. tables[list_kind][45] = &list_compute_root_uav replaces the generic slot thunk. Slot 45 therefore skips capture::list_call, the x2w-frame trace and draw_calls_seen, unlike slot 43, which is only in list_typed. Slot 51 does the same and says why. Also, with the table entry set, list_typed[45] is never reached.
3. The misaligned case (guest_subrange_va_384 + 1) is logged as "is not an aliased placed buffer range with unordered access". That address is inside an aliased UAV buffer and is refused only for its alignment.
4. The translated path still checks title root constants against 8 words. is_bound(tr->uds[i].a, tr->uds[i].b, 1) in d3d12_compute_dispatch.inl uses the default capacity, so a translated shader that reads word 8 or later is still refused, though the store now keeps up to 32. This isn't a regression; passing the declared count could be a follow-up.
5. Two stale comments: d3d12_draw.inl "In render mode slot 43 is the forwarded compute parameter setter.", and the fixture's "Negative control 2: Dispatch without a compute pipeline -> counted as skipped".

AI-assisted.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

This branch no longer merges into current main (17b662a2). git merge-tree --write-tree origin/main fc0c862b exits 1 with one conflict, in CMakePresets.json. As before, the conflict is in the pr preset's include.name regex: 866e48ef (#3389) added startup_compute_packed_d16_x_uav_reference to the same line that this branch extends with startup_compute_dispatch_root_warp, startup_list_dispatch[a-z_-]* and the others. Keeping the names from both sides should resolve it.

Could you rebase onto current main or merge it in, then re-run the pr preset? My review of fc0c862b found nothing blocking. The open change requests (R0Y00 on 8cdc5589, pigalot on 61f0e76e) still need re-reviews from the people who filed them.

AI-assisted.

@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed @JohnConnorNPC's SHOULD and NIT 3 / NIT 5 from the fc0c862b review in 1b6efea4.

SHOULD — surviving all_bound constants mutant. tests/startup_compute_dispatch.cpp now writes only root constant words 0, 1 and 31 (leaving words 2-30 unbound) after binding a UAV at byte 64, then calls Dispatch(1, 1, 1). The dispatch must be refused; the shader reads only words 0, 1 and 31, so a check that looks at word 0 alone forwards it and writes 39 there. Mutant is_bound(i, 0, p.constants_count, cap) -> is_bound(i, 0, 1, cap), applied alone on this head:

sentinel at offset 64: 0x00000027 (expected 0x66666666, pins partial constants mutant)
startup_compute_dispatch_root_warp ... Failed

Reverted and rebuilt; the unmodified head passes.

NIT 3. The slot 45 refusal now logs the alignment case separately:

x2w-render compute root UAV 0: title 0xad00181 maps to desktop 0x30003a181, which is not 16-byte aligned

The previous message remains for unplaced, unaliased and no-UAV-flag targets.

NIT 5. Corrected d3d12_draw.inl ("slots 37, 39, 43 and 45 are the forwarded compute parameter setters") and the fixture's "counted as skipped" -> "refused".

NIT 2 (slot 45 generic thunk) and NIT 4 (the translated path's 8-word check) are left as-is; both were marked nit / follow-up.

Receipts

ctest --preset dev --no-tests=error -j 1 -R '^(startup_list_dispatch.*|startup_compute_dispatch_root_(warp|hardware)|startup_root_constant_store|startup_compute_dispatch_(warp|hardware)|compute_root_hardware|startup_compute_root_srv_dispatch_hardware|startup_indirect_root_constants_hardware)$'
  • 17/17 passed.
ctest --preset dev --no-tests=error -j 1 -E hardware -R '^(startup_root_constant_store|startup_compute_dispatch_root_warp|startup_list_dispatch.*|startup_compute_root|compute_root_warp|startup_indirect_root_constants_warp|startup_compute_binding_trace_warp|startup_compute_dispatch_.*_warp|startup_compute_dispatch_warp|startup_compute_root_srv_dispatch_warp)$'
  • 26 passed, 1 capability skip (startup_compute_dispatch_native_warp, "the adapter has no 32-lane waves").
ctest --preset release --no-tests=error -j 1 -R '^(startup_compute_dispatch_root_(warp|hardware)|startup_root_constant_store)$'
  • 3/3 passed.

Both backends print the new line:

sentinel at offset 64: 0x66666666 (expected 0x66666666, pins partial constants mutant)

Environment: WARP (Microsoft Basic Render Driver) and AMD Radeon RX 6600M, Windows 11 build 26300, D3D12 debug layer on (X2W_D3D12_DEBUG=1 as registered); the fixture does not print the driver version. Dev and release builds were rerun on this commit; git diff --check is clean.

The earlier changes-requested reviews are the only outstanding items, so this is ready for a re-check of 1b6efea4 by @R0Y00 and @pigalot.

AI-assisted.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from 1b6efea to d7813a9 Compare November 29, 2026 13:37
@Holastor

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (17b662a2). The only conflict was in CMakePresets.json; resolution keeps upstream's new startup_compute_packed_d16_x_uav_reference in the pr filter alongside this PR's targets and filter entries.

New head: d7813a9b (the fix commit from the previous comment, content unchanged; the old hash 1b6efea4 is gone after the rebase).

Re-ran on the rebased base:

  • targeted 17-test set (startup_list_dispatch.*, startup_compute_dispatch_root_(warp|hardware), startup_root_constant_store, startup_compute_dispatch_(warp|hardware), compute_root_hardware, startup_compute_root_srv_dispatch_hardware, startup_indirect_root_constants_hardware): 17/17 passed in dev;
  • release (startup_compute_dispatch_root_(warp|hardware), startup_root_constant_store): 3/3 passed.

Environment: WARP (Microsoft Basic Render Driver) and AMD Radeon RX 6600M, Windows 11 build 26300, D3D12 debug layer on. GitHub now reports the PR as mergeable; CI will run the merged pr preset.

The earlier changes-requested reviews remain the outstanding items, so this is ready for a re-check of d7813a9b by @R0Y00 and @pigalot.

AI-assisted.

@pigalot pigalot 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.

Retested d7813a9b integrated over main c3cae611 (tree c43ae55a). The merge is clean and git diff --cached --check origin/main is clean. This is the re-review of my changes request on 61f0e76e.

Earlier findings on 61f0e76e.

  • Finding 1 (slots 37, 39 and 45 forwarded to parameters the root does not declare): addressed. Slots 37 and 39 forward only when compute_params has a 32-bit constants parameter at that index, and only the words the store kept. Slot 45 returns for a parameter past the end or of another type. startup_compute_dispatch_warp, which crashed on 61f0e76e, passes in Debug and Release, and CI now runs it.
  • Finding 2 (slot 45 bound title memory that no placed buffer covers): addressed. Slot 45 binds only an aliased placed buffer that has ALLOW_UNORDERED_ACCESS; upload memory, unplaced memory, a copied placement and a buffer without the flag are refused, each with a fixture control.
  • The five surviving mutants: four are killed now (type check, alignment check, unset root UAV, unset constants; see the table). The fifth, "slot 45 ignores placed.reject", is equivalent and I was wrong to ask for a fixture: placed_buffer_range returns a reject only as {nullptr, nullptr, true}, so the placed.owner test already fails.
  • R0Y00's requests on 8cdc5589 (subrange offset, reject check, 32-word capacity) are in the code, and the offset is pinned (first table row).

What I ran. Full dev and release builds of the trial merge, then:

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -E hardware -R '^(startup_root_constant_store|startup_compute_dispatch_root_warp|startup_list_dispatch.*|startup_compute_root|compute_root_warp|startup_indirect_root_constants_warp|startup_compute_binding_trace_warp|startup_compute_dispatch_.*_warp|startup_compute_dispatch_warp|startup_compute_root_srv_dispatch_warp|startup_indirect_.*_warp)$'
python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(startup_compute_dispatch_root_hardware|startup_list_dispatch_native_hardware|startup_compute_dispatch_hardware|startup_compute_dispatch_native_hardware|startup_compute_root_srv_dispatch_hardware|startup_indirect_root_constants_hardware|compute_root_hardware)$'
  • WARP: 58 of 60 pass in each preset. startup_compute_dispatch_native_warp and startup_compute_dispatch_texture_native_warp are capability skips, not passes.
  • Hardware: 7 of 7 pass in each preset. startup_compute_dispatch_root_hardware prints 0x11111111 at 0, 0x66666666 at 64, 0x33333333 at 128, 59 at 256, 0x44444444 at 384, 39 at 448, 0 for the non-aliased target and 0 debug-layer errors.
  • startup_compute_dispatch_root_* is not registered on main c3cae611.
  • tests/docs_links_check.py and tests/bidi_controls_check.py pass.
  • A local startup run of this head was judged no worse than its baseline.

Finding (blocking): no test fails when slot 37 stops forwarding.

With list->SetComputeRoot32BitConstant(parameter, value, offset) removed from list_compute_constant, all 58 WARP tests still pass. The fixture calls slot 37 twice. The first call (word 31) is followed by a Dispatch that must be refused. The second (word 0) is followed only by the Dispatch after x2w_d3d12_fixture_restore_compute_root, and the restore sets the word from the store. So the store half of slot 37 is tested and the forward half is not. For the same reason, leaving slot 37's capacity at the translated 8 words also passes: nothing reads a slot 37 word at offset 8 or above from the desktop list.

The forward itself works at this head. Probe (three lines added after the fixture's slot 37 (1, 5, 0) call, then restored): a slot 37 write of 4 at word 31, a slot 45 bind at +192, and a Dispatch.

Shim value at +192 (WARP)
unmodified 61 (5 × 10 + 7 + 4)
slot 37 forward removed 39
slot 37 capacity left at 8 59

A case like this in the fixture, with its own target and before the stand-in root pass, pins both. That is the only change I am asking for.

Mutants (each applied alone, dev build, the 60-test WARP set above, sources restored from their raw bytes, git diff --quiet clean afterwards; hardware was not rerun per mutant):

Mutant Result
slot 45 binds the base VA (offset dropped) killed: 0x3b at offset 0
slot 45 ALLOW_UNORDERED_ACCESS check dropped killed: fixture fails
slot 45 parameter type check dropped killed: 2 debug-layer errors
slot 45 alignment check dropped killed: debug-layer error, sentinel at 384 overwritten
a failed slot 45 bind keeps the previous address killed: 0x3b at 384
dispatch treats an unset root UAV as bound killed: 0x3b at 384
dispatch checks only constant word 0 killed: 0x27 at 64
dispatch treats unset root constants as bound killed: 0 at 128
restore without constants replay killed: 0 at 256
restore without UAV replay killed: 256 unchanged, 0x3b at 384; startup_indirect_count_split_warp also fails
root UAV not counted as a forwarded parameter killed: 256 and 448 unchanged
root constants not counted as a forwarded parameter killed: 256 and 448 unchanged
slot 39 forward removed killed: 2 at 448
slot 39 forwards count, not the kept span killed: 2 debug-layer errors
store_root_constants returns count, not the kept span killed: 2 debug-layer errors
slot 39 stores at the translated 8-word capacity killed: 256 and 448 unchanged
store is_bound: no full-width mask case killed: startup_root_constant_store and the fixture
store set: no full-width mask case killed: startup_root_constant_store and the fixture
store is_bound capacity guard removed killed: startup_root_constant_store
store set capacity guard removed killed: startup_root_constant_store
store word() limited to 8 words killed: startup_root_constant_store
slot 37 forward removed survives (the finding above)
slot 37 stores at the translated 8-word capacity survives (the finding above)
translated dispatch replays root SRVs only, as on main survives
rectangle-list conversion sets the root only, as on main survives
slot 37 accepts any parameter type equivalent: a non-constants parameter has constants_count 0, so the store drops the write and nothing is forwarded
slot 39 accepts any parameter type equivalent, same reason

21 killed, 4 survive, 2 equivalent.

Non-blocking.

  • The two restore_compute_root calls added since aa7a96b5 (after a translated dispatch and after the rectangle-list conversion) have no test: reverting either to what main does passes all 60 tests. Both reuse the helper the fixture does test, and the startup run above showed no change, so I am not blocking on them. A native Dispatch after either path, under a root with constants, would pin them.
  • By reading, not reproduced: slot 45 and the forwarded Dispatch never call require_state for the bound buffer. The fixture moves its buffer to UNORDERED_ACCESS on the desktop list itself, and slot 26 does not forward transition barriers. A buffer the shim has already moved to another state in the same recording (for example as a translated dispatch input) would be dispatched in that state, and a later require_state would transition from a state the list no longer has. require_state(self, alias, D3D12_RESOURCE_STATE_UNORDERED_ACCESS) for each bound root UAV before list->Dispatch may be the fix; I have not tested it.
  • By reading: after a real root, then a root with no desktop root signature, then the first root again, desktop_compute_root_uavs is kept while the constants and the root SRV mask are cleared. A root with only a root UAV would then dispatch without a new slot 45 call, where the root SRV case ("root changed and changed back") is refused.
  • list_compute_root assigns compute_srv_bound and compute_root_has_arguments twice in a row; the second pair of lines can go.
  • docs/experiments.md still has an older Startup list Dispatch paragraph that says slots 37, 39, 41 and 45 have no handler yet.
  • The fixture's header still lists "Dispatch with 0 threads" as a negative control; it is refused there only because no pipeline is bound.

Verdict: changes requested on d7813a9b, for the slot 37 forward only. Everything I asked for on 61f0e76e is addressed.

Environment: AMD Ryzen 7 9800X3D, NVIDIA GeForce RTX 5090 driver 32.0.16.1088, WARP (Microsoft Basic Render Driver), Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, D3D12 debug layer on.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux passed on d7813a9b.

This reply was AI-assisted.

@Holastor

Copy link
Copy Markdown
Contributor Author

Addressed the blocking finding at 8fb73981: the fixture now pins slot 37's forward and its 32-word capacity.

Change. tests/startup_compute_dispatch.cpp adds a target at offset 192. After the fixture's slot 37 (1, 5, 0) it binds a UAV at +192, writes word 31 with 4 through slot 37, and dispatches before restore_compute_root, so the store's replay can no longer mask the forward. The shader reads scale=5, bias=7, extra=4 and writes 61. Word 31 is then written back to 2 so the restored dispatch at offset 256 still expects 59.

Mutants (each applied alone, release build, then reverted; git diff -- src/startup_stubs/ is empty afterwards):

Mutant Value at +192 Result
none 61 passes
slot 37 forward removed (list->SetComputeRoot32BitConstant call dropped) 39 fixture fails (exit 26)
slot 37 capacity left at the translated 8 words 59 fixture fails (exit 26)

Runs (release, MSVC, debug layer on):

  • WARP (Microsoft Basic Render Driver):
    ctest --preset release --no-tests=error -j 1 -E hardware -R '^(startup_root_constant_store|startup_compute_dispatch_root_warp|startup_list_dispatch.*|startup_compute_root|compute_root_warp|startup_indirect_root_constants_warp|startup_compute_binding_trace_warp|startup_compute_dispatch_.*_warp|startup_compute_dispatch_warp|startup_compute_root_srv_dispatch_warp|startup_indirect_.*_warp)$'
    — 58 passed, 1 capability skip (startup_compute_dispatch_native_warp, no 32-lane waves), 0 failed.
  • Hardware (AMD Radeon RX 6600M, Windows 11 build 26300):
    ctest --preset release --no-tests=error -R '^startup_compute_dispatch_root_hardware$' — passed.
    192 = 61, 256 = 59, sentinels at 0/64/128/384 intact, cut-write 39 at 448, non-aliased target 0, device removed reason 0x0, 0 debug errors. WARP prints the same values.

The non-blocking items are left as-is.

AI-assisted.

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Delta review of 8fb73981 (one commit after d7813a9b, tests/startup_compute_dispatch.cpp only) against main 5de0b114. I only read the code and built or ran nothing.

  • The new +192 case does what the remaining blocking finding asked for, as far as the code shows. Just before it, the full slot 39 write leaves scale 3, bias 7 and extra 2, and slot 37 then sets word 0 to 5. The case binds +192, writes word 31 = 4 through slot 37 and dispatches before x2w_d3d12_fixture_restore_compute_root. That gives 5 × 10 + 7 + 4 = 61. Without the forward the desktop list still holds 3/7/2, which reads 39. With the translated 8-word capacity the word 31 write is dropped, which reads 59. Each of those trips return 26.
  • Writing word 31 back to 2 keeps the restored dispatch at 256 at 59. The later UAV-Upload/NoUavFlag/NotAliased controls now follow a +192 bind, so a "failed bind keeps the previous address" mutant would write 59 over the 61 there and still be killed.
  • git merge-tree --write-tree origin/main 8fb73981 exits 0 (tree e8db32ac). git diff --check d7813a9b 8fb73981 exits 0.
  • CI on 8fb73981 is still running. The gfx1013 job has passed; the Windows and Linux Python jobs are still in progress.

Nothing new on our side blocks this. The two standing change requests (on 8cdc5589 and d7813a9b) still need their reviewers to look again.

AI-assisted.

@Holastor
Holastor requested review from Leyukaka and pigalot November 29, 2026 15:12
@Leyukaka

Leyukaka commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Taking this over since there has been no activity for 48 h; will hand back if you resume. Your commits stay as they are and keep your authorship; I will rebase onto current main, address the open review points and report the test results here.

@Holastor

Holastor commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@Leyukaka There were no open change requests on the latest commit — everything was already addressed and we were only waiting on re-review/approval and merge. That said, if anything turns out to be off or needs changes after rebase/checks, I'm fine handing it over to you for follow-ups.

@Leyukaka

Leyukaka commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks, @Holastor. Handing it back, then. main has moved and the branch now conflicts in CMakePresets.json; I rebased your seven commits (authorship and messages unchanged) onto main 959306d4 and added one commit for pigalot's remaining non-blocking points: Leyukaka:takeover-2491 at fb972d8b4. Locally, ctest --preset dev -R '^(startup_root_constant_store|startup_list_dispatch(_.*)?|startup_compute_dispatch(_root)?_(warp|hardware)|startup_indirect_rectlist_(warp|hardware))$' passed 16/16 on that commit. Feel free to reset your branch to it, or take only the rebase; I won't open a separate PR.

@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from 8fb7398 to fb972d8 Compare December 1, 2026 17:54
@Holastor

Holastor commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Reset d3d12/compute-dispatch-root-bindings to fb972d8b (Leyukaka:takeover-2491) and force-pushed.

Verified locally on fb972d8b with:

.\tools\dev.ps1; ctest --preset dev --no-tests=error -R ^(startup_root_constant_store|startup_list_dispatch(_.*)?|startup_compute_dispatch(_root)?_(warp|hardware)|startup_indirect_rectlist_(warp|hardware))$ -V
  • 16/16 passed (0 failed, 6.21 sec)
  • Hardware: AMD Radeon RX 6600M, driver 32.0.21045.11001, debug layer enabled
  • WARP: Microsoft Basic Render Driver, driver 10.0.26100.10068, debug layer enabled

Holastor and others added 9 commits December 1, 2026 23:03
Extend x2w_root_constants::Store to support capacity up to 32 words per
parameter for native slot 86 roots while preserving the 8-word default for
translated compute. In list_compute_constant and list_compute_constants, forward
valid 32-bit root constants to the desktop command list when desktop_compute_root
is bound.

Implement list slot 45 (SetComputeRootUnorderedAccessView) in d3d12_xs.dll,
translating guest placed buffer subrange offsets to desktop GPU virtual addresses
and routing through bind_compute_root_view so restore_compute_root replays it.

Update restore_compute_root to replay all bound 32-bit root constants in addition
to root SRVs and UAVs after an intervening shim compute pass.

Update CreateRootSignature and list_dispatch to consider compute root parameters
forwarded and check that all declared root parameters are bound before dispatch.

Add synthetic fixture tests/startup_compute_dispatch.cpp exercising WARP and
hardware backends, verifying root constant bounds checking, full 32-word native
root constants with vector padding, restoration across shim passes, and placed
buffer subrange UAV dispatch with dedicated sentinels pinning unset/invalid states.
The restore fixture now clobbers the constants and the UAV through a
same-layout root before x2w_d3d12_fixture_restore_compute_root, so the
replay loop is required for the dispatch to read 59; without it the
fixture reads 0 at the subrange or writes at the clobbered UAV.

store_root_constants returns the words it kept and slots 37/39 forward
exactly that span, so a cut write no longer marks words bound while the
desktop list stays unset. The fixture dispatches after a 33-word write
to the 32-word parameter and must read 39 at offset 448.

Pin is_bound's full-width mask and both capacity guards in the store
test, rename the unbound-root refusal to cover UAVs and constants, and
update the slot 14 docs and the README row.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Slot 45 (SetComputeRootUnorderedAccessView) now forwards only an aliased
placed buffer created with D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS. Upload
pages are read-only for shaders and a copied placement would not show the
write to the title, so both are refused and logged instead of being bound as
desktop GPU addresses.

The fixture adds three negative controls: upload memory, a placed buffer
without the UAV flag, and a non-aliased copied placement. Each was verified by
a mutation that writes into the refused target: exit 22, 23 and 24.

Co-Authored-By: Claude Code <noreply@anthropic.com>
A translated slot 67 dispatch and the rectangle-list argument conversion both
set the title's desktop compute root again, but only root SRVs were replayed.
Root UAVs and 32-bit constants stayed unset on the desktop list while the pass
still reported them bound, so a later native Dispatch could be forwarded with
them missing. Both paths now call restore_compute_root, which replays root
SRVs, root UAVs and 32-bit constants.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Update comments that still described only root SRVs as forwarded, drop the
duplicate slot 37/39 registrations, and add startup_root_constant_store,
startup_list_dispatch* and startup_compute_dispatch_warp (plus the targets they
need) to the pr preset. The pr preset now runs the tests that caught the
regression during review.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Write only root constant words 0, 1 and 31 in the fixture, leaving words 2-30 unbound, and assert the Dispatch is refused with the sentinel at offset 64 untouched. This kills the mutant that checks only word 0 in the all_bound loop.

Log a misaligned slot-45 desktop address separately instead of the unplaced-range message, and correct two stale comments about the forwarded compute parameter setters.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The fixture wrote word 31 only through slot 39 and word 0 through slot 37,
then relied on restore_compute_root, whose store replay masks a missing
slot 37 forward. Add a target at offset 192 and dispatch before the restore:
the desktop root should read scale=5, bias=7, extra=4 and write 61. Without
the forward it reads 39; with the translated 8-word capacity it reads 59.
Write extra=2 back afterwards so the restored dispatch at 256 still expects 59.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@Holastor
Holastor force-pushed the d3d12/compute-dispatch-root-bindings branch from fb972d8 to 890b170 Compare December 1, 2026 18:05
@Holastor

Holastor commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Leyukaka! Reset d3d12/compute-dispatch-root-bindings onto your rebased stack (main 959306d4 with the CMakePresets.json conflict resolved and the non-blocking review follow-ups included) and updated the d3d12_xs standin export expectations at 890b170.

Ready for re-review and merge from @R0Y00 and @pigalot.

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.

8 participants