Repository navigation
GPU: streamed textures take video memory only for the levels the title holds (opt-in; 0.4-1.4 GB less on current main) - #2389
Conversation
…vel (opt-in) With VICTORY_LEVELS_ON_DEMAND=1, a placed or streamed 2D title texture of 1 MiB or more (no render target, depth or unordered access) gets a reserved host texture. Only the mip levels whose title memory is committed get tiles, from a pool of 64 MiB heaps, through UpdateTileMappings at the staging refresh that uploads them. Levels the title has not streamed in take no video memory; they read as zeros, as upstream's upload of unmapped memory already gives. Needs tiled resources tier 2. In Grand Theft Auto VI's world (RTX 5080, Linux, Proton, vkd3d-proton 3.2.0), the same exe with the switch off and on: about 14.5 GB of video memory in use against about 9.5 GB, about 3.9-4.6 GB of levels not allocated, the same picture, and no measurable frame time (the texture side costs about 1 ms a frame). The mechanism is fxceless/victory-fork's (tiles.rs at 9376fd6), ported onto main's texture design. Based on work by 507KAZ, who found it is the switch that makes the title fit a 12 GB card. Co-Authored-By: fxceless <36782933+fxceless@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cked mips) CI's adapter packs no mips for the 2048x2048 BC1 test texture, so giving the 1x1 level gives only that level. The test expected the packed tail on every host; it now expects either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
catminou4
left a comment
There was a problem hiding this comment.
Streamed textures take video memory only for the levels the title maps (tiles module, +868). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Large feature: tiled resource wiring with queue-ordered tile mappings. Needs hardware validation.
|
I ran Both adapters passed with the debug layer off. With Could the fixture wait for the mapping work before teardown? This checks synthetic tile mappings and their cleanup. It doesn’t measure streaming or VRAM savings in the title. AI-assisted with Codex. |
Found by DrDarkDK: with the D3D12 debug layer on (VICTORY_D3D12_DEBUG=1), levels_take_tiles_when_given_and_give_them_back dropped the tiled texture while its UpdateTileMappings were still queued, and the test process exited with code 2173. An empty submission now waits for them first. The title is not affected: Tiled::give runs only while uploading for a list, and that list holds the texture past the mappings queued ahead of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@DrDarkDK thanks, that was a real gap in the fixture. Fixed in I also checked whether the title can hit the same thing, and it can't. On the RTX 5080 under Wine with vkd3d-proton, |
…el (VICTORY_LEVELS_ON_DEMAND) # Conflicts: # crates/victory-gpu/src/texture.rs
…#2389 merge Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…EVELS_ON_DEMAND in the run command Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent RTX 4060 Laptop / Wine check of Tested
Not tested AI use |
Main now makes title textures on first use, places them in heaps made ahead, and uploads only the subresources that changed, from shared staging space, in one upload list per submission. The reserved texture for levels on demand is made in make_texture ahead of the heap placement (Resource::host passes whether the title placed the texture); with the switch off nothing changes. Tiles are given in Staging::refresh, which now runs from bindless::uploads before the upload list is recorded and executed, so the mappings still reach the host queue first; since an upload no longer copies every level, levels just given tiles (and those host_writes gives before a host copy or resolve, which it records as a pending upload into the submission's upload list) are detiled and uploaded whether their bytes changed or not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated triage for the maintainers. Merge candidate. On your latest reply: thanks. The title now gives the current figure ("0.4-1.4 GB less on current main"). That matches your Linux A/B (about 1.4 GB less peak video memory) and the native Windows RTX 5070 Ti run in the thread (about 0.4-0.6 GB, tier 4, clean exit). Nothing is left open from triage. Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous main (old upstream base) is the first parent; the second is upstream main with the current heads of our pull requests merged in: Marvisak#2143, Marvisak#1849 (carried onto main's per-region runtime_pages), Marvisak#259, Marvisak#491, Marvisak#2153, Marvisak#2099, Marvisak#2071 (main covers it), Marvisak#2162, Marvisak#2218, Marvisak#2088, Marvisak#2389, Marvisak#177's element-type key on main's three handle maps, and the README. Marvisak#2112 (opt-in, in place) stays in the renderer branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged
|
# Conflicts: # crates/victory-gpu/src/lib.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HostTexture::tiled records 0 bytes, so evict_among/choose and give_up credited nothing for a tiled texture: past BUDGET_HIGH the loop gave up every older tiled texture to free 'over' bytes, and they were made, mapped and uploaded again. Eviction now uses held_bytes(): the allocation, or the tiles a tiled texture's levels have (Tiled::given_bytes). evict_unused also no longer counts the pool's free tiles as used, as it already does for free space in the heaps of textures. Found by the maintainer's triage of Marvisak#2389. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Both points are fixed in
The tile test now also checks the pool's free bytes as a level takes its tiles. From an in-title A/B on this branch (fork build, before this fix; ~3 min in the world each, medians):
So no frame-time cost, and about 1.4 GB less. |
|
A note on the size of the saving, since the title still says about 5 GB. That figure was measured on the older base, before |
… new base The renderer README of the old branch (5fff8e0, f44ae53, eb4918e, 9a41398, b673d84, f711b62, 9b32e6f), carried over as one change since main's README moved under each of them: the renderer section with the run command (raw access chains off, VICTORY_PIPELINE_JOURNAL=1, VICTORY_LEVELS_ON_DEMAND=1), and the stack's rows after main's. Adapted: upstream base 67e8ae1; no Marvisak#2366 row (main's 8ff7913 replaces it), no Marvisak#67 row (not in this rebuild); Marvisak#1152 and Marvisak#2389 kept. The journal and soft-crash notes (e543c44) and the breadcrumbs row (1f0d6c3) are not repeated: Marvisak#491's and Marvisak#2292's current heads put them in the variables table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous renderer (old upstream base 940d32f) is the first parent and is also kept as the branch renderer-2026-11-25-oldbase; the second parent is the rebuild: fork main (upstream main 63bcca4 + our pull requests) with the renderer stack merged on it: Marvisak#439 (on main: update/439-main's resolution), Marvisak#2309, Marvisak#2167, Marvisak#2118, Marvisak#2311, Marvisak#1722, Marvisak#1751, Marvisak#688, Marvisak#1872, Marvisak#2292, Marvisak#2310, Marvisak#2112 (opt-in), Marvisak#2230 (latch on by default), Marvisak#2389, Marvisak#2088 (small windows opt-in), Marvisak#2099's new head, and tonight's Marvisak#491 journal fixes. Merged upstream since: Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906, Marvisak#1152; superseded by main: Marvisak#1769, Marvisak#1763, Marvisak#2366. The picture on this base still shows the overlay that plain upstream main shows too; that is being looked into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@/tmp/v2389c.md |
|
Measured on native Windows, which the description lists as not tried: Windows 11 26300, RTX 5070 Ti 16 GB (tiled resources tier 4), title 1.0.2.1 with the default console (Series X). Two diagnostics builds, one of
The switch line reports So it works on Windows/NVIDIA, but the saving at this spot is about 0.4–0.6 GB, not ~5 GB. Here all host textures take 5.8 GB, and only 213 of them pass the filter (2D, one layer, ≥1 MiB, not a target). I did not compare the picture side by side. 🤖 Generated with Claude Code (Claude Opus 5.5) |
|
@kawaii-shakal thanks, the first Windows run of this, and it's clean: tier 4, no refreshes without memory, a clean exit. Your 0.4–0.6 GB at that spot agrees with my 1.4 GB on Linux in a busier scene. Since |
fuzeofficlal
left a comment
There was a problem hiding this comment.
The on-demand reserved texture path and eviction accounting (held_bytes, tiles::free_bytes) are well structured, and the existing tests pass on Windows 11 with RTX 5090 (tier 4) and WARP (tier 3) under VICTORY_D3D12_DEBUG=1 and VICTORY_LEVELS_ON_DEMAND=1 (tiles:: 4/4, texture:: 3/3, resource:: 18/18, draw::tests 20/20).
However, two lifetime/synchronization bugs in tile reclamation and host_writes reproduce reliably on RTX 5090 and WARP and need to be fixed before merge:
-
Blocking —
Tiled::droprecycles tiles and destroysID3D12HeapwhileID3D12Resourcestill has live COM holders (crates/victory-gpu/src/tiles.rs:473-491,236-247):HostHeap::kept(descriptor/host.rs),host::retire(RETIRED, released only at the end ofHost::execute), andHostList::keephold COM clones ofID3D12Resource(copy.texture), notArc<HostTexture>. That is whyplacement.rsdefers freeing heap ranges and empty heaps inHostTexture::dropviaplacement::free(self.texture.clone(), p)untillast_holder(&resource)confirms no other COM reference remains.Tiled::dropinstead callsgive_backimmediately whenArc<HostTexture>drops. In normal execution this happens both when the title releases a texture whose descriptor-heap slot still views it, and duringevict_unused()->give_up()(which movesID3D12ResourceintoRETIREDviadescriptor::evict, then dropsArc<HostTexture>immediately at the start ofHost::execute, ahead ofbindless::uploadsandrelease_retired()).- Reproduced both failure modes live on Windows 11:
- Silent physical-tile aliasing corruption (RTX 5090 and WARP, zero Debug Layer warnings): filling reserved texture
Awith0xAA, keeping a liveID3D12Resourceclone (asHostHeap::kept/RETIREDdoes), droppingTiled, then allocating textureBand filling it with0x55handsA's exact physical tile run(0, 32)toBand silently overwritesA(before=[aa, aa, aa, aa, aa, aa, aa, aa]->after_B_wrote_0x55=[55, 55, 55, 55, 55, 55, 55, 55]). - Premature
ID3D12Heapdestruction / GPU fault (RTX 5090, both with and withoutVICTORY_D3D12_DEBUG=1): with two 64 MiB heaps inPOOL, dropping theTiledowners on heap 0 while oneID3D12Resourceclone remains live immediately drops heap 0 (pool[index] = None,heaps_mb=128->64, given_back=0->1); a subsequentCopyTextureRegionfrom that liveID3D12Resourcecrashes the process on RTX 5090 with0xc0000409 (STATUS_STACK_BUFFER_OVERRUN)even without the debug layer.
- Silent physical-tile aliasing corruption (RTX 5090 and WARP, zero Debug Layer warnings): filling reserved texture
- Fix: mirror
placement.rsby passing(self.texture.clone(), runs)fromHostTexture::dropinto a pending list intiles.rs, and only returning tile runs / releasing empty heaps oncelast_holder(&resource)is true (and after any queuedUpdateTileMappingshave completed).
-
Blocking —
host_writescallstiled.give(UpdateTileMappings) at command-list record time (crates/victory-gpu/src/texture.rs:243-264):- Calling
tiled.give(©.texture, every)directly fromhost_writes(texture.rs:254) queuesUpdateTileMappingsontohost.queue()from recording threads beforeHost::execute. - If a recorded list is reset or dropped without being executed (or the texture is dropped before a submission drains the queue),
Tiled::dropdestroys the backing heap whileUpdateTileMappingsis still in flight onhost.queue()— reproduced live with exit code2173on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1. - It also breaks submission ordering: because lists need not execute in recording order, mapping recycled (uninitialized) tiles onto a reserved texture at record time exposes stale previous-owner tile data to any earlier submission that samples the texture before
list's upload runs. - Fix: defer giving tiles for
host_writes(and settingpending) until submission preparation insideHost::execute(ahead oflist's upload list, matchingStaging::give_heldandlist.defer_host).
- Calling
One smaller non-blocking note: in Staging::refresh_now, the untracked !committed(self.memory, size) branch (crates/victory-gpu/src/texture.rs:678-699) returns early with zeros without calling give_held, so an untracked partially-committed reserved texture would never receive tiles for its committed small mips.
…ission Fixes the two blocking bugs and the minor one from fuzeofficlal's review of Marvisak#2389, which reproduced them on an RTX 5090 and WARP. 1. Tiles went back to the pool, and an emptied heap to the host GPU, as soon as the Arc<HostTexture> dropped. Heap slots (HostHeap::kept), retired copies (host::retire) and lists (HostList::keep) hold COM clones of the ID3D12Resource past that, so the next reserved texture could be given the same physical tiles while a view of the old one lived (silent aliasing), and a heap could be released under a live mapped resource (0xc0000409 on the next copy from it). HostTexture::drop now hands its resource and Tiled to tiles::free, as it already does with placement::free for placed textures. tiles::reap gives the tiles back (and releases empty heaps) only once placement::last_holder says nothing else holds the resource and every UpdateTileMappings queued before the texture went has run: Host::execute reads tiles::queued() before signalling its fence and reports tiles::ran() after waiting for it, then reaps after release_retired(). Reaps also run at each take and at free_bytes. 2. host_writes called Tiled::give at record time, queuing UpdateTileMappings before Host::execute. A list reset or dropped unrun left a mapping in flight for a texture that could then go with its heap (exit 2173 under VICTORY_D3D12_DEBUG=1), and a submission made before the writing list's saw the new tiles with their last owner's bytes. host_writes now only records the texture in the list (HostList::defer_tiles); Host::execute gives every level tiles for those lists (texture::give_for_host_writes) ahead of the submission's upload list, which uploads the levels just given (Staging pending), as Staging::give_held does for streamed levels. So every mapping is now queued during a submission's preparation and that submission waits for it. 3. Staging::refresh_now's untracked, not fully committed branch uploaded zeros and never called give_held, so a partly mapped reserved texture never got tiles for the small levels it holds. For levels-on-demand textures that branch now reads the memory through copy_mapped (zeros where unmapped), as the tracked path does, and goes on as a committed texture: give_held gives tiles to the held levels and they are uploaded with their bytes. Textures made committed keep the zeros. Tests: tiles::tests::tiles_go_back_only_once_nothing_holds_the_texture_ and_its_mappings_ran (the review's repro: a texture let go of while a clone of its resource is held keeps its tiles, another texture is not given them, and they go back once the clone goes and the mapping ran) and resource::tests::a_host_write_gives_tiles_at_submission_not_when_ recorded (a list dropped unrun gives no tiles; a submitted one makes every level whole). Both fail with the old behaviour. tiles::FORCED (tests only) makes the textures of one thread levels on demand without the process-wide switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@fuzeofficlal thanks, both were real. Fixed in
Two new tests, both failing with the old behaviour:
Clippy is clean with and without diagnostics. Under Wine (RTX 5080), the full |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Every host texture takes video memory for all its mip levels, including the levels the title hasn't streamed in yet. In Grand Theft Auto VI's world that is gigabytes of memory nothing reads: the title's streaming holds most textures at their small levels, and the large ones arrive later or never. It's a large part of why the world doesn't fit a 12 GB card.
Change
Opt-in, with
VICTORY_LEVELS_ON_DEMAND=1. It needs tiled resources tier 2 or higher.VICTORY_LEVELS_MIN_KB), that is not a render target, depth or unordered-access texture, gets a reserved host texture (CreateReservedResource, orCreateReservedResource2when it needs castable formats).UpdateTileMappings). Small levels that share the packed tail go together. The tiles come from a pool of 64 MiB heaps (tiles.rs).main's upload of unmapped title memory already gives, so the picture doesn't change.host_writtengives it every level first.host texturesline shows the textures alive, the MB given, the MB not allocated, and theUpdateTileMappingscalls.Measured
Grand Theft Auto VI Series X 1.0.2.1, the first mission's prison yard. RTX 5080 on Linux, Proton with vkd3d-proton 3.2.0, on our stack (this PR plus other open PRs). Same exe, with the switch off and on:
UpdateTileMappings) costs about 1 ms per frame. There were 140UpdateTileMappingscalls in all, about 0.25 ms in total, and none after streaming settled. The rest of the frame-time spread is the scene's own streaming, which looks the same with the switch off.UpdateTileMappingsbecomes sparse binding, and that path is what I measured.How it was found
507KAZ (who doesn't use GitHub; shared with permission) tuned fxceless/victory-fork on an RTX 4070 12 GB with 16 GB of RAM to get the world running. Of the fork's memory switches, this one made the difference: about 2.2–3.0 GB freed on his card. The mechanism is fxceless's (
tiles.rsin fxceless/victory-fork at9376fd6), ported ontomain's texture design.Differences from the fork:
mainhas no registry for them. GPU: textures viewed only from a smaller level are uploaded from it on #2149 would add the first-viewed one.The measurement above is ours.
Related
VICTORY_TEXTURE_MIP_DROP) drop top levels everywhere, which lowers quality. This keeps every level the title holds.Tested
cargo test -p victory-gpu --lib --features diagnostics tiles::(Windows build under Proton, RTX 5080): 4 passed. This includes the GPU testlevels_take_tiles_when_given_and_give_them_back, which gives tiles to levels of a real reserved texture.texture::: 3 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without--features diagnostics: clean.AI-assisted (Claude Code).
🤖 Generated with Claude Code