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

Open
github-bot wants to merge 8 commits from github-bot/gh-2389 into main AGit
Owner

@⁠desplmfao on GitHub · 2026-11-25 12:31 UTC · original
desplmfao:perf/texture-levels-on-demand → main · +1248 −23 · 6 files · 8 commits · open

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.

  • Which textures. A placed or streamed 2D title texture, one layer, of at least 1 MiB (VICTORY_LEVELS_MIN_KB), that is not a render target, depth or unordered-access texture, gets a reserved host texture (CreateReservedResource, or CreateReservedResource2 when it needs castable formats).
  • Which levels get memory. Only the levels whose title memory is committed get tiles, at the staging refresh that uploads them (UpdateTileMappings). Small levels that share the packed tail go together. The tiles come from a pool of 64 MiB heaps (tiles.rs).
  • Levels without tiles read as zeros. That is what main's upload of unmapped title memory already gives, so the picture doesn't change.
  • Host writes. Before the host GPU writes a reserved texture (copy, resolve, alias copy), host_written gives it every level first.
  • Status. A line next to the host textures line shows the textures alive, the MB given, the MB not allocated, and the UpdateTileMappings calls.

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:

switch off switch on
Video memory in use (whole card) ~14.5 GB ~9.5 GB
Levels not allocated – 3.9–4.6 GB
Frame time, same phase of the scene ~1,100–1,200 ms ~1,100–1,230 ms early, 946 settled
Picture – identical
  • Cost. The texture side (staging refresh including the held-level checks and UpdateTileMappings) costs about 1 ms per frame. There were 140 UpdateTileMappings calls 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.
  • Not tried: native Windows, and AMD. Under vkd3d-proton, UpdateTileMappings becomes 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.rs in fxceless/victory-fork at 9376fd6), ported onto main's texture design.

Differences from the fork:

  • No view clamping and no slot re-making. Levels without tiles read as zeros here.
  • No neighbour or first-viewed checks, because main has no registry for them. #2149 would add the first-viewed one.
  • No card-budget gate.

The measurement above is ours.

  • #2149 reads, uploads and watches only from a texture's first viewed level on. It explicitly leaves out the video memory of unread levels, which is what this saves, so the two complement each other.
  • #1272 and #2146 (VICTORY_TEXTURE_MIP_DROP) drop top levels everywhere, which lowers quality. This keeps every level the title holds.
  • #2161 frees idle placed textures. That's a different axis (whole textures, not levels).

Tested

  • cargo test -p victory-gpu --lib --features diagnostics tiles:: (Windows build under Proton, RTX 5080): 4 passed. This includes the GPU test levels_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

**@⁠desplmfao** on GitHub · 2026-11-25 12:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389) `desplmfao:perf/texture-levels-on-demand` → `main` · +1248 −23 · 6 files · 8 commits · open ## 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. - **Which textures.** A placed or streamed 2D title texture, one layer, of at least 1 MiB (`VICTORY_LEVELS_MIN_KB`), that is not a render target, depth or unordered-access texture, gets a **reserved** host texture (`CreateReservedResource`, or `CreateReservedResource2` when it needs castable formats). - **Which levels get memory.** Only the levels whose title memory is committed get tiles, at the staging refresh that uploads them (`UpdateTileMappings`). Small levels that share the packed tail go together. The tiles come from a pool of 64 MiB heaps (`tiles.rs`). - **Levels without tiles read as zeros.** That is what `main`'s upload of unmapped title memory already gives, so the picture doesn't change. - **Host writes.** Before the host GPU writes a reserved texture (copy, resolve, alias copy), `host_written` gives it every level first. - **Status.** A line next to the `host textures` line shows the textures alive, the MB given, the MB not allocated, and the `UpdateTileMappings` calls. ## 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: | | switch off | switch on | |---|---|---| | Video memory in use (whole card) | ~14.5 GB | **~9.5 GB** | | Levels not allocated | – | 3.9–4.6 GB | | Frame time, same phase of the scene | ~1,100–1,200 ms | ~1,100–1,230 ms early, 946 settled | | Picture | – | identical | - **Cost.** The texture side (staging refresh including the held-level checks and `UpdateTileMappings`) costs about 1 ms per frame. There were 140 `UpdateTileMappings` calls 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. - **Not tried:** native Windows, and AMD. Under vkd3d-proton, `UpdateTileMappings` becomes 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.rs` in fxceless/victory-fork at `9376fd6`), ported onto `main`'s texture design. Differences from the fork: - No view clamping and no slot re-making. Levels without tiles read as zeros here. - No neighbour or first-viewed checks, because `main` has no registry for them. #2149 would add the first-viewed one. - No card-budget gate. The measurement above is ours. ## Related - **#2149** reads, uploads and watches only from a texture's first viewed level on. It explicitly leaves out the video memory of unread levels, which is what this saves, so the two complement each other. - **#1272 and #2146** (`VICTORY_TEXTURE_MIP_DROP`) drop top levels everywhere, which lowers quality. This keeps every level the title holds. - **#2161** frees idle placed textures. That's a different axis (whole textures, not levels). ## Tested - `cargo test -p victory-gpu --lib --features diagnostics tiles::` (Windows build under Proton, RTX 5080): 4 passed. This includes the GPU test `levels_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](https://claude.com/claude-code)
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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #2389.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:24 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 13:16 UTC · original

