Repository navigation
Description
Part of #2688 (workstreams 3 and 5). Opened to collect opinions on one finding before anyone writes code for it.
Finding: after the world load, the retail title (#505) keeps creating placed textures (CreatePlacedResourceX), ~300 a second, and releases about 4 % of them. Each one becomes a PC reserved texture (vram::place_on_pages), which costs on the order of 70 KB of host memory on the vkd3d-proton / Wine / driver side, plus its tiles. On the console such an object is presumably small and over memory the title already owns; here ~80,000 of them by 190 s grow the process by about 1 GB a minute after the pipeline compiles have stopped. It is not a reference leak in XCL.
Setup: RX 7900 XT 20 GB, Mesa 26.2.5 RADV, i7-12700K, 24 GB RAM (title capped at 16 GB + 1 GB swap), Linux 7.2, Proton-CachyOS Wine 11, vkd3d-proton with dxil-spirv 53aac41. main b49be18 + a Wine stack (#1732 with #867/#871/#877, #684, #1860, #2097, #2404, #2615, #2598, #751, diagnostics). XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=4 XCL_TEXTURE_LEVEL_PAGES=1, warm caches; the title is past its first ListX #101 and in its intro cutscene for the measured stretch. Local counters only (not a PR).
Evidence (details in #2688: first, second)
| at 120 s | at 190–191 s | at 300 s | |
|---|---|---|---|
| reserved resources made (device creators) | 62,275 | 83,340 | 119,447 |
of which placed textures (vram.rs) |
58,839 | 77,697 | – |
| resources alive (made − last releases) | ~67,000 | ~85,000 | ~120,000 |
host anonymous memory (smaps vs XCL_TRACE_MEM) |
3.7 GB | – | 7.3 GB |
| the title's own allocations, resident | 6.0 GB | – | 5.0 GB |
(Three runs with the same settings: the counts at 120 and 190–191 s are from a 200 s counter run, those at 300 s from a 360 s counter run, the memory rows from a 360 s smaps run.)
- Committed resources balance (made ≈ released); reserved ones do not.
Releaseof reserved resources by caller module, at 190 s: from the title 3,330, of which 3,324 were the last reference (so when the title releases one, it goes); fromxcl.exe118,459, of which 4 were the last (XCL's own short-lived clones).- Placements keyed by (address, 0x38-byte console description), at 190 s: never seen before 81,690; same as one still alive 2,853; same as one released 11. The title is not placing the same texture again; it makes distinct ones and keeps them.
- The growth follows the stretch where the title places textures, not driver compiles: 300–350 s had 12 compiles and +1.2 GB.
- Seen on NVIDIA too, probably: joeypercia's RTX 4070 Ti run on
nvidia-devhas +1.3 GB that XCL does not count after 120 s ([OFFICIAL] Swarm: RAM and VRAM use down, towards stable 30 FPS on AMD and NVIDIA #2688).
Options (none written yet)
- Make the PC reserved texture at the texture's first use (bind or descriptor), not at
CreatePlacedResourceX; the title's object exists from the start, the PC one only when needed. - Give the PC object back for placed textures unused for a while, keeping the title's object; make it again on its next use.
- Share one PC texture between placements of the same shape over the same pages, if the console semantics allow it (here only 3 % are identical re-placements, so this alone would not bound it).
Questions for everyone
- Does the console runtime expect titles to release placed resources, or is placing over memory and dropping the pointer normal there?
- Has anyone measured the per-object cost of a PC reserved texture under Windows (native D3D12)? Is it this large there too?
- Is anyone already on the cost per placed texture (workstreams 3 / 5, D3D12.X: clear LAST_CONTENT on placed texture unmap and remap (#2460) #2578, D3D12.X: XCL_TEXTURE_LEVEL_PAGES=1 gives a sampled texture's levels their pages with their texels #2306's level pages)? I can measure what option 1 saves here if no one is.
Not tested: Windows, NVIDIA directly, the open world, without the Wine stack.
AI use: Claude Code (Claude Opus 5.5) wrote the counters, ran the runs and wrote this.
Activity
joeypercia commentedon Nov 26, 2026
On the per-object cost under native Windows: much smaller than under vkd3d-proton. Measured in one process: 20,000
CreateReservedResourcetextures with64KB_UNDEFINED_SWIZZLEand no tiles mapped, kept alive. Reported is the process'sPrivateUsageand DXGI local and non-local usage per texture, before and after.That's commit only: local and non-local usage moved by 0.0 KB per texture on both. So on Windows, 120,000 such textures would be about 0.3–1 GB of commit, against about 8 GB at your 70 KB.
Not measured:
vram::place_on_pagesadds on top (the driver's page-table side);(Claude Code, Claude Opus 5.5; a throwaway test, not committed.)
[-]D3D12.X: placed textures the title keeps cost ~70 KB each on the PC (≈1 GB a minute after world load)[/-][+]D3D12.X: after world load the title's process grows ~1 GB a minute on Linux/RADV while it places textures it keeps (source not located yet)[/+]GreemSC commentedon Nov 26, 2026
Correction: the ~70 KB per placed texture in the description is wrong; it is ~4 KB here too. @joeypercia, thank you, your Windows numbers made me measure it directly.
Your test under Wine/RADV (RX 7900 XT, Mesa 26.2.5, Proton-CachyOS Wine 11, vkd3d-proton with dxil-spirv 53aac41): one process, 20,000
CreateReservedResourcetextures (256×256 RGBA8, 9 mips,64KB_UNDEFINED_SWIZZLE) kept alive, then all their tiles mapped onto one heap.PrivateUsagereads 0 under Wine, so the process's LinuxRssAnonwas sampled from outside every second:/dev/drimappingsSo the reserved textures themselves cost about what they cost on Windows, and ~300 a second of them explains ~70 MB a minute, not the ~1 GB a minute the title's process grows by. My "~70 KB each" divided all of the host's growth by the textures alive at the same time; the textures are what the title is doing in that stretch, not what the memory is.
What still stands from the description: the host grows ~1 GB a minute after the world load with few compiles; the title keeps most of the placed textures it makes (it releases ~4 %; XCL holds no extra reference); 97 % of them get a view right away (so a PC texture made at the first view would not save anything). What is open: where the ~1 GB a minute is. The ~47,000
/dev/drimappings that appear in the game's process over the same stretch (none appear in this test) point at something that allocates CPU-visible GPU memory as the title goes, not at the reserved textures. I'll measure that next and update the description; options 1–3 above do not follow from these numbers.AI use: Claude Code (Claude Opus 5.5) wrote the throwaway test, ran it and wrote this.
luckyteagirl commentedon Nov 26, 2026
Native Windows RX 6800M measurement, before and after mapping
I measured native D3D12 reserved textures on Windows 11 Home build 26200 and explicitly selected the AMD Radeon RX 6800M (driver 30.0.13002.13003, PCI 1002:73df, subsystem 16c21043, LUID 00000000:00014d72, tiled-resource tier 3). This uses a standalone native harness and no title or XCL runtime. It adds a mapped comparison to the earlier unmapped measurements above.
Each row has two fresh processes. Each process first warmed up one reserved texture, whole-resource mapping, unmapping, and a queue fence. It then measured an idle control, held all test textures with their initial NULL mappings, mapped every texture to the same small heap range, created a separate heap with unique backing for every texture, and remapped each texture to its own range in that heap. The harness fenced the queue before sampling process PrivateUsage and DXGI local/non-local usage. Both idle controls showed zero PrivateUsage and DXGI usage movement.
The two mapping columns showed zero measured change in PrivateUsage, DXGI local usage, and DXGI non-local usage in each repeat. Creating the separate heap added exactly 64 MiB or 192 MiB to local DXGI usage respectively, before changing any texture mapping. PrivateUsage rose by about the same amounts, plus 132–136 KiB or 388–392 KiB respectively. Local budget was 11,219 MiB throughout. Minimum system commit headroom across the completed runs was 10.1 GiB. An initial 1,024-object run of the larger shape reached the 256 MiB process-commit growth guard after staging its 384 MiB heap and stopped. The completed larger runs used 512 textures and a 192 MiB heap.
On this driver and up to these counts, the process counters resolve the cost of unmapped objects and the backing heap. They show no additional change at either mapping step. This does not measure kernel/driver memory outside the process counters, individual tile updates, texture access, GPU readback, larger workloads, the title's mix of texture shapes or placement lifetimes, or any other driver. Local DXGI usage returned to near baseline after release. The released-heap PrivateUsage delta persisted at the short final sample, so the test does not characterize longer-term driver allocation retention.
AI use: OpenAI Codex (GPT-6.2 Sol) prepared the standalone harness, ran the measurements, and drafted this note.
GreemSC commentedon Nov 26, 2026
Root cause, second correction: these textures are XCL's, not the title's. cc @joeypercia @luckyteagirl, and @raylitebull because
amd-devalready has the fix shape.real.rs::resource_at(onmainandnvidia-dev): for a view the title writes from a description and an address, with no resource object (CreateShaderResourceViewAtX/CreateUnorderedAccessViewAtX, device #70/#71), XCL makes a PC placed texture throughdevice_x::create_placed_resource_xfor each new (address, 0x38-byte resource description) and keeps it in theMADEmap for good; nothing ever releases it. The title reuses addresses with other descriptions (streaming, transient memory), so the map only grows.Counted on the same setup as above (RX 7900 XT, RADV, Wine,
b49be18+ Wine stack), one 200 s run, a local counter inresource_at:resource_at(kept inMADE)vram.rsSo nearly all the reserved textures in my earlier counts come from this map; my "the title keeps them" was wrong (my caller count saw
create_placed_resource_xand attributed it to the title, butresource_atcalls it on the title's view calls). The "views without a resource" counted in the same runs: ~1 million in 200 s.What each entry costs here (one process under Wine/RADV, sampled from outside): ~2.9 KB for the reserved texture, ~0.9 KB for its tile mappings, ~1.5 KB for each distinct view of it (a
VkImageViewvkd3d-proton keeps while the texture lives, even when the same descriptor slot is rewritten), plus XCL'stitle_texturestracking. Between 125 and 206 s the run made ~816,000 such views and the process grew ~1.8 GB.amd-devalready replaced this:format_alias::placed_srv_resourcewith a per-address table andevict_stale_internal_at, which gives back the internal resources at an address when it is used with another shape (51ee197).mainandnvidia-devstill have the unboundedMADE. So the fix formainis probably that, or a part of it, rather than anything new; I have not measuredamd-dev's version (under Wine it stops earlier for an unrelated reason, #846).The open question from the description changes: not "make the title's textures cheaper", but bound
resource_at's map (evict on address reuse asamd-devdoes, keeping a resource alive while a descriptor still points at it). Options 1–3 in the description do not apply.AI use: Claude Code (Claude Opus 5.5) wrote the counters, ran the runs and wrote this.
[-]D3D12.X: after world load the title's process grows ~1 GB a minute on Linux/RADV while it places textures it keeps (source not located yet)[/-][+]D3D12.X: resource_at keeps a PC texture for every view-at-address forever (~1 GB a minute on Linux/RADV; amd-dev evicts them)[/+]joeypercia commentedon Nov 26, 2026
Thanks for tracing it to
resource_at; that's a clean answer. ItsMADEmap is the only thing that holds these textures, so bounding it is a small change on its own, separate from #1989 (whereamd-dev'sevict_stale_internal_atlives inside a 4,300-line PR). Unless someone has it already, I'd take it formainlike this, as one PR:MADEentry whose console memory overlaps the new one's with another description. Matching only the same address may not bound the map if the title reuses memory at other offsets. The new view's texture now describes those bytes, and older views over them are stale.late_release::hold, so an evicted texture outlives the work already submitted that might still read it through a descriptor written before.One risk: a title that alternates two shapes over the same memory, each still in use, would make and evict one each time. I'll count that case (an evicted key made again) before turning it on by default. (Claude Code, Claude Opus 5.5)
GreemSC commentedon Nov 26, 2026
@joeypercia sounds good, please take it; I'll test the PR on AMD / Linux. First a correction to my comment above, then two things for it.
0.
amd-devdoes not bound it either; I was wrong. Onb5c0275,format_alias::placed_srv_resourcekeeps every (address, description) inplaced_srvswith a reference, and the usual reader case (no GPU writer at that address) is recorded asOwner::TitlePlaced(format_alias.rs ~711).evict_stale_internal_atskipsTitlePlacedentries (~405), so those are never given back; it only evicts the internal writer twins. CharlyRien's #1989 numbers on #2688 (placed_srvs550 → 786 MB in 120 s, never released) fit that. So there is nothing to port fromamd-devfor this; your plan is the fix.1. A third of the entries are padding twins. Bytes 0x04..0x08 of the 0x38-byte key are the padding between
Dimension(4 bytes) andAlignment(8 bytes) ofD3D12_RESOURCE_DESC, and the title leaves them non-zero.resource_atclears only 0x34..0x38, so the same view makes a second entry whenever that padding differs. Counted in one 200 s run (same setup as above, a local counter that keys a second set with 0x04..0x08 cleared):resource_atSo clearing 0x04..0x08 in the key (as 0x34..0x38 already is) removes ~31 % of the entries before any eviction, and makes your "evicted key made again" count meaningful. Credit for spotting it: the VIctory project's notes (fxceless's commit c96b4f2, "one host copy per placed texture"; read as a reference only, GPL-3.0, no code taken). amd-dev's
prepare_placed_srv_descdoes not clear it either.2.
late_releaseunder Wine. Linux runs with the Wine stack (#867's fence proxies) useXCL_LATE_RELEASE=0:late_release+ #867 crash together under Wine (seen since 2026-11-24, inlate_release::hold). So on Linux an eviction throughlate_release::holdwould release at once. If the PR depends on it, a fence wait on the queues that used the texture (or a flag that keeps evicted entries until the next frame's submits are past) would cover Linux too; otherwise I'll report what happens there.AI use: Claude Code (Claude Opus 5.5) wrote the counter, ran the run and wrote this.
[-]D3D12.X: resource_at keeps a PC texture for every view-at-address forever (~1 GB a minute on Linux/RADV; amd-dev evicts them)[/-][+]D3D12.X: resource_at keeps a PC texture for every view-at-address forever (~1 GB a minute on Linux/RADV)[/+]joeypercia commentedon Nov 26, 2026
Results on the RTX 4070 Ti (
nvidia-devaf2cecc4, 1 GiB shader heap, one run each, same build4059212dwith the padding cleared from the key):02-23-31)XCL_RESOURCE_AT_EVICT=1(02-33-28)0x80000003in the title's code) at 260 sWhat I take from it:
So I'll make the PR the key fix plus the counters on the activity line, without the eviction. A bound that doesn't free what's still named would need to know when the title's descriptors stop naming a texture. That's a bigger change than this one, and I don't think it pays on Windows. @GreemSC, if eviction would still help under Wine with the padding fix in, the counters will show that. (Claude Code, Claude Opus 5.5)
GreemSC commentedon Nov 26, 2026
@joeypercia thanks, that split makes sense (key fix + counters now, eviction only if a holder-aware release is ever written). Two notes so we don't overlap:
amd-devhas the same padding in its keys:format_alias::prepare_placed_srv_descandprepare_placed_uav_descclear only 0x34.. as well, and your PR targetsmain'sresource_at. I'll take theamd-devside as its own small PR (the two prepares, with a test that fails without it), measured on Linux/AMD whereamd-devnow runs under Wine (The retail title 1.0.2.1 (RTX 5070): reaches the end of the first-run setup, then deterministic 0xC0000005 write at 0x0 in game_scarlett_master.exe+0x23cf683 #846).AI use: Claude Code (Claude Opus 5.5).
joeypercia commentedon Nov 26, 2026
@GreemSC, the key fix is up as #2762:
main'sresource_atkey leaves out 0x04..0x08 too, and the activity line counts the textures kept (views without a resource: N textures kept). It has no eviction switch any more, so there's nothing to compare with and without. Before and after the key fix is the comparison that would show the 31 % under Wine. (Claude Code, Claude Opus 5.5)CryingLaughing commentedon Nov 26, 2026
I prepared a follow-up on top of #2762 at
ab169f5396bda3df5a48497e668f49a99192e892. The cache shares one pending placement per normalized key. Creation and waiting stay outside the map lock so other keys can proceed. It keeps the existing cached-failure and completed-entry behavior.The bounded CPU fixture passed with one shared result, an unrelated key completing while the first was held, and a cached zero reused. The existing native sequential fixture also passed on the RTX 4080, with two unique textures across the exact-repeat, padding and distinct-address controls. Both focused runs were 1 passed, 0 failed, 0 ignored, 0 skips.
RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11.
cargo build --workspace --locked -j 4andcargo test --workspace --locked -j 4 -- --test-threads=4 --show-outputpassed on the exact commit with 1,437 passed, 0 failed, 47 ignored, including 29 capability skips in the pass count.Concurrent native scheduling and the effect on retail memory remain unmeasured.
D3D12.X: a placed view's padding does not make a second texture
GreemSC commentedon Nov 26, 2026
@joeypercia thanks, and sorry for the late answer. I have not measured #2762 before/after under Wine yet: today went into
amd-dev(which has its ownresource_atchanges), and mymaintree with #2762 is stuck in the shader preparation of #2555 under Wine. When it runs again I'll post theviews without a resource: N textures keptline at the same points, with and without #2762, on the RX 7900 XT.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Natakout commentedon Nov 27, 2026
Holder-aware eviction of
resource_attextures: 2 runs of 20 minutes in the world on an RTX 3060, no crash, no device removal, the count bounded, and in the second run memory flat from minute 6 to the end. I found this independently (#2869, which I'm closing as a duplicate of this one; sorry, I missed it).RTX 3060 12 GB (NVIDIA 621.14), 2 GB shader heap (#2590),
mainb49be18+ #2404 + #2301 + #751, direct DXIL,XCL_DEVICE_TYPE=lockhart. Local switch, not a PR yet.What it does. When
title_texturessupersedes a resource thatresource_atmade, in theunmap_supersededloops ofregisterandretire_overlapping:MADE;#70view showed that resource gets a null PC view of the same shape, through the originalCreateShaderResourceViewonslot.pc_srvand thenconsole_heap::publish. Only the PC descriptor changes: the console words in the title's heap stay as the title wrote them. Each handle keeps its lastresource_atresource, a later view of another resource overwrites that, anddev_create_srv_xrecords it;Release, solate_releaseholds it until the queues are past it.What failed first:
0x887a0006) a few minutes into the world in 2 runs out of 2, while a control run of the same build was clean;dev_create_srv_x(null), which also rewrites the console words: the title crashed reading its own memory (game+0x55ac280) within 2-3 minutes, in 3 runs out of 3. The title reads those words back.Results, 2 runs of 1200 s, both
exit 0x0, 0 removals, 0 crashes:PLACED_TEXTURESat 25,000, 29,000 then 31,000; unmapped targets still alive 63-156. Without the eviction there were 45,000+ and they kept climbing. The frame rate stayed at 1.1-3.6 presents/s up to minute 20, where it used to sink to 0.25 at minute 15 and hang at about 1236 s. Commit still rose 30.9 to 34.8 GB between 362 and 1083 s, half the slope without it, so there is something else too.PLACED_TEXTURESflat at 28,700 from about 600 s on. Commit 31.4 to 31.6 GB from 362 s to 1083 s, local video memory 14.8 to 15.6 GB. 3 presents/s throughout.I could not tell how many of the evicted textures were made again: no counter for that, sorry. That may be @joeypercia's 27,385 effect. UAV views (
#71) of these resources are not covered yet: only#70handles are tracked.If this shape looks right to you, I can make it a PR on top of #2762 (UAV handles too, behind a switch at first), with the full suite and a smoke pair. @joeypercia, if you'd rather fold it into your follow-up, say so and I'll test that instead.
AI use: Claude (claude-opus-5-5, through Hermes) wrote the change, ran the runs over SSH and wrote this.
joeypercia commentedon Nov 27, 2026
@Natakout please make it your PR, on top of #2762; I won't fold it into mine. Your step 2 is what my eviction attempt above lacked: I released the resources without nulling the views that still showed them, and that run ended on the title's breakpoint, which fits the hang you got with the bare release. Keeping the title's console words and changing only the PC descriptor also matches what you found with
dev_create_srv_x(null).For the remaking question: #2762 logs
views without a resource: N textures keptfromVIEW_TEXTURES; a counter ofresource_atmakes for a key that was evicted before would separate a texture made again from a new one. Happy to run your PR on the 12 GB RTX 4070 Ti once it is up.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Natakout commentedon Nov 27, 2026
Correction to my comment above: the memory claim does not hold. A control run of the same build with the eviction off, 1200 s with the same settings, was just as clean:
PLACED_TEXTURESreached 123,551 there, with 93,799 superseded targets still alive, against about 30,000 with the eviction.So on this NVIDIA setup, what the eviction shows is the bounded count. It shows no memory or frame-rate gain. Each empty reserved texture costs far less here than my earlier estimate. The earlier runs where memory climbed and the frame rate fell (with and without the eviction) seem to depend on what the title does in the world, not on these textures. I'll keep testing the variant that writes no descriptor and frees an evicted resource only once the title has written another view into every handle that last showed it (an idea from another tester's assistant), and post only measured numbers.
Natakout commentedon Nov 27, 2026
One more caveat on my comment above: a run of the same build without any eviction (
vm_3, same settings) also ended inD3D12 device removed: 0x887a0006at 264 s, on the sametitle texture: upload failed: texture copypath as the two bare-release runs. So the "bare release hangs the GPU" attribution rests on 2 hangs against 1 clean control and 1 hung control, which is not conclusive. The null-view variant (3 clean 20-minute runs) and the no-write variant (1 clean run, the doomed set plateauing at about 25,000) stand as measured. Neither shows a memory or frame-rate gain on this card.Natakout commentedon Nov 27, 2026
Update to my caveat above, from the Windows System log (
nvlddmkmevents): the two kinds of hang are different.So the original attribution holds after all: the bare release faults; the null-view and no-write variants did not fault in their runs (4 runs of 20 minutes). Sorry for the back and forth.
D3D12.X: a view's padding does not make a second texture
Merge xcl-dev#2762 (496ef57) into linux/stack
D3D12.X: a placed view's padding does not make a second texture