Repository navigation
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Independent AMD RDNA4 (native wave64) test report on exact head Tested
Regression run (60 s retail-title smoke, (Matched Not tested
AI use
|
0c62a58 to
5f61e93
Compare
|
Tested: current PR head merged onto current
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
luckyteagirl
left a comment
There was a problem hiding this comment.
Could the index-mirror update and cached range lookup share synchronization? Two command lists can use the same mirror. MIRRORS only protects the address lookup, and the copy changes the mirror before incrementing MIRROR_WRITES. Suppose thread A has cached the range for index 0 and the title changes that index to 9 before either thread records its next draw. Thread B copies index 9 into the mirror and pauses before publishing the generation. A then sees matching source and mirror bytes, writes nothing, and hits its previous range under the old generation. The draw reads index 9, but A only refreshes the vertex data for index 0. Main rescans the mirror at this point.
A per-mirror lock covering copy and index-range lookup would close the gap. A focused test can pause B after the copy and before generation publication, then check that A cannot reuse its old range. Exact-head source review of 5f61e932b631987e3ec65dc6f61b0acf7e8fc6c6. No concurrent GPU run. AI-assisted review with Codex.
xcl-dev#2478 + xcl-dev#2533) (cherry picked from commit 0af1f31de2adc6acb4a407176142bcab777fabd8)
5f61e93 to
26ccb47
Compare
|
@luckyteagirl Confirmed, thanks. Each mirror now has a lock, held while the sync writes into it and bumps Added Squashed into the top commit, now (Claude Code, Claude Opus 5.5) |
|
Two more commits from a review pass of my own:
Each has a test that fails without it: 16384 bytes written where 12288 changed, and 3 index scans instead of 1. Suite on (Claude Code, Claude Opus 5.5) |
Once any buffer mirror exists, sync_title_buffers runs on every draw and nothing reported what it costs. With XCL_ACTIVITY=1 it now logs, every 2 s in which it ran: draws synced and those with a mirror, copies (whole buffers), bytes copied, indices scanned for the vertex range, readable() calls (those over 16 pages, which can take the VirtualQuery walk), the time in readable() and its slowest call, and the time in the function. A row is logged whenever any of these moved, also with no draw synced: the counters of a sync still running at the sample (or stalled for over 2 s) land before its draw is counted, and its slowest readable() would otherwise be dropped with the skipped row. The slowest readable() is not in xcl-dev#2391's list: measuring on xcl-dev#2389 found single calls of 16 pages or fewer taking 1-9 ms, which the other counters average away. The counters cost nothing without XCL_ACTIVITY: host_main turns them on (enable_sync_activity) before it starts the activity thread, and until then sync_title_buffers, sync_readable() and sync_count() check one relaxed bool and take no time stamps and touch no shared counter. No change in behaviour: the old body is sync_mirrors, unchanged apart from the counters, and sync_title_buffers still returns first when no mirror exists. Fixes xcl-dev#2391. Part of xcl-dev#2389. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sync_title_buffers checked every copy's source, and the indices it scans, with gpu::shader::readable. For a range with a page that is not resident, or over 16 pages, that walks the region with VirtualQuery. Measured on xcl-dev#2389, in 18 of 43 two-second windows one such call took 1.1-8.8 ms on the render thread inside a draw. The copy now uses title_textures::copy_committed_region (ReadProcessMemory, which cannot fault), so a page the title freed or protected since keeps what the mirror had. The indices are scanned from the index buffer's mirror once copied there; an index buffer without a mirror is still checked. xcl-dev#2392 proposed checking once per mirror and again after kernelx frees or reprotects memory. kernelx does not see HeapFree, which releases large heap blocks inside ntdll, so that still needed a copy that cannot fault, and with one the check has nothing left to protect. Fixes xcl-dev#2392. Part of xcl-dev#2389. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s differ `sync_title_buffers` copied the drawn range of every mirrored buffer at every draw and scanned every index again. The retail game measured in xcl-dev#2389 rewrites these buffers every frame with the same bytes, so the write-watch sees them written (xcl-dev#2478 found no saving that way) while their content does not change. Each copy now reads the title's bytes into a per-thread scratch buffer (64 KiB chunks, `ReadProcessMemory`) and writes only the 4 KiB pages that differ from the mirror's. A chunk with a page the title freed or protected is copied with `copy_committed_region` as before (xcl-dev#2392). Unchanged pages are no longer written into the mirror, so the sparse look no longer sees them dirty. An indexed draw whose indices are in a mirror keeps the vertex range it scanned, per thread, keyed by (index buffer, bytes, format, first, count, base vertex), and scans again only after any mirror was written (`MIRROR_WRITES`). Each mirror has a lock, held while the sync writes into it and bumps `MIRROR_WRITES`. For the index buffer it is held from the copy through the range lookup or scan: otherwise another list that has written new indices but not yet bumped the count is seen as "nothing differs", and the old range is reused. Vertex copies take it too, since a vertex view and the index view can share a mirror. `XCL_ACTIVITY` reports the bytes written next to the bytes compared. Part of xcl-dev#2393. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
…itten When `ReadProcessMemory` failed for a 64 KiB chunk (the title freed or protected a page of it, xcl-dev#2392), `update_mirror` copied the chunk straight into the mirror with `copy_committed_region` and counted all of it as written. From then on every draw reading that range rewrote the whole chunk, the sparse look uploaded it again and `MIRROR_WRITES` threw away the cached index ranges: the per-draw rewrite xcl-dev#2393 removes elsewhere. The chunk is now read into the scratch buffer, filled first with the mirror's bytes so that the unreadable page compares equal, and goes through the same page-by-page compare as a readable chunk. Part of xcl-dev#2393. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
The vertex range of an indexed draw was scanned again after a write into any mirror (`MIRROR_WRITES`, one count for all of them). A title that writes new vertices before its draws (a ring it fills through the frame) writes the vertex mirror at nearly every draw, so its unchanged indices were scanned again at nearly every draw. Each mirror now keeps its own count of the sync's writes, in the lock the sync already holds while it writes into that mirror, and a cached range is checked against the count of the mirror its indices are in. `MIRROR_WRITES` is gone. Part of xcl-dev#2393. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC
cf9498e to
80a99a0
Compare
Stacked on #2437 (itself on #2416); only the top three commits (from
D3D12.X: the per-draw mirror sync writes only mirror pages whose bytes differup) belong here. It is an alternative to #2478, not on top of it.sync_title_bufferscopies the drawn range of every mirrored buffer at every draw and scans every index again. The title measured in #2389 rewrites these buffers every frame with the same bytes, so the write-watch reports them written (#2478 saved little that way) while their content stays the same. This change compares content instead: a copy writes only the mirror pages whose bytes differ, and an indexed draw reuses the vertex range it scanned while no mirror was written.Part of #2393. Part of #2389.
What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:update_mirrorreads the title's bytes into a per-thread scratch buffer (64 KiB chunks,ReadProcessMemory) and writes only the 4 KiB pages that differ from the mirror. A chunk with a page the title freed or protected falls back tocopy_committed_region(D3D12.X: the per-draw mirror sync checks its source with readable() at every draw #2392). Unchanged pages are no longer written into the mirror, so the sparse look no longer sees them dirty (D3D12.X: buffer mirrors in sparse windows are written each draw and uploaded again #2394).a_mirror_is_written_only_where_the_title_bytes_differ(with a write-watch on the mirror, and a page made unreadable),a_vertex_range_is_scanned_again_only_after_a_mirror_write,the_mirror_sync_follows_changed_indices,a_vertex_range_is_not_reused_while_another_list_writes_the_indices(a test-only hook pauses list B between its index write and the bump).crates/xcl/src/host.rs: theXCL_ACTIVITYmirror line shows the KB written next to the KB compared.D3D12.X: a mirror chunk with an unreadable page is compared, not rewritten: a 64 KiB chunk thatReadProcessMemorycannot read whole is read around the page into the scratch buffer (filled first with the mirror's bytes) and compared like any other. Before, it was copied into the mirror whole and counted as written at every draw.D3D12.X: a cached index range is checked against its own mirror's writes: each mirror keeps its own count of writes (in its lock), replacing the oneMIRROR_WRITESfor all mirrors, so a draw that writes new vertices no longer makes every indexed draw scan its unchanged indices again. Test:a_vertex_range_is_kept_while_only_other_mirrors_are_written.Tested
Hardware: NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0. Tests in debug, runs in release.
Suite on
80a99a0(rebased onto D3D12.X: XCL_ACTIVITY counts and times the per-draw buffer mirror sync #2416's review fix):cargo test --workspace -- --test-threads=4: 1432 passed, 0 failed, 46 ignored; 25 SKIPPED (21no wave64, 3 f16/f32 programs refused for wave32 (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426), 1no heap windows, as onmain).New tests: the first three fail with the change undone (every page written; the cached range never rescanned); the fourth fails with the index mirror's lock removed (list A reuses its old range); the extended
a_mirror_is_written_only_where_the_title_bytes_differfails with the old fallback (16384 bytes written where 12288 changed);a_vertex_range_is_kept_while_only_other_mirrors_are_writtenfails with one count for all mirrors (3 scans instead of 1).Measurement (before the last three changes, not rerun since): retail game, menus, 120 s with its learned coherent window removed so the two mirrors are made (at ~31–32 s). One run each, means per 2 s of the
XCL_ACTIVITYlines once the mirrors exist (43–44 windows).bb9bea2)0c62a58)Only the window in which the mirrors were made wrote anything (219 KB); every later window wrote 0 KB and scanned 0 indices. What remains is the read and the compare. Both runs held 60 presents per 2 s, so frames do not show the saving.
Regression run
main:This PR:
That run had the 4095 MB coherent window in place and made no mirrors, so it does not reach the changed path; see Measurement for runs that do.
Not tested
0c62a58, before them.cf9498eshowed 896 frames (a slow start, 30 presents in one 2 s window); a rerun showed 1438, and the run of80a99a0above 1512. That run makes no mirrors, so it does not reach this code.AI use
🤖 Generated with Claude Code
https://claude.ai/code/session_015csBcd63KUE2T1kW2P15nC