D3D12.X: resource_at keeps a PC texture for every view-at-address forever (~1 GB a minute on Linux/RADV) #2743

Open
opened 2026-11-26 11:14:34 +00:00 by github-bot · 10 comments
Owner

@⁠GreemSC on GitHub · 2026-11-26 09:44 UTC · original

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.
  • Release of 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); from xcl.exe 118,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-dev has +1.3 GB that XCL does not count after 120 s (#2688).

Options (none written yet)

  1. 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.
  2. Give the PC object back for placed textures unused for a while, keeping the title's object; make it again on its next use.
  3. 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, #2578, #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.

**@⁠GreemSC** on GitHub · 2026-11-26 09:44 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743) 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](https://git.gtahub.st/github/xcl-dev--xcl/issues/2688), [second](https://git.gtahub.st/github/xcl-dev--xcl/issues/2688)) | | 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. - `Release` of 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); from `xcl.exe` 118,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-dev` has +1.3 GB that XCL does not count after 120 s (#2688). **Options (none written yet)** 1. 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. 2. Give the PC object back for placed textures unused for a while, keeping the title's object; make it again on its next use. 3. 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, #2578, #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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:14:35 +00:00
Author
Owner

@⁠joeypercia on GitHub · 2026-11-26 09:47 UTC · original

On the per-object cost under native Windows: much smaller than under vkd3d-proton. Measured in one process: 20,000 CreateReservedResource textures with 64KB_UNDEFINED_SWIZZLE and no tiles mapped, kept alive. Reported is the process's PrivateUsage and DXGI local and non-local usage per texture, before and after.

texture RTX 4070 Ti (621.40) Radeon RDNA2 iGPU
256×256 RGBA8, 9 mips 8.1 KB 8.5 KB
1024×1024 BC7, 11 mips 5.7 KB 8.9 KB
64×64 RGBA8 2.6 KB 6.7 KB

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:

  • the tile mappings vram::place_on_pages adds on top (the driver's page-table side);
  • the title's real mix of shapes;
  • whether the 4070 Ti run's +1.3 GB of "other" video memory after 120 s (#2688) has anything to do with these textures. A reserved texture alone doesn't show up in video memory here.

(Claude Code, Claude Opus 5.5; a throwaway test, not committed.)

**@⁠joeypercia** on GitHub · 2026-11-26 09:47 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7188481690) On the per-object cost under native Windows: much smaller than under vkd3d-proton. Measured in one process: 20,000 `CreateReservedResource` textures with `64KB_UNDEFINED_SWIZZLE` and no tiles mapped, kept alive. Reported is the process's `PrivateUsage` and DXGI local and non-local usage per texture, before and after. | texture | RTX 4070 Ti (621.40) | Radeon RDNA2 iGPU | |---|---:|---:| | 256×256 RGBA8, 9 mips | 8.1 KB | 8.5 KB | | 1024×1024 BC7, 11 mips | 5.7 KB | 8.9 KB | | 64×64 RGBA8 | 2.6 KB | 6.7 KB | 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: - the tile mappings `vram::place_on_pages` adds on top (the driver's page-table side); - the title's real mix of shapes; - whether the 4070 Ti run's +1.3 GB of "other" video memory after 120 s (#2688) has anything to do with these textures. A reserved texture alone doesn't show up in video memory here. (Claude Code, Claude Opus 5.5; a throwaway test, not committed.)
Author
Owner

@⁠GreemSC on GitHub · 2026-11-26 10:00 UTC · original

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 CreateReservedResource textures (256×256 RGBA8, 9 mips, 64KB_UNDEFINED_SWIZZLE) kept alive, then all their tiles mapped onto one heap. PrivateUsage reads 0 under Wine, so the process's Linux RssAnon was sampled from outside every second:

step RssAnon per texture /dev/dri mappings
before 70.3 MB 35
20,000 reserved textures made 127.8 MB ~2.9 KB 35
their 6 tiles each mapped 146.4 MB ~+0.9 KB 35
then 20,000 committed UPLOAD buffers (256 KB) made, mapped, released 146.4 MB 0 35

So 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/dri mappings 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.

**@⁠GreemSC** on GitHub · 2026-11-26 10:00 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7188772558) **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 `CreateReservedResource` textures (256×256 RGBA8, 9 mips, `64KB_UNDEFINED_SWIZZLE`) kept alive, then all their tiles mapped onto one heap. `PrivateUsage` reads 0 under Wine, so the process's Linux `RssAnon` was sampled from outside every second: | step | RssAnon | per texture | `/dev/dri` mappings | |---|---:|---:|---:| | before | 70.3 MB | | 35 | | 20,000 reserved textures made | 127.8 MB | **~2.9 KB** | 35 | | their 6 tiles each mapped | 146.4 MB | **~+0.9 KB** | 35 | | then 20,000 committed UPLOAD buffers (256 KB) made, mapped, released | 146.4 MB | 0 | 35 | So 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/dri` mappings 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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 10:00 UTC · original

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.

