startup: invalidate cached constants when the graphics root changes #1801
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1808"
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 SuperCraft3M on 2026-11-24T19:02:29Z.
Follow-up to #1744.
Changing the graphics root invalidates all cached root arguments. The startup shim already cleared the descriptor tables and root addresses but retained constants consumed by translated shaders. Clear those constants in the same invalidation path. Setting the same root still preserves translated arguments.
Extend the root reset fixture to feed a nonzero root constant into the blue channel. The unfixed implementation reads back blue 173 after switching roots, where the expected value is zero. The original root, redundant rebind and out-of-range writes retain the expected texture and constant.
Tested
49eea1e7on Windows 11 build 26300.9711:Two passed with no skips. WARP used Microsoft Basic Render Driver 10.0.26100.9711. Hardware used NVIDIA GeForce RTX 4070 with driver 32.0.16.2114. This fixture runs with the D3D12 debug layer disabled.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:18:13Z.
Review: COMMENTED
Review of
49eea1e7(head of this PR, baseecc6e6ce, which already contains #1744). Comment only, no approval.Verdict: no blocking findings on the code. Two process points below, and one verification gap on my side.
Interaction with #1744. Not redundant. #1744 clears
pass.root_addresswhen the root signature changes. This PR keeps that, folds the descriptor-table reset into the sameif (pass.root != params)block (the old code computed the same comparison twice), and adds the root constants, which #1744 left alone. The block now reads clearly: tables, addresses and constants are invalidated together, and setting the same signature again keeps all three. That matches the public D3D12 rule that root arguments are invalidated by a different root signature. I checked the other writers ofpass.constants: the only writer is slot 40 (list_root_constants, bounds-checked to 16 parameters of 8 words), and the only reader is the translated draw (d3d12_draw.inl, guarded byud.a < 16 && ud.b < 8).memset(pass.constants, 0, sizeof(pass.constants))covers exactly the 16x8 array.Process points
SetGraphicsRoot32BitConstant, slot 38): it clearspass.constantsinside the sameif (pass.root != params)block oflist_graphics_root(std::fill_n(&pass.constants[0][0], 16 * 8, 0u)). The two PRs will conflict textually and do the same thing there. Whichever lands second needs a rebase and should drop its copy of the clearing. Worth coordinating in the threads.list_graphics_root, a few lines below.The test.
startup_root_resetnow binds a table and a root constant (parameter 1, value 173, read as the blue channel viaudsrc 3 rootconst 1 0). The four cases are specific: bound and same-signature keep blue 173, the switched signature expects 0, out-of-range keeps both and logs four lines. The PR text says the switched case read blue 173 before the fix, which is the negative control I would want. The fixture change instartup_stream_setup.cpponly adds the second root parameter whenX2W_TEST_ROOT_RESETis set.Commands run locally (worktree at the exact head SHA above, Linux)
git diff --check origin/main...HEAD,tests/docs_links_check.py(17 files, 368 links),tests/bidi_controls_check.py: clean.python3 -m py_compile tests/startup_root_reset_check.py: compiles.Not run, honestly stated: I could not build or run the Windows test (
startup_root_reset_{warp,hardware}) or mutate the C++ here. The pipeline's Windows step was blocked by a command guard in my session, and this machine cannot compiled3d12_xs_device.cpp. So I did not run the two source mutations I would have wanted (removing thememset, and clearing constants unconditionally so that same-signature also drops them). Both should be caught by thebound/same_rootandswitch_rootcases as written, but that is my reading, not a run.AI-assisted; commands listed were executed locally.
upstream-sync referenced this pull request2026-11-24 22:00:58 +00:00