Streamed textures fit on 12 GB cards: host copies go without their largest mips past a cap #60

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

@⁠SpeezusChrist23 on GitHub · 2026-11-26 00:32 UTC · original
SpeezusChrist23:rx6700xt-texture-cap → main · +440 −20 · 4 files · 1 commits · open

Streamed textures fit on 12 GB cards: host copies go without their largest mips past a cap

On a 12 GB card the runtime reaches the card's video-memory budget early in the prologue. The log says textures picked by index: VRAM texture budget reached; new allocations wait, and textures that stream in after that stay blank. People and walls show missing colours and textures.

This change gives large streamed textures a host copy without their largest mips while memory fills. They show slightly softer instead of not at all. It is ported from Belobug's AMD fork (Belobug/VIctory-Belobug-AMD: over_cap, skipped_mips, HostTexture.skip, without_mips) and adapted to this fork's lazy host copies and staging buffers.

What is capped

  • Only textures placed by address or made from a view (Backing::Address / ViewAddress).
  • Only 2-D, block-compressed (BC1-BC7) textures with a mip chain.
  • No render targets, depth or UAV textures.
  • At least one mip always stays, and the sides stay multiples of 4.

The cap

  • VICTORY_TEXTURE_MAX=<px> sets it; 0 turns it off.
  • By default it is 1024 px while the process uses under 70% of the card's budget, 512 under 85%, and 256 above that.
  • It is decided when the host copy is made, and again after the sweep lets a copy go.
  • room() is unchanged and stays the last resort.

Where the code changed

  • resource.rs: the skip and the cap rule; the host copy is made smaller.
  • texture.rs: skipped mips are not staged or uploaded; the remaining mips go to the right host subresources.
  • descriptor/host.rs: SRVs move MostDetailedMip, MipLevels and ResourceMinLODClamp past the skipped mips.
  • list.rs: texture copies and read-backs map to the host copy's subresources; copies of skipped mips are left out.

Tested

  • Hardware: RX 6700 XT (12 GB, RDNA2), i5-12600K, 32 GB RAM, Windows 11, retail title, prologue.
  • Before: about 10.0 of 11.0 GB of video memory in use, the budget line logged, and missing textures and colours.
  • After: 8.6 of 11.0 GB in use. Textures show, for example the jumpsuits, skin, hair, bunk beds and window light. Large textures lose one mip (for example 1024 → 512). Frame rate is unchanged.
  • New unit tests:
    • resource::tests::a_large_streamed_texture_goes_without_its_largest_mips
    • resource::tests::subresources_map_past_the_skipped_mips
    • texture::first_mip_tests::staged_parts_go_to_the_host_copys_subresources
    • descriptor::host::tests::a_view_moves_past_the_skipped_mips
  • CI commands, run locally:
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.
    • cargo test --workspace --locked: all pass except some victory-shader emit::barycentric_tests. Those fail the same way on unmodified main (2e01ab4) on this machine, so they are not related to this change; probably the DXIL validator setup here.

Known limits

  • The cap level is fixed when a host copy is made. A texture made while memory is tight stays smaller until its copy is let go and made again.
  • A title copy into a skipped top mip is left out, as in Belobug's version.
  • This does not fix the haze in bright, sunlit scenes. That looks like the missing ray-traced lighting, which is a separate issue.

Unrelated to this change: the title also runs stable into gameplay on this RDNA2 card (about 4-5 fps), which the README's list of tested cards does not include yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S4xxd1tzZBWeKd4wieFYTZ

