Restore native compute root arguments after indexed indirect validation #2275

Merged
R0Y00 merged 2 commits from upstream-pr/2283 into main 2026-11-25 10:25:12 +00:00
R0Y00 commented 2026-11-25 10:03:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T10:03:23Z.


Refs #874

The indexed-indirect GPU validator changes the native compute root. Restore the last root and upload SRVs that the shim forwarded to the native command list. A guest root call handled without setting a native root preserves the existing native binding. Active compute PSOs still hit the guard.

The source-built fixture verifies the draw's color and argument guards. A subsequent native compute dispatch then reads the previously bound upload SRV without repeating the binding. The two cases use distinct input words and cover a forwarded root and a later unforwarded root call.

Windows Release on 20edfda with the D3D12 debug layer enabled, RTX 4060 Laptop GPU driver 32.0.16.1656 and WARP 10.0.26100.9818:

cmake --build out/build/local-compute --target startup_indirect_draw_indexed
ctest --test-dir out/build/local-compute --no-tests=error -R '^startup_indirect_translated_indexed(_upload|_rect)?_(warp|hardware)$' --output-on-failure

6/6 passed, zero skips. The older DLL on both backends hit the previous live-binding refusal and left the first four expected colored pixels clear.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6601945149 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2283). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T10:03:23Z. --- Refs #874 The indexed-indirect GPU validator changes the native compute root. Restore the last root and upload SRVs that the shim forwarded to the native command list. A guest root call handled without setting a native root preserves the existing native binding. Active compute PSOs still hit the guard. The source-built fixture verifies the draw's color and argument guards. A subsequent native compute dispatch then reads the previously bound upload SRV without repeating the binding. The two cases use distinct input words and cover a forwarded root and a later unforwarded root call. Windows Release on 20edfda with the D3D12 debug layer enabled, RTX 4060 Laptop GPU driver 32.0.16.1656 and WARP 10.0.26100.9818: ```powershell cmake --build out/build/local-compute --target startup_indirect_draw_indexed ctest --test-dir out/build/local-compute --no-tests=error -R '^startup_indirect_translated_indexed(_upload|_rect)?_(warp|hardware)$' --output-on-failure ``` 6/6 passed, zero skips. The older DLL on both backends hit the previous live-binding refusal and left the first four expected colored pixels clear.
tedin7 commented 2026-11-25 10:05:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:05:50Z.

Review: COMMENTED


Review of head 20edfda7e77d75ce4799edd30be5d5a464c1e08e (comment only).

Scope read: d3d12_draw.inl (validate_indexed_arguments restore, draw_translated guard), d3d12_xs_device.cpp (Pass fields, list_compute_root, list_compute_upload_srv), tests/startup_indirect_draw_indexed.cpp, docs/experiments.md.

Commands executed locally (Linux):

  • git diff --stat origin/main...HEAD: 4 files, +95/-13
  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files / 435 links OK
  • python3 tests/bidi_controls_check.py: 1576 files, no bidi controls
  • gh pr checks 2283: Python checks on Linux pass; Windows jobs pending at review time

Title and body are neutral, MIT/clean-room wording is fine, PR is Draft and mergeable.

Findings

  • P1: none.
  • P2 (src/startup_stubs/d3d12_draw.inl:1602-1611): the restore re-applies only the root signature and the upload SRVs. Other root parameters the guest had set on that native compute root (constants, UAV/CBV addresses, descriptor tables) are lost after the clamp dispatch, and a later dispatch without re-binding would see stale or unset arguments. The test uses an SRV plus a UAV set after the draw, so it cannot catch this. Either track and restore the other parameter kinds, or state in the docs/comment that only SRVs are restored. The same loss was present before, but the guard that refused it is now removed, so the gap is newly reachable.
  • P2 (d3d12_xs_device.cpp:2332-2336): desktop_compute_upload_srvs is cleared only when the root pointer changes. A guest that re-sets the same root and then relies on an SRV being unbound gets the old SRV back on restore. Probably harmless, but worth a comment that this deliberately mirrors the native list.
  • nit (d3d12_xs_device.cpp:2148): std::array<..., 64> is a magic number; the parameter >= size() check silently drops higher parameters. A named constant tied to the root-parameter limit would help.
  • nit (d3d12_draw.inl:1601): the comment mentions "slot 43"; a named constant or the slot-name header reference would age better.

