startup: record root CBV addresses for translated draws (slot 42) #1647

Merged
tedin7 merged 4 commits from upstream-pr/1654 into main 2026-11-24 16:48:12 +00:00
tedin7 commented 2026-11-24 16:17:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:17:48Z.


Change

Command-list slot 42 (SetGraphicsRootConstantBufferView) now stores the title address for a root parameter that the root signature declares as a CBV, in the same root_address table that a translated shader already reads for a root pointer (srv N buf root P in the manifest, d3d12_draw.inl). Until now only the SRV call (slot 44) filled that table, so a translated stage that reads its constants through a root CBV saw address 0 and a null buffer, and the draw was still counted as translated.

Rules of the new handler list_root_cbv:

  • ignored unless the list is recording and a graphics root signature is bound;
  • ignored when the parameter is not below the root parameter count and below 16;
  • a parameter that is not a CBV is ignored with one log line (root CBV N ignored ...) for the whole run;
  • a null or unreadable address clears pass.root_address[parameter] = 0 so a previous binding is not left stale;
  • otherwise pass.root_address[parameter] = address.

Nothing is forwarded to the desktop list and srv_bound is not touched (bit 0 means a vertex-fetch SRV is bound).

The slot number is derived, not observed: desktop SetGraphicsRootConstantBufferView is 38 and the console order sits four above it from SetDescriptorHeaps on (slots 32, 34, 36, 40, 44, 47, 48, 50 and 52 already follow that shift). tools/startup/capture.py names slot 42 the same way. No title log in this repository exercises it yet. A trace of one frame (X2W_D3D12_TRACE_FRAME) showing slot 42 with a root-parameter index and a title address would confirm it.

Overlap: no hunk touches the regions changed by #1469, #1567 or #1641. #1441 adds list slots in the same registration block, three lines away from the one added here.

Refs #870.

Verification

Linux checks at commit 109e7dc8:

  • git diff --check: clean.
  • python3 tests/docs_links_check.py: self-test passed, 16 Markdown files and 348 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1278 tracked files, no bidirectional controls.
  • python3 -m py_compile tests/startup_root_cbv_check.py: ok.

Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at commit 109e7dc8:

  • Debug (--preset dev):
    • cmake --build --preset dev --target d3d12_xs_shim startup_stream_consumer startup_stub_consumer d3d12x_graphics_list_check -- -j 6: passed (25.38s).
    • ctest --preset dev -R '^(startup_root_cbv_warp|stream_root_srv_warp|startup_stream_draw_warp|startup_stubs|d3d12x_graphics_list_warp|startup_cb_blend_warp|startup_address_buffer_srv_warp)$' --parallel 4 --no-tests=error --output-on-failure: 7/7 passed (3.32s, including startup_root_cbv_warp 3.00s).
  • Release /O2 (--preset release):
    • cmake --build --preset release --target d3d12_xs_shim startup_stream_consumer startup_stub_consumer d3d12x_graphics_list_check -- -j 6: passed (38.36s).
    • ctest --preset release -R '^(startup_root_cbv_warp|stream_root_srv_warp|startup_stream_draw_warp|startup_stubs|d3d12x_graphics_list_warp|startup_cb_blend_warp|startup_address_buffer_srv_warp)$' --parallel 4 --no-tests=error --output-on-failure: 7/7 passed (3.49s, including startup_root_cbv_warp 3.19s).
  • Mutation check: temporarily disabled list_typed[42] in src/startup_stubs/d3d12_xs_device.cpp on Windows Server 2025 (--preset dev) and ran ctest --preset dev -R '^startup_root_cbv_warp$' --output-on-failure: failed as expected (bound read 00000000 instead of ffff00ff), then restored cleanly.

Not run: startup_root_cbv_hardware (the Windows test node only has WARP; skips with 77 without a hardware adapter).

Evidence and follow-up

