GPU: a title texture's host texture is made on its first use (the first-use half of #431) #1969

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

@⁠AgneyaK on GitHub · 2026-11-25 01:56 UTC · original
AgneyaK:gpu/host-textures-on-first-use → main · +76 −19 · 1 files · 1 commits · open

Ports the first-use half of #431 (by @⁠AntoninMichelq) onto current main. #431 and #1526 closed each other as duplicates (see #431), so nothing open covered it. The other half of #431, freeing host objects only after running submissions, is already in main (host::retire / release_retired).

What

A title texture's host copy was made when the title created the resource. Most are never used by a list, and on small cards the unused ones spill into system RAM. With #431 on the older base, a 6 GB / 16 GB laptop's story load went from 22.7 to 18.2 GB private and from 7.2 to 3.7 GB of GPU memory in RAM. 0xKaji measured ~7.85 → ~5.39 GiB of host textures on an 8 GB card with #1526.

  • Resource.host is a OnceLock. Resource::host makes the texture on first use, from the creation state and clear value kept with the resource (made_with), then registers it in TEXTURES_AT. Every host_resource / host_copy / host_transition is a first use: views, targets, copies, barriers.
  • Paths that must not create one read host_made instead: current, alias_source (it holds TEXTURES_AT), and Drop.
  • texture_at (placed views) still makes its texture at once, as before.
  • Lock order stays one way: the placed-texture map, then MEMORY (in shared_texture), then TEXTURES_AT. Nothing takes them the other way round.

Tested

Windows 11 26300, Rust 1.98.1, on main 940d32f:

  • New test a_texture_gets_its_host_copy_on_first_use: no host texture at creation, made on the first host_resource, made once, registered by memory once made.
  • cargo test -p victory-gpu --locked: 140 passed, 3 failed, the same 3 that fail on main here (the Intel Iris Xe the tests run on: the 2 heap-cap tests of #1744, and the castable test that #1765 fixes).
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean. cargo xtask policy: ok.

Not tested yet: the title on this exact tree. On NVIDIA, main stops at boot without #1763 (#1754), so a title run needs that too. I'll post the numbers here once I have them.

AI use: Claude Code (Claude Opus 5.5) ported the change (from a local port made earlier in the same setup), wrote the test and ran the checks; the results are from the runs described.

🤖 Generated with Claude Code

**@⁠AgneyaK** on GitHub · 2026-11-25 01:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1969) `AgneyaK:gpu/host-textures-on-first-use` → `main` · +76 −19 · 1 files · 1 commits · open Ports the **first-use half of #431** (by @⁠AntoninMichelq) onto current `main`. #431 and #1526 closed each other as duplicates (see [#431](https://git.gtahub.st/github/Marvisak--VIctory/pulls/431)), so nothing open covered it. The other half of #431, freeing host objects only after running submissions, is already in `main` (`host::retire` / `release_retired`). ## What A title texture's host copy was made when the title created the resource. Most are never used by a list, and on small cards the unused ones spill into system RAM. With #431 on the older base, a 6 GB / 16 GB laptop's story load went from 22.7 to 18.2 GB private and from 7.2 to 3.7 GB of GPU memory in RAM. 0xKaji measured ~7.85 → ~5.39 GiB of host textures on an 8 GB card with #1526. - `Resource.host` is a `OnceLock`. `Resource::host` makes the texture on first use, from the creation state and clear value kept with the resource (`made_with`), then registers it in `TEXTURES_AT`. Every `host_resource` / `host_copy` / `host_transition` is a first use: views, targets, copies, barriers. - Paths that must not create one read `host_made` instead: `current`, `alias_source` (it holds `TEXTURES_AT`), and `Drop`. - `texture_at` (placed views) still makes its texture at once, as before. - Lock order stays one way: the placed-texture map, then `MEMORY` (in `shared_texture`), then `TEXTURES_AT`. Nothing takes them the other way round. ## Tested Windows 11 26300, Rust 1.98.1, on `main` `940d32f`: - New test `a_texture_gets_its_host_copy_on_first_use`: no host texture at creation, made on the first `host_resource`, made once, registered by memory once made. - `cargo test -p victory-gpu --locked`: 140 passed, 3 failed, the same 3 that fail on `main` here (the Intel Iris Xe the tests run on: the 2 heap-cap tests of #1744, and the castable test that #1765 fixes). - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. `cargo xtask policy`: ok. Not tested yet: the title on this exact tree. On NVIDIA, `main` stops at boot without #1763 (#1754), so a title run needs that too. I'll post the numbers here once I have them. AI use: Claude Code (Claude Opus 5.5) ported the change (from a local port made earlier in the same setup), wrote the test and ran the checks; the results are from the runs described. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ports the first-use half of #431 (AntoninMichelq) onto current main; the
other half (freeing host objects only after running submissions) is
already in main.

