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

Open
romn4rch wants to merge 3 commits from upstream-pr/3343 into main
romn4rch commented 2026-11-28 11:21:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by romn4rch on 2026-11-28T11:21:34Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5539590414 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3343). Originally posted by [romn4rch](https://github.com/romn4rch) on 2026-11-28T11:21:34Z. --- 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).
KelboLive commented 2026-11-28 21:23:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:23:24Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100142211 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3343#pullrequestreview-6100142211). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:23:24Z. **Review:** APPROVED --- 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 commented 2026-11-28 21:57:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:49Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100255295 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3343#pullrequestreview-6100255295). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:57:49Z. **Review:** APPROVED --- 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.
Leyukaka commented 2026-11-29 07:01:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T07:01:49Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6101835772 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3343#pullrequestreview-6101835772). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T07:01:49Z. **Review:** COMMENTED --- 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`.
JohnConnorNPC commented 2026-11-29 12:48:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T12:48:50Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7256081857 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3343#issuecomment-7256081857). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-29T12:48:50Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3343:upstream-pr/3343'
git switch 'upstream-pr/3343'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3343'
git switch 'upstream-pr/3343'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3343'
git switch 'upstream-pr/3343'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3343'
git switch 'main'
git merge --squash 'upstream-pr/3343'
git switch 'main'
git merge --ff-only 'upstream-pr/3343'
git switch 'main'
git merge 'upstream-pr/3343'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3343
No description provided.