**@⁠SpeezusChrist23** on GitHub · 2026-11-26 00:32 UTC · [original](https://github.com/DexNom/VIctory/pull/60) `SpeezusChrist23:rx6700xt-texture-cap` → `main` · +440 −20 · 4 files · 1 commits · open ## Streamed textures fit on 12 GB cards: host copies go without their largest mips past a cap On a 12 GB card the runtime reaches the card's video-memory budget early in the prologue. The log says `textures picked by index: VRAM texture budget reached; new allocations wait`, and textures that stream in after that stay blank. People and walls show missing colours and textures. This change gives large streamed textures a host copy without their largest mips while memory fills. They show slightly softer instead of not at all. It is ported from Belobug's AMD fork ([Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD): `over_cap`, `skipped_mips`, `HostTexture.skip`, `without_mips`) and adapted to this fork's lazy host copies and staging buffers. **What is capped** - Only textures placed by address or made from a view (`Backing::Address` / `ViewAddress`). - Only 2-D, block-compressed (BC1-BC7) textures with a mip chain. - No render targets, depth or UAV textures. - At least one mip always stays, and the sides stay multiples of 4. **The cap** - `VICTORY_TEXTURE_MAX=<px>` sets it; `0` turns it off. - By default it is 1024 px while the process uses under 70% of the card's budget, 512 under 85%, and 256 above that. - It is decided when the host copy is made, and again after the sweep lets a copy go. - `room()` is unchanged and stays the last resort. **Where the code changed** - `resource.rs`: the skip and the cap rule; the host copy is made smaller. - `texture.rs`: skipped mips are not staged or uploaded; the remaining mips go to the right host subresources. - `descriptor/host.rs`: SRVs move `MostDetailedMip`, `MipLevels` and `ResourceMinLODClamp` past the skipped mips. - `list.rs`: texture copies and read-backs map to the host copy's subresources; copies of skipped mips are left out. ### Tested - **Hardware:** RX 6700 XT (12 GB, RDNA2), i5-12600K, 32 GB RAM, Windows 11, retail title, prologue. - **Before:** about 10.0 of 11.0 GB of video memory in use, the budget line logged, and missing textures and colours. - **After:** 8.6 of 11.0 GB in use. Textures show, for example the jumpsuits, skin, hair, bunk beds and window light. Large textures lose one mip (for example 1024 → 512). Frame rate is unchanged. - **New unit tests:** - `resource::tests::a_large_streamed_texture_goes_without_its_largest_mips` - `resource::tests::subresources_map_past_the_skipped_mips` - `texture::first_mip_tests::staged_parts_go_to_the_host_copys_subresources` - `descriptor::host::tests::a_view_moves_past_the_skipped_mips` - **CI commands, run locally:** - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean. - `cargo test --workspace --locked`: all pass except some `victory-shader` `emit::barycentric_tests`. Those fail the same way on unmodified `main` (2e01ab4) on this machine, so they are not related to this change; probably the DXIL validator setup here. ### Known limits - The cap level is fixed when a host copy is made. A texture made while memory is tight stays smaller until its copy is let go and made again. - A title copy into a skipped top mip is left out, as in Belobug's version. - This does not fix the haze in bright, sunlit scenes. That looks like the missing ray-traced lighting, which is a separate issue. Unrelated to this change: the title also runs stable into gameplay on this RDNA2 card (about 4-5 fps), which the README's list of tested cards does not include yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01S4xxd1tzZBWeKd4wieFYTZ
Ported from Belobug's AMD fork (Belobug_VIctory-Belobug-AMD; over_cap,
skipped_mips, HostTexture.skip and without_mips arrived in its imported
base 78028ad; 5d7bd16 builds on the same mip skipping for views with a
least level of detail and is not ported). Adapted to this fork's lazy
host copies and staging buffers.

A streamed texture (placed by address or made from a view, Backing::Address
/ ViewAddress) that is 2-D, block-compressed (BC1-BC7), has a mip chain and
no target, depth or unordered access flag gets a host copy without the
fewest largest mips that bring both sides to the cap (at least one mip
stays; sides stay multiples of 4). The cap is VICTORY_TEXTURE_MAX (pixels,
0 = no cap) or by default 1024 while the card is under 70% of its budget,
512 under 85%, 256 above; it is decided when the host copy is made (again
after the sweep lets one go).

- resource.rs: HostTexture.skip; over_cap / mips_over / texture_max;
  host_texture shrinks width, height and mip count; skipped_mips, skip_of,
  host_subresource (title subresource -> host one).
- texture.rs: staging buffers stage title mips from max(first, skip) on and
  copy each part into the host subresource slice * (mips - skip) +
  mip - skip; skipped mips are neither read nor uploaded.
- descriptor/host.rs: SRVs of such a copy move MostDetailedMip, MipLevels
  and ResourceMinLODClamp down by skip (without_mips / cut_mips).
- list.rs: CopyTextureRegion / read backs map subresource indices to the
  host copy's and drop copies of skipped mips; CopyResource between copies
  with different skips is left out.

room() stays the last resort, now counting the smaller host copies.

Tested on an RX 6700 XT (12 GB, RDNA2), Windows 11, the title's prologue: before, the
runtime reached the card's budget ("textures picked by index: VRAM texture budget
reached; new allocations wait") at about 10.0 of 11.0 GB and later textures stayed
blank; with the cap, 8.6 of 11.0 GB and they show (largest mip left out, e.g.
1024 -> 512). Frame rate unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01S4xxd1tzZBWeKd4wieFYTZ
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:32:58 +00:00
Author
Owner

@⁠SpeezusChrist23 on GitHub · 2026-11-26 00:34 UTC · original

