D3D12.X: the page budget sees textures in use by their T# in the view heaps #782
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!782
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-782"
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?
@albertoglvn on GitHub · 2026-11-24 05:12 UTC · original
albertoglvn:tsharp-use→main· +516 −1 · 5 files · 2 commits · openThe page budget of #640 orders CPU-filled textures by their last transition. A title that only samples a texture never submits a transition for it, so on the newer retail title (TitleID 7952987A) every CPU-filled texture on the pages looked unused since it was placed (measured in https://github.com/ivall/xcl/pull/640#issuecomment-7121841224). This gives the budget a second use signal: the T# in the console view heaps. Part of #333.
Stacked on #640; only the top commit belongs here.
What is in it
console_heap.rs:note_indexrecords which shared-heap SRV index a view of a placed texture was made at.referencedreads word 0 of every image T# in the view heaps and returns the textures named by a shader-visible heap, and those named only by CPU-only heaps. A T# keeps that index wherever the title copies it.real.rs:dev_create_srv_xnotes the index when the budget is on. A view in a heap outside the shared heap can't be followed, so its texture is pinned (never evicted).title_textures.rs: about once a second, before the title's work,look_at_view_heapsmarks those textures as used. Evicted ones found in a shader-visible heap are mapped again and uploaded whole.map_again(shared with the transition path) skips a texture released since it was taken from the evicted set, and keeps one that can't be mapped again evicted, so a later use retries it.vram.rs:evict_lrutakes textures whose T# is in no view heap first (any size, once 2 s old).EVICT_RETRY(1 s). Without this, every tile taken at the budget sorted and walked the same shared textures again (33 million pass-overs in one run).textures_are_referenced_by_the_heaps_their_t_is_in,page_budget_takes_unseen_textures_first_and_passes_over_shared_pages.Nothing changes without
XCL_PAGE_BUDGET_MB.Tested
cargo test --workspace -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched: 689 passed, 0 failed, 41 ignoredSKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)XCL_PAGE_BUDGET_MB=4096, on an earlier local build of the same two changes plus measurement logging (details in https://github.com/ivall/xcl/pull/640#issuecomment-7122239021):EVICT_RETRYthere was no pass-over storm: 60 presents per 2 s until 50 s.Regression run
main:
this PR's head:
Not tested
Releaseand the hook forgetting its pages, a look at the heaps could still name itAI use
🤖 Generated with Claude Code
@mastrr9 on GitHub · 2026-11-24 05:20 UTC · original
Independent native Windows NVIDIA RTX 5080 (16 GB) build/test run and code review at head
4928ce58a33cc884c2dd448720b16ea8b5a5f2d5.Code Review Findings
Nice to see
map_againnow skipping released textures and re-inserting intoEVICTEDon remap failure! Two remaining edge cases spotted in the diff:INDEX_RESmapping when a descriptor slot is reused for a non-placed resource (crates/xcl/src/hle/d3d12x/console_heap.rs,INDEX_RES/real.rs:1997):dev_create_srv_xonly callsconsole_heap::note_index(&slot, res as usize)whenvram::is_placed_texture(res as usize)is true, andINDEX_REShas no removal path when a slot is overwritten or a resource is freed.s.indexpreviously held a placed textureR1and is later overwritten with a non-placed image SRVR2(orR1is released and its COM address reused),w[3] >> 28 >= 8still matches an image T# andreferenced()continues mappingw[0](s.index) back toR1.vram::tracking()is on anddev_create_srv_xcreates a view for a non-placed or null resource, removeslot.indexfromINDEX_RES(and/or prune entries forresourceinforget_pages).refresh_oncestill drops failed remaps fromEVICTED(crates/xcl/src/hle/d3d12x/title_textures.rs,refresh_once):map_again, the CPU-write revive loop inrefresh_oncecallssuper::vram::remap_if_unmapped(r)without checking itsboolreturn value. If remapping fails,rwas already removed fromEVICTEDbytake_evicted, is never put back viaevicted_again, andupload_all(todo)proceeds to upload into the still-unmapped reserved texture.map_again: checkingis_placed_texture(res)beforeID3D12Resource::from_raw_borrowed(&p)still leaves a narrow TOCTOU window if another thread runs finalReleasebetween the check andremap_if_unmapped; grabbing a strongID3D12Resourceclone fromTEXTURESunder lock before callingremap_if_unmappedeliminates raw-pointer borrowing completely.)Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4ok):hle::d3d12x::console_heap::tests::textures_are_referenced_by_the_heaps_their_t_is_inhle::d3d12x::vram::tests::page_budget_takes_unseen_textures_first_and_passes_over_shared_pageshle::d3d12x::vram::tests::page_budget_evicts_the_least_recently_touched_cpu_filled_texturehle::d3d12x::title_textures::tests::a_texture_mapped_again_after_eviction_is_uploaded_even_if_unchangedgpu::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
d3d12SDKLayers.dllnot installed on this host), AMD/wave64 hardware,XCL_PAGE_BUDGET_MBunder a retail title, and release build.AI use: Antigravity (Gemini 4 Neon) performed the code review, ran the RTX 5080 workspace tests, and drafted this comment.
@MesshM on GitHub · 2026-11-24 05:23 UTC · original
Test run of
4928ce58a33cc884c2dd448720b16ea8b5a5f2d5on AMD RDNA4. I merged it onto currentmaind208e14locally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 708 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 667 passed, 0 failed, 21 ignoredSKIPPED;page_budget_takes_unseen_textures_first_and_passes_over_shared_pages,page_budget_evicts_the_least_recently_touched_cpu_filled_textureand the T# tests pass.Review: Using the T# in the view heaps as a second use signal covers textures a title only samples and never transitions, which the budget of #640 otherwise saw as unused. At 517 lines I reviewed the structure, not every line; I could not check the eviction order on a title.
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.
@crosettiremi on GitHub · 2026-11-24 06:09 UTC · original · edited 2026-11-24 06:12 UTC
Windows / RX 7900 XT results for
4928ce5on a local integration with #640, #610 and the same compact compute preloader as the baseline. Both runs used device_type=anaconda, the same saved player profile and initial application caches, XCL_PAGE_BUDGET_MB=6144, and a 28 GiB Windows job private-commit cap. The driver cache was shared between runs. The #782 integrated workspace suite reported 741 passed, 0 failed, 41 ignored. One counted pass self-skipped for missing xgameruntime.dll. The two new heap-reference and eviction tests both ran and passed.At approximately 75 seconds after Player1's A press, while the title was still streaming:
With #782 the title exited at about 151 s process uptime with 0xc0000409, with zero device removals and no explicit allocation failure in the game log. The smoke summary's crash counter was zero despite that exit status. Without #782 the game continued longer and DRED later reported a GPU page fault at 0xd000. The new run ended before that point, so it cannot establish whether #782 changes the GPU fault.
This is one run per configuration, with elapsed time aligned to the account selection rather than an identical stream of title requests. The data shows substantially fewer remaps in this workload, along with target pages above the configured budget under a constrained process. It may help to distinguish bytes pinned by visible references from other unevictable pages when evaluating the budget.
The completed Windows job wrapper recorded a peak of 28,672 MiB for the #782 run, equal to its configured total limit. This is a whole-job high-water mark across the game and harness. The game log does not identify a failed allocation or the origin of 0xc0000409.
@ArturoWolff on GitHub · 2026-11-24 07:19 UTC · original
Linux / RTX 4060 8 GB — what still occupies the texture-page pool
Tested: XCL
beaa245ca04e212f064efc7cafcdce104bc5c0a2plus the #640/#782 diff from head4928ce58a33cc884c2dd448720b16ea8b5a5f2d5and local, opt-in counting diagnostics. This was a local integration, not an unmodified PR-head build. GE-Proton 11-14, vkd3d-proton v3.1 with #775's dxil-spirv update, DXC 1.9.2609.5, RTX 4060 (8 GB), unpacked title 1.0.2.1. Cross-built the locked workspace forx86_64-pc-windows-gnullvmin release. Ran the title offline in the default Series X profile withXCL_PAGE_BUDGET_MB=4096,XCL_PSO_PRELOAD=0,XCL_ACTIVITY=1, and A scripted at 52 s.Not tested: With-budget vs. no-budget performance under identical input and timing, visual correctness of a different eviction policy, full workspace test suite, or native Windows. All seven pin-reason snapshots reconciled to the physical tile total; four focused counting tests passed.
AI use: Hermes Agent (
gpt-6.2-sol) wrote and ran the local counting diagnostics and drafted this report from the verified measurements.@iggyvilla on GitHub · 2026-11-24 07:34 UTC · original
Test run of
4928ce58a33cc884c2dd448720b16ea8b5a5f2d5on AMD RDNA2 8 GB. Its merge base withmainis
3db536eb; I also built the top commit's parent38bf6a32(#640 alone) for the page-budget runs.Tested
26300; rustc 1.100.0
stable-x86_64-pc-windows-msvccargo build --release -p xclandcargo build --workspaceon the head: both exit 0 (one warning,a pre-existing
fetch_updatedeprecation inxgameruntime)cargo test --workspace --no-fail-fast -- --test-threads=4on the head: 685 passed, 5 failed,41 ignored across 16 test targets (
xcllib: 645 / 5 / 21). 0SKIPPED, so no GPU test wasskipped on this card.
placed_title_textures_share_vram_and_preserve_pixels(the known #470mismatch:
3D 64x64x64 4 mips: subresource 2 mismatch; it fails alone too) and fourPoisonErrorcascades that follow its panic:
transitions_apply_when_their_list_is_submitted,d32s8_targets_take_their_own_size_of_video_memory,page_budget_evicts_the_least_recently_touched_cpu_filled_textureandpage_budget_takes_unseen_textures_first_and_passes_over_shared_pages. Each of the four passeswhen rerun alone (
--exact --test-threads=1); the new T# test passes on RDNA2.XCL_NETWORK=0, no page budget. Both werebuilt from clean detached worktrees of the same commit the block names.
XCL_PAGE_BUDGET_MB=4096, parent38bf6a32(#640 only) first, thenthe head, 60 s each:
The budget never engaged in either run: target pages peaked around 287 MB, pools at 320 MB, local
video memory around 1.8 GB, 0 evictions and 0 remaps in both logs, and the frame counts are within
noise of each other. This title (28872443D20A7) does not fill the placed pages in 60 s, unlike the
7952987A title in the description, so at 4096 MB the new code stays idle here.
XCL_PAGE_BUDGET_MB=256(fourpools), parent first, then the head, 60 s each:
215 textures evicted and 0 mapped again; the last three present samples are 0 0 0; pages 586 MB
(pools 640 MB), local video memory 2588 MB.
shader-visible heap, so none is old enough to take), pages 287 MB (pools 320 MB), local video memory
1841 MB, and still 48 and 32 presents per 2 s at the end.
stays about 750 MB lower in local video memory (1841 vs 2588 MB); the budget is a soft cap in both
(the pools go past it). It is one run each, so the frame difference is indicative rather than a
repeated measurement. Since the head had no evictions here, the remap path (
map_again) was notexercised in-game on this machine, only by the unit test.
Review
I read the top commit (4 files, +284/-24) line by line and checked each point below against the code at
this head. The structure is good: the second signal is derived at one place (
referenced), the evictionorder change is one filter in
evict_lru, and themap_againextraction removes a duplicate withoutchanging the
submittedpath.CopyDescriptors(Simple)is not followed.console_heap.rs:436copy_wordsrenumbers word 0 for an image to the destination's own PC index (w[0] = dst.index),but
note_indexis only called fromdev_create_srv_xfor placed textures (real.rs:1997). So afterdev_copy_descriptors_simple_x/dev_copy_descriptors_x->copy_console_slots->copy_words, thedestination slot names
dst.index, whichINDEX_REShas no entry for, andreferenced()misses it.The texture is then seen only through its source slot; if that one is in a CPU-only heap it is
Seen::CpuOnly, andseen(vram.rs:715) refreshestouchedonly forVisible, so it stays on the5 s / 4-tile rule and can be evicted while sampled; if the source slot is reused it becomes
Seen::Noneand goes at 2 s. The module comment says titles copy views into the shader-visible heap,and this is exactly the sample-only case the PR targets, so I would add the destination index to
INDEX_RESincopy_words(from the source index's entry) and inpublish_range's path. It costsone map insert per copied image T#.
EVICT_RETRYcan take the pools past the budget.vram.rs:311take_tile, at the budget, callsevict_lru, then popsfree, then pops the oldestcoolingtile, and only when both are empty fallsthrough to
CreateHeap; that lastCreateHeaphas no cap check. While the new 1 s hold(
vram.rs:483) makesevict_lrureturn at once, a run that keeps allocating can create a new 64 MBpool during the hold. It is a soft cap today anyway (the 256 MB run's head reached 5 pools without
one eviction round), but the retry makes the overshoot avoidable; consider a cap check before that
CreateHeap, or reusing only cooled tiles.vram.rs:483setsevict_afterwheneverfreed < want, including a round with no candidates (everything younger than 2 s/5 s) or withshared == 0. Then the next second cannot evict although a texture may have crossed the agethreshold. The cost the retry avoids is walking the same shared-passed-over candidates, so gating it
on
shared > 0keeps the benefit and drops the needless hold.INDEX_REShas no removal path. The earlier review comment about this is right; the concretegaps I confirmed:
note_indexis not called (and does not remove) when the same slot gets a view ofa non-placed or null resource, and nothing prunes the index on release (
vram::forgetremoves thetarget and the
EVICTEDentry only). A stale index keeps the old texture "in use" and can makeseenpull it out ofEVICTEDand remap+upload it although the title no longer uses it, and the mapgrows for the whole session. Removing the entry when a slot is rewritten for a non-placed resource,
and on release, closes it.
title_textures.rs:840(#640 code, not this diff)take_evictedthenremap_if_unmappedwith the result dropped, and noevicted_again. That is thesame failure this commit now handles in
map_again: if the remap fails (out of memory - the 8 GBcase), the texture leaves
EVICTEDunmapped and is never retried, so it reads as zeros for the restof the run. Using
evicted_againhere too would make it consistent.Checked and found fine: lock order -
referencedtakesINDEX_RESthenHEAPSand there is no reversepath (
slot()takesHEAPSthenGLOBAL;note_indextakes onlyINDEX_RES);seendropsPAGESbefore taking
EVICTED;map_againnever holdsPAGESandTEXTURESat once. Reading the heapshadows while title threads write them can tear a T#, but a texture seen at the previous look is at most
about 1 s old when
evict_lruruns, belowEVICT_UNSEEN_AGE(2 s), so one missed look does not evict atexture that is in use. The
Seen::CpuOnlyhandling itself is conservative: a T# in a CPU-only heapcannot be sampled as it is, and it protects that texture from the 2 s rule only.
One limitation worth stating in the description: without the shared heap every placed texture that gets
an SRV is pinned (
pinwhennote_indexreturns false), so the budget can evict almost nothing in thatmode. That is the safe choice, but it is a mode where the budget does not work.
Not tested
this machine's title does not fill the pages in 60 s.
XCL_SAMPLE_*data.or flickering textures.
AI use
opencode with DeepSeek V4.1 Flash (opencode-go/deepseek-v4.1-flash) built the commits, ran the suite and
the smoke runs, read the logs, and wrote this report. It did not write or change any code.
@iggyvilla on GitHub · 2026-11-24 07:34 UTC · original
Code read of
4928ce5; nothing built or run. One point beyond the RDNA2 test report above (which covers thecopy_wordspath, the failed remap inrefresh_onceand theINDEX_RESremoval):The stack is not a stack. The branch carries
38bf6a3, an older revision of #640 (current head808a8a4:EVICT_IDLEinstead of the older retry logic).git merge-treeof #640's head with this head conflicts invram.rsandtitle_textures.rs, in either order. Please rebase4928ce5on #640's head so only the T# commit is left here.AI use: Claude Code, Claude Sonnet 5.5, read the code at the head above and drafted this; a person checked it before posting.
@Filip722 on GitHub · 2026-11-24 11:33 UTC · original · edited 2026-11-24 11:35 UTC
I independently reproduced the descriptor-copy issue reported above on the exact head
4928ce5. The synthetic test copies a tracked image SRV into a slot that already tracks a different texture.copy_wordsrewrites T# word 0 to the destination index, and the table still returns the old destination texture. The case then overwrites that slot with a buffer and checks that its image tracking is cleared.I cross-built two isolated Windows MSVC release test binaries and ran
hle::d3d12x::console_heap::tests::copied_texture_views_follow_the_destination_index --exact --nocaptureunder Proton Experimental 11.0-20261112 on Bazzite 44. The head with the added test recorded 0 passed and 1 failed. A local variant that copies the source index's tracking to the destination for an image and removes the destination tracking for a non-image recorded 1 passed and 0 failed. The test uses synthetic descriptor words and does not require a GPU.OpenAI Codex with GPT-6.2-Sol high assisted with the reproduction and report.
Retail follow-up on the RTX 5060 Laptop GPU (8 GB, NVIDIA 615.78.08). I ran two offline Series X sessions on main
47efa2ewith #640, #793 and #820, Proton Experimental11.0-20261112, vkd3d-proton v3.1 with #257 and dxil-spirv1dc543f. Both used a 2,048 MiB page budget and 512 MiB coherent memory. The first run recorded 1,386 texture evictions and 21 remaps. Adding #782's top commit to the second build gave 3,951 evictions and 935 remaps, and the window displayed full loading artwork. Both runs still exited with avkAllocateMemoryaccess violation during loading. This was one pair of sequential runs using the same prefix and caches.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@RodrigoTorreao on GitHub · 2026-11-24 23:27 UTC · original
AMD RDNA2, retail title: with this PR the story loading artwork stays on screen under
XCL_PAGE_BUDGET_MB=3072; without it (#640 alone) it goes black within seconds and never comes back. Same tree, same budget, same path through the menus. This confirms @requiemsnkrp's finding on #640 on a second vendor, and that this PR fixes it. @iggyvilla's RDNA2 runs above were 60 s in the menus, so they did not reach the loading screens.Tested
main689f2dbwith #640 at its current head (5d6fac8) and this PR's commit (4928ce5) on top, merged locally. That is the restack @iggyvilla asked for, and it needed the hand port below. Both PRs also conflict withmainsince #1747 (vram::Pagesnow takes tiles throughTilePool::take_batch, andtake_tileis gone), so these runs use a port, not your heads:take_tileintoPages::bind, just beforetake_batch. At the cap, cooling tiles are reused first, thenevict_lruruns, then its tiles are reused before they cool, astake_tiledid.seen/tracking/ the unseen-first order and the shared-page pass-over as you wrote them. "Map again" goes through #640's currentvram::revive(itsrevive_listedtail made into a helper thatlook_at_view_heapsalso calls). A round that frees less than it wanted holds the next back through #640'sevict_idle_until, instead of a separateevict_after.cargo test --release -p xcl --lib -- hle::d3d12x::vram hle::d3d12x::console_heap hle::d3d12x::title_textures: 31 passed, 0 failed, 1 ignored. That includestextures_are_referenced_by_the_heaps_their_t_is_inand your eviction-order test, adapted to the port.placed_title_textures_share_vram_and_preserve_pixels. It fails on RDNA2 atmaintoo (3-D packed mips, see #1028).XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=300 XCL_FRAME_DUMP=10, noXCL_PSO_WAIT_MS;What the budget does not do here
Not tested
main).AI use
main, built and tested the tree, ran the runs, and compared the dumped frames and the logs.xcl.log; the frame counts come from a script over the frame dumps, which I don't attach (game renders).@DavidM1911 on GitHub · 2026-11-25 11:08 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.