RGBA8 texture Textures per child 64 KiB tiles per texture Unmapped PrivateUsage per texture, across repeats Same backing mapping delta Unique remapping delta after the heap was allocated
64×64, 1 mip 1,024 1 6.82–6.84 KiB 0 B 0 B
256×256, 9 mips 512 6 8.46–8.56 KiB 0 B 0 B

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.

**@⁠luckyteagirl** on GitHub · 2026-11-26 10:00 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7188773609) ### 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. | RGBA8 texture | Textures per child | 64 KiB tiles per texture | Unmapped PrivateUsage per texture, across repeats | Same backing mapping delta | Unique remapping delta after the heap was allocated | |---|---:|---:|---:|---:|---:| | 64×64, 1 mip | 1,024 | 1 | 6.82–6.84 KiB | 0 B | 0 B | | 256×256, 9 mips | 512 | 6 | 8.46–8.56 KiB | 0 B | 0 B | 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.
Author
Owner

@⁠GreemSC on GitHub · 2026-11-26 10:15 UTC · original

Root cause, second correction: these textures are XCL's, not the title's. cc @⁠joeypercia @⁠luckyteagirl, and @⁠raylitebull because amd-dev already has the fix shape.

real.rs::resource_at (on main and nvidia-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 through device_x::create_placed_resource_x for each new (address, 0x38-byte resource description) and keeps it in the MADE map 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 in resource_at:

at made by resource_at (kept in MADE) reserved textures from vram.rs the title's own releases of placed resources
60 s 16,015 16,898 4
120 s 59,309 59,087 59
190 s 79,515 78,852 2,957

So 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_x and attributed it to the title, but resource_at calls 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 VkImageView vkd3d-proton keeps while the texture lives, even when the same descriptor slot is rewritten), plus XCL's title_textures tracking. Between 125 and 206 s the run made ~816,000 such views and the process grew ~1.8 GB.

amd-dev already replaced this: format_alias::placed_srv_resource with a per-address table and evict_stale_internal_at, which gives back the internal resources at an address when it is used with another shape (51ee197c). main and nvidia-dev still have the unbounded MADE. So the fix for main is probably that, or a part of it, rather than anything new; I have not measured amd-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 as amd-dev does, 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.

**@⁠GreemSC** on GitHub · 2026-11-26 10:15 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7189125960) **Root cause, second correction: these textures are XCL's, not the title's.** cc @⁠joeypercia @⁠luckyteagirl, and @⁠raylitebull because `amd-dev` already has the fix shape. `real.rs::resource_at` (on `main` and `nvidia-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 through `device_x::create_placed_resource_x` for each new (address, 0x38-byte resource description) and keeps it in the `MADE` map 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 in `resource_at`: | at | made by `resource_at` (kept in `MADE`) | reserved textures from `vram.rs` | the title's own releases of placed resources | |---|---:|---:|---:| | 60 s | 16,015 | 16,898 | 4 | | 120 s | 59,309 | 59,087 | 59 | | 190 s | 79,515 | 78,852 | 2,957 | So 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_x` and attributed it to the title, but `resource_at` calls 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 `VkImageView` vkd3d-proton keeps while the texture lives, even when the same descriptor slot is rewritten), plus XCL's `title_textures` tracking. Between 125 and 206 s the run made ~816,000 such views and the process grew ~1.8 GB. **`amd-dev` already replaced this**: `format_alias::placed_srv_resource` with a per-address table and `evict_stale_internal_at`, which gives back the internal resources at an address when it is used with another shape (51ee197c). `main` and `nvidia-dev` still have the unbounded `MADE`. So the fix for `main` is probably that, or a part of it, rather than anything new; I have not measured `amd-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 as `amd-dev` does, 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.
Author
Owner

@⁠joeypercia on GitHub · 2026-11-26 10:16 UTC · original

Thanks for tracing it to resource_at; that's a clean answer. Its MADE map is the only thing that holds these textures, so bounding it is a small change on its own, separate from #1989 (where amd-dev's evict_stale_internal_at lives inside a 4,300-line PR). Unless someone has it already, I'd take it for main like this, as one PR:

  1. Evict on overlap, not only the same address. A new (address, description) evicts every MADE entry 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.
  2. Release through late_release::hold, so an evicted texture outlives the work already submitted that might still read it through a descriptor written before.
  3. A counter on the activity line: entries alive, made, evicted. The PR then shows, on a run that reaches the world, whether the map levels off. On the 4070 Ti, video memory was past the budget by 3.6–4.5 GB in each of the four runs that got that far (#2688), and #2750's census puts XCL's own resources next to it.

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)

