D3D12.X: a vertex or index buffer with a mirror is bound without VirtualQuery #693
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!693
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/693/head"
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?
@iggyvilla on GitHub · 2026-11-24 03:34 UTC · original
iggyvilla:xcl-gpu-va-mirror-first→main· +41 −1 · 1 files · 1 commits · merged 2026-11-24 10:06 UTCgpu_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 #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; #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
@pvfreis on GitHub · 2026-11-24 03:52 UTC · original
Test report for f44cc79 (this PR's head) against its merge base on main
dd2ae9a70a, on NVIDIA (the PR lists NVIDIA as not tested). The new test passes; no regression elsewhere.Tested
cargo build --workspace --locked --offline, thencargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4, for both commits:dd2ae9a: 689 passed, 1 failed, 41 ignoredhle::d3d12x::list_x::tests::a_mirrored_buffer_binds_its_mirror_without_asking_readable, which passes; the log shows the test buffer outside unified memory taking the mirror path ("mirrored at 0x420010000, each draw copies what it reads")gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)test_title_runs_and_game_folder_is_untouched(e2e.rs:225,presents0), because these runs are in an isolated non-interactive session whereCreateSwapChainForHwndreturns 0x887A0022. An interactive run of main at7ebf1b8on this machine passed it.Not tested
Tested and written with Claude Code (Claude Opus 5.5); the runs are real, on the hardware above.
@mastrr9 on GitHub · 2026-11-24 03:54 UTC · original
Code audit + NVIDIA RTX 5080 test run on
f44cc7937cc6afd7782d6d60ee2ca48e5c84c2d0:Review
Looks clean — checking
mirrored(va, bytes)beforegpu::shader::readable(va as usize, bytes)safely avoids theVirtualQuerywalk on every subsequent bind of an already-mirrored vertex/index buffer, whilesync_title_bufferscontinues to validate what it reads from title memory.Tested
rustc 1.100.0(MSVC), debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4: 691 passed, 0 failed, 41 ignored.hle::d3d12x::list_x::tests::a_mirrored_buffer_binds_its_mirror_without_asking_readable: passed.SKIPPEDGPU tests (2, wave32-only adapter):gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.Not tested
scripts/smoke.ps1run (test suite only).AI use: code review and test run orchestrated with Antigravity (Gemini 4 Neon) on the hardware listed above.
@MesshM on GitHub · 2026-11-24 03:59 UTC · original
Test run of
f44cc7937cc6afd7782d6d60ee2ca48e5c84c2d0on AMD RDNA4. I merged it onto currentmainf4ce27clocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 702 passed, 0 failed, 41 ignored, exit code 0; 0SKIPPEDa_mirrored_buffer_binds_its_mirror_without_asking_readablepasses.Review: A buffer with a mirror is bound to the mirror before
readable()is asked, so theVirtualQuerywalk is skipped for it, and the mirror is read without touching the source. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@lordon1a on GitHub · 2026-11-24 04:10 UTC · original
Independent test report on
f44cc79:Tested
616.64, SM 6.6), Intel i7-12700H, Windows 11 Home 26H2 (build 26200),rustc 1.100.0(x86_64-pc-windows-gnullvm), debug buildcargo test -p xcl --lib hle::d3d12x::list_x -- --test-threads=1 --nocapture: 17 passed, 0 failed, 0 ignored in0.15s(includinga_mirrored_buffer_binds_its_mirror_without_asking_readable)Not tested
xcl-smoke)AI use
f44cc79in a detached worktree, audited the diff, ranlist_xtests, and posted this report.@brainhay5 on GitHub · 2026-11-24 04:10 UTC · original
Retail result on
mainf4ce27c+ this PR (merge, clean), RTX 5070 Ti, driver 32.0.16.1088, Windows 11 22631, interactive session,XCL_NETWORK=0, release, full launch.It changes the failure rather than fixing it:
Wait64BitValueXtimeouts return at 124 s — this time expecting0x8c8(plainf4ce27cexpects0x623in the same run), memory holds0.game_scarlett_master.exe+0x23cf683write-to-null is logged at 126.7 s, but the process stays alive and hung (13.5 GB working set,Responding: True, no further output) instead of exiting.Plain
mainat the same commit exits cleanly at ~120 s with the same fault. So this PR is not the cause of the crash, and it does not clear it; the run now stalls after the fault instead of terminating.The
BufferLocation = 0x3063, SizeInBytes = 0, StrideInBytes = 0view I saw in theIASetVertexBufferstrace on plain main is not obviously changed by this PR, but I did not re-trace with it applied.Not tested: AMD, other titles,
XCL_SAMPLE_*.AI use: OpenCode, DeepSeek V4.1 Flash 1017.
@JoaoPauluu on GitHub · 2026-11-24 04:11 UTC · original
Test report: #693 under Wine (Linux, NVIDIA): GTA VI reaches the mirrored-buffer path
A retail-title run of this PR under Wine / vkd3d-proton, base
main91f9a5eagainst headf44cc79. No regression, and GTA VI does bind mirrored vertex and index buffers outside unified memory, the case this PR changes, though only in the last seconds of these runs.Setup
experimental-11.0-20261112(wine-11.0), vkd3d-proton v3.1 (4522cc1a) + the patch from #257, DXVK from Proton, DXC 1.9.2609,DXVK_CONFIG="dxgi.hideNvidiaGpu = False"x86_64-pc-windows-gnu(mingw-w64-gcc 16.2.0), release buildsscripts/linux/smoke.shfrom #257,XCL_NETWORK=0, alternating base / PR / PR / base91f9a5ef44cc79Both 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
main63cdc25, for #667, the same two lines appear at 58.9 s), so these runs don't show the per-bindVirtualQuerycost either way: the mirrors exist for under a second before the title is ended.(The first pair.
peak commit: 0 MBis XCL reading 0 MB committed under Wine, see #257.)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.
@LocranKing on GitHub · 2026-11-24 04:18 UTC · original
Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32).
Tested
f44cc7937cc6afd7782d6d60ee2ca48e5c84c2d0(pr-693, clean tree)8024 MiB VRAM, driver32.0.16.2101),rustc 1.100.0(x86_64-pc-windows-msvc, MSVC14.44.35207), DXC1.9.2602.17(SDK10.0.26100.0),--releasecargo test --workspace --release --no-fail-fast -- --test-threads=4: 691 passed, 0 failed, 41 ignored, exit0;2 (no wave64)skipped (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware)Regression run (
scripts/smoke.ps1, 60 s,XCL_NETWORK=0, title folder name redacted)main (
f4ce27c):PR #693 (
f44cc79):Not tested: Debug build,
XCL_SAMPLE_*tests on this branch, runs past 60 s, AMD / wave64 hardware.AI use: Antigravity (
Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.@iggyvilla on GitHub · 2026-11-24 05:29 UTC · original
@brainhay5 Thanks for the retail run. I went through the path after a title access violation on
f4ce27c+ #693 (eh.rsunhandled_filter→report::write_final→ the title's own unhandled-exception filter →hk_nt_terminate_process). Nothing on that path takes the mirror table (MIRRORSinlist_x.rs) or a lock that #693'smirrored()call holds.mirrored()takes and drops the lock in one expression and is never called with another lock held, and the waits inwrite_finalare bounded at 2 s. So I don't see a way for #693 itself to block the exit.#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
0x8c8instead of0x623, and 2100 frames presented is close to0x8c8= 2248. But that is an inference.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
WerFault.exeis running for it, and whetherreport.jsonhas acrashentry?(Analysis written with Claude Code, Claude Opus 5.5, from reading the code; nothing was run for it.)
@milas6669 on GitHub · 2026-11-24 06:01 UTC · original
Regression run of
f44cc7937cc6(PR head, built as it is, not merged onto main) againstmaine50836b, on a retail title.Tested
scripts/smoke.ps1 -Seconds 60, the same title and time for both, one run each, main first:main (
e50836b):this PR (f44cc79):
What this does and does not say
Not tested
cargo teston this head (I did not run the test suite for this report)AI use
@relativespace2K on GitHub · 2026-11-24 03:56 UTC · original · edited 2026-11-24 09:05 UTC
Tested — re-tested at the new head, native Windows / AMD RDNA2
03912e8de71cd43700fc3fa4857fd51fa2a0e552, based on1ec4c98(the branchnow includes
mainup to #873; the previous report was forf44cc79).Windows 11 IoT Enterprise LTSC 26100; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug;
no
XCL_SAMPLE_*.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:1ec4c9803912e8test (here
3D 64x64x64 4 mips: subresource 2 mismatch, its isolated failure) and thetwo
PoisonErrorfollow-ons. This PR does not touch them. Currentmain077ce40also gives 672/3/41 in the lib tests, the same as this head.
a_mirrored_buffer_binds_its_mirror_without_asking_readable: 1 passed,0 failed. The log shows the test buffer outside unified memory taking the mirror path
(
mirrored at 0x420010000, each draw copies what it reads).SKIPPEDGPU tests on this adapter.Not tested: retail title /
smoke.ps1(so not the draw-time cost this PR targets),release build, Intel.
AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and drafted this report.
@ivall on GitHub · 2026-11-24 10:06 UTC · original
Merged (
02bfd1d). Checked on main02bfd1dtogether with #891, #693, #551 and #631:cargo test --workspace -- --test-threads=4green (685 lib tests), and a retail run through the menus and intro into the start of the world load withXCL_PSO_WAIT_MS=50: no crash, no device removal.