I ran levels_take_tiles_when_given_and_give_them_back at 0db32bd on native Windows with an RTX 4070 Ti (621.01, tiled resources tier 4) and WARP (tier 3).

Both adapters passed with the debug layer off. With VICTORY_D3D12_DEBUG=1, both reached the final mapping step, then the test process exited with code 2173 before reporting a result. I added a test-only queue wait by submitting an empty list through host.execute before dropping the tiled texture. With that wait, the test passed on both adapters with the debug layer enabled.

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.

**@⁠DrDarkDK** on GitHub · 2026-11-25 13:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7163541338) I ran `levels_take_tiles_when_given_and_give_them_back` at `0db32bd` on native Windows with an RTX 4070 Ti (621.01, tiled resources tier 4) and WARP (tier 3). Both adapters passed with the debug layer off. With `VICTORY_D3D12_DEBUG=1`, both reached the final mapping step, then the test process exited with code 2173 before reporting a result. I added a test-only queue wait by submitting an empty list through `host.execute` before dropping the tiled texture. With that wait, the test passed on both adapters with the debug layer enabled. 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.*
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 13:22 UTC · original

@⁠DrDarkDK thanks, that was a real gap in the fixture. Fixed in 8c896eb, the way you suggested: an empty submission through host.execute, which submits and waits, now runs before the tiled texture is dropped. That way the queued UpdateTileMappings are done before the heaps go back to the pool.

I also checked whether the title can hit the same thing, and it can't. Tiled lives inside the host texture, and Tiled::give only runs while uploading for a list (texture.rs). That list keeps the texture alive, and its mappings are queued on the same queue ahead of it, so in the game the heaps never go back while a mapping is pending. Only the test dropped the texture right after mapping.

On the RTX 5080 under Wine with vkd3d-proton, tiles:: gives 4 passed, and clippy is clean. I couldn't reproduce the debug-layer exit here, since there's no D3D12 debug layer under vkd3d. A rerun on your 4070 Ti with VICTORY_D3D12_DEBUG=1 would confirm it.

**@⁠desplmfao** on GitHub · 2026-11-25 13:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7163676409) @⁠DrDarkDK thanks, that was a real gap in the fixture. Fixed in `8c896eb`, the way you suggested: an empty submission through `host.execute`, which submits and waits, now runs before the tiled texture is dropped. That way the queued `UpdateTileMappings` are done before the heaps go back to the pool. I also checked whether the title can hit the same thing, and it can't. `Tiled` lives inside the host texture, and `Tiled::give` only runs while uploading for a list (`texture.rs`). That list keeps the texture alive, and its mappings are queued on the same queue ahead of it, so in the game the heaps never go back while a mapping is pending. Only the test dropped the texture right after mapping. On the RTX 5080 under Wine with vkd3d-proton, `tiles::` gives 4 passed, and clippy is clean. I couldn't reproduce the debug-layer exit here, since there's no D3D12 debug layer under vkd3d. A rerun on your 4070 Ti with `VICTORY_D3D12_DEBUG=1` would confirm it.
Author
Owner

@⁠pickles976 on GitHub · 2026-11-25 15:07 UTC · original

Independent RTX 4060 Laptop / Wine check of 8c896ebb1650d1575fee2a1689a03804e4e04a83, including the mapping-wait fixture fix. The initial test runs used an isolated, unmodified copy of this exact head, not our title integration tree.

Tested

  • RTX 4060 Laptop, 8 GiB VRAM; Intel i7-13620H; 16 GiB system RAM; NVIDIA 590.48.01; Linux 6.17.0-40-generic; Wine 11.0, DXVK 3.1.1-209, stock vkd3d-proton 3.2.0 (2576c0b4adfae4a). Rust 1.98.1, debug, Windows MSVC cross-build with Wine as the Cargo runner; VICTORY_ADAPTER=nvidia.
  • Commands after configuring the Windows SDK linker environment:
    cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-gpu --lib --features diagnostics tiles:: -- --test-threads=1 --nocapture
    cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-gpu --lib --features diagnostics texture:: -- --test-threads=1 --nocapture
    
    Results: 4 passed / 0 failed / 0 ignored, then 3 passed / 0 failed / 0 ignored.
  • To rule out the GPU fixture's silent early-return paths, I separately replaced only its missing-host and insufficient-tier returns with test assertions in a temporary checkout and reran levels_take_tiles_when_given_and_give_them_back. 1 passed; reported tiled-resource tier 4. The real reserved-texture mapping, packed-tail, repeated-give and teardown assertions were reached. No runtime code was changed for that probe.

Not tested
Full workspace suite, native Windows, the D3D12 debug layer, AMD/Intel, or title streaming on this exact head. No claim of measured VRAM savings, playable world rendering, or fitting the game into 8 GiB follows from these synthetic tests.

AI use
omp with openai-codex/gpt-6-astra prepared the isolated checkouts, ran the checks and temporary no-skip probe, and drafted this report from the output.