Before

https://github.com/user-attachments/assets/e6e5d83c-c355-4730-904e-3bbeb6e8f3ed

**@⁠SpeezusChrist23** on GitHub · 2026-11-26 00:34 UTC · [original](https://github.com/DexNom/VIctory/pull/60#issuecomment-7178902085) Before https://github.com/user-attachments/assets/e6e5d83c-c355-4730-904e-3bbeb6e8f3ed
Author
Owner

@⁠SpeezusChrist23 on GitHub · 2026-11-26 00:36 UTC · original

After

https://github.com/user-attachments/assets/f8a2ccec-b0c4-4c1f-b5ec-52d8a2660d2b

**@⁠SpeezusChrist23** on GitHub · 2026-11-26 00:36 UTC · [original](https://github.com/DexNom/VIctory/pull/60#issuecomment-7178934927) After https://github.com/user-attachments/assets/f8a2ccec-b0c4-4c1f-b5ec-52d8a2660d2b
Author
Owner

@⁠SpeezusChrist23 on GitHub · 2026-11-26 00:51 UTC · original

Found a bug while testing, please hold off on merging.

With the cap on, some character skin textures load corrupted, as rainbow pixel noise. In the photo below, both of the guard's arms are affected and one hand is blue. Most other textures in the same scenes look correct.

For comparison, with the cap off (VICTORY_TEXTURE_MAX=0), the same kind of skin textures don't load at all and show up black. So the cap does get them loading, but some of them land with their data in the wrong place.

My suspect is how the skipped mips interact with textures that stream in only partly, for example when only their middle pages are resident. I'm working on a fix and will update this PR once it's tested on the same scene.

Tested on an RX 6700 XT (12 GB), retail title, prologue (prison).image

**@⁠SpeezusChrist23** on GitHub · 2026-11-26 00:51 UTC · [original](https://github.com/DexNom/VIctory/pull/60#issuecomment-7179177323) Found a bug while testing, please hold off on merging. With the cap on, some character skin textures load corrupted, as rainbow pixel noise. In the photo below, both of the guard's arms are affected and one hand is blue. Most other textures in the same scenes look correct. For comparison, with the cap off (VICTORY_TEXTURE_MAX=0), the same kind of skin textures don't load at all and show up black. So the cap does get them loading, but some of them land with their data in the wrong place. My suspect is how the skipped mips interact with textures that stream in only partly, for example when only their middle pages are resident. I'm working on a fix and will update this PR once it's tested on the same scene. Tested on an RX 6700 XT (12 GB), retail title, prologue (prison).![image](https://github.com/user-attachments/assets/65c0145b-ee4b-4826-9227-95a7bf0e42f6)
Author
Owner

@⁠SpeezusChrist23 on GitHub · 2026-11-26 00:54 UTC · original

Update: false alarm for this PR. The rainbow-noise skin does not come from the texture cap. I was testing a second, separate change at the same time (an ambient-light stand-in for the missing ray-traced lighting), and that one causes it:

  • This PR's change alone (cap on, no ambient change): the same guard in the same doorway renders correctly.
  • Ambient change on, cap off (VICTORY_TEXTURE_MAX=0): the guard's arms are still rainbow noise and his body is black (unloaded).
  • I also re-read every path the cap touches: staging and uploads, partly resident refreshes, SRVs, textures picked by index, copies, and remade host copies. Each host subresource gets the title's own mip, and every view and copy is mapped past the skipped mips.

So this PR is ready for review again. Sorry for the noise! The ambient change stays local until its issue is fixed.

**@⁠SpeezusChrist23** on GitHub · 2026-11-26 00:54 UTC · [original](https://github.com/DexNom/VIctory/pull/60#issuecomment-7179242594) **Update: false alarm for this PR.** The rainbow-noise skin does not come from the texture cap. I was testing a second, separate change at the same time (an ambient-light stand-in for the missing ray-traced lighting), and that one causes it: - This PR's change alone (cap on, no ambient change): the same guard in the same doorway renders correctly. - Ambient change on, cap **off** (`VICTORY_TEXTURE_MAX=0`): the guard's arms are still rainbow noise and his body is black (unloaded). - I also re-read every path the cap touches: staging and uploads, partly resident refreshes, SRVs, textures picked by index, copies, and remade host copies. Each host subresource gets the title's own mip, and every view and copy is mapped past the skipped mips. So this PR is ready for review again. Sorry for the noise! The ambient change stays local until its issue is fixed.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/texture.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/60/head:github-bot/gh-60'
git switch 'github-bot/gh-60'

Merge

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