Skip to content

startup: opt-in skip of the graphics root SRV copy that no draw reads - #3028

Open
lukaslw-lab wants to merge 7 commits into
R0Y00:mainfrom
lukaslw-lab:runtime/root-srv-copy-at-real-draw
Open

lukaslw-lab wants to merge 7 commits into
R0Y00:mainfrom
lukaslw-lab:runtime/root-srv-copy-at-real-draw

Conversation

@lukaslw-lab

@lukaslw-lab lukaslw-lab commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Change

Fixes #3027 (slot 44 copies a 64 KiB root SRV window at every call, but no draw reads the copy). Refs #2948, #2949.

X2W_D3D12_ROOT_SRV_AT_DRAW=1 (opt-in): list slot 44 at a title address without an upload mapping skips the 64 KiB copy into the upload ring. The title address is kept for translated draws as before, and the parameter stays unbound on the desktop list (srv_bound clear). Unset, slot 44 copies at every call, as on main.

No draw reads that desktop binding in the current stand-in:

  • Translated draws set their own root signature and read the SRV from its title address (pass.root_address) at the draw.
  • list_draw forwards only with pass.pipeline_real. build_stream_pipeline accepts a graphics stream only with VS/PS or MS/PS, and every accepted one gets an indirect graphics root, so pipeline_real holds only for compute pipelines.
  • A slot 61 graphics draw requires indirect_graphics.root == pass.graphics_root: an empty root, or for a cached mesh pipeline the title's root, whose only root SRV comes from the validated lease.

Changes:

  • d3d12_xs_device.cpp list_root_srv: under the switch, it counts and returns before readable_window / upload_from_title. The comment there says a desktop graphics pipeline that reads a root SRV would need the copy at its draw.
  • Fixture export x2w_d3d12_root_srv_copies(skipped, copied); a report line before the render totals when the switch is set: x2w-render root SRV copies (X2W_D3D12_ROOT_SRV_AT_DRAW): skipped N, copied M.
  • Docs: switch row and the root SRV paragraph in docs/startup-runtime.md; docs/experiments/startup-root-srv-at-draw.md.
  • Why opt-in: it removes the desktop binding. With no reader that changes no draw today, but a future desktop graphics pipeline would depend on it.
  • History: the first revision (bedfcafc) kept the address pending and copied at a reading draw. Review showed that no such draw can exist, so the pending state and its two call sites were removed.
  • Overlap (trial merges against main e446b072): merges cleanly and adds no conflict with cpp-migration or runtime: compile a supported graphics pair on first use in the stand-in #2981. The one new text conflict is with draft Integrate mesh translation, D3D12 rendering and memory handling #2603, on the X2W_TEST_ROOT_CBV line of tests/startup_stream_setup.cpp.

Verification

Windows 10 22H2, i7-4790K, RTX 3080 Ti (NVIDIA 32.0.16.1047) and WARP; dev and release; commit 41b3c771 (d4d76b88 adds only the retest table).

ctest --preset <dev|release> --no-tests=error -j 1 -R '^(startup_root_.*|startup_stream_draw.*|startup_address_.*|startup_indirect_.*|startup_table_alias_.*|startup_frame_copy_.*|startup_copied_vertex_srv_.*|startup_placed_vertex_.*|startup_list_resubmit.*|upload_reservation)$'

125 tests per preset, run with the switch unset and set: 123/125 pass in each of the four runs. The two failures are startup_list_resubmit_nodebug_hardware and startup_list_resubmit_nodebug_untracked_hardware (SegFault). Both fail the same way on unmodified main on this host. 18 capability skips (WARP without mesh shaders, startup_root_heap without the debug layer), the same in every run.

  • startup_root_srv_draw_{warp,hardware}: slot 44 binds a title buffer holding red, the title writes green, then a translated draw reads the SRV through its root pointer. Both modes draw green. The fixture then reads the stand-in's counts: unset skipped 0, copied 1; set skipped 1, copied 0.
    • Negative control (local mutation): ignoring the switch fails X2W_D3D12_ROOT_SRV_AT_DRAW=1: copies (skipped, copied) (0, 1), expected (1, 0) on both adapters.