**@⁠pickles976** on GitHub · 2026-11-25 15:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7166337420) Independent **RTX 4060 Laptop / Wine** check of `8c896ebb1650d1575fee2a1689a03804e4e04a83`, including the mapping-wait fixture fix. The initial test runs used an isolated, unmodified copy of this exact head, not our title integration tree. **Tested** - RTX 4060 Laptop, 8 GiB VRAM; Intel i7-13620H; 16 GiB system RAM; NVIDIA 590.48.01; Linux 6.17.0-40-generic; Wine 11.0, DXVK 3.1.1-209, stock vkd3d-proton 3.2.0 (`2576c0b4adfae4a`). Rust 1.98.1, debug, Windows MSVC cross-build with Wine as the Cargo runner; `VICTORY_ADAPTER=nvidia`. - Commands after configuring the Windows SDK linker environment: ```sh cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-gpu --lib --features diagnostics tiles:: -- --test-threads=1 --nocapture cargo +1.98.1 test --locked --target x86_64-pc-windows-msvc -p victory-gpu --lib --features diagnostics texture:: -- --test-threads=1 --nocapture ``` Results: **4 passed / 0 failed / 0 ignored**, then **3 passed / 0 failed / 0 ignored**. - To rule out the GPU fixture's silent early-return paths, I separately replaced only its missing-host and insufficient-tier returns with test assertions in a temporary checkout and reran `levels_take_tiles_when_given_and_give_them_back`. **1 passed; reported tiled-resource tier 4.** The real reserved-texture mapping, packed-tail, repeated-give and teardown assertions were reached. No runtime code was changed for that probe. **Not tested** Full workspace suite, native Windows, the D3D12 debug layer, AMD/Intel, or title streaming on this exact head. No claim of measured VRAM savings, playable world rendering, or fitting the game into 8 GiB follows from these synthetic tests. **AI use** omp with `openai-codex/gpt-6-astra` prepared the isolated checkouts, ran the checks and temporary no-skip probe, and drafted this report from the output.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:02 UTC · original · edited 2026-11-26 08:25 UTC

Automated triage for the maintainers.

Merge candidate. bb9ab45 addresses both points from the last triage. In crates/victory-gpu/src/resource.rs, HostTexture::held_bytes() returns the allocation for an ordinary texture and Tiled::given_bytes() (the tiles its levels hold) for a tiled one. evict_among/choose and give_up now use it, so giving up a tiled texture is credited with what it frees. evict_unused subtracts tiles::free_bytes() next to placement::free_bytes(). The default path is unchanged when VICTORY_LEVELS_ON_DEMAND is unset: reserved_texture returns None, and tiles::status() returns early when no tiled texture was made. CI check passes and the PR merges cleanly.

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

