Restore native compute root arguments after indexed indirect validation #2275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2283"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
20edfdawith the D3D12 debug layer enabled, RTX 4060 Laptop GPU driver 32.0.16.1656 and WARP 10.0.26100.9818: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.
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/-13git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: self-test passed, 18 Markdown files / 435 links OKpython3 tests/bidi_controls_check.py: 1576 files, no bidi controlsgh pr checks 2283: Python checks on Linux pass; Windows jobs pending at review timeTitle and body are neutral, MIT/clean-room wording is fine, PR is Draft and mergeable.
Findings
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.d3d12_xs_device.cpp:2332-2336):desktop_compute_upload_srvsis 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.d3d12_xs_device.cpp:2148):std::array<..., 64>is a magic number; theparameter >= size()check silently drops higher parameters. A named constant tied to the root-parameter limit would help.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.
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 on20edfda7.Scope read:
git diff origin/main...HEADford3d12_draw.inl(restore invalidate_indexed_arguments, relaxed guard indraw_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(newrestore_computecases),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/-13git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: self-test passed, 18 Markdown files / 436 links OKpython3 tests/bidi_controls_check.py: 1579 files, no bidi controlsgh pr checks 2283: Linux Python checks and gfx1013 fixtures pass; "Build and test on Windows" still pending when I lookedTitle and body are neutral, MIT/clean-room wording is fine, mergeable.
Previous P2s
docs/experiments.mdnow says the validation dispatch restores "the last native compute root and its forwarded upload SRVs", so the limit is documented. The code comment atd3d12_draw.inl:1602-1603still 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.desktop_compute_upload_srvscleared 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.64, slot43in 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 thedesktop_compute_rootassignment, should fail the two newrestore_computereadbacks (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.