D3D12.X: a ray-tracing build's scratch gets window tiles of its own #3522
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3522"
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?
Imported from ivall/xcl. Originally posted by Lakanya on 2026-11-30T12:01:55Z.
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 #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 (#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
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T02:52:28Z.
Source review of current head
b46e9e33. These three paths need focused regressions before the scratch allocation can be relied on:A first scratch mapping can hide an existing CPU view.
before_execute_lockedprocesses the new own-tile requests before resolving queued mirror requests. If a GPU-view tile already points to a committed CPU tile but has no cached mirror link yet,ensure_mappedcan create a privatesrc == 0tile. The later mirror lookup skips already mapped tiles, and remapping skipssrc == 0entries. A partial scratch write can therefore lose visibility of neighboring CPU bytes. Check the actual CPU view before assigning an own tile, and let an own tile yield when a real CPU view is mapped later. A regression should queue the first mirror request and a partial scratch write in one submit, then verify a CPU-written marker survives that submit and a later remap.Tile allocation failure can let an unbacked build submit.
ensure_mappedbreaks iftake_tile()fails, after the new request has been drained. With a fresh reserved scratch tile and no unrelated dirty pages or clears, preparation remainsReady. Keep the unmet request and returnRetryRequiredbefore submitting the build. The existingNO_TILEStest injection can check failure, recovery, and resubmission of the same recorded list.Update builds use the initial-build scratch size.
build_writesalways preparesScratchDataSizeInBytes. The DXR prebuild contract defines a separateUpdateScratchDataSizeInBytes, obtained for the originalALLOW_UPDATEbuild and used for subsequent updates. If the sizes differ, this can leave a required update tile unbacked or map an unnecessary neighbor. Retain that update requirement from the original prebuild query, select it whenPERFORM_UPDATEis set, and test both size orderings across a 64 KiB tile boundary. Merely reading the update field from a query made withPERFORM_UPDATEmay return zero, so the original requirement matters.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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:28:28Z.
merge-check
base:
7d86c5d2b7head:
b46e9e3331merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2899 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (
bvh_builder.rs,sparse.rs+62; stacked on #3521). Nothing changes by default (only the hook, behindXCL_SPARSE_LAZY=1, callswill_write_unbacked), so the run above doesn't reach it. Findings: (1) it can permanently hide a GPU view's memory (from reading, high confidence in the mechanism):give_own_tiles->ensure_mapped(~8160, beforemap_mirrors/take_asks~7756) only skips tiles already linked to the title's memory (mirror_src), not tiles that have CPU memory behind them but aren't linked yet (first use, request still queued, or parked after their memory was handed back). Such a tile becomes one of XCL's own;take_asks(~6766) then treats it as having no view and drops its request, andremap_mirrors(~6850) skipssrc == 0tiles, so it never shows the title's memory again. Destinations and copies take the same path viagive(). (2) These tiles are never given back (~3844, ~7014): nothing decommits them and remaps skip them, so memory grows with every distinct scratch address and survives release and reuse of the address, and a later commit there shows old scratch bytes where the title expects zeros (the PR lists this as not checked). (3) Compact copies get the source's maximum size (~120) and PERFORM_UPDATE builds useScratchDataSizeInBytesinstead ofUpdateScratchDataSizeInBytes(~108), so reserved-only tiles past the title's allocation get permanent tiles. (4) Whentake_tile()returns None, the rest of the request is dropped without a log (~3877). (5) The test callsgive_own_tilesdirectly; nothing covers the OWN_ASKS submit path or a tile with CPU memory behind it. Fine: the new tiles are mapped on the sparse queue and the fence is signalled before the title queue's wait at the same submit, tiles reused from the pool are cleared, and pages never committed are skipped for uploads and copies back.performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: not yet: own-tile backing can permanently hide a GPU view's memory for tiles with CPU memory behind them that aren't linked yet (finding 1), and those tiles are never given back (finding 2); nothing changes without XCL_SPARSE_LAZY=1
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:08:41Z.
Triage (#1607) – head
b46e9e3Stacked on #3521; only
b46e9e33belongs 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.sparse.rs:will_write_unbacked/State::give_own_tilesfollow thewill_writepattern (asked lock-free, taken at the next submit). No problems found in the PR's own commit.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:42:17Z.
Re-review (head
5abd576b; diff fromb46e9e33, which I merge-checked, read). Not a merge-check:PR descriptionis red until the smoke pair is rerun on this head, and no full suite has run on it yet.give_own_tilescheckstile_showsand asks for a link instead (sparse.rs~3861-3863), and an own tile gives way to a CPU view that appears later (yield_own~3886, ~6815-6821, ~6908).PERFORM_UPDATEbuild uses the savedUpdateScratchDataSizeInBytes(bvh_builder.rs~123-133).take_tile()failures. These are no longer silent: the tiles stay asked for and the submit returnsRetryRequired(~7644-7656, ~8234-8240).yield_ownremoves them, and no decommit or release path frees them. A later commit at that address shows the old scratch bytes instead of zeros, because the existing entry isn't added toto_zero(~5865-5885). Theownset is never cleared on commit or decommit either. Unverified edge case: a title commits over an own tile in a GPU view, a page is then mapped there, andyield_ownparks the title's own memory.end_title(0x80004005)afterrefresh_for's three quick retries (title_textures.rs~2052-2063). That's better than a silently wrong build, but the message is the generic "sparse upload preparation..." one and doesn't mention the scratch.yield_ownwhile a build that uses it is still running on the GPU is safe.give_own_asksis tested directly, but thebefore_execute_lockedpath still isn't. "What is in it" doesn't describe the new code, and still namesb46e9e33as the top commit.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Lakanya on 2026-12-01T11:18:48Z.
Thanks both. Updated to
5abd576b(rebased on #3521's2e2d9320, review fixes squashed into the one commit):give_own_tilesnow checks what the tile shows first. One over a CPU view not linked yet gets no tile of its own; it is asked for as a mirror in the same submit. A tile of its own that comes to show a CPU view later (a remap, or an ask) gives its tile up and is linked over it.a_scratch_write_never_hides_a_cpu_view_not_linked_yetqueues the first mirror ask and a partial scratch write in one submit and checks the CPU's bytes after that submit and after a later remap;an_own_tile_gives_way_to_a_page_mapped_there_later.RetryRequired; after the bounded retries the title stops with that error instead of running the build over nothing.own_tiles_that_find_no_memory_hold_the_submit_backusesNO_TILESfor failure, retry and recovery (through the submit's helper, not a real recorded list).PERFORM_UPDATEbuild gives theUpdateScratchDataSizeInByteskept from theALLOW_UPDATEbuild it updates (also through clones/compactions and in place); not known, the larger of the two sizes its own query gives.an_update_writes_the_update_scratch_of_the_structure_it_updateschecks both orderings across a 64 KiB boundary.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
xcl-smokepair are in the description; the commit is now +352/−29. The pair is run withXCL_DIRECT_COMPACT=0on both sides: without it this head reaches, at ~130 s, the compute program whose compact form hangs NVIDIA (#3261 / #3516), and the device was removed there.AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and the regression run, and wrote this reply.
Imported from ivall/xcl. Originally posted by AAsobu on 2026-12-01T13:40:51Z.
merge-check
base:
b2b1f109d2head:
5abd576bc7merge: clean (brings #3521's commit
2e2d9320with it, as the PR is stacked on it)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2912 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps); failing: none. The 4
bvh_buildertests and the 5 newsparsetests ran and pass (none skipped: tiled resources tier 2, reserved buffers and unified memory are all present here).review: read the whole diff (+642/-6 with #3521's part:
bvh_builder.rs,sparse.rs,resolver.rs,mod.rs). WithoutXCL_SPARSE_LAZY=1the resolver hook returns the original export andwill_write_unbackedreturns at once, so the default path is unchanged. With it, the three build/copy exports ofXboxBvhBuilder.dllare wrapped and call the module's own prebuild query (no stream) before the builder records; the round-1 points (a scratch tile over a CPU view not linked yet, a failed allocation letting the build run over nothing, the update scratch size) are each addressed with a test as the author lists. Open, as the description says: tiles of their own are never given back when the address is released (Foniass's finding 2), so underXCL_SPARSE_LAZY=1they can accumulate over a long run; the opt-in path only.before_execute_lockedreturnsRetryRequiredfromgive_own_asks(sparse.rs:8236) beforebefore_execute_on_with(:8252), whose maintenance (land_finished_readbacks,flush_parked_with,drain_quarantined_with,retire_free_pools_with,:7825-7851) could free tiles. The caller tries 3 times with onlyyield_nowbetween (title_textures.rs:2053-2060), then stops the title. So a temporary lack of video memory for a scratch tile is fatal.ownis cleared only inyield_own(self.own.removeatsparse.rs:3889is the only one). A tile that is decommitted, or committed by the title, stays inown, and a later CPU view callsyield_ownon what is now an ordinary committed tile and parks it.OWN_ASKSserved by whichever queue submits next, a scratch tile with a CPU view only queued inasks, the doubletile_showsinremap_mirrors, andyield_ownrecycling a tile without a fence wait.XCL_SPARSE_LAZY=1,will_write_unbackedreturns at once,OWN_ASKSstays empty andgive_own_asksreturns true. My four runs with the switch hit none of the above in 160-190 s in the world each.performance: retail title, in the world, every run with
XCL_SPARSE_LAZY=1. Release builds ofmainb2b1f109(A) and this merge (B), runs A, B, A, B of 300 s,xcl.exewith the #2590 profile at 2048 MB, the same env as my #3527 check today (XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4, start prompt byXCL_PRESS_A_AT, no input), and the defaultXCL_DIRECT_COMPACT. The log of each B run shows the batched build and copy exports wrapped. From world entry + 30 s: presents per 2 s A 1.03 / 1.05, B 0.83 / 1.09 (B1 was the first run of a new binary and still building driver pipelines); draws per 2 s A 3745 / 4041, B 2966 / 4288; peak process commit A 42,746 / 43,122 MB, B 40,970 / 41,711 MB; peak VRAM A 17,142 / 17,324 MB, B 16,200 / 17,135 MB; 0 device removals in all four (world entry at 109-137 s, so each run spent 160-190 s in the world without the hang the PR's smoke pair avoids withXCL_DIRECT_COMPACT=0). On screen (the user watched all four): in B1 one city shot came out sharp and coloured where A1 had it washed out, but B2 did not repeat it, so I do not count it as a change.verdict: not yet: the default path is untouched, but the opt-in path has new findings I confirmed in the code (a temporary video-memory shortage for an own scratch tile stops the title, because the retry returns before the maintenance that could free tiles;
ownis never cleared on decommit or commit);XCL_SPARSE_LAZY=1should not be offered with them open. It carries #3521's commit, so that one should be merged with it or firsthardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), results checked by me
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T08:46:35Z.
Diff review (head
5abd576bc, read-only code review — not a test report):Good progress on the round-1 fixes (
tile_showscheck ingive_own_tiles,RetryRequiredon unmet own-tile allocations, andUpdateScratchDataSizeInBytestracking inbvh_builder.rs), and the default path remains untouched withoutXCL_SPARSE_LAZY=1. Reading the fullsparse.rsdiff turned up 2 lifetime/synchronization issues in the opt-inself.ownpath:Stale
self.ownmembership and unzeroed scratch bytes acrosscommit_range_with_protection/decommit_range(crates/xcl/src/hle/d3d12x/sparse.rs:3860,:3869,:3887,:5836-5887,:5891-5941,:6816-6822,:6908):give_own_tilesinsertstintoself.own(sparse.rs:3869) andMIRROR_ASKED(sparse.rs:3860), andyield_own(sparse.rs:3887) is the only placeself.own.removeis called:owntile (commit_range_with_protection,sparse.rs:5836-5887): bothensure_listed(sparse.rs:3775) andensure_mapped(sparse.rs:3915) skiptbecauseself.mapped.contains_key(&t)is already true. Lines5868-5879then clearentry.holesbits without adding(t, TILE)toself.to_zero(exposing stale GPU scratch bytes on newly committed pages instead of zeros) and without removingtfromself.own.decommit_range,sparse.rs:5891-5941):decommit_rangeremovestfromself.mapped(sparse.rs:5925) and parks its pool tile (sparse.rs:5933), but never removestfromself.own.In both cases, a subsequent regular committed tile at
tstill hasself.own.contains(&t) == trueande.src == 0, sotake_asks(sparse.rs:6816-6821) orremap_mirrors(sparse.rs:6908) seeingUnder::Cpu(_)callsyield_own(t)and removes/parks the title's live committed tile. Clearingtfromself.ownindecommit_rangeand incommit_range_with_protection(and queueing(t, TILE)intoself.to_zerowhen committing over anowntile) closes both paths.yield_ownparks and immediately recycles anowntile without waiting for in-flight GPU scratch writes (crates/xcl/src/hle/d3d12x/sparse.rs:3886-3899,:6664-6666,:6701,:7829-7845,:8024,:8036):When
remap_mirrors(sparse.rs:6908, called at:7829) ortake_asks(sparse.rs:6820, called insidemap_mirrorsat:7830) callsyield_own(w), line3896inserts(w, e.pool)intoself.parkedwith no GPU fence wait or quarantine. In the same submit,new_mirror(sparse.rs:6664-6666,:6701) can immediately pop(w, e.pool)back out ofself.parked(bypassingflush_parked_with/quarantine_tiles_forat:7845,:6115) and scheduleupload_zeros(:8024) +upload_dirty(:8036) onto the sparse copy queue (self.queue), which does not wait on earlier title-queue submissions. If a previously submitted acceleration-structure build is still writing scratch towon a title queue whenwtransitions to a CPU view, the clear/fill races directly with the in-flight GPU build.AI use: Antigravity (Gemini 4 Neon) audited the full diff against
mainand drafted this review.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/sparse.rs; line 8234give_own_asksreturns RetryRequired before the submit's maintenance inbefore_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_forretries 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.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/sparse.rs; line 3862A scratch tile that shows a CPU view is only pushed to
self.asks, which may not be served this submit, yetgive_own_asksstill reports success, so the build runs over a tile with no video memory. That happens whenmap_mirrorsreturns beforetake_asks(non-emptylater, or the fill budget used up), whentake_askstakes only MIRROR_ASKS_MAX asks at a time, or whenfill_latergives 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 nomappedentry is also skipped at ~3857 (mirror_src) and not covered by will_write.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/sparse.rs; line 3886The
ownset is only cleared byyield_own. It isn't cleared when the tile leavesmapped(decommit_tilesdrops an all-holes own tile on any decommit touching it), or when the CPU commits pages there (commit_rangemakes 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 inown. A later remap or ask that finds a CPU view at T callsyield_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.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/sparse.rs; line 3869Own 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_mirrorsskips 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.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/sparse.rs; line 7633OWN_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.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Code review location:
crates/xcl/src/hle/d3d12x/sparse.rs; line 6908Not certain about this one:
remap_mirrorscallstile_showstwice, once inside theyield_owncondition and again fornow, and the view can change in between. If another thread unmaps the page between the two calls,yield_ownhas already parked the tile and removed it fromown. Thennowis Nothing withlinkedNone, 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.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T11:14:28Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by kole07139 on 2026-12-02T11:49:53Z.
merge-check claim
head:
5abd576bc7Imported from ivall/xcl. Originally posted by kole07139 on 2026-12-02T12:10:18Z.
merge-check
base:
1c8b551475head:
5abd576bc7merge: clean (brings #3521's commit
2e2d9320with it)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2919 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 driver cache needs Developer Mode; the same set as main). The library harness ran to its end; the PR's 10 tests (bvh_builder and the new sparse ones) passed, none skipped. Failing: none.
review: read #3522's own commit (+352/-29) in this merge; #3521's part I checked on #3521 this morning. With
XCL_SPARSE_LAZYunset nothing changes (will_write_unbackedreturns at once, sogive_own_asksis a no-op). With it, I agree with AAsobu's updated check and confirm these review points of this head in the code of this merge:give_own_asksreturnsRetryRequired(sparse.rs:8236-8241) beforebefore_execute_on_with(:8252) and the maintenance in it that could free tiles.refresh_fortries 3 times with onlyyield_nowbetween (title_textures.rs:2052-2061), thenprepare_title_submissionstops the title;mapped_after_waitstops on the first (list_x.rs:3620).give_memorylets the title go on in the same situation.OWN_ASKSis one global list (sparse.rs:7627) taken by whichever queue submits next (:8236), so that stop can land on an unrelated queue's submit (bmjask).ownis cleared only inyield_own(sparse.rs:3889), not on decommit or commit (Decodere, AAsobu).XCL_SPARSE_LAZY=1: the hooks are installed (Batched2X and Copy). As a counting probe on the same hooks showed on #3521, the title makes no build before world load, which this card doesn't reach. So none of the opt-in path ran here.SubmitStep::Wait/Restartpath, and fall back asgive_memorydoes (log once) rather than stop. Keeping the asks per queue would cover (2).performance: none by default. Retail title, main
1c8b5514vs this merge (1842da70), 60 s each, 0 device removals and 0 crashes:XCL_SPARSE_LAZY=1: 1594 -> 1593 frames, 17236 -> 19119 MB.verdict: not yet: with XCL_SPARSE_LAZY=1 a video-memory shortage for a build's scratch stops the title (the retry returns before the maintenance that could free tiles), the asks are global across queues, and
ownis not cleared on decommit/commit; these are open review points of this head, confirmed here in the code. The default path is unchanged.hardware / tool and model: NVIDIA GeForce RTX 3070 8 GB (driver 32.0.16.2140), Intel Core i9-9900K, Windows 11 Pro N 26200 / Claude Code with Claude Opus 5.5 (ran the merge, build, suite and smoke runs, checked the code, and wrote this check)
AI-written; posted without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:12:01Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.