**@⁠Marvisak** on GitHub · 2026-11-25 16:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7167543587) · edited 2026-11-26 08:25 UTC <!-- victory-triage v1 head=bb9ab450759cf5be2bb776f0cf690945d67fc9a2 verdict=merge-candidate at=2026-11-26T08:20:18Z --> Automated triage for the maintainers. **Merge candidate.** `bb9ab45` addresses both points from the last triage. In `crates/victory-gpu/src/resource.rs`, `HostTexture::held_bytes()` returns the allocation for an ordinary texture and `Tiled::given_bytes()` (the tiles its levels hold) for a tiled one. `evict_among`/`choose` and `give_up` now use it, so giving up a tiled texture is credited with what it frees. `evict_unused` subtracts `tiles::free_bytes()` next to `placement::free_bytes()`. The default path is unchanged when `VICTORY_LEVELS_ON_DEMAND` is unset: `reserved_texture` returns `None`, and `tiles::status()` returns early when no tiled texture was made. CI `check` passes and the PR merges cleanly. 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](https://claude.ai/code)_
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 16:19 UTC · original

Merged main in ef1dcd6 and 29f572a (merge commits, no rebase). main had reworked texture creation in the meantime: textures fed from title memory are placed in heaps made ahead, made on first use and several at a time, uploads come from large staging buffers, and only subresources whose bytes changed are uploaded. The hooks moved:

  • resource.rs: with VICTORY_LEVELS_ON_DEMAND=1, an eligible streamed texture is made reserved before main's heap placement, so it never goes into a heap made ahead. If the reserved texture can't be made, it falls through to main's placement or committed path unchanged. With the switch off, reserved_texture returns None immediately and creation is exactly main's.
  • texture.rs: main now uploads only changed subresources, but a level that just got tiles has to be uploaded whether it changed or not (its tiles may hold a previous owner's data). A pending level mask on Staging covers those levels. They're detiled and uploaded at the next refresh, and they go back into the mask if a detile fails. host_written became main's host_writes: a reserved texture a host copy writes gets every level its tiles before that submission's upload list, which runs ahead of the copy.
  • list.rs: identical to main.
  • tiles.rs: Tiled::without is no longer test-only, and the module note describes the new flow.

tiles::, texture:: and resource:: give 24 passed under Wine on an RTX 5080, and clippy is clean with and without --features diagnostics. The in-title check on this merged head (picture and video memory) is still to come. I'll post it here.

**@⁠desplmfao** on GitHub · 2026-11-25 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7167793583) Merged `main` in `ef1dcd6` and `29f572a` (merge commits, no rebase). `main` had reworked texture creation in the meantime: textures fed from title memory are placed in heaps made ahead, made on first use and several at a time, uploads come from large staging buffers, and only subresources whose bytes changed are uploaded. The hooks moved: - **resource.rs:** with `VICTORY_LEVELS_ON_DEMAND=1`, an eligible streamed texture is made reserved *before* `main`'s heap placement, so it never goes into a heap made ahead. If the reserved texture can't be made, it falls through to `main`'s placement or committed path unchanged. With the switch off, `reserved_texture` returns `None` immediately and creation is exactly `main`'s. - **texture.rs:** `main` now uploads only changed subresources, but a level that just got tiles has to be uploaded whether it changed or not (its tiles may hold a previous owner's data). A `pending` level mask on `Staging` covers those levels. They're detiled and uploaded at the next refresh, and they go back into the mask if a detile fails. `host_written` became `main`'s `host_writes`: a reserved texture a host copy writes gets every level its tiles before that submission's upload list, which runs ahead of the copy. - **list.rs:** identical to `main`. - **tiles.rs:** `Tiled::without` is no longer test-only, and the module note describes the new flow. `tiles::`, `texture::` and `resource::` give 24 passed under Wine on an RTX 5080, and clippy is clean with and without `--features diagnostics`. The in-title check on this merged head (picture and video memory) is still to come. I'll post it here.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 01:31 UTC · original

Both points are fixed in bb9ab45, on top of a fresh merge of main (67a6614):

  • Eviction: HostTexture::held_bytes() returns the allocation for an ordinary texture. For a tiled one, it returns the bytes of the tiles its levels have (Tiled::given_bytes, which was test-only and isn't any more). evict_among/choose and give_up use it, so giving up a tiled texture is credited with what it really frees.
  • Free tiles: tiles::free_bytes() is subtracted in evict_unused, next to placement::free_bytes().

The tile test now also checks the pool's free bytes as a level takes its tiles. tiles::, texture:: and resource:: give 25 passed under Wine (RTX 5080), and clippy is clean with and without diagnostics.

From an in-title A/B on this branch (fork build, before this fix; ~3 min in the world each, medians):

VICTORY_LEVELS_ON_DEMAND ms/frame GPU peak video memory
1 741 399 11,047 MiB
0 788 416 12,434 MiB

So no frame-time cost, and about 1.4 GB less.

**@⁠desplmfao** on GitHub · 2026-11-26 01:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7179857548) Both points are fixed in `bb9ab45`, on top of a fresh merge of `main` (`67a6614`): - **Eviction:** `HostTexture::held_bytes()` returns the allocation for an ordinary texture. For a tiled one, it returns the bytes of the tiles its levels have (`Tiled::given_bytes`, which was test-only and isn't any more). `evict_among`/`choose` and `give_up` use it, so giving up a tiled texture is credited with what it really frees. - **Free tiles:** `tiles::free_bytes()` is subtracted in `evict_unused`, next to `placement::free_bytes()`. The tile test now also checks the pool's free bytes as a level takes its tiles. `tiles::`, `texture::` and `resource::` give 25 passed under Wine (RTX 5080), and clippy is clean with and without diagnostics. From an in-title A/B on this branch (fork build, before this fix; ~3 min in the world each, medians): | `VICTORY_LEVELS_ON_DEMAND` | ms/frame | GPU | peak video memory | |---|---:|---:|---:| | 1 | 741 | 399 | 11,047 MiB | | 0 | 788 | 416 | 12,434 MiB | So no frame-time cost, and about 1.4 GB less.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 01:54 UTC · original

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 main's texture rework: heaps made ahead, uploads from staging buffers, and only changed subresources uploaded. On current main, the in-title A/B above gives about 1.4 GB less peak video memory (11,047 against 12,434 MiB) with no frame-time cost. So main itself now spends much less on streamed textures, and the switch saves correspondingly less on top of it.

**@⁠desplmfao** on GitHub · 2026-11-26 01:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7180267122) 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 `main`'s texture rework: heaps made ahead, uploads from staging buffers, and only changed subresources uploaded. On current `main`, the in-title A/B above gives about 1.4 GB less peak video memory (11,047 against 12,434 MiB) with no frame-time cost. So `main` itself now spends much less on streamed textures, and the switch saves correspondingly less on top of it.
github-bot changed title from GPU: streamed textures take video memory only for the levels the title holds (opt-in, ~5 GB less) to GPU: streamed textures take video memory only for the levels the title holds (opt-in; 0.4-1.4 GB less on current main) 2026-11-26 08:07:24 +00:00
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 12:36 UTC · original · reviewed

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.

**@⁠catminou4** on GitHub · 2026-11-25 12:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#pullrequestreview-6057697815) · **reviewed** 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.
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 04:35 UTC · original

@/tmp/v2389c.md

**@⁠pickles976** on GitHub · 2026-11-26 04:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7182725423) @/tmp/v2389c.md
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-26 07:13 UTC · original

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 main 63bcca4 and one of main + this PR (bb9ab45) with VICTORY_LEVELS_ON_DEMAND=1. Same save, standing still in the world. The numbers come from the process's own report lines (video memory: via QueryVideoMemoryInfo and GetProcessMemoryInfo, host textures:, this PR's line), read 120 s after the first report where textures used by lists pass 1 GB.

main this PR
video memory on the card 6,512 MB 6,112 MB
process commit 25,341 MB 24,775 MB
host textures 5,842 MB 5,226 MB
of them used by lists 3,697 MB 3,180 MB
levels not allocated – 218 MB (peak 266)

