Host textures of placed textures come out of 64 MiB heaps (VICTORY_PLACED_TEX=1, off by default) #903

Open
github-bot wants to merge 1 commit from github-bot/gh-903 into main AGit
Owner

@⁠TG0000 on GitHub · 2026-11-25 12:20 UTC · original
TG0000:gpu/placed-textures → main · +410 −4 · 5 files · 1 commits · open

Making a host texture for one of the title's placed textures is a committed resource, a kernel allocation of its own. With VICTORY_PLACED_TEX=1 (off by default) those textures come out of 64 MiB heaps: only textures without target, depth or unordered access flags, up to 32 MiB, whose contents are uploaded whole. Others, and textures with levels on demand (tiles), are made as before.

How it works (placed.rs):

  • two kinds of heaps (4 KiB and 64 KiB placement), best fit, free ranges joined again;
  • a range belongs to the COM object, through a small object set as private data: it comes back with the last reference to the texture (slots, lists, title texture), and then only behind the submissions running at that moment (host::retire);
  • free bytes inside the heaps count as room for the texture queue; an empty heap is freed after 5 s, but for one of each kind.

New log line, also with the switch off: how many were made and the time each took.

Measured on an RX 6800 16 GB, Ryzen 5900X, Windows 11, one launch, both ways in the same launch in ABBA order (18 blocks, warm cache):

committed placed difference (95 %)
making one texture 599 us 21 us -562 ± 37 us
the "made" part of the texture pass, per frame 91.5 ms 10.8 ms -91 ± 34 ms (paired by block, so not the difference of the two medians)
whole pass over the heap, per frame 209 ms 114 ms -78 ± 49 ms
frame 486 ms 396 ms -82 ± 110 ms: not shown

0 of 32,349 textures had to be committed instead. Two whole launches, one each way and not matched: median 417 and 369 ms, the card's memory 10.1 and 10.9 GB (about 1.2 GB of it free inside heaps).

Not the same code base: those numbers are from a build on 7b0f736 with other changes of ours. Adapted to f85101b, the switch was on in three launches of 420 s of a combined build with no device removal; that build has more than this PR, so it says nothing about the gain. This head has not been run in a game.

Limits: no aliasing barrier between two textures that have a range one after the other (the first has finished, and the second is uploaded whole before it is read); the other readers of the card's memory budget count the heaps' free bytes as used; NVIDIA and Intel not tested; pictures compared by eye only, no new kind of fault seen.