Mutation: the changed code is Windows-only C++ (D3D12), so I could not build and mutate it on Linux. Not run here: dropping the restore loop, or the fill(0), should make the new retained-SRV readback checks fail on Windows. A real mutation run still needs the Windows pass.

Windows proof: I did not queue Win2025 for this review. The author reports 6/6 on Release with the debug layer; the CI Windows jobs were still pending when I looked. The GPU-readback comparison in the fixture is the right kind of proof.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6055514006 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2283#pullrequestreview-6055514006). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:05:50Z. **Review:** COMMENTED --- Review of head `20edfda7e77d75ce4799edd30be5d5a464c1e08e` (comment only). **Scope read:** `d3d12_draw.inl` (validate_indexed_arguments restore, draw_translated guard), `d3d12_xs_device.cpp` (Pass fields, list_compute_root, list_compute_upload_srv), `tests/startup_indirect_draw_indexed.cpp`, `docs/experiments.md`. **Commands executed locally (Linux):** - `git diff --stat origin/main...HEAD`: 4 files, +95/-13 - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files / 435 links OK - `python3 tests/bidi_controls_check.py`: 1576 files, no bidi controls - `gh pr checks 2283`: Python checks on Linux pass; Windows jobs pending at review time Title and body are neutral, MIT/clean-room wording is fine, PR is Draft and mergeable. **Findings** - P1: none. - P2 (`src/startup_stubs/d3d12_draw.inl:1602-1611`): the restore re-applies only the root signature and the upload SRVs. Other root parameters the guest had set on that native compute root (constants, UAV/CBV addresses, descriptor tables) are lost after the clamp dispatch, and a later dispatch without re-binding would see stale or unset arguments. The test uses an SRV plus a UAV set after the draw, so it cannot catch this. Either track and restore the other parameter kinds, or state in the docs/comment that only SRVs are restored. The same loss was present before, but the guard that refused it is now removed, so the gap is newly reachable. - P2 (`d3d12_xs_device.cpp:2332-2336`): `desktop_compute_upload_srvs` is cleared only when the root pointer changes. A guest that re-sets the same root and then relies on an SRV being unbound gets the old SRV back on restore. Probably harmless, but worth a comment that this deliberately mirrors the native list. - nit (`d3d12_xs_device.cpp:2148`): `std::array<..., 64>` is a magic number; the `parameter >= size()` check silently drops higher parameters. A named constant tied to the root-parameter limit would help. - nit (`d3d12_draw.inl:1601`): the comment mentions "slot 43"; a named constant or the slot-name header reference would age better. **Mutation:** the changed code is Windows-only C++ (D3D12), so I could not build and mutate it on Linux. Not run here: dropping the restore loop, or the `fill(0)`, should make the new retained-SRV readback checks fail on Windows. A real mutation run still needs the Windows pass. **Windows proof:** I did not queue Win2025 for this review. The author reports 6/6 on Release with the debug layer; the CI Windows jobs were still pending when I looked. The GPU-readback comparison in the fixture is the right kind of proof. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 10:24:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:24:53Z.

Review: COMMENTED


Re-review of head 1bba6e6f15816f0207019410e3f0f69058448d16 (comment only). Previous review was on 20edfda7.

Scope read: git diff origin/main...HEAD for d3d12_draw.inl (restore in validate_indexed_arguments, relaxed guard in draw_translated), d3d12_xs_device.cpp (desktop_compute_root, desktop_compute_upload_srvs, list_compute_root, list_compute_upload_srv), tests/startup_indirect_draw_indexed.cpp (new restore_compute cases), docs/experiments.md. The new head is the previous head plus a merge of main; the PR's own diff is still 4 files.

Commands executed locally (Linux):

  • git diff --stat origin/main...HEAD: 4 files, +96/-13
  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files / 436 links OK
  • python3 tests/bidi_controls_check.py: 1579 files, no bidi controls
  • gh pr checks 2283: Linux Python checks and gfx1013 fixtures pass; "Build and test on Windows" still pending when I looked