The switch line reports tier=4 on=true. The PR's own line said 213 alive (267 made so far), 159 MB given to 506 levels alive; 210 MB not allocated (369 MB if every level had memory), with 577 UpdateTileMappings calls in all. There were no refreshes without memory, and the run exited cleanly.

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** on GitHub · 2026-11-26 07:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7185226208) 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 `main` 63bcca4 and one of `main` + this PR (bb9ab45) with `VICTORY_LEVELS_ON_DEMAND=1`. Same save, standing still in the world. The numbers come from the process's own report lines (`video memory:` via `QueryVideoMemoryInfo` and `GetProcessMemoryInfo`, `host textures:`, this PR's line), read 120 s after the first report where textures used by lists pass 1 GB. | | `main` | this PR | |---|---|---| | video memory on the card | 6,512 MB | 6,112 MB | | process commit | 25,341 MB | 24,775 MB | | host textures | 5,842 MB | 5,226 MB | | of them used by lists | 3,697 MB | 3,180 MB | | levels not allocated | – | 218 MB (peak 266) | The switch line reports `tier=4 on=true`. The PR's own line said `213 alive (267 made so far), 159 MB given to 506 levels alive; 210 MB not allocated (369 MB if every level had memory)`, with 577 `UpdateTileMappings` calls in all. There were no refreshes without memory, and the run exited cleanly. 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](https://claude.com/claude-code) (Claude Opus 5.5)
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 08:02 UTC · original

@⁠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 main's texture rework, main itself spends much less on streamed textures, and only the textures that pass the filter can save anything (213 of yours). The "~5 GB" in the title came from the older base, so I've changed the title to "0.4–1.4 GB less on current main".