**@⁠joeypercia** on GitHub · 2026-11-26 10:16 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7189151688) Thanks for tracing it to `resource_at`; that's a clean answer. Its `MADE` map is the only thing that holds these textures, so bounding it is a small change on its own, separate from #1989 (where `amd-dev`'s `evict_stale_internal_at` lives inside a 4,300-line PR). Unless someone has it already, I'd take it for `main` like this, as one PR: 1. **Evict on overlap, not only the same address.** A new (address, description) evicts every `MADE` entry 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. 2. **Release through `late_release::hold`**, so an evicted texture outlives the work already submitted that might still read it through a descriptor written before. 3. **A counter on the activity line:** entries alive, made, evicted. The PR then shows, on a run that reaches the world, whether the map levels off. On the 4070 Ti, video memory was past the budget by 3.6–4.5 GB in each of the four runs that got that far (#2688), and #2750's census puts XCL's own resources next to it. 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)
Author
Owner

@⁠GreemSC on GitHub · 2026-11-26 10:21 UTC · original

@⁠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-dev does not bound it either; I was wrong. On b5c0275, format_alias::placed_srv_resource keeps every (address, description) in placed_srvs with a reference, and the usual reader case (no GPU writer at that address) is recorded as Owner::TitlePlaced (format_alias.rs ~711). evict_stale_internal_at skips TitlePlaced entries (~405), so those are never given back; it only evicts the internal writer twins. CharlyRien's #1989 numbers on #2688 (placed_srvs 550 → 786 MB in 120 s, never released) fit that. So there is nothing to port from amd-dev for 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) and Alignment (8 bytes) of D3D12_RESOURCE_DESC, and the title leaves them non-zero. resource_at clears 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):

at made by resource_at made with non-zero padding twins of an earlier entry once the padding is cleared
60 s 16,015 306 242
120 s 59,676 18,772 18,572
190 s 80,953 25,082 24,844 (31 %)

So 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_desc does not clear it either.

2. late_release under Wine. Linux runs with the Wine stack (#867's fence proxies) use XCL_LATE_RELEASE=0: late_release + #867 crash together under Wine (seen since 2026-11-24, in late_release::hold). So on Linux an eviction through late_release::hold would 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.

**@⁠GreemSC** on GitHub · 2026-11-26 10:21 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7189249905) @⁠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-dev` does not bound it either; I was wrong.** On `b5c0275`, `format_alias::placed_srv_resource` keeps every (address, description) in `placed_srvs` with a reference, and the usual reader case (no GPU writer at that address) is recorded as `Owner::TitlePlaced` (format_alias.rs ~711). `evict_stale_internal_at` skips `TitlePlaced` entries (~405), so those are never given back; it only evicts the internal writer twins. CharlyRien's #1989 numbers on #2688 ([`placed_srvs` 550 → 786 MB in 120 s, never released](https://git.gtahub.st/github/xcl-dev--xcl/issues/2688)) fit that. So there is nothing to port from `amd-dev` for 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) and `Alignment` (8 bytes) of `D3D12_RESOURCE_DESC`, and the title leaves them non-zero. `resource_at` clears 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): | at | made by `resource_at` | made with non-zero padding | twins of an earlier entry once the padding is cleared | |---|---:|---:|---:| | 60 s | 16,015 | 306 | 242 | | 120 s | 59,676 | 18,772 | 18,572 | | 190 s | 80,953 | 25,082 | **24,844 (31 %)** | So 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](https://github.com/DoubleGhosty/cool_fox/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_desc` does not clear it either. **2. `late_release` under Wine.** Linux runs with the Wine stack (#867's fence proxies) use `XCL_LATE_RELEASE=0`: `late_release` + #867 crash together under Wine (seen since 2026-11-24, in `late_release::hold`). So on Linux an eviction through `late_release::hold` would 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.
Author
Owner

@⁠joeypercia on GitHub · 2026-11-26 10:39 UTC · original

Results on the RTX 4070 Ti (nvidia-dev af2cecc4, 1 GiB shader heap, one run each, same build 4059212d with the padding cleared from the key):

eviction off (02-23-31) XCL_RESOURCE_AT_EVICT=1 (02-33-28)
textures alive for views without a resource 46,017 at 171 s, 62,822 at 403 s, still climbing 21,569 at 155 s, 23,994 at 260 s, flat
made / let go / made again after that 62,822 / 0 / 0 75,767 / 51,773 / 27,385
video memory at about 210 s 13.0–13.2 GB (budget 10.5) 13.3–13.4 GB (budget 10.5)
end device removed at 404 s the title's own breakpoint (0x80000003 in the title's code) at 260 s