New test tests/startup_root_cbv_check.py reuses draw_texture from startup_address_srv_check.py: the translated pixel stage is replaced by a hand-written stage that returns asfloat(constants.Load4(0)) from ByteAddressBuffer t0, bound with the manifest line srv 0 buf root 0. The consumer (startup_root_cbv.cpp, selected by X2W_TEST_ROOT_CBV) declares root parameter 0 as a CBV and, before one draw, does one of:

mode call expected left half of the 8x4 target
bound slot 42 with the address of a yellow colour 255,255,0,255
unbound none 0,0,0,0
null slot 42 with the yellow address, then slot 42 with address 0 0,0,0,0
wrong_type parameter 0 declared as SRV, slot 42 called twice 0,0,0,0 and exactly one root CBV log line

The right half keeps the clear colour in all four modes.

Assumptions: the console uses the desktop argument order for this call (parameter in the first argument, GPU address in the second), as slots 40 and 44 do. The same gap exists for root UAV (slot 46, derived the same way) and the single-constant call (slot 38); both are left out to keep this to one behaviour.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6586308642 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:17:48Z. --- ## Change Command-list slot 42 (`SetGraphicsRootConstantBufferView`) now stores the title address for a root parameter that the root signature declares as a CBV, in the same `root_address` table that a translated shader already reads for a root pointer (`srv N buf root P` in the manifest, `d3d12_draw.inl`). Until now only the SRV call (slot 44) filled that table, so a translated stage that reads its constants through a root CBV saw address 0 and a null buffer, and the draw was still counted as translated. Rules of the new handler `list_root_cbv`: - ignored unless the list is recording and a graphics root signature is bound; - ignored when the parameter is not below the root parameter count and below 16; - a parameter that is not a CBV is ignored with one log line (`root CBV N ignored ...`) for the whole run; - a null or unreadable address clears `pass.root_address[parameter] = 0` so a previous binding is not left stale; - otherwise `pass.root_address[parameter] = address`. Nothing is forwarded to the desktop list and `srv_bound` is not touched (bit 0 means a vertex-fetch SRV is bound). The slot number is derived, not observed: desktop `SetGraphicsRootConstantBufferView` is 38 and the console order sits four above it from `SetDescriptorHeaps` on (slots 32, 34, 36, 40, 44, 47, 48, 50 and 52 already follow that shift). `tools/startup/capture.py` names slot 42 the same way. No title log in this repository exercises it yet. A trace of one frame (`X2W_D3D12_TRACE_FRAME`) showing slot 42 with a root-parameter index and a title address would confirm it. Overlap: no hunk touches the regions changed by #1469, #1567 or #1641. #1441 adds list slots in the same registration block, three lines away from the one added here. Refs #870. ## Verification Linux checks at commit `109e7dc8`: - `git diff --check`: clean. - `python3 tests/docs_links_check.py`: self-test passed, 16 Markdown files and 348 links. - `python3 tests/bidi_controls_check.py`: self-test passed, 1278 tracked files, no bidirectional controls. - `python3 -m py_compile tests/startup_root_cbv_check.py`: ok. Windows Server 2025 (Build 26100, MSVC 14.44.35207, D3D12 WARP) at commit `109e7dc8`: - **Debug (`--preset dev`)**: - `cmake --build --preset dev --target d3d12_xs_shim startup_stream_consumer startup_stub_consumer d3d12x_graphics_list_check -- -j 6`: passed (`25.38s`). - `ctest --preset dev -R '^(startup_root_cbv_warp|stream_root_srv_warp|startup_stream_draw_warp|startup_stubs|d3d12x_graphics_list_warp|startup_cb_blend_warp|startup_address_buffer_srv_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **7/7 passed** (`3.32s`, including `startup_root_cbv_warp` `3.00s`). - **Release `/O2` (`--preset release`)**: - `cmake --build --preset release --target d3d12_xs_shim startup_stream_consumer startup_stub_consumer d3d12x_graphics_list_check -- -j 6`: passed (`38.36s`). - `ctest --preset release -R '^(startup_root_cbv_warp|stream_root_srv_warp|startup_stream_draw_warp|startup_stubs|d3d12x_graphics_list_warp|startup_cb_blend_warp|startup_address_buffer_srv_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **7/7 passed** (`3.49s`, including `startup_root_cbv_warp` `3.19s`). - **Mutation check**: temporarily disabled `list_typed[42]` in `src/startup_stubs/d3d12_xs_device.cpp` on Windows Server 2025 (`--preset dev`) and ran `ctest --preset dev -R '^startup_root_cbv_warp$' --output-on-failure`: failed as expected (`bound` read `00000000` instead of `ffff00ff`), then restored cleanly. Not run: `startup_root_cbv_hardware` (the Windows test node only has WARP; skips with 77 without a hardware adapter). ## Evidence and follow-up New test `tests/startup_root_cbv_check.py` reuses `draw_texture` from `startup_address_srv_check.py`: the translated pixel stage is replaced by a hand-written stage that returns `asfloat(constants.Load4(0))` from `ByteAddressBuffer` `t0`, bound with the manifest line `srv 0 buf root 0`. The consumer (`startup_root_cbv.cpp`, selected by `X2W_TEST_ROOT_CBV`) declares root parameter 0 as a CBV and, before one draw, does one of: | mode | call | expected left half of the 8x4 target | |---|---|---| | `bound` | slot 42 with the address of a yellow colour | 255,255,0,255 | | `unbound` | none | 0,0,0,0 | | `null` | slot 42 with the yellow address, then slot 42 with address 0 | 0,0,0,0 | | `wrong_type` | parameter 0 declared as SRV, slot 42 called twice | 0,0,0,0 and exactly one `root CBV` log line | The right half keeps the clear colour in all four modes. Assumptions: the console uses the desktop argument order for this call (parameter in the first argument, GPU address in the second), as slots 40 and 44 do. The same gap exists for root UAV (slot 46, derived the same way) and the single-constant call (slot 38); both are left out to keep this to one behaviour. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-24 17:01:51 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 17:01:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:33:12Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 109e7dc80c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043329634 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654#pullrequestreview-6043329634). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T16:33:12Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `109e7dc80c` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 17:01:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:36:50Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043386476 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654#pullrequestreview-6043386476). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:36:50Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 17:02:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:28:36Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T16:33:15.560480Z 109e7dc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137725167 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654#issuecomment-7137725167). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T16:28:36Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"109e7dc80cfcdb82b5461822fdd36a19d7d1d5be","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T16:33:15.560480Z">2026-11-24T16:33:15.560480Z</relative-time> | `109e7dc` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
R0Y00 commented 2026-11-24 17:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:44:21Z.


