Repository navigation
Conversation
present_now submits its copy with q.ExecuteCommandLists, which is XCL's own hook: it re-entered q_execute_command_lists -> title_textures::refresh outside own_work, so every presented frame paid a second full look at the title's memory (GetWriteWatch over every watched range, then a copy of each dirty texture to hash it). On a retail title at 125 s that second look (refresh reached from present_now) was 26.7 % of the submit thread, profiled on f44cc79 (xcl-dev#693's head), where the submit thread is the limit. The copy reads only the presented resource. Render targets are the GPU's (vram::place, not kept in step), so no look can bring a CPU write to them; what the CPU wrote elsewhere since the title's last submit stays dirty (GetWriteWatch resets only in a look) and is uploaded before the title's next ExecuteCommandLists, the first work that can read it. A presented resource that is kept in step with title memory still gets the look, as before. The skipped look also made the queue wait for the pages mapped since its last work (vram::before_execute); the copy now calls it itself, as XCL's other own_work submits do. The look also runs sparse::before_execute (CPU writes into mapped sparse tiles); the copy skips it, and the title's next submit does it. (Hypothesis: no title presents a sparse-window resource that is not kept in step.) The title-texture GPU test now checks that a refresh under own_work uploads nothing and the next refresh uploads the write. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
NVIDIA run, since Not tested lists NVIDIA. Tested
Not tested
AI use
|
|
I measured the actual windowed PresentX copy at 0f77bf1 on Windows 11 with an RTX 3080 Ti (621.35) and Graphics Tools. I used the stock synthetic title with a scratch counter after the refresh guard and another after the write-watch scan. For its direct PresentX copy from a DEFAULT render target, restoring the old submit path in the same binary gave one refresh and one write-watch scan. The PR path gave zero of each. Both runs passed the debug-layer e2e test and logged the same D3D12 message IDs and counts. Neither reported device removal. This measures scan count for the synthetic render target. It leaves CPU time and the path for textures kept in step with title memory unmeasured. AI-assisted. Codex (GPT-6) added the scratch counters and ran the comparison. |
|
Test report for this PR's head Tested
SKIPPED tests (the same on
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
present_now(crates/xcl/src/hle/d3d12x/present.rs) submits its copy to the swap chain withq.ExecuteCommandLists, which is XCL's own hook. So it came back intoq_execute_command_lists→title_textures::refreshoutsideown_work. As a result, every presented frame paid a second full look at the title's memory:GetWriteWatchover every watched range, then a hash of each dirty texture. That look is only for the title's own work. The copy is now submitted asown_work, the same way XCL's texture uploads are.Why skipping that look can't miss a write the present needs: the copy reads only the presented resource.
vram::place) and are not kept in step with title memory, so no look could bring a CPU write to them.GetWriteWatchresets its bits only during a look. It is uploaded before the title's nextExecuteCommandLists, which is the first work that can read it.title_textures::addressknows it) still gets the look, as before.vram::before_execute). The copy now calls that itself insideown_work, as XCL's other own-work submits do, so skipping the look never skips that wait.sparse::before_execute(CPU writes into mapped sparse tiles) andrecheck_gpu_view_sources. The copy skips both; the title's nextExecuteCommandListsruns them. The copy reads only the presented resource, which is either GPU-owned (vram::place, no sparse window) or kept in step (it then gets the look). That no title presents a sparse-window resource that is not kept in step is a hypothesis, not measured.Conflicts with open PRs: #674 (triple-buffer
Presenter) and #711 (draft, its 2-buffer subset) change the sameq.ExecuteCommandListsline inpresent.rs(they move it intopresent_frame_on). Whichever lands second re-applies this wrapper: keep theirpresent_frame_onandp.queue, and wrap only theExecuteCommandListsin theown_workconditional (aftervram::before_execute); the meaning is the same. No code dependency on #693, #455, #562 or #786.What is in it
crates/xcl/src/hle/d3d12x/present.rs: the copy'sExecuteCommandListsruns insidetitle_textures::own_workunless the presented resource is kept in step, aftervram::before_execute(+13/−1).crates/xcl/src/hle/d3d12x/title_textures.rs:gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changesnow also checks that a refresh insideown_workuploads nothing, and that the next refresh uploads the write. That is the rule the change relies on. The test checks existing behaviour, so it passes without thepresent.rschange too. Testing the present path itself would need a window and a swap chain.Tested
AMD Radeon RX 6650 XT (RDNA2), driver 32.0.21045.29003, Ryzen 7 5700X, Windows 10.0.26300, rustc 1.100.0. Debug for the tests; release for the smoke runs (with
CARGO_PROFILE_RELEASE_DEBUG=1for the profiles).cargo test --workspace --no-fail-fast -- --test-threads=4on0f77bf1: 724 passed, 3 failed, 41 ignored, 0 SKIPPED. The 3 failures are the ones already onmain:placed_title_textures_share_vram_and_preserve_pixelsalso fails on its own. It is the packed-mip bug that D3D12.X: map a one-slice title texture's packed mips where D3D12 addresses them #470 fixes.transitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memorypass on their own. In the full run they fail fromPoisonErrorafter the first failure; Tests: a panicking title-texture test no longer poisons the others #673 fixes that.Submit-thread profile of a retail title past the account prompt: a 20 s sample at 125 s, the same steps on both builds (taken on
1d22c03, before adding thevram::before_executewait):mainbefore D3D12.X: a vertex or index buffer with a mirror is bound without VirtualQuery #693 (merged as de1809c), the render thread'sVirtualQueryingpu_vawas the limit. The submit thread wasn't among the two busiest threads, so this profile was taken on D3D12.X: a vertex or index buffer with a mirror is bound without VirtualQuery #693's head (f44cc79), with and without this commit. It predates the rebase onto the currentmain; I did not repeat it. There is no code dependency on D3D12.X: a vertex or index buffer with a mirror is bound without VirtualQuery #693:refreshreached frompresent_now(hash +GetWriteWatch+VirtualQuery)mainbase alone (dd2ae9a against 1d22c03), one run each gave 5.8 and 7.1 fps. That is within this title's run-to-run noise.Regression run
The title's first minute varies a lot between runs on this machine (earlier runs gave 300 to 1500 frames); these eight runs all landed in the same mode. After an unmeasured warm-up of each build, with no other build or title run on the machine, the runs alternated: head 446,
main449,main446, head 447 frames; no device removals or crashes. The second pair is shown.main:This PR:
Not tested
mainalone: there, the render thread hides it.AI use
claude-opus-5-5): wrote the change, the test, the initial profiles, and the initial PR description.4d0a00a, verifiedscripts/pr_check.py --local, and updated this description.claude-sonnet-5-5): rebased the branch ontomain6efdabc, reran the suite and the smoke runs above on0f77bf1, and updated this description.