**@⁠desplmfao** on GitHub · 2026-11-26 08:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7186116526) @⁠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 `main`'s texture rework, `main` itself spends much less on streamed textures, and only the textures that pass the filter can save anything (213 of yours). The "~5 GB" in the title came from the older base, so I've changed the title to "0.4–1.4 GB less on current main".
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 11:39 UTC · original · requested changes

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:

  1. Blocking — Tiled::drop recycles tiles and destroys ID3D12Heap while ID3D12Resource still 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 of Host::execute), and HostList::keep hold COM clones of ID3D12Resource (copy.texture), not Arc<HostTexture>. That is why placement.rs defers freeing heap ranges and empty heaps in HostTexture::drop via placement::free(self.texture.clone(), p) until last_holder(&resource) confirms no other COM reference remains.
    • Tiled::drop instead calls give_back immediately when Arc<HostTexture> drops. In normal execution this happens both when the title releases a texture whose descriptor-heap slot still views it, and during evict_unused() -> give_up() (which moves ID3D12Resource into RETIRED via descriptor::evict, then drops Arc<HostTexture> immediately at the start of Host::execute, ahead of bindless::uploads and release_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 A with 0xAA, keeping a live ID3D12Resource clone (as HostHeap::kept / RETIRED does), dropping Tiled, then allocating texture B and filling it with 0x55 hands A's exact physical tile run (0, 32) to B and silently overwrites A (before=[aa, aa, aa, aa, aa, aa, aa, aa] -> after_B_wrote_0x55=[55, 55, 55, 55, 55, 55, 55, 55]).
      • Premature ID3D12Heap destruction / GPU fault (RTX 5090, both with and without VICTORY_D3D12_DEBUG=1): with two 64 MiB heaps in POOL, dropping the Tiled owners on heap 0 while one ID3D12Resource clone remains live immediately drops heap 0 (pool[index] = None, heaps_mb=128->64, given_back=0->1); a subsequent CopyTextureRegion from that live ID3D12Resource crashes the process on RTX 5090 with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) even without the debug layer.
    • Fix: mirror placement.rs by passing (self.texture.clone(), runs) from HostTexture::drop into a pending list in tiles.rs, and only returning tile runs / releasing empty heaps once last_holder(&resource) is true (and after any queued UpdateTileMappings have completed).
  2. Blocking — host_writes calls tiled.give (UpdateTileMappings) at command-list record time (crates/victory-gpu/src/texture.rs:243-264):

    • Calling tiled.give(&copy.texture, every) directly from host_writes (texture.rs:254) queues UpdateTileMappings onto host.queue() from recording threads before Host::execute.
    • If a recorded list is reset or dropped without being executed (or the texture is dropped before a submission drains the queue), Tiled::drop destroys the backing heap while UpdateTileMappings is still in flight on host.queue() — reproduced live with exit code 2173 on both RTX 5090 and WARP under VICTORY_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 setting pending) until submission preparation inside Host::execute (ahead of list's upload list, matching Staging::give_held and list.defer_host).

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 11:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#pullrequestreview-6073508365) · **requested changes** 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: 1. **Blocking — `Tiled::drop` recycles tiles and destroys `ID3D12Heap` while `ID3D12Resource` still 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 of `Host::execute`), and `HostList::keep` hold COM clones of `ID3D12Resource` (`copy.texture`), not `Arc<HostTexture>`. That is why `placement.rs` defers freeing heap ranges and empty heaps in `HostTexture::drop` via `placement::free(self.texture.clone(), p)` until `last_holder(&resource)` confirms no other COM reference remains. - `Tiled::drop` instead calls `give_back` immediately when `Arc<HostTexture>` drops. In normal execution this happens both when the title releases a texture whose descriptor-heap slot still views it, and during `evict_unused()` -> `give_up()` (which moves `ID3D12Resource` into `RETIRED` via `descriptor::evict`, then drops `Arc<HostTexture>` immediately at the start of `Host::execute`, ahead of `bindless::uploads` and `release_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 `A` with `0xAA`, keeping a live `ID3D12Resource` clone (as `HostHeap::kept` / `RETIRED` does), dropping `Tiled`, then allocating texture `B` and filling it with `0x55` hands `A`'s exact physical tile run `(0, 32)` to `B` and silently overwrites `A` (`before=[aa, aa, aa, aa, aa, aa, aa, aa]` -> `after_B_wrote_0x55=[55, 55, 55, 55, 55, 55, 55, 55]`). - **Premature `ID3D12Heap` destruction / GPU fault (RTX 5090, both with and without `VICTORY_D3D12_DEBUG=1`)**: with two 64 MiB heaps in `POOL`, dropping the `Tiled` owners on heap 0 while one `ID3D12Resource` clone remains live immediately drops heap 0 (`pool[index] = None`, `heaps_mb=128->64, given_back=0->1`); a subsequent `CopyTextureRegion` from that live `ID3D12Resource` crashes the process on RTX 5090 with `0xc0000409 (STATUS_STACK_BUFFER_OVERRUN)` even without the debug layer. - Fix: mirror `placement.rs` by passing `(self.texture.clone(), runs)` from `HostTexture::drop` into a pending list in `tiles.rs`, and only returning tile runs / releasing empty heaps once `last_holder(&resource)` is true (and after any queued `UpdateTileMappings` have completed). 2. **Blocking — `host_writes` calls `tiled.give` (`UpdateTileMappings`) at command-list record time (`crates/victory-gpu/src/texture.rs:243-264`)**: - Calling `tiled.give(&copy.texture, every)` directly from `host_writes` (`texture.rs:254`) queues `UpdateTileMappings` onto `host.queue()` from recording threads before `Host::execute`. - If a recorded list is reset or dropped without being executed (or the texture is dropped before a submission drains the queue), `Tiled::drop` destroys the backing heap while `UpdateTileMappings` is still in flight on `host.queue()` — reproduced live with exit code `2173` on both RTX 5090 and WARP under `VICTORY_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 setting `pending`) until submission preparation inside `Host::execute` (ahead of `list`'s upload list, matching `Staging::give_held` and `list.defer_host`). 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.
Fixes the two blocking bugs and the minor one from fuzeofficlal's review
of #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 <[email protected]>
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 12:46 UTC · original

@⁠fuzeofficlal thanks, both were real. Fixed in 6b91df4:

  1. Tiles given back under live clones: HostTexture::drop now hands its resource and its Tiled to tiles::free, as it already does with placement::free for placed textures. tiles::reap gives the tiles back, and frees an empty heap, only when placement::last_holder(&resource) is true and every UpdateTileMappings queued before the texture was let go has run. Host::execute reads the mapping counter before signalling its fence and records it as run only after its waits succeed. reap runs after release_retired(), at the start of take(), and in free_bytes(). It releases the resource first and gives the tiles back outside the lock.
  2. Mappings at record time: host_writes now only notes the texture in the list (HostList::defer_tiles, cleared by a reset). Host::execute gives the tiles after sync_heaps and ahead of bindless::uploads (texture::give_for_host_writes). One difference from your suggestion: pending is set there too, not in host_writes. Otherwise a list dropped unrun would leave pending set, and a later refresh would give tiles for a write that never happened. Every mapping is now queued while a submission is prepared, and that submission waits for it.
  3. refresh_now, untracked and partly committed: for levels-on-demand textures it now reads through copy_mapped (zeros where unmapped), then hashes, calls give_held, detiles and uploads like the committed path. So the mapped small levels get their tiles and their bytes. Committed textures keep the old zero upload.

Two new tests, both failing with the old behaviour:

  • tiles::tests::tiles_go_back_only_once_nothing_holds_the_texture_and_its_mappings_ran (your repro: a clone of the resource held, then a new texture given level 0 gets no overlapping tiles)
  • resource::tests::a_host_write_gives_tiles_at_submission_not_when_recorded

Clippy is clean with and without diagnostics. Under Wine (RTX 5080), the full victory-gpu run has the same 30 failures as main there. In the title with VICTORY_LEVELS_ON_DEMAND=1 it runs into the world with no crash and no tile warnings, and video memory is in the same range as before (~10.3 GB). I couldn't confirm that VICTORY_D3D12_DEBUG=1 reaches the debug layer under vkd3d-proton, so a rerun of your RTX 5090/WARP repro would be the real check.

**@⁠desplmfao** on GitHub · 2026-11-26 12:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#issuecomment-7192433156) @⁠fuzeofficlal thanks, both were real. Fixed in `6b91df4`: 1. **Tiles given back under live clones:** `HostTexture::drop` now hands its resource and its `Tiled` to `tiles::free`, as it already does with `placement::free` for placed textures. `tiles::reap` gives the tiles back, and frees an empty heap, only when `placement::last_holder(&resource)` is true and every `UpdateTileMappings` queued before the texture was let go has run. `Host::execute` reads the mapping counter before signalling its fence and records it as run only after its waits succeed. `reap` runs after `release_retired()`, at the start of `take()`, and in `free_bytes()`. It releases the resource first and gives the tiles back outside the lock. 2. **Mappings at record time:** `host_writes` now only notes the texture in the list (`HostList::defer_tiles`, cleared by a reset). `Host::execute` gives the tiles after `sync_heaps` and ahead of `bindless::uploads` (`texture::give_for_host_writes`). One difference from your suggestion: `pending` is set there too, not in `host_writes`. Otherwise a list dropped unrun would leave `pending` set, and a later refresh would give tiles for a write that never happened. Every mapping is now queued while a submission is prepared, and that submission waits for it. 3. **`refresh_now`, untracked and partly committed:** for levels-on-demand textures it now reads through `copy_mapped` (zeros where unmapped), then hashes, calls `give_held`, detiles and uploads like the committed path. So the mapped small levels get their tiles and their bytes. Committed textures keep the old zero upload. Two new tests, both failing with the old behaviour: - `tiles::tests::tiles_go_back_only_once_nothing_holds_the_texture_and_its_mappings_ran` (your repro: a clone of the resource held, then a new texture given level 0 gets no overlapping tiles) - `resource::tests::a_host_write_gives_tiles_at_submission_not_when_recorded` Clippy is clean with and without diagnostics. Under Wine (RTX 5080), the full `victory-gpu` run has the same 30 failures as `main` there. In the title with `VICTORY_LEVELS_ON_DEMAND=1` it runs into the world with no crash and no tile warnings, and video memory is in the same range as before (~10.3 GB). I couldn't confirm that `VICTORY_D3D12_DEBUG=1` reaches the debug layer under vkd3d-proton, so a rerun of your RTX 5090/WARP repro would be the real check.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 13:09 UTC · original · approved these changes

Re-reviewed and re-verified 6b91df4a (based on origin/main 63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 tier 4 and WARP tier 3, Rust 1.98.1 MSVC, Windows SDK 10.0.26100.0 dxil.dll; synthetic tests only, no game files).

All three issues from the previous review are cleanly fixed and verified:

  1. Deferred tile & heap reclamation (crates/victory-gpu/src/resource.rs:994-996, tiles.rs:213-275, host.rs:1290,1340,1459):
    • HostTexture::drop now routes through tiles::free(self.texture.clone(), tiled), and tiles::reap() releases texture before dropping tiled outside the lock only once freed[i].queued <= ran and placement::last_holder(&freed[i].texture) is true.
    • Live COM-clone aliasing probe re-run (0xAA vs 0x55): before=[aa, aa, aa, aa, aa, aa, aa, aa], after_B_wrote_0x55=[aa, aa, aa, aa, aa, aa, aa, aa], 0 D3D12 Debug Layer messages on both RTX 5090 and WARP (was silent 0x55 overwrite on bb9ab450).
    • 2-heap premature heap destruction probe re-run: while a live COM clone remains on heap 0, heaps_mb=128->128, given_back=0->0, and CopyTextureRegion succeeds cleanly with 0 errors on pure RTX 5090 (no debug layer), RTX 5090 (VICTORY_D3D12_DEBUG=1), and WARP (VICTORY_D3D12_DEBUG=1) (was a 0xc0000409 crash on RTX 5090 on bb9ab450). Dropping the last COM clone and calling reap() cleanly returns heap 0 (heaps_mb=128->64, given_back=0->1).
  2. Deferred host_writes tile mapping (crates/victory-gpu/src/texture.rs:247-285, host.rs:1219-1223,2321-2330):
    • host_writes now records only HostList::defer_tiles (cleared by HostList::reset), and give_for_host_writes runs inside Host::execute ahead of bindless::uploads, also setting staging.pending there so unrun lists never dirty pending.
    • Re-run probe on RTX 5090 & WARP (VICTORY_D3D12_DEBUG=1): tiles::queued() stays unchanged at record time, reset and earlier out-of-order submissions see 0 tiles, unrun dropped lists tear down cleanly (exit 0; previously exit code 2173), and actual submission maps all levels with 0 debug messages.
  3. Untracked partially-committed reserved textures (crates/victory-gpu/src/texture.rs:703-708): now read via copy_mapped into Scratch so committed small mips flow through give_held and upload properly.

Verification

  • cargo xtask policy: 192 files ok.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features): 0 warnings.
  • RTX 5090 (VICTORY_D3D12_DEBUG=1, VICTORY_LEVELS_ON_DEMAND=1, --features diagnostics, --test-threads=1): tiles::tests, texture::tests, resource::tests, draw::tests — 47 passed, 0 failed.
  • WARP (VICTORY_D3D12_WARP=1, VICTORY_D3D12_DEBUG=1, VICTORY_LEVELS_ON_DEMAND=1, --features diagnostics): 47 passed, 0 failed.

