Repository navigation
D3D12.X: a vertex or index buffer with a mirror is bound without VirtualQuery - #693
Conversation
|
Test report for f44cc79 (this PR's head) against its merge base on main dd2ae9a, on NVIDIA (the PR lists NVIDIA as not tested). The new test passes; no regression elsewhere. Tested
Not tested
Tested and written with Claude Code (Claude Opus 5.5); the runs are real, on the hardware above. |
|
Code audit + NVIDIA RTX 5080 test run on ReviewLooks clean — checking Tested
Not tested
AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above. |
|
Tested — re-tested at the new head, native Windows / AMD RDNA2
Not tested: retail title / AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and drafted this report. |
|
Test run of Tested
Review: A buffer with a mirror is bound to the mirror before Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
Independent test report on Tested
Not tested
AI use
|
|
Retail result on It changes the failure rather than fixing it:
Plain The Not tested: AMD, other titles, AI use: OpenCode, DeepSeek V4.1 Flash 1017. |
Test report: #693 under Wine (Linux, NVIDIA): GTA VI reaches the mirrored-buffer pathA retail-title run of this PR under Wine / vkd3d-proton, base Setup
Both PR runs log, at about 59 s: The base runs didn't get that far into the scene before the 60 s ended (in one 60 s run of mine on (The first pair. Not tested
AI use: Claude Code (Claude Opus 5.5) built both commits, ran every run above on the machine above and wrote this report. The blocks and counts are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one. |
|
Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32). Tested
Regression run ( main ( PR #693 ( Not tested: Debug build, AI use: Antigravity ( |
|
@brainhay5 Thanks for the retail run. I went through the path after a title access violation on f4ce27c + #693 ( #693 does change what the GPU gets for a buffer whose title memory is unreadable at a later bind. Before, the bind got the title's address, which the PC's GPU has no address for. Now it gets the buffer's mirror, with the unreadable part not copied. That can explain why the run gets further: the counter it waits on reaches To find where the process is stuck after the fault, could you capture the threads of the hung process (a minidump, or Process Explorer's thread stacks) and check whether (Analysis written with Claude Code, Claude Opus 5.5, from reading the code; nothing was run for it.) |
|
Regression run of Tested
main (e50836b): this PR (f44cc79): What this does and does not say
Not tested
AI use
|
gpu_va asked gpu::shader::readable() on every bind of a buffer outside unified memory before it looked for the buffer's mirror. On a title's memory that is not resident, readable() falls back to a VirtualQuery walk of the whole region: in a retail title past its account prompt the render thread spent 97 % in NtQueryVirtualMemory, 70.9 % of it via IASetVertexBuffers -> gpu_va -> readable and 7.8 % via IASetIndexBuffer. A range that has a mirror was readable when the mirror was made, and sync_title_buffers checks readable() itself before each copy, so the bind now looks the mirror up first and asks readable() only for the first bind of a range. The window check stays first, so a PC resource's GPU address that falls in a window by number is still passed through. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f44cc79 to
03912e8
Compare
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>
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>
gpu_va(crates/xcl/src/hle/d3d12x/list_x.rs) calledgpu::shader::readable()on every vertex and index buffer bind outside unified memory, before it looked for the mirror the buffer already has. When the title's memory isn't resident,readable()falls back to aVirtualQuerywalk of the whole region. Past the account prompt in a retail title, that walk took 68.8 % of the render thread (see below). The bind now looks up the mirror first. Only the first bind of a range still callsreadable(). That is safe because the mirror was made from readable memory, andsync_title_bufferscallsreadable()itself before each copy into it. The window check stays first, so a PC resource's GPU address that falls in a window by number is still passed through unchanged.Related: #582 (the slowdown past the menus), #501 (
VirtualQuerywalks hold the address space).What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:gpu_vareturns an existing mirror before callingreadable()(one commit, +10/−1).a_mirrored_buffer_binds_its_mirror_without_asking_readable. It makes a buffer's pagesPAGE_NOACCESSafter its first bind and checks that the next bind still gets the same mirror. Without the fix the test fails, because the bind returns the title's address.Tested
AMD Radeon RX 6650 XT (RDNA2), driver 32.0.21045.29003, Ryzen 7 5700X, Windows 10.0.26300, rustc 1.100.0, debug tests and a release build (with
CARGO_PROFILE_RELEASE_DEBUG=1for symbols).cargo test --workspace --no-fail-fast -- --test-threads=4on03912e8(rebased onto1ec4c98): 713 passed, 3 failed, 41 ignored, 0 SKIPPED. (The first run had two e2e failures becausexcl_testtitle.exewas not built yet; aftercargo build --workspace,--test e2epasses 3/3. The counts above include that rerun.) The 3 failures are the same known ones as 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.I profiled the title's render thread past the account prompt (a 20 s sample at 125 s, the same steps on both builds; taken before the rebase, on
82c3681againstmain@dd2ae9a, the same code):main(dd2ae9a)NtQueryVirtualMemoryviagpu_va→readable(IASetVertexBuffers/IASetIndexBuffer)timestamp)fps did not change in this scene. With the render thread mostly idle, the limit is now the submit thread, which runs at 86–89 % of a core on both builds in
title_textures::refreshandNtGetWriteWatchunderExecuteCommandLists. This PR does not change that thread.Regression run
The title's first minute varies a lot between runs on this machine (here 477 to 1555 frames), so the runs alternate (head,
main,main, head) after an unmeasured warm-up run of each build (the game was freshly moved to a new disk). Pair 1: head 1555 frames,main482 (the head run landed in the fast mode; not a result for the PR). Pair 2, matched, is shown:main481, head 477. No device removals or crashes in any run.main:This PR:
Not tested
sync_title_bufferschecks before it copies.AI use
claude-opus-5-5). It wrote the change, the test and this description, and ran the tests, profiles and smoke run above.🤖 Generated with Claude Code