In the source-built WARP comparison, switching to a different root signature and then back reused the old CBV colour before this fix. 61a55f63 invalidates stored root addresses on a signature change and preserves them when binding the same signature again. The root CBV, address SRV and 1D SRV Release tests passed 6/6 on RTX and WARP with no skips. The slot number is still an inference from the command-list ordering. https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-a-root-signature

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7138131268 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654#issuecomment-7138131268). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T16:44:21Z. --- In the source-built WARP comparison, switching to a different root signature and then back reused the old CBV colour before this fix. 61a55f63 invalidates stored root addresses on a signature change and preserves them when binding the same signature again. The root CBV, address SRV and 1D SRV Release tests passed 6/6 on RTX and WARP with no skips. The slot number is still an inference from the command-list ordering. https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-a-root-signature
chatgpt-codex-connector[bot commented 2026-11-24 17:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:33:13Z.

Code review location: docs/startup-runtime.md; line 150

@@ -144,6 +144,16 @@ by reading a render log. The device prints the counts by cause value, so
 checks without a device that each cause lands in the slot printed under its label, and that the
 header's names follow the same order. The control swaps the buffer and token slots and must fail.
 
+## Root constant buffer views
+
+Command-list slot 42 (desktop `SetGraphicsRootConstantBufferView` plus four) records the title address for a root
+parameter that the root signature declares as a CBV. A translated shader that reads through its root pointer sees that

P1 Badge Add root-CBV support to the required experiment documentation

This adds a public root-CBV binding capability, but documents it only in docs/startup-runtime.md, leaving both README.md and docs/experiments.md unchanged. AGENTS.md requires a README or experiment-note update when a public capability changes, and CONTRIBUTING.md places reproduction details in docs/experiments.md. Update the relevant capability entry and add the fixture's build/test commands and synthetic-only scope so contributors can discover and reproduce the new support without consulting the commit message.

AGENTS.md reference: AGENTS.md:L193-L194

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4683226940 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654#discussion_r4683226940). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T16:33:13Z. **Code review location:** `docs/startup-runtime.md`; line 150 ~~~~diff @@ -144,6 +144,16 @@ by reading a render log. The device prints the counts by cause value, so checks without a device that each cause lands in the slot printed under its label, and that the header's names follow the same order. The control swaps the buffer and token slots and must fail. +## Root constant buffer views + +Command-list slot 42 (desktop `SetGraphicsRootConstantBufferView` plus four) records the title address for a root +parameter that the root signature declares as a CBV. A translated shader that reads through its root pointer sees that ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Add root-CBV support to the required experiment documentation** This adds a public root-CBV binding capability, but documents it only in `docs/startup-runtime.md`, leaving both `README.md` and `docs/experiments.md` unchanged. `AGENTS.md` requires a README or experiment-note update when a public capability changes, and `CONTRIBUTING.md` places reproduction details in `docs/experiments.md`. Update the relevant capability entry and add the fixture's build/test commands and synthetic-only scope so contributors can discover and reproduce the new support without consulting the commit message. AGENTS.md reference: [AGENTS.md:L193-L194](https://github.com/R0Y00/Xbox2Windows/blob/109e7dc80cfcdb82b5461822fdd36a19d7d1d5be/AGENTS.md#L193-L194) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 17:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:36:50Z.

Code review location: docs/startup-runtime.md; line 150

@@ -144,6 +144,16 @@ by reading a render log. The device prints the counts by cause value, so
 checks without a device that each cause lands in the slot printed under its label, and that the
 header's names follow the same order. The control swaps the buffer and token slots and must fail.
 
+## Root constant buffer views
+
+Command-list slot 42 (desktop `SetGraphicsRootConstantBufferView` plus four) records the title address for a root
+parameter that the root signature declares as a CBV. A translated shader that reads through its root pointer sees that

Fixed in 49d15fc240: added a "Startup root constant buffer views" section to docs/experiments.md with the synthetic-only scope, the fixture/check files, and the build/ctest commands. Ran locally: git diff --check, tests/docs_links_check.py, tests/bidi_controls_check.py, x2w_pipe.py preflight. AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4683273279 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1654#discussion_r4683273279). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:36:50Z. **Code review location:** `docs/startup-runtime.md`; line 150 ~~~~diff @@ -144,6 +144,16 @@ by reading a render log. The device prints the counts by cause value, so checks without a device that each cause lands in the slot printed under its label, and that the header's names follow the same order. The control swaps the buffer and token slots and must fail. +## Root constant buffer views + +Command-list slot 42 (desktop `SetGraphicsRootConstantBufferView` plus four) records the title address for a root +parameter that the root signature declares as a CBV. A translated shader that reads through its root pointer sees that ~~~~ --- Fixed in 49d15fc24096aeb6f36088d518035ee2262728a8: added a "Startup root constant buffer views" section to `docs/experiments.md` with the synthetic-only scope, the fixture/check files, and the build/ctest commands. Ran locally: `git diff --check`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `x2w_pipe.py preflight`. AI-assisted; commands listed were executed locally.
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!1647
No description provided.