Title and body are neutral, MIT/clean-room wording is fine, mergeable.

Previous P2s

  • P2 #1 (only SRVs restored): partly resolved. docs/experiments.md now says the validation dispatch restores "the last native compute root and its forwarded upload SRVs", so the limit is documented. The code comment at d3d12_draw.inl:1602-1603 still says the clamp "invalidates its arguments" without saying that only upload SRVs come back. Other kinds (root constants, UAV/CBV addresses, tables) are still not restored. Still P2, but a one-line comment would close it.
  • P2 #2 (desktop_compute_upload_srvs cleared only when the root changes, d3d12_xs_device.cpp:2333-2334): partly resolved. The new test case (guest root call that never reaches the native list) covers the "no native root" path. Re-setting the same root still keeps old SRV addresses and there is no comment saying this mirrors the native list. Low risk, comment only.
  • nit (magic 64, slot 43 in the comment): unchanged.

New findings: P1: none. No new P2.

Mutation: the changed code is Windows-only C++ (D3D12), so I could not build or mutate it on Linux. Expected kills on Windows: removing the restore loop in validate_indexed_arguments, or removing the desktop_compute_root assignment, should fail the two new restore_compute readbacks (0x31ac1579 and 0xcafe0489). A real mutation run still needs the Windows pass.

Windows proof: I did not queue Win2025 for this review (Stage-2 owns it). The GPU readback of the retained SRV after the indexed draw is the right kind of proof; the CI Windows job was still pending.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6055797773 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2283#pullrequestreview-6055797773). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:24:53Z. **Review:** COMMENTED --- Re-review of head `1bba6e6f15816f0207019410e3f0f69058448d16` (comment only). Previous review was on `20edfda7`. **Scope read:** `git diff origin/main...HEAD` for `d3d12_draw.inl` (restore in `validate_indexed_arguments`, relaxed guard in `draw_translated`), `d3d12_xs_device.cpp` (`desktop_compute_root`, `desktop_compute_upload_srvs`, `list_compute_root`, `list_compute_upload_srv`), `tests/startup_indirect_draw_indexed.cpp` (new `restore_compute` cases), `docs/experiments.md`. The new head is the previous head plus a merge of main; the PR's own diff is still 4 files. **Commands executed locally (Linux):** - `git diff --stat origin/main...HEAD`: 4 files, +96/-13 - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files / 436 links OK - `python3 tests/bidi_controls_check.py`: 1579 files, no bidi controls - `gh pr checks 2283`: Linux Python checks and gfx1013 fixtures pass; "Build and test on Windows" still pending when I looked Title and body are neutral, MIT/clean-room wording is fine, mergeable. **Previous P2s** - P2 #1 (only SRVs restored): **partly resolved.** `docs/experiments.md` now says the validation dispatch restores "the last native compute root and its forwarded upload SRVs", so the limit is documented. The code comment at `d3d12_draw.inl:1602-1603` still says the clamp "invalidates its arguments" without saying that only upload SRVs come back. Other kinds (root constants, UAV/CBV addresses, tables) are still not restored. Still P2, but a one-line comment would close it. - P2 #2 (`desktop_compute_upload_srvs` cleared only when the root changes, `d3d12_xs_device.cpp:2333-2334`): **partly resolved.** The new test case (guest root call that never reaches the native list) covers the "no native root" path. Re-setting the same root still keeps old SRV addresses and there is no comment saying this mirrors the native list. Low risk, comment only. - nit (magic `64`, slot `43` in the comment): unchanged. **New findings:** P1: none. No new P2. **Mutation:** the changed code is Windows-only C++ (D3D12), so I could not build or mutate it on Linux. Expected kills on Windows: removing the restore loop in `validate_indexed_arguments`, or removing the `desktop_compute_root` assignment, should fail the two new `restore_compute` readbacks (0x31ac1579 and 0xcafe0489). A real mutation run still needs the Windows pass. **Windows proof:** I did not queue Win2025 for this review (Stage-2 owns it). The GPU readback of the retained SRV after the indexed draw is the right kind of proof; the CI Windows job was still pending. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 11:02:18 +00:00
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!2275
No description provided.