A title texture's host copy was made when the title created the
resource. Most are never used by a list, and on small cards the rest
spills into system RAM: with #431 on the older base, a 6 GB / 16 GB
laptop's story load went from 22.7 to 18.2 GB private and from 7.2 to
3.7 GB of GPU memory in RAM.

`Resource::host` now makes it on first use (a view, a target, a copy, a
barrier: every `host_resource` / `host_copy` / `host_transition`), from
the creation state and clear value kept with the resource, and registers
the texture by memory then. Paths that must not create one (`current`,
`alias_source` while it holds `TEXTURES_AT`, `Drop`) read `host_made`.

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

@⁠AgneyaK on GitHub · 2026-11-25 02:06 UTC · original

In-title result, and it's weaker than I hoped, so here it is plainly.

Setup: RTX 3050 6 GB Laptop, 16 GB RAM. main 940d32f + #1763 (NVIDIA stops at boot without it, #1754), with and without this PR. Diag build, a local NVIDIA-adapter patch (not in any PR), scripted Enter into the story. An outside guard killed the game when free RAM fell under 800 MB (this laptop blue-screened in the NVIDIA driver at ~24 GB private earlier tonight).

profile build stopped at host textures (MB) used by lists
Series X base 72 s, frame 1,024 1,556 (4,887 MB) 247 MB
Series X this PR 68 s, frame 1,024 1,516 (4,826 MB) 239 MB
Series S base 70 s, frame 1,331 1,559 (2,660 MB) 242 MB
Series S this PR 62 s, frame 1,028 1,542 (2,545 MB) 220 MB

So at boot it saves ~1–4%, not the 20% that #431 gave on the old base. The reason: descriptor::sync_heaps now mirrors every slot of the title's view heap before each submission, and making a slot's view (descriptor/host.rs make, View::Shader → host_copy) is a first use. So every texture that has a descriptor is made at once, used or not. By frame 256 this PR already has 1,515 host textures.

What it may still save: textures made after the heap is mirrored and never put in a slot. An earlier local run of the same change on 70564ae (another session on this laptop, not repeated tonight) had 4,852 instead of 8,777 MB of host textures at the same point of the story load. I could not get that far safely tonight: on both profiles free RAM drops by ~3 GB in a few seconds as the story starts, and the guard stopped every run there.

To get #431's old effect on current main, the mirror would have to stop making textures: a slot's view made only when a list or a heap-indexing draw can reach it. That's a bigger change than this PR. I'm happy to close this one if you'd rather not take it on its own.

AI use: Claude Code (Claude Opus 5.5) ran these builds and wrote this; the results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-25 02:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1969#issuecomment-7150326907) In-title result, and it's weaker than I hoped, so here it is plainly. **Setup:** RTX 3050 6 GB Laptop, 16 GB RAM. `main` `940d32f` + #1763 (NVIDIA stops at boot without it, #1754), with and without this PR. Diag build, a local NVIDIA-adapter patch (not in any PR), scripted Enter into the story. An outside guard killed the game when free RAM fell under 800 MB (this laptop blue-screened in the NVIDIA driver at ~24 GB private earlier tonight). | profile | build | stopped at | host textures (MB) | used by lists | |---|---|---|---|---| | Series X | base | 72 s, frame 1,024 | 1,556 (4,887 MB) | 247 MB | | Series X | this PR | 68 s, frame 1,024 | 1,516 (4,826 MB) | 239 MB | | Series S | base | 70 s, frame 1,331 | 1,559 (2,660 MB) | 242 MB | | Series S | this PR | 62 s, frame 1,028 | 1,542 (2,545 MB) | 220 MB | **So at boot it saves ~1–4%, not the 20% that #431 gave on the old base.** The reason: `descriptor::sync_heaps` now mirrors every slot of the title's view heap before each submission, and making a slot's view (`descriptor/host.rs` `make`, `View::Shader` → `host_copy`) is a first use. So every texture that has a descriptor is made at once, used or not. By frame 256 this PR already has 1,515 host textures. What it may still save: textures made after the heap is mirrored and never put in a slot. An earlier local run of the same change on `70564ae` (another session on this laptop, not repeated tonight) had 4,852 instead of 8,777 MB of host textures at the same point of the story load. I could not get that far safely tonight: on both profiles free RAM drops by ~3 GB in a few seconds as the story starts, and the guard stopped every run there. To get #431's old effect on current `main`, the mirror would have to stop making textures: a slot's view made only when a list or a heap-indexing draw can reach it. That's a bigger change than this PR. I'm happy to close this one if you'd rather not take it on its own. AI use: Claude Code (Claude Opus 5.5) ran these builds and wrote this; the results are from the runs described.
Author
Owner

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

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/resource.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1969#issuecomment-7156995721) · edited 2026-11-25 16:04 UTC <!-- victory-triage v1 head=001c15336ac7f2c8be5f3869c8a5c65fa43fae9b verdict=needs-rebase at=2026-11-25T16:17:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/resource.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Slay326 on GitHub · 2026-11-25 14:13 UTC · original

