Repository navigation
Conversation
|
Source review of current head
The #3521 review covers different destination-copy and postbuild-output paths. These findings are from source and the documented API contract; I did not run a build, GPU test, or title on #3522. AI use: Codex (GPT-6.2 Sol) checked the exact submit paths and contract; Codex (GPT-6.2 Astra) independently traced the mapping and allocation lifetimes. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
With XCL_SPARSE_LAZY=1 a tile the title commits has no video memory until the CPU's first bytes go up to it, or a placed buffer or a copy names it. XboxBvhBuilder.dll writes its acceleration structures with compute programs through the sparse windows, which none of those see: in a retail title the destination tiles of its builds and of every compaction copy had none, so the structures read as zeros and rays hit nothing. With the switch, the builder's batched and single build exports and its copy export are hooked when the title resolves them. Each build asks the builder's own GetRaytracingAccelerationStructurePrebuildInfo for the most it writes (XCL's prebuild_size underestimates some top levels) and gives that range to sparse::will_write, which maps it before the list runs; a clone or compacted copy writes as much as its source's build or the copy that made it, and a destination whose new size is unknown forgets its old one. A build's postbuild infos get the bytes of their type at their own DestBuffer, which can be on a tile of its own. The prebuild query is made before the size map's lock is taken. Without XCL_SPARSE_LAZY=1 nothing is hooked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title maps physical pages over the scratch of XboxBvhBuilder's builds whose bytes XCL keeps at another address, so the scratch address stays reserved: no commit lists its tiles and no CPU view links them. With XCL_SPARSE_LAZY=1 the builder's scratch writes went nowhere in 256 of 256 builds checked in a retail title, and its passes read zeros back. sparse::will_write_unbacked asks, like will_write, for the next submit: the range's window tiles with no entry and no CPU view under them get video memory of their own, the pages the CPU has not committed holes (nothing goes up or comes back there). The builder hook asks it for the scratch range the builder's own prebuild query gives, and for its destinations and copies too (tiles already listed are left to will_write). A tile that already shows a CPU view not linked yet is not given a tile of its own: it is asked for as a mirror in the same submit, so the CPU's bytes there stay visible; a tile of its own that comes to show a CPU view later (a page mapped there) gives its tile up and is linked over it. When tiles of its own find no video memory the asks are kept and the submit returns RetryRequired, so a build never runs over scratch with nothing behind it. A PERFORM_UPDATE build's scratch is the UpdateScratchDataSizeInBytes of the ALLOW_UPDATE build (or copy) it updates, kept from that build's query; not known, the larger of the two scratch sizes the update's own query gives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Stacked on #3521; only b46e9e3 belongs here. The 117 shared added lines are #3521's commit, so this is not a duplicate. No other open PR gives unbacked scratch tiles video memory. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
b46e9e3 to
5abd576
Compare
|
Re-review (head 5abd576; diff from b46e9e3, which I merge-checked, read). Not a merge-check:
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
Thanks both. Updated to
Each new test fails with its fix reverted (the CPU-view one with both checks removed). Left as follow-ups, listed in the description: giving tiles of their own back when the address is released (Foniass 2; needs a release signal), and mirror tiles being bound by the per-submit fill budget. Tests and a new AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and the regression run, and wrote this reply. |
|
merge-check
|
|
Diff review (head Good progress on the round-1 fixes (
AI use: Antigravity (Gemini 4 Neon) audited the full diff against |
bmjask
left a comment
There was a problem hiding this comment.
Review of 5abd576b: 6 finding(s). 6 are 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.
| let asks = std::mem::take(&mut *WRITE_ASKS.lock().unwrap_or_else(|e| e.into_inner())); | ||
| s.give_memory(&asks); | ||
| } | ||
| if !give_own_asks(s, &OWN_ASKS, &OWN_ASKING) { |
There was a problem hiding this comment.
give_own_asks returns RetryRequired before the submit's maintenance in before_execute_on_with (land_finished_readbacks, flush_parked_with, drain_quarantined_with, retire_free_pools_with), so a retry never frees the video memory it's waiting for. When VRAM is short (take_tile/CreateHeap fails for one scratch tile while parked or quarantined tiles could be freed), refresh_for retries before_execute 3 times with only yield_now in between. Each try returns here before any parked or quarantined tile is released, so all three fail identically and the title is stopped. A temporary shortage becomes fatal. Running that maintenance before give_own_asks, or between retries, would let it recover.
| // `remapped`) | ||
| MIRROR_ASKED.insert(t, ()); | ||
| if matches!(tile_shows(t), Under::Cpu(_)) { | ||
| self.asks.push(t); |
There was a problem hiding this comment.
A scratch tile that shows a CPU view is only pushed to self.asks, which may not be served this submit, yet give_own_asks still reports success, so the build runs over a tile with no video memory. That happens when map_mirrors returns before take_asks (non-empty later, or the fill budget used up), when take_asks takes only MIRROR_ASKS_MAX asks at a time, or when fill_later gives no memory because the CPU tile's holes are 0xFFFF. The builder's scratch writes go nowhere and its reads return zeros, despite the PR's promise that a build never runs over scratch with nothing behind it. A linked view tile that was refused (mirror_cap reached, or no memory) and has no mapped entry is also skipped at ~3857 (mirror_src) and not covered by will_write.
|
|
||
| /// Window tile `w`'s video memory of its own (`give_own_tiles`) is parked, to be taken back | ||
| /// when it is linked over the CPU view it now shows (`new_mirror`). False: it has none. | ||
| fn yield_own(&mut self, w: usize) -> bool { |
There was a problem hiding this comment.
The own set is only cleared by yield_own. It isn't cleared when the tile leaves mapped (decommit_tiles drops an all-holes own tile on any decommit touching it), or when the CPU commits pages there (commit_range makes it an ordinary committed tile). Suppose own tile T is given, then the title commits pages at T (or decommits and recommits it). T is now a normal committed tile with src == 0 but still in own. A later remap or ask that finds a CPU view at T calls yield_own, which removes the entry, its runs and its to_zero pieces and parks the tile, so the committed pages' GPU bytes and tracking are lost. Before this PR such a tile was never handed to a view.
| (holes, !holes) | ||
| }); | ||
| if self.mapped.contains_key(&t) { | ||
| self.own.insert(t); |
There was a problem hiding this comment.
Own tiles have no release path and no cap. They're given back only when a CPU view appears, aren't counted against mirror_cap, and remap_mirrors skips them when the page is unmapped (the Nothing arm). A title that moves its BVH scratch between addresses over time keeps 64 KiB of VRAM per old scratch tile forever, so the pools grow until take_tile fails. That then hits the fatal RetryRequired path above and starves mirror tiles. Releasing own tiles that no recorded build references (e.g. when the build's list is retired) would bound it.
| /// build's scratch): that address stays reserved, so no commit gives its tiles an entry and no | ||
| /// CPU view links them. With `lazy_commits`, such tiles get video memory of their own at the next | ||
| /// submit, before the list's (`State::give_own_tiles`). Never waits for the state. | ||
| pub(super) fn will_write_unbacked(va: usize, len: usize) { |
There was a problem hiding this comment.
OWN_ASKS is one global list, filled at record time and taken by whichever queue submits next. So the RetryRequired can land on an unrelated queue's submit: if a build is recorded on a compute list and a copy or present submit on another queue drains OWN_ASKS first and can't get tiles, that unrelated submit fails 3 times and the title is stopped. The reverse also happens: a bundle or list executed again after its own tile was yielded or decommitted runs over scratch with no memory, because its ask was used up at the first submit. Attaching the asks to the recording, and serving them when that list is executed, would fix both.
| if self.mapped.get(&g).is_some_and(|e| e.src == 0) { | ||
| // (a tile of the window's own is not a view's – but one given for a GPU write where | ||
| // nothing showed a CPU view gives way to one shown now) | ||
| if self.mapped.get(&g).is_some_and(|e| e.src == 0) && !(self.own.contains(&g) && matches!(tile_shows(g), Under::Cpu(_)) && self.yield_own(g)) { |
There was a problem hiding this comment.
Not certain about this one: remap_mirrors calls tile_shows twice, once inside the yield_own condition and again for now, and the view can change in between. If another thread unmaps the page between the two calls, yield_own has already parked the tile and removed it from own. Then now is Nothing with linked None, so the loop continues without linking and without giving the memory back, and the next scratch write over T goes nowhere until a new ask.
|
merge-check claim |
|
merge-check
AI-written; posted without a human check of each point. |
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
Stacked on #3521; only the top commit (
5abd576b) belongs here.The second half of what XboxBvhBuilder.dll needs under
XCL_SPARSE_LAZY=1. The title maps physical pages over the scratch of its builds whose bytes XCL keeps at another address, so the scratch address stays reserved: no commit lists its tiles and no CPU view links them, and neitherwill_write(#3521) nor the mirror path gives them video memory. In a retail title, 256 of 256 builds checked had no video memory under their scratch when their submission ran, so the builder's passes read zeros back from it. Part of #505.What is in it (one commit,
5abd576b; updated after review and rebased on #3521's new head)crates/xcl/src/hle/d3d12x/sparse.rs:will_write_unbacked, asked likewill_writeand taken by the next submit. The range's window tiles with no entry and no CPU view under them get video memory of their own (State::give_own_tiles, throughensure_mapped, cleared if reused). The pages the CPU has not committed are holes, so nothing goes up or comes back there. Tiles already listed are left towill_write.take_asksinmap_mirrors), so what the CPU wrote there stays visible.remap_mirrors, or an ask:take_asks) gives its tile up (yield_own, parked and taken back bynew_mirror) and is linked over it.RetryRequired(give_own_asks), so a build never runs over scratch with nothing behind it. After the bounded retries oftitle_textures::refresh_forthe title is stopped with that error, as for any other failed preparation.crates/xcl/src/hle/d3d12x/bvh_builder.rs: a build also gives its scratch, for the size the builder's own prebuild query gives. APERFORM_UPDATEbuild gives theUpdateScratchDataSizeInBytesof theALLOW_UPDATEbuild it updates (kept from that build's query, carried through clones and compactions, and found for in-place updates); not known, the larger of the two scratch sizes the update's own query gives. Every range the hook gives goes through both asks.an_unbacked_gpu_write_gets_tiles_of_its_own;own_tiles_that_find_no_memory_hold_the_submit_back(NO_TILES: refused, asked again, refused again, then given and the submit goes on);a_scratch_write_never_hides_a_cpu_view_not_linked_yet(the first mirror ask and a partial scratch write in one submit; the CPU's bytes on the GPU after that submit and after a later remap);an_own_tile_gives_way_to_a_page_mapped_there_later;an_update_writes_the_update_scratch_of_the_structure_it_updates(both size orderings across a 64 KiB tile boundary, in place, of a copy, unknown).Tested
XCL_DIRECT_DXIL,XCL_HEAP_WINDOWS,XCL_HEAP_FLATandXCL_SPARSE_LAZYunset for the tests.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on5abd576b: the 41 integration harnesses and binaries 148 passed, 0 failed, 20 ignored. The library harness ends early (0x80004005) on this PR and onmain9dfbe3eaalike: a test's title reachesend_title("sparse upload preparation still failed after bounded retries"). With--test-threads=1it ends duringbind::tests::gpu_two_pass_indirect_commands_keep_their_own_records, after the tests before it (that test passes inhle::d3d12x::bindalone). TheRetryRequiredthis PR adds is taken only whenXCL_SPARSE_LAZY=1asks for tiles, which no test outside the new ones does.cargo test -p xcl --lib <filters> -- --test-threads=4:hle::d3d12x::sparse hle::d3d12x::bvh_builder: 150 passed, 0 failed, 1 ignored, none skipped (145 on D3D12.X: XboxBvhBuilder builds give their destinations video memory #3521).hle::d3d12x::bind: 116 passed, 0 failed, 0 ignored.hle::d3d12x::list_x: 113 passed, 0 failed, 0 ignored (the same onmain9dfbe3ea).--skip hle::d3d12x::bind --skip hle::d3d12x::list_x) ends at the sameend_titleon this PR and onmain, so it has no count;gpu_direct_image_get_resinfo_d16fails in it on both.NO_TILEStest with the asks dropped, the give-way test withremap_mirrorsskipping every tile of the window's own, and the CPU-view test with both the check ingive_own_tilesand the one intake_asksremoved (with only the first removed it still passed, becausetake_askslinks the tile in the same submit; the test now also checks before the submit that no tile of its own was made, which was not run against that removal).SKIPPEDon this adapter before the library harness ended: 22 "no wave64",heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows). None is a test of this PR.Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 600, the release build of each commit, the same environment for both:XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=6 XCL_SPARSE_LAZY=1 XCL_SMALL_TEXTURES=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_HEAPS=sparse:1024 XCL_TWO_PASS_BATCH=1 XCL_TWO_PASS_MB=1536 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_HEAP_FLAT=1 XCL_DEPTH_UAV_TWIN=1 XCL_FRAME_DUMP=300 XCL_DIRECT_COMPACT=0, scripted A presses (XCL_PRESS_A_AT), both run on 2026-12-01 (this PR's first, with the translation cache cold for this switch).Why
XCL_DIRECT_COMPACT=0: without it, this head's runs (twice) and7737e074(the first revision rebased on #3521's new head, without this revision's fixes) had the device removed (0x887a0006) at 120–132 s, around frame 1900, with no DRED breadcrumbs. Those runs reach frame ~1900 with 25–31 presents per 2 s, further and faster than any earlier run of this title here, and so reach a compute programmainbuilds in the direct DXIL compact form (cs 95cc13288a27a96e: 20,965 blocks, 226,680 B DXIL). #3261 let that program take the compact form; the removal it then causes on NVIDIA at the first world frame is what #3516 (open) fixes, andXCL_DIRECT_COMPACT=0avoids onmain. #3521's own run builds the same program at 150 s and ends its 600 s without a removal. With the compact form off, this head ran 600 s with no removal or crash.main:
this PR's head:
Not tested
tile_showsgaveNoView), so the CPU-view paths are covered by the tests only.main) and run on to 600 s: video memory is ~5 GB over this 8 GB card's budget there, onmainas well.RehydrateRaytracingAccelerationStructureBatched2Xis not hooked (D3D12.X: XboxBvhBuilder builds give their destinations video memory #3521).XCL_SPARSE_LAZY=1nothing changes and that path was not run.Follow-ups (from the reviews, left out of this PR to keep it under ~400 lines)
AI use
RetryRequiredwhen no video memory, update scratch sizes), ran the tests and the regression runs, and wrote this description.🤖 Generated with Claude Code