Skip to content

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

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-b2-rootcbv
Nov 24, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
tedin7:x2w-frontier-b2-rootcbv

Conversation

@tedin7

@tedin7 tedin7 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Slot 42 stores the title address of a CBV root parameter in root_address, the table a translated shader reads through its root pointer. Adds startup_root_cbv_{warp,hardware} with a bound, an unbound, a null and a wrong-type case.
@tedin7
tedin7 marked this pull request as ready for review November 24, 2026 16:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread docs/startup-runtime.md Resolved
@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

In the source-built WARP comparison, switching to a different root signature and then back reused the old CBV colour before this fix. 61a55f6 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

@R0Y00
R0Y00 merged commit d53d238 into R0Y00:main Nov 24, 2026
5 checks passed
denn0x added a commit to denn0x/Xbox2Windows that referenced this pull request Nov 25, 2026
Conflicts resolved keeping both sides:
- d3d12_draw.inl: mip comment line, upstream's wording (R0Y00#1630).
- d3d12_xs_device.cpp: Pass keeps local compute root state and upstream viewport/scissor flags (R0Y00#1657);
  local ExecuteIndirect trace (slot 61) and upstream list_root_cbv (slot 42, R0Y00#1654) both kept.
- xcrdapi.cpp: local failure tally, RDS5 shift/slice and stream cache kept next to upstream's BCPack
  census (R0Y00#1622); queue worker is upstream's CreateThread worker (R0Y00#1410), the local
  tally_failure("exception") moved into fail_entry.
- run.ps1: upstream venv python and exit code (R0Y00#1535/R0Y00#1603) with local --fast-exit/--log-repeats.
- gfx2hlsl.py image(): local 1D lowering (load, sample, sample_l, a16) kept over upstream's
  sample-only 1D guard; startup_image_sample_l_check keeps the local 1D SampleLevel expectation,
  startup_image_3d_check keeps the local 1D assertions plus upstream's cube-dimension refusal.

Tests adjusted for local behaviour: startup_run_ps1_check expects the two local debugger
arguments, startup_translator_check's StubPipeline has ps_entry_reads, and the coverage check's
hand-built Pipeline sets packed_position_vgpr (new in R0Y00#1634).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants