d3d12: compute dispatch root-binding review follow-up #3345

Open
github-bot wants to merge 3 commits from github-bot/gh-3343 into main AGit
Owner

@⁠romn4rch on GitHub · 2026-11-28 11:21 UTC · original
romn4rch:copilot/pr-2491-review-088f7f23 → main · +713 −50 · 12 files · 3 commits · open

Replacement submission for #2491. This branch contains the existing compute root-binding and Dispatch work plus the verified review follow-up commit. The original PR remains open because its author-owned branch was not writable from this account; these PRs overlap in scope, so please keep only one submission and close/mark the other as superseded when choosing.

Validation: the WARP/hardware compute-dispatch fixtures, native Dispatch WARP fixture, and root-constant store test passed (4/4).

**@⁠romn4rch** on GitHub · 2026-11-28 11:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3343) `romn4rch:copilot/pr-2491-review-088f7f23` → `main` · +713 −50 · 12 files · 3 commits · open Replacement submission for #2491. This branch contains the existing compute root-binding and Dispatch work plus the verified review follow-up commit. The original PR remains open because its author-owned branch was not writable from this account; these PRs overlap in scope, so please keep only one submission and close/mark the other as superseded when choosing. Validation: the WARP/hardware compute-dispatch fixtures, native Dispatch WARP fixture, and root-constant store test passed (4/4).
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 <[email protected]>
Co-authored-by: Copilot App <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 11:27:22 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:23 UTC · original · approved these changes

LGTM — solid follow-up that extends compute dispatch forwarding to root UAVs and 32-bit constants alongside root SRVs.

  • store_root_constants returns words kept so the forwarder emits exactly the words both sides store, preventing drift.
  • Slots 37/39 validate parameter type and clamp capacity to the declared constant count.
  • Slot 45 handles upload and placed-buffer UAVs with alignment checks.
  • restore_compute_root replays all constant words after a shim compute pass clobbers the desktop root.
  • decide_dispatch checks SRV/UAV/constants individually rather than a single bitmask.
  • Root constant store capacity expanded to 32 words with a 32-bit bound mask (avoids full-range mask wrap).
  • New test uses sentinel pins at offsets 0/128/384 to catch mutants that relax binding checks.

Error messages generalized consistently across the codebase.

**@⁠KelboLive** on GitHub · 2026-11-28 21:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3343#pullrequestreview-6100142211) · **approved these changes** LGTM — solid follow-up that extends compute dispatch forwarding to root UAVs and 32-bit constants alongside root SRVs. - `store_root_constants` returns words kept so the forwarder emits exactly the words both sides store, preventing drift. - Slots 37/39 validate parameter type and clamp capacity to the declared constant count. - Slot 45 handles upload and placed-buffer UAVs with alignment checks. - `restore_compute_root` replays all constant words after a shim compute pass clobbers the desktop root. - `decide_dispatch` checks SRV/UAV/constants individually rather than a single bitmask. - Root constant store capacity expanded to 32 words with a 32-bit bound mask (avoids full-range mask wrap). - New test uses sentinel pins at offsets 0/128/384 to catch mutants that relax binding checks. Error messages generalized consistently across the codebase.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:57 UTC · original · approved these changes

LGTM — solid follow-up that extends compute dispatch forwarding to root UAVs and 32-bit constants alongside root SRVs.

  • store_root_constants returns words kept so the forwarder emits exactly the words both sides store, preventing drift.
  • Slots 37/39 validate parameter type and clamp capacity to the declared constant count.
  • Slot 45 handles upload and placed-buffer UAVs with alignment checks.
  • restore_compute_root replays all constant words after a shim compute pass clobbers the desktop root.
  • decide_dispatch checks SRV/UAV/constants individually rather than a single bitmask.
  • Root constant store capacity expanded to 32 words with a 32-bit bound mask (avoids full-range mask wrap).
  • New test uses sentinel pins at offsets 0/128/384 to catch mutants that relax binding checks.

Error messages generalized consistently across the codebase.

**@⁠KelboLive** on GitHub · 2026-11-28 21:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3343#pullrequestreview-6100255295) · **approved these changes** LGTM — solid follow-up that extends compute dispatch forwarding to root UAVs and 32-bit constants alongside root SRVs. - `store_root_constants` returns words kept so the forwarder emits exactly the words both sides store, preventing drift. - Slots 37/39 validate parameter type and clamp capacity to the declared constant count. - Slot 45 handles upload and placed-buffer UAVs with alignment checks. - `restore_compute_root` replays all constant words after a shim compute pass clobbers the desktop root. - `decide_dispatch` checks SRV/UAV/constants individually rather than a single bitmask. - Root constant store capacity expanded to 32 words with a 32-bit bound mask (avoids full-range mask wrap). - New test uses sentinel pins at offsets 0/128/384 to catch mutants that relax binding checks. Error messages generalized consistently across the codebase.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 07:01 UTC · original · reviewed