Tests on this head (ca03c64, on a253706), Windows, RX 6800 and WARP, one thread: victory-gpu 170 passed, 1 failed; victory-shader 215 passed. The failure is warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which also failed 2 of 6 times on unchanged f85101b here (#847 and #849 are about it). Two of the tests are new. cargo clippy -D warnings for the Windows target, with and without all features, with #841's patch on top: one error, shadow.rs (is_multiple_of), the same on unchanged a253706.

Does it help elsewhere? The new log line with VICTORY_PLACED_TEX=0 and 1 on another card would tell.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠TG0000** on GitHub · 2026-11-25 12:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/903) `TG0000:gpu/placed-textures` → `main` · +410 −4 · 5 files · 1 commits · open Making a host texture for one of the title's placed textures is a committed resource, a kernel allocation of its own. With `VICTORY_PLACED_TEX=1` (off by default) those textures come out of 64 MiB heaps: only textures without target, depth or unordered access flags, up to 32 MiB, whose contents are uploaded whole. Others, and textures with levels on demand (`tiles`), are made as before. How it works (`placed.rs`): - two kinds of heaps (4 KiB and 64 KiB placement), best fit, free ranges joined again; - a range belongs to the COM object, through a small object set as private data: it comes back with the last reference to the texture (slots, lists, title texture), and then only behind the submissions running at that moment (`host::retire`); - free bytes inside the heaps count as room for the texture queue; an empty heap is freed after 5 s, but for one of each kind. New log line, also with the switch off: how many were made and the time each took. **Measured** on an RX 6800 16 GB, Ryzen 5900X, Windows 11, one launch, both ways in the same launch in ABBA order (18 blocks, warm cache): | | committed | placed | difference (95 %) | |---|---|---|---| | making one texture | 599 us | 21 us | -562 ± 37 us | | the "made" part of the texture pass, per frame | 91.5 ms | 10.8 ms | -91 ± 34 ms (paired by block, so not the difference of the two medians) | | whole pass over the heap, per frame | 209 ms | 114 ms | -78 ± 49 ms | | frame | 486 ms | 396 ms | -82 ± 110 ms: **not shown** | 0 of 32,349 textures had to be committed instead. Two whole launches, one each way and not matched: median 417 and 369 ms, the card's memory 10.1 and 10.9 GB (about 1.2 GB of it free inside heaps). **Not the same code base:** those numbers are from a build on 7b0f736 with other changes of ours. Adapted to f85101b, the switch was on in three launches of 420 s of a combined build with no device removal; that build has more than this PR, so it says nothing about the gain. **This head has not been run in a game.** Limits: no aliasing barrier between two textures that have a range one after the other (the first has finished, and the second is uploaded whole before it is read); the other readers of the card's memory budget count the heaps' free bytes as used; NVIDIA and Intel not tested; pictures compared by eye only, no new kind of fault seen. Tests on this head (ca03c64, on a253706), Windows, RX 6800 and WARP, one thread: victory-gpu 170 passed, 1 failed; victory-shader 215 passed. The failure is `warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, which also failed 2 of 6 times on unchanged f85101b here (#847 and #849 are about it). Two of the tests are new. `cargo clippy -D warnings` for the Windows target, with and without all features, with #841's patch on top: one error, `shadow.rs` (`is_multiple_of`), the same on unchanged a253706. Does it help elsewhere? The new log line with `VICTORY_PLACED_TEX=0` and `1` on another card would tell. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A committed resource is a kernel allocation of its own. Off by default. A
range comes back with the last reference to its texture, behind the
submissions running then.

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

@⁠wildheathen on GitHub · 2026-11-25 21:43 UTC · original

An NVIDIA data point for the idea, with a caveat first: the numbers below are from my own implementation of the same idea, not from this PR's head.

Machine: RTX 5080 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11, Series X profile.

What I ran: on ca8829f, plus #868 and a couple of other streaming changes:

  • shader-read-only host textures (no target, depth or UAV flags) placed in 256 MiB D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES heaps;
  • power-of-two pieces from 64 KiB to 16 MiB, at most 4 GiB in all;
  • a piece reused 5 s after its host texture is dropped. That rest is cruder than your COM ticket behind retire.

Results: A/B in one build with only the switch changed, two pairs, 480 s each, warm cache, DRED off. World = frame-rate lines with 500 or more draws.

committed (1 / 2) placed (1 / 2)
world mean frame 580 / 784 ms 300 / 311 ms
frame-rate lines over 1 s 8 / 16 3 / 2
median of the 5 s windows 327 / 405 ms 191 / 207 ms
frames presented in 480 s 3,304 / 3,307 4,007 / 3,854
profiler mean frame 128.4 / 126.1 ms 107.9 / 114.3 ms

A burst-window profile (62–92 s, the loading burst of up to 5,000 uploads a frame) had about 38 ms a frame on the recording threads in CreateCommittedResource for host textures before the change. That is what this removes, and on this card it is mostly the long frames that go.

Memory and picture: the card's memory in use settled at 12.5–13.4 GB, against 11–13.2 GB without. Captured frames at 1,500–3,000 show correct textures (faces, cloth, labels) by eye.

**@⁠wildheathen** on GitHub · 2026-11-25 21:43 UTC · [original](https://github.com/fxceless/victory-fork/pull/903#issuecomment-7175460097) An NVIDIA data point for the idea, with a caveat first: **the numbers below are from my own implementation of the same idea, not from this PR's head.** **Machine:** RTX 5080 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11, Series X profile. **What I ran:** on `ca8829f`, plus #868 and a couple of other streaming changes: - shader-read-only host textures (no target, depth or UAV flags) placed in 256 MiB `D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES` heaps; - power-of-two pieces from 64 KiB to 16 MiB, at most 4 GiB in all; - a piece reused 5 s after its host texture is dropped. That rest is cruder than your COM ticket behind `retire`. **Results:** A/B in one build with only the switch changed, two pairs, 480 s each, warm cache, DRED off. World = frame-rate lines with 500 or more draws. | | committed (1 / 2) | placed (1 / 2) | |---|---|---| | world mean frame | 580 / 784 ms | **300 / 311 ms** | | frame-rate lines over 1 s | 8 / 16 | **3 / 2** | | median of the 5 s windows | 327 / 405 ms | **191 / 207 ms** | | frames presented in 480 s | 3,304 / 3,307 | **4,007 / 3,854** | | profiler mean frame | 128.4 / 126.1 ms | **107.9 / 114.3 ms** | A burst-window profile (62–92 s, the loading burst of up to 5,000 uploads a frame) had about 38 ms a frame on the recording threads in `CreateCommittedResource` for host textures before the change. That is what this removes, and on this card it is mostly the long frames that go. **Memory and picture:** the card's memory in use settled at 12.5–13.4 GB, against 11–13.2 GB without. Captured frames at 1,500–3,000 show correct textures (faces, cloth, labels) by eye.
Author
Owner

@⁠Exopus-0x65f7ad0 on GitHub · 2026-11-26 07:23 UTC · original

A data point from an 8 GB card, with a visible result.

Setup: RTX 5060 Ti 8 GB, 16 GB of RAM, Windows 11, Series S profile. Our tree is fork main plus a stack of open PRs: #1219, #1218, #1264, #1246, and the heap worker #1007 with passes chained. Opening cutscene, warm caches.

Result: ca03c64 merged with two small conflicts. host_texture_as gains the placed argument; our #1219 reserved-texture path passes false. VICTORY_PLACED_TEX=1:

  • The diner waitress's face is textured and lit. In every earlier run tonight (about 15) it was black or blotchy red. The extra in the hat at the next table also has a face now, where it was black before.
  • The log reports 73,711 host textures placed in 45 heaps (about 1.2 GB free inside them), at 30–75 µs each. Before, each was a committed allocation; the heap worker's profile here had texture creation at about 118 ms per frame, 58 ms of it waiting in the graphics kernel.
  • Average frame rate is unchanged within run-to-run noise (3.3 fps against 3.4–4.2), with no device loss over the cutscene.

My reading: with texture creation this cheap, the queue of textures picked by index keeps up at scene changes, so her slot no longer shows an older view while it waits. I measured this in one run; the earlier runs without the switch all showed the defect.

🤖 Generated with Claude Code

**@⁠Exopus-0x65f7ad0** on GitHub · 2026-11-26 07:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/903#issuecomment-7185408275) A data point from an 8 GB card, with a visible result. **Setup:** RTX 5060 Ti 8 GB, 16 GB of RAM, Windows 11, Series S profile. Our tree is fork `main` plus a stack of open PRs: #1219, #1218, #1264, #1246, and the heap worker #1007 with passes chained. Opening cutscene, warm caches. **Result:** `ca03c64` merged with two small conflicts. `host_texture_as` gains the `placed` argument; our #1219 reserved-texture path passes `false`. `VICTORY_PLACED_TEX=1`: - **The diner waitress's face is textured and lit.** In every earlier run tonight (about 15) it was black or blotchy red. The extra in the hat at the next table also has a face now, where it was black before. - The log reports 73,711 host textures placed in 45 heaps (about 1.2 GB free inside them), at 30–75 µs each. Before, each was a committed allocation; the heap worker's profile here had texture creation at about 118 ms per frame, 58 ms of it waiting in the graphics kernel. - Average frame rate is unchanged within run-to-run noise (3.3 fps against 3.4–4.2), with no device loss over the cutscene. My reading: with texture creation this cheap, the queue of textures picked by index keeps up at scene changes, so her slot no longer shows an older view while it waits. I measured this in one run; the earlier runs without the switch all showed the defect. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/903/head:github-bot/gh-903'
git switch 'github-bot/gh-903'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-903'
git switch 'github-bot/gh-903'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-903'
git switch 'github-bot/gh-903'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-903'
git switch 'main'
git merge --squash 'github-bot/gh-903'
git switch 'main'
git merge --ff-only 'github-bot/gh-903'
git switch 'main'
git merge 'github-bot/gh-903'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.