What I take from it:

  • Eviction bounds the count but not the memory, on Windows at least. The evicted textures' memory is under the textures that replace them, and on native D3D12 an unmapped reserved texture is about 8 KB of commit and no video memory (above). So the video memory past the budget isn't these objects.
  • More than half the evictions come back (27,385 of 51,773). The title uses two or more descriptions over the same memory by turns, and both stay in use. Evicting on overlap then means making textures over and over, and possibly freeing one a descriptor still names. The title's breakpoint in the one eviction run may come from that; I can't tell from one run.
  • The padding in the key is a plain win: the same view no longer makes a second object. On your setup that's 31 % of them, and each costs more there.

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)

**@⁠joeypercia** on GitHub · 2026-11-26 10:39 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7189666296) Results on the RTX 4070 Ti (`nvidia-dev` `af2cecc4`, 1 GiB shader heap, one run each, same build `4059212d` with the padding cleared from the key): | | eviction off (`02-23-31`) | `XCL_RESOURCE_AT_EVICT=1` (`02-33-28`) | |---|---|---| | textures alive for views without a resource | 46,017 at 171 s, 62,822 at 403 s, still climbing | 21,569 at 155 s, 23,994 at 260 s, flat | | made / let go / made again after that | 62,822 / 0 / 0 | 75,767 / 51,773 / **27,385** | | video memory at about 210 s | 13.0–13.2 GB (budget 10.5) | 13.3–13.4 GB (budget 10.5) | | end | device removed at 404 s | **the title's own breakpoint** (`0x80000003` in the title's code) at 260 s | What I take from it: - **Eviction bounds the count but not the memory**, on Windows at least. The evicted textures' memory is under the textures that replace them, and on native D3D12 an unmapped reserved texture is about 8 KB of commit and no video memory (above). So the video memory past the budget isn't these objects. - **More than half the evictions come back** (27,385 of 51,773). The title uses two or more descriptions over the same memory by turns, and both stay in use. Evicting on overlap then means making textures over and over, and possibly freeing one a descriptor still names. The title's breakpoint in the one eviction run may come from that; I can't tell from one run. - **The padding in the key is a plain win**: the same view no longer makes a second object. On your setup that's 31 % of them, and each costs more there. 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)
Author
Owner

@⁠GreemSC on GitHub · 2026-11-26 10:42 UTC · original

@⁠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-dev has the same padding in its keys: format_alias::prepare_placed_srv_desc and prepare_placed_uav_desc clear only 0x34.. as well, and your PR targets main's resource_at. I'll take the amd-dev side as its own small PR (the two prepares, with a test that fails without it), measured on Linux/AMD where amd-dev now runs under Wine (#846).
  • Eviction under Wine: once your PR is up I'll run it on Linux/AMD and post what the counters show there, with and without your switch, since each object costs more under vkd3d-proton (~4 KB + ~1.5 KB per distinct view, measured above).

AI use: Claude Code (Claude Opus 5.5).

**@⁠GreemSC** on GitHub · 2026-11-26 10:42 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7189733386) @⁠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-dev` has the same padding in its keys**: `format_alias::prepare_placed_srv_desc` and `prepare_placed_uav_desc` clear only 0x34.. as well, and your PR targets `main`'s `resource_at`. I'll take the `amd-dev` side as its own small PR (the two prepares, with a test that fails without it), measured on Linux/AMD where `amd-dev` now runs under Wine (#846). - **Eviction under Wine**: once your PR is up I'll run it on Linux/AMD and post what the counters show there, with and without your switch, since each object costs more under vkd3d-proton (~4 KB + ~1.5 KB per distinct view, measured above). AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠joeypercia on GitHub · 2026-11-26 10:53 UTC · original

@⁠GreemSC, the key fix is up as #2762: main's resource_at key 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)

**@⁠joeypercia** on GitHub · 2026-11-26 10:53 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7189977470) @⁠GreemSC, the key fix is up as #2762: `main`'s `resource_at` key 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)
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 12:19 UTC · original

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 4 and cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output passed 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.

**@⁠CryingLaughing** on GitHub · 2026-11-26 12:19 UTC · [original](https://github.com/xcl-dev/xcl/issues/2743#issuecomment-7191862418) I prepared a follow-up on top of #2762 at [`ab169f5396bda3df5a48497e668f49a99192e892`](https://github.com/CryingLaughing/xcl/commit/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 4` and `cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output` passed 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.