Startup run of the main executable (#870), release, warm shader cache, scripted input, 250 s, X2W_D3D12_RING_RELEASE_AT_SUBMIT=1 and X2W_D3D12_TABLE_ALIAS=1 in every run, two pairs (second in reverse order), on 41b3c771:

switch unset switch set
mean fps 150–240 s, pair 1 / pair 2 6.3 / 6.5 13.9 / 13.4
executes 24,065 / 33,220 69,730 / 54,789
slot 44 time (threads; µs per call) 1.17 / 1.11; 52 / 48 0.29 / 0.29; 5 / 6
copies skipped / copied n/a 6.9 / 4.9 million; 0
null bindings buffer; token per 1,000 translated draws 0; 23.4 / 29.8 0; 24.2 / 33.0
process commit peak 18.7 / 18.5 GiB 18.7 / 18.7 GiB

The first revision gave 6.3 / 7.1 → 14.8 / 14.0 fps in the same setup. Without other switches, it cut the buffer null bindings from 164,727 to 88 (#2948), but some ring reservations were still refused, so this complements #2949. No device removal and no ring refusals in any retest run.

AI-assisted: the change, tests and this description were written with Claude; I ran the startup comparison.

🤖 Generated with Claude Code

lukaslw-lab and others added 4 commits November 27, 2026 07:08
…s it

Slot 44 (SetGraphicsRootShaderResourceView) at a title address without an
upload mapping copies a 64 KiB window of title memory into the upload ring
and binds it on the desktop list. Only a real-pipeline draw (list_draw) and
an indirect graphics draw on the title's root signature read that binding;
translated draws set their own root signature and copy the SRV from
pass.root_address themselves.

X2W_D3D12_ROOT_SRV_AT_DRAW=1 keeps the address pending at slot 44
(pass.srv_pending) and makes the copy in bind_pending_root_srvs at those two
draws. Pending bits are cleared wherever srv_bound is cleared. The copy and
bind are shared (bind_root_srv_copy). A report line counts deferred copies
and those made at a draw. Unset, slot 44 behaves as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd without the copy

startup_root_srv_draw_{warp,hardware}: slot 44 sees red at a title address without an upload mapping, the title writes green, then a translated draw reads it through its root pointer. Both modes draw green; with X2W_D3D12_ROOT_SRV_AT_DRAW unset slot 44 also logs its copy, with it set nothing is copied. Mutant: ignoring the switch fails 'X2W_D3D12_ROOT_SRV_AT_DRAW=1: 1 slot 44 copy lines, expected none'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… before the render totals; document the switch

Moves bind_root_srv_copy and bind_pending_root_srvs below list_root_srv and the report line above the render totals, away from the lines open PRs R0Y00#2491 and R0Y00#2919 also change. No behaviour change. Adds the switch row, a root SRV paragraph in docs/startup-runtime.md and docs/experiments/startup-root-srv-at-draw.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
x2w_d3d12_root_srv_copies exports the deferred, made-at-a-draw and copied counts; startup_root_srv_draw prints them after the draw is recorded and the check expects (0, 0, 1) unset and (1, 0, 0) with X2W_D3D12_ROOT_SRV_AT_DRAW=1. Mutant: ignoring the switch fails with (0, 0, 1), expected (1, 0, 0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Independent integration run at bedfcafc with main 3b6c38a8. I rebuilt startup_stream_consumer and d3d12_xs_shim, then ran ctest --preset <dev|release> --no-tests=error -V -R '^startup_(root_srv_draw|stream_draw|root_reset|root_cbv|table_alias)_(warp|hardware)$'. Each preset passed 10/10 without skips on Windows 11 build 26200.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656. Both adapters drew the expected green through the translated path, with the copied count 1 when the switch was unset and 0 when set. Table-alias debug checks reported zero errors. The PR's original-executable benchmark remains contributor evidence.

The positive deferred desktop bind remains untested. In list_draw, bind_pending_root_srvs runs before the target/topology gate, so a skipped draw with a real pipeline can consume and copy a pending SRV. Also, bind_pending_root_srvs clears the pending mask and counts an at-draw copy before bind_root_srv_copy confirms it obtained a desktop address. The direct and indirect callers cannot distinguish a failed copy from a successful bind. Please defer until the remaining draw checks accept the draw, preserve or explicitly invalidate the pending state on copy failure, and make the counter match successful copies. Add a narrow fixture for a consuming desktop draw and a skipped or failed bind, so the two new call sites have observable coverage.

lukaslw-lab and others added 3 commits November 27, 2026 09:44
Review of R0Y00#3028: no draw can read the desktop root SRV binding. list_draw
forwards only with pipeline_real, which holds only for compute pipelines
(every accepted desktop graphics stream gets an indirect graphics root), and
a slot 61 graphics draw binds a pipeline over the list's root (empty, or the
cached mesh root whose only SRV comes from its lease). The pending state,
bind_pending_root_srvs and both call sites are removed: with
X2W_D3D12_ROOT_SRV_AT_DRAW=1 slot 44 counts and skips the copy and the
parameter stays unbound. The fixture export reports (skipped, copied).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two startup pairs (second reversed) on 41b3c77 with ring and alias set:
6.3 / 6.5 fps unset against 13.9 / 13.4 set, no buffer nulls or ring
refusals, the same commit peak.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukaslw-lab lukaslw-lab changed the title startup: opt-in copy of a graphics root SRV only for a draw that reads it startup: opt-in skip of the graphics root SRV copy that no draw reads Nov 27, 2026
@lukaslw-lab

Copy link
Copy Markdown
Contributor Author

Thanks for the integration run and the careful read. Following the deferred bind into a fixture showed that no draw can read the desktop binding in the current stand-in, so d4d76b88 drops the deferral: with the switch set, slot 44 skips the copy and the parameter stays unbound on the desktop list. bind_pending_root_srvs, the pending state and both call sites are gone, so the ordering and failed-copy issues you found no longer exist.

Why no consuming draw can be built:

reader what it needs why it never reads a slot 44 copy
list_draw forward pass.pipeline_real build_stream_pipeline accepts a graphics stream only with VS/PS or MS/PS ("desktop indirect graphics stream needs ..."), and every accepted one gets indirect_graphics.root. list_pipeline sets pipeline_real = available && !indirect_graphics.root, so it holds only for compute pipelines. A vertex-only desktop stream (my first fixture attempt) is refused by the same rule.
slot 61 graphics indirect_graphics.root == pass.graphics_root A non-mesh desktop pipeline is built only over an empty root (root_without_bindings), so the list's root has no SRV parameter. A cached mesh pipeline uses the title's root, and its only root SRV (cached_srv_root) comes from the validated lease; slot 44 already returns early for it.
translated draws pass.root_address They read the title address at the draw, unchanged by the switch.

What changed (7fb8bd88, then a merge of main 3b6c38a8 as 41b3c771, and the retest note d4d76b88):

  • list_root_srv: under the switch, it counts and returns before readable_window / upload_from_title. Unset is byte-for-byte the old path, plus the copied counter.
  • The export is now x2w_d3d12_root_srv_copies(skipped, copied). The fixture asserts unset (0, 1) and set (1, 0), still with the green pixel check.
  • If a desktop graphics pipeline that reads a root SRV is added later, the code comment and the experiment note say that it needs the copy at its draw. Without one, srv_bound bit 0 stays clear, so list_draw skips the draw rather than using an older binding.

Receipts on 41b3c771 (d4d76b88 adds only the note), Windows 10 22H2 19045, RTX 3080 Ti driver 32.0.16.1047 and WARP 10.0.19041; the fixture runs without the debug layer:

check result
ctest --preset <dev|release> --no-tests=error -j 1 -R '^startup_root_srv_draw_(warp|hardware)$' -V 2/2 per preset; unset skipped 0, copied 1, set skipped 1, copied 0; 32 pixels exact (green left, clear right)
mutant: root_srv_at_draw() returns false fails on both adapters: X2W_D3D12_ROOT_SRV_AT_DRAW=1: copies (skipped, copied) (0, 1), expected (1, 0)
affected matrix (startup_root_.*, startup_stream_draw.*, startup_address_.*, startup_indirect_.*, startup_table_alias_.*, startup_frame_copy_.*, ...) switch unset / set 123/125 in each of release/dev × unset/set; 18 capability skips (no mesh shaders on WARP, startup_root_heap needs the debug layer); the 2 failures are startup_list_resubmit_nodebug{,_untracked}_hardware, which segfault on unmodified main on this host too
startup run, ring + alias set, two pairs (second reversed), 150–240 s unset 6.3 / 6.5 fps, set 13.9 / 13.4; slot 44 1.17 / 1.11 → 0.29 / 0.29 threads; buffer nulls 0, no ring refusals, no removal; commit peak 18.5–18.7 GiB both

The experiment note keeps the bedfcafc tables (no run there made a copy at a draw, so slot 44 did the same work) and adds this retest.

Copy link
Copy Markdown
Contributor

I rebuilt startup_stream_consumer and startup_list_resubmit from d4d76b881d8ab72782f61a67479de518f2c55f33 in Release on Windows 11 build 26300.10075 and ran:

ctest --preset release --no-tests=error -j 1 -R '^startup_(root_srv_draw|list_resubmit_nodebug|list_resubmit_nodebug_untracked)_(warp|hardware)$' -V

All six tests passed, with no skips. The root SRV fixture read exactly 32 green pixels in both switch modes on WARP (10.0.26100.10068) and RTX 4070 (32.0.16.2124). With the switch disabled, the counter showed 0 skipped and 1 copied. With it enabled, it showed 1 skipped and 0 copied. That verifies the translated draw observed the write after Slot 44 in both modes.

The two hardware resubmit tests that segfaulted on the reported Windows 10 setup both passed here, with a device removal reason of S_OK. This run covers Release and synthetic fixtures.

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.

startup: slot 44 copies a 64 KiB root SRV window at every call, but no draw reads the copy

3 participants