startup: refresh a frame copy when the title rewrites its memory #1651
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1658"
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 tedin7 on 2026-11-24T16:31:54Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T16:40:59Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
1a6e8ccℹ️ About Codex in GitHub
Your 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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T17:11:40Z.
e01e5bd4keeps 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.