Repository navigation
D3D12.X: read a view heap's slots in place when scanning for superseded targets - #3592
Royalflamejlh wants to merge 2 commits into
Conversation
…eads view heaps in place)
|
Review (head 6622097, diff read, not a merge-check; draft, checks red):
Fine: the fast path only applies when the table lies in a registered view heap, each range is cut to that heap's end, ranges outside any heap still go through AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
6622097 to
6ccc2f8
Compare
|
@Foniass thanks; fixed at
AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and drafted this reply. |
|
Follow-up review (head 6ccc2f8, since 6622097, diff read, not a merge-check; draft, checks red):
New: none. Fine: the in-place copy now runs under AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
The merge of 6ccc2f8 kept the stack's older line, which copied a view heap's slots without HEAPS; the reviewed head copies them under it (copy_view_heap_slots) and its test failed here without this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A superseded target bound through a descriptor table is remapped when a draw or dispatch binds the table (xcl-dev#3179), but only the first 256 slots of each table were read. A view further in – a bindless SRV range, or a range at an explicit offset past slot 256 – was never seen: the target kept no tiles, its writes were dropped and its reads returned zeros. The root signature's SRV and UAV ranges of each descriptor table (RTS0 1.0 and 1.1, appended and unbounded ones included) are now kept in the layout, and the scan reads those ranges and nothing else. An unbounded range ends with the view heap the table lies in (console_heap::view_heap_remaining_slots); outside any view heap it has no known extent and is not read. CBV and sampler ranges cannot name a placed target and are skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed targets While any target is superseded, every draw and dispatch bound on XCL's ABI scans the descriptor ranges its layout declares for views of superseded targets (note_superseded_in_tables, xcl-dev#3443). A table outside the committed window, such as the title's view heaps in sparse window 0, was read with read_committed_into, one read for each declared range (about 41 a bind in that run), and under Wine each read asks VirtualQuery first (Windows reads it with one ReadProcessMemory). In a run in the title's world that VirtualQuery was the first call site of all, about 17 µs a call for a 32-byte slot. A range inside a registered view heap is already cut to the heap's end, and the heap's slots are committed while it is registered (XCL commits a heap it places in the sparse windows; one in the title's memory was committed when it was made): such a range is now copied where it is, under HEAPS as view_slot_words copies, so a heap unregistered on another thread since its lookup is not freed under the copy; it is then read with read_committed_into, as a range outside any view heap is. Measured with two other changes (one read of a few resident pages in read_committed_into under Wine, and the memory report reusing its commit sum) on a tree carrying other unmerged work, RTX 4060 Ti, Wine 11.21, 1 run each with the same options, the title in its world: 1.19 -> 3.70 frames a second. What each change gives on its own was not measured. Test: in-heap ranges are found without read_committed (red without the change); a bounded range outside any heap, or in one unregistered since its lookup, is read through it; a view heap's slots are copied only while it is registered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6ccc2f8 to
00ce564
Compare
|
Follow-up review (head 00ce564, since 6ccc2f8, diff read, not a merge-check; checks red):
New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
CI triage (#3041, log read only — not a merge-check) for head The failing
Now that AI use: Antigravity (Gemini 4 Neon) read the CI log and PR diff and drafted this triage note (no local build or test run). |
bmjask
left a comment
There was a problem hiding this comment.
Review of 00ce5644: 1 finding(s) (1 high), most severe first.
- High
crates/xcl/src/hle/d3d12x/console_heap.rs:1102: Not certain about this one:copy_view_heap_slotsreads a heap's memory directly on the assumption that it stays readable while registered, but for Memory::Title heaps the memory belongs to the title and was only checked as readable onc.... (inline)
These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
| if !heaps.iter().any(|h| !h.sampler && addr >= h.shadow && addr + out.len() <= h.shadow + (h.n as usize) * (SLOT as usize)) { | ||
| return false; | ||
| } | ||
| unsafe { std::ptr::copy_nonoverlapping(addr as *const u8, out.as_mut_ptr(), out.len()) }; |
There was a problem hiding this comment.
High: Not certain about this one: copy_view_heap_slots reads a heap's memory directly on the assumption that it stays readable while registered, but for Memory::Title heaps the memory belongs to the title and was only checked as readable once, at register(). read_committed_into, which this path now bypasses, skipped no-access and guard pages. If window 0 is sparse (so in_committed is false), the heap is Memory::Title, and the title's allocator later changes protection on part of that pool (a guard page for tracking, a VirtualProtect to NOACCESS) or decommits it, the next bind while any target is superseded runs copy_nonoverlapping over those pages. That's an access violation in the title, or it consumes the title's guard page, where the old path zero-filled those regions. Keeping the direct copy for UMA/sparse heaps and using read_committed_into for Memory::Title would avoid it.
There was a problem hiding this comment.
Not changed: the pages copied here are the heap's own, not memory the title uses for anything else. A Memory::Title heap's slots are what the title's allocation hook returned for this heap (runtime_alloc(bytes, D3D_DESCRIPTOR_HEAP), console_heap.rs:815), checked readable there (:816), and given back only by free (:962), after unregister (:907) has taken the heap out of HEAPS; the copy holds HEAPS (:1098). The title writes its descriptors into those pages, so it has no reason to guard or decommit them while the heap lives. main already reads the same pages in place under the same lock: view_slot_words (:1488) and exact_view_slot_words (:1501), called from vram.rs:524, :593 and :690. A page made unreadable there would fault in those first.
AI use: Claude Code (Claude Opus 5.5) checked the code and wrote this reply.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
Stacked on #3443; only the top commit (
00ce5644c) belongs here. (Edited: rebased ontomain1c8b5514; #3443's commit is carried asc7eccd9d9, its author kept, so the branch builds on today'smain.)With #3443, once any render target is superseded, every draw and dispatch bound on XCL's ABI reads each descriptor range its layout declares, one 32-byte slot at a time (about 41 reads a bind), through
title_textures::read_committed_into. Under Wine that function asksVirtualQueryregion by region (its whole-range read is skipped there, #2844), each call under Wine's one virtual-memory lock. A range inside a registered view heap is now copied where it is: its slots stay committed while the heap is registered. Ranges outside every heap are read as before.What is in it
hle/d3d12x/bind.rs(scan_superseded_in_tables_with): a range inside a registered view heap is read in place; a test that the scan reads such ranges where they are (5 against 0 without the change).Tested
x86_64-pc-windows-gnu, release, head6ccc2f80c(Foniass's review points fixed; the results below that name662209739were taken there) on D3D12.X: look for superseded targets in every declared table range #3443's7afecf845:cargo test -p xcl --release --lib -- bind::: 115 passed, 1 failed (gpu_two_pass_indirect_commands_keep_their_own_records, which fails onmain6bfb5c515here too), 1 SKIPPED.6ccc2f80c, under Wine on CPU Vulkan (no card),cargo test -p xcl --release --lib -- --test-threads=4: 2578 passed, 13 failed, 29 ignored; the parent7afecf845fails the same 13;main6bfb5c51: 2735 passed, 11 failed (the 2 extra here are theindirect_guardtests, fixed onmainafter this branch's base). Skipped on all three trees: a test that crashes the binary under Wine, the D32S8 test that hangs under Wine, and theuma_drivertests (over 12 GB).XCL_LOOK_STATS=2, from another fork), 1 run each, 900 s: theVirtualQuerycall site inread_committed_intomade 150,000 to 195,000 calls a second, 1.12 s of thread time a second on average; frames a second in the world 1.19. With this change and two others of ours together (a cheaper Wine read inread_committed_into, and reusing the memory report's commit sum): that call site was not in the top list, and 3.70 frames a second. The gain from this change alone was not measured.Regression run
RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, release builds by
scripts/smoke.ps1, the same retail title for 60 s each.main:this PR's head:
Not tested
read_committed_intomakes oneReadProcessMemoryfor the range, so the gain is expected to be small), AMD, the whole suite.AI use