Review of head 088f7f23, by reading only (not built or run).

As the description says, this replaces #2491: the branch is #2491's two commits (d0ccda2f, aa7a96b5) plus 088f7f23. git diff aa7a96b5 088f7f23 -- src is empty. The new commit changes only tests/startup_compute_dispatch.cpp (log-count checks) and CMakeLists.txt (X2W_TRAP_LOG for the two startup_compute_dispatch_root_* tests). git merge-tree --write-tree origin/main 088f7f23 exits 0 on main 212d4b5f.

The three points of the aa7a96b5 review on #2491 are unchanged at this head, same line numbers; details are there:

  1. Slot 45 takes a list_upload_gpu hit as the root UAV address (d3d12_xs_device.cpp:4455-4456); those pages are UPLOAD heap, GENERIC_READ (list_upload_pages.h:19,27). No fixture case reaches this branch.
  2. Slot 45's placed branch (:4458-4469) uses the owner's desktop buffer when placed.alias is null and does not check D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; the translated output path refuses both (d3d12_compute_dispatch.inl:641, :645).
  3. d3d12_compute_dispatch.inl:774-778 (root SRVs only) and the rect-list conversion (d3d12_xs_device.cpp:3899, guarded by has_compute_root_views at :3887, which ignores constants) set the desktop compute root again without restore_compute_root; a later Dispatch still passes all_bound (:4574-4590).

New at this head:

  • The expected counts match the fixture.
    • 5 "not bound" refusals: Dispatch at tests/startup_compute_dispatch.cpp:302 (no arguments), :314 (UAV, no constants), :331 (unplaced UAV), :382 (misaligned UAV), :389 (rejected UAV).
    • 3 dropped-UAV lines: slot 45 at :328 (unplaced), :379 (+384 + 1), :387 (~0).
  • The +384 + 1 address is inside the placed buffer and is dropped for alignment (d3d12_xs_device.cpp:4471), yet the line it logs (:4480) says "is not an upload or placed buffer range". The new check counts that text.
  • One mutation survives by reading: is_bound(i, 0, p.constants_count, cap) at d3d12_xs_device.cpp:4584 reduced to count 1. Every refused Dispatch has either no constant word set or all 32, and both forwarded ones follow a 32-word write. A Dispatch after a partial write (words 0-1 only, for example) that must be refused would pin it.
  • tests/startup_compute_dispatch.cpp:364 says the offset 31, count 2 write is "rejected". Store::set cuts it to one word at offset 31 (root_constant_store.h:48-49) and slot 39 forwards that word (d3d12_draw.inl:3466-3468). The full write at :368 overwrites that word, so the readback is unaffected.

Minor:

  • docs/experiments.md on main has two ## Startup list Dispatch sections (lines 17188 and 17224). This PR updates the first; the second still says only root SRV parameters are forwarded.

CI passes at 088f7f23. The pr preset runs startup_compute_dispatch_root_warp only.

Points 1-3 are still open at 088f7f23.

**@⁠Leyukaka** on GitHub · 2026-11-29 07:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3343#pullrequestreview-6101835772) · **reviewed** Review of head `088f7f23`, by reading only (not built or run). As the description says, this replaces #2491: the branch is #2491's two commits (`d0ccda2f`, `aa7a96b5`) plus `088f7f23`. `git diff aa7a96b5 088f7f23 -- src` is empty. The new commit changes only `tests/startup_compute_dispatch.cpp` (log-count checks) and `CMakeLists.txt` (`X2W_TRAP_LOG` for the two `startup_compute_dispatch_root_*` tests). `git merge-tree --write-tree origin/main 088f7f23` exits 0 on `main` `212d4b5f`. The three points of the `aa7a96b5` review on #2491 are unchanged at this head, same line numbers; details are there: 1. Slot 45 takes a `list_upload_gpu` hit as the root UAV address (`d3d12_xs_device.cpp:4455-4456`); those pages are UPLOAD heap, `GENERIC_READ` (`list_upload_pages.h:19,27`). No fixture case reaches this branch. 2. Slot 45's placed branch (`:4458-4469`) uses the owner's desktop buffer when `placed.alias` is null and does not check `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS`; the translated output path refuses both (`d3d12_compute_dispatch.inl:641`, `:645`). 3. `d3d12_compute_dispatch.inl:774-778` (root SRVs only) and the rect-list conversion (`d3d12_xs_device.cpp:3899`, guarded by `has_compute_root_views` at `:3887`, which ignores constants) set the desktop compute root again without `restore_compute_root`; a later Dispatch still passes `all_bound` (`:4574-4590`). New at this head: - The expected counts match the fixture. - 5 "not bound" refusals: Dispatch at `tests/startup_compute_dispatch.cpp:302` (no arguments), `:314` (UAV, no constants), `:331` (unplaced UAV), `:382` (misaligned UAV), `:389` (rejected UAV). - 3 dropped-UAV lines: slot 45 at `:328` (unplaced), `:379` (`+384 + 1`), `:387` (`~0`). - The `+384 + 1` address is inside the placed buffer and is dropped for alignment (`d3d12_xs_device.cpp:4471`), yet the line it logs (`:4480`) says "is not an upload or placed buffer range". The new check counts that text. - One mutation survives by reading: `is_bound(i, 0, p.constants_count, cap)` at `d3d12_xs_device.cpp:4584` reduced to count 1. Every refused Dispatch has either no constant word set or all 32, and both forwarded ones follow a 32-word write. A Dispatch after a partial write (words 0-1 only, for example) that must be refused would pin it. - `tests/startup_compute_dispatch.cpp:364` says the offset 31, count 2 write is "rejected". `Store::set` cuts it to one word at offset 31 (`root_constant_store.h:48-49`) and slot 39 forwards that word (`d3d12_draw.inl:3466-3468`). The full write at `:368` overwrites that word, so the readback is unaffected. Minor: - `docs/experiments.md` on `main` has two `## Startup list Dispatch` sections (lines 17188 and 17224). This PR updates the first; the second still says only root SRV parameters are forwarded. CI passes at `088f7f23`. The `pr` preset runs `startup_compute_dispatch_root_warp` only. Points 1-3 are still open at `088f7f23`.
Author
Owner

