Repository navigation
startup: refresh a frame copy when the title rewrites its memory - #1658
Merged
Merged
Conversation
frame_copy keeps the bytes each entry was made from and makes a new ring slice when the title's memory no longer matches. Adds startup_frame_copy_{warp,hardware} with a rewritten and an untouched constant buffer.
tedin7
marked this pull request as ready for review
November 24, 2026 16:40
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Owner
|
e01e5bd keeps snapshot caching optional when an allocation fails. The already-reserved upload slice can still be filled directly. Windows Release frame-copy and address-SRV checks passed 4/4 on RTX and WARP. In a local variant that forced the refresh snapshot allocation to fail, both frame-copy readbacks still passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
frame_copyind3d12_draw.inlkeeps one upload-ring copy per frame for each(address, bytes)that a translated draw reads from title memory (constant buffers, vertex and index ranges, root pointers). It never checked the contents. A title that rewrites the same address between two draws of one frame, such as a dynamic constant buffer, gave the second draw the first draw's data.Each entry now also keeps the bytes it was made from. A lookup is a hit only when the address and size match and the title's memory still equals those bytes (
memcmp). Otherwise the draw gets a new ring slice, filled from a fresh snapshot, and the entry is replaced. The slice the first draw already uses is not touched. The first four refreshes logframe copy of ... refreshed.Choices:
memcmpcannot collide. The old lookup keyaddress * prime ^ bytescould also name two different ranges; the stored address and size now settle that case.DRAW:1024buffers and constants,DRAW:1074indices) probereadable_windowfor the whole range immediately before calling, as they did for the oldmemcpy. The compare reads the same bytes under the same probe.draw_lockis held, so the map needs no lock of its own.Cost: one extra copy of each range per frame and a
memcmpper repeated lookup, both of the size of the data the draw already reads.Only
frame_copyand its map changed in the draw file; no hunk ind3d12_xs_device.cpp, none nearpipeline_foror the draw call sequence. Overlap with #1441, #1469, #1567, #1641 and #1654: none in source; #1654 also adds a test to the sameCMakeLists.txtanddocs/startup-runtime.mdin different places.Refs #870.
Verification
Run on Linux only; the draw fixture needs Windows:
git diff --check: clean.python tests/docs_links_check.py: self-test passed, 16 Markdown files and 349 links.python tests/bidi_controls_check.py: self-test passed, 1277 tracked files, no bidirectional controls.python -m py_compile tests/startup_frame_copy_check.py: ok.x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-onlyontests/startup_frame_copy.cppandtests/startup_stream_draw.cpp: no diagnostics.d3d12_xs_device.cpp(which includes the draw file): only the two MSVC-only__try/__excepterrors inlocal_log.h. That one compile peaked near 1 GB of memory.Windows Server 2025 (WARP),
python3 x2w_pipe.py win2025 1658 --force --targets startup_stream_consumer,startup_stub_xg_xs,startup_stub_consumer,d3d12_xs_shim,d3d12x_graphics_list_check --regex '^(startup_frame_copy_warp|startup_stream_draw_warp|startup_stubs|d3d12x_graphics_list_warp|startup_cb_blend_warp|stream_root_srv_warp|startup_address_srv_warp|startup_address_buffer_srv_warp)$'at1a6e8cc3:ctest --preset dev): 8/8 passed, includingstartup_frame_copy_warp(1.78 s)./O2(ctest --preset release): 8/8 passed, includingstartup_frame_copy_warp(1.68 s).startup_frame_copy_hardwareis not run: the node only has WARP.Evidence and follow-up
tests/startup_frame_copy_check.pyreusesdraw_texturefromstartup_address_srv_check.py: the translated pixel stage is replaced by one that returnsasfloat(constants.Load4(0))from aByteAddressBufferbound withsrv 0 buf table 0 0.tests/startup_frame_copy.cpp(selected byX2W_TEST_FRAME_COPY) creates a title-memory descriptor heap with one CBV over a 256-byte array, binds it, draws the left half of the 8x4 target, then draws the right half through a second scissor:changedsameOn the base commit the
changedcase should give red on both halves; that was not run.Assumption: both draws fall in the same frame, which the fixture guarantees by recording one list and presenting nothing in between.
Checklist
AI-assisted; commands listed were executed locally.