On an RTX 3070, draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view fails with this PR alone on 940d32f (round 0: one host texture); it passes on main.

  • Cause: the test makes the placed view's texture before the resource object's first use. The placed texture is made at once without the unordered-access use, so the object's later first use cannot share it and replaces it: two host textures where main has one.
  • In the title the same order would split a GPU-written texture from its placed view (the R32_UINT writer and its R9G9B9E5 view); the alias copy bridges only same-start cases.
  • In a 480 s world run (merged with #1962, #2161, #2129, #2180, #1873) the image looked the same as without the PR. Host textures were 7.4 GB there against 10.35 GB without #1969 and #2161; I did not run the two apart.

AI-assisted.

**@⁠Slay326** on GitHub · 2026-11-25 14:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1969#issuecomment-7164938398) On an RTX 3070, `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view` fails with this PR alone on `940d32f` (`round 0: one host texture`); it passes on `main`. - **Cause:** the test makes the placed view's texture before the resource object's first use. The placed texture is made at once without the unordered-access use, so the object's later first use cannot share it and replaces it: two host textures where `main` has one. - **In the title** the same order would split a GPU-written texture from its placed view (the R32_UINT writer and its R9G9B9E5 view); the alias copy bridges only same-start cases. - **In a 480 s world run** (merged with #1962, #2161, #2129, #2180, #1873) the image looked the same as without the PR. Host textures were 7.4 GB there against 10.35 GB without #1969 and #2161; I did not run the two apart. AI-assisted.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 14:39 UTC · original

Second RTX 3070 confirming Slay326's failure. 001c153 (as-is, on main 940d32f), driver 616.56, Windows 11, debug:

tree draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view --exact, 3 runs cargo test -p victory-gpu --locked
main 940d32f 3 of 3 pass 141 passed, 2 failed
this PR 3 of 3 fail at draw.rs:2185, round 0: one host texture (left false, right true) 141 passed, 3 failed

The 2 failures on main are the same on both trees (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views). The extra one with the PR is this test. No SKIPPED lines.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-25 14:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1969#issuecomment-7165621964) Second RTX 3070 confirming Slay326's failure. `001c153` (as-is, on `main` `940d32f`), driver 616.56, Windows 11, debug: | tree | `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view --exact`, 3 runs | `cargo test -p victory-gpu --locked` | |---|---|---| | `main` `940d32f` | 3 of 3 pass | 141 passed, 2 failed | | this PR | 3 of 3 fail at `draw.rs:2185`, `round 0: one host texture` (left `false`, right `true`) | 141 passed, 3 failed | The 2 failures on `main` are the same on both trees (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`). The extra one with the PR is this test. No `SKIPPED` lines. AI-assisted (Claude Code). Synthetic tests only.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/resource.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1969'
git switch 'github-bot/gh-1969'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1969'
git switch 'github-bot/gh-1969'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1969'
git switch 'main'
git merge --squash 'github-bot/gh-1969'
git switch 'main'
git merge --ff-only 'github-bot/gh-1969'
git switch 'main'
git merge 'github-bot/gh-1969'
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!1969
No description provided.