@⁠JohnConnorNPC on GitHub · 2026-11-29 12:48 UTC · original

I reviewed 088f7f23 against main 77d1ba4d by reading it. I did no Windows build or GPU run.

MUST

  1. Please don't merge this head. Both authors suggested closing it as superseded by #2491, and I agree.
    • It conflicts with main. git merge-tree --write-tree --name-only origin/main 088f7f23 gives CONFLICT (content): Merge conflict in CMakePresets.json.
    • Resolving the conflict would also bring back code that #2491 has since fixed. The slot 45 handler here still has if (const auto gpu = list_upload_gpu(self, address, 1)) and the placed.owner->own().real fallback, which are Leyukaka's points 1 and 2.
    • record_translated_dispatch still replays only desktop_compute_upload_srvs after a translated dispatch (point 3).
    • #2491 at fc0c862b has those fixes and is rebased on current main.

SHOULD
2. If you still want the log-count checks from 088f7f23, they would need porting onto #2491, because a rebase here won't carry them over correctly. They count lines that contain is not an upload or placed buffer range, which #2491 no longer logs. It now logs is not an aliased placed buffer range with unordered access. #2491's three new slot 45 controls (upload page, no UAV flag, non-aliased) also add refused Dispatches and dropped binds, so the expected 5 and 3 no longer hold.

AI-assisted.

**@⁠JohnConnorNPC** on GitHub · 2026-11-29 12:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3343#issuecomment-7256081857) I reviewed `088f7f23` against `main` `77d1ba4d` by reading it. I did no Windows build or GPU run. **MUST** 1. Please don't merge this head. Both authors suggested closing it as superseded by #2491, and I agree. - It conflicts with `main`. `git merge-tree --write-tree --name-only origin/main 088f7f23` gives `CONFLICT (content): Merge conflict in CMakePresets.json`. - Resolving the conflict would also bring back code that #2491 has since fixed. The slot 45 handler here still has `if (const auto gpu = list_upload_gpu(self, address, 1))` and the `placed.owner->own().real` fallback, which are Leyukaka's points 1 and 2. - `record_translated_dispatch` still replays only `desktop_compute_upload_srvs` after a translated dispatch (point 3). - #2491 at `fc0c862b` has those fixes and is rebased on current `main`. **SHOULD** 2. If you still want the log-count checks from `088f7f23`, they would need porting onto #2491, because a rebase here won't carry them over correctly. They count lines that contain `is not an upload or placed buffer range`, which #2491 no longer logs. It now logs `is not an aliased placed buffer range with unordered access`. #2491's three new slot 45 controls (upload page, no UAV flag, non-aliased) also add refused Dispatches and dropped binds, so the expected 5 and 3 no longer hold. AI-assisted.
This pull request has changes conflicting with the target branch.
  • CMakePresets.json
  • src/startup_stubs/d3d12_xs_device.cpp
  • src/startup_stubs/list_dispatch.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3345/head:github-bot/gh-3343'
git switch 'github-bot/gh-3343'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3343'
git switch 'github-bot/gh-3343'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3343'
git switch 'github-bot/gh-3343'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3343'
git switch 'main'
git merge --squash 'github-bot/gh-3343'
git switch 'main'
git merge --ff-only 'github-bot/gh-3343'
git switch 'main'
git merge 'github-bot/gh-3343'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.