Non-blocking Test Note

  • Running tiles::tests in parallel under VICTORY_D3D12_DEBUG=1 on RTX 5090 hit a test-only race on the global POOL between levels_take_tiles_when_given_and_give_them_back (crates/victory-gpu/src/tiles.rs:689-697) and the new tiles_go_back_only_once_nothing_holds_the_texture_and_its_mappings_ran: both grab 32 tiles from the first 64 MiB heap concurrently, causing line 697 to panic (65011712 0) and unwinding to drop the test's bare Tiled without tiles::free (exit code 2173 under the debug layer). Serializing the POOL-measuring tests in tiles::tests with a test-only Mutex<()> would avoid parallel test flakiness.
  • Note for maintainers: when merging alongside #2101, #2101's test call make_texture(&d, 0, std::ptr::null()) will need the 4th false (on_demand) argument added here.

Production lifetime and synchronization issues are fully resolved. Approved.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 13:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2389#pullrequestreview-6074678042) · **approved these changes** Re-reviewed and re-verified `6b91df4a` (based on `origin/main` `63bcca43`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 tier 4 and WARP tier 3, Rust `1.98.1` MSVC, Windows SDK `10.0.26100.0` `dxil.dll`; synthetic tests only, no game files). All three issues from the previous review are cleanly fixed and verified: 1. **Deferred tile & heap reclamation (`crates/victory-gpu/src/resource.rs:994-996`, `tiles.rs:213-275`, `host.rs:1290,1340,1459`):** - `HostTexture::drop` now routes through `tiles::free(self.texture.clone(), tiled)`, and `tiles::reap()` releases `texture` before dropping `tiled` outside the lock only once `freed[i].queued <= ran` and `placement::last_holder(&freed[i].texture)` is true. - **Live COM-clone aliasing probe re-run (`0xAA` vs `0x55`):** `before=[aa, aa, aa, aa, aa, aa, aa, aa]`, `after_B_wrote_0x55=[aa, aa, aa, aa, aa, aa, aa, aa]`, 0 D3D12 Debug Layer messages on both RTX 5090 and WARP (was silent `0x55` overwrite on `bb9ab450`). - **2-heap premature heap destruction probe re-run:** while a live COM clone remains on heap 0, `heaps_mb=128->128`, `given_back=0->0`, and `CopyTextureRegion` succeeds cleanly with 0 errors on **pure RTX 5090 (no debug layer)**, **RTX 5090 (`VICTORY_D3D12_DEBUG=1`)**, and **WARP (`VICTORY_D3D12_DEBUG=1`)** (was a `0xc0000409` crash on RTX 5090 on `bb9ab450`). Dropping the last COM clone and calling `reap()` cleanly returns heap 0 (`heaps_mb=128->64, given_back=0->1`). 2. **Deferred `host_writes` tile mapping (`crates/victory-gpu/src/texture.rs:247-285`, `host.rs:1219-1223,2321-2330`):** - `host_writes` now records only `HostList::defer_tiles` (cleared by `HostList::reset`), and `give_for_host_writes` runs inside `Host::execute` ahead of `bindless::uploads`, also setting `staging.pending` there so unrun lists never dirty `pending`. - **Re-run probe on RTX 5090 & WARP (`VICTORY_D3D12_DEBUG=1`):** `tiles::queued()` stays unchanged at record time, reset and earlier out-of-order submissions see 0 tiles, unrun dropped lists tear down cleanly (exit 0; previously exit code `2173`), and actual submission maps all levels with 0 debug messages. 3. **Untracked partially-committed reserved textures (`crates/victory-gpu/src/texture.rs:703-708`):** now read via `copy_mapped` into `Scratch` so committed small mips flow through `give_held` and upload properly. ### Verification - `cargo xtask policy`: `192 files ok`. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): 0 warnings. - **RTX 5090 (`VICTORY_D3D12_DEBUG=1`, `VICTORY_LEVELS_ON_DEMAND=1`, `--features diagnostics`, `--test-threads=1`):** `tiles::tests`, `texture::tests`, `resource::tests`, `draw::tests` — **47 passed, 0 failed**. - **WARP (`VICTORY_D3D12_WARP=1`, `VICTORY_D3D12_DEBUG=1`, `VICTORY_LEVELS_ON_DEMAND=1`, `--features diagnostics`):** **47 passed, 0 failed**. ### Non-blocking Test Note - Running `tiles::tests` in parallel under `VICTORY_D3D12_DEBUG=1` on RTX 5090 hit a test-only race on the global `POOL` between `levels_take_tiles_when_given_and_give_them_back` (`crates/victory-gpu/src/tiles.rs:689-697`) and the new `tiles_go_back_only_once_nothing_holds_the_texture_and_its_mappings_ran`: both grab 32 tiles from the first 64 MiB heap concurrently, causing line 697 to panic (`65011712 0`) and unwinding to drop the test's bare `Tiled` without `tiles::free` (`exit code 2173` under the debug layer). Serializing the `POOL`-measuring tests in `tiles::tests` with a test-only `Mutex<()>` would avoid parallel test flakiness. - Note for maintainers: when merging alongside `#2101`, `#2101`'s test call `make_texture(&d, 0, std::ptr::null())` will need the 4th `false` (`on_demand`) argument added here. Production lifetime and synchronization issues are fully resolved. Approved.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2389/head:github-bot/gh-2389'
git switch 'github-bot/gh-2389'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2389'
git switch 'github-bot/gh-2389'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2389'
git switch 'github-bot/gh-2389'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2389'
git switch 'main'
git merge --squash 'github-bot/gh-2389'
git switch 'main'
git merge --ff-only 'github-bot/gh-2389'
git switch 'main'
git merge 'github-bot/gh-2389'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2389
No description provided.