Large title textures are made without their most detailed levels when the card is short of room (VICTORY_TEXTURE_DROP_LEVELS) #1219

Open
github-bot wants to merge 6 commits from github-bot/gh-1219 into main AGit
Owner

@⁠Steenax6 on GitHub · 2026-11-26 00:26 UTC · original
Steenax6:pr/texture-drop-levels → main · +1857 −129 · 8 files · 6 commits · open

What

On a 12 GB card the title's textures do not all fit beside the targets and the buffer copies. In our runs some 22,000 textures picked by index waited for room in every run, and which ones were there differed from run to run: the first room came up lit in one run and dark in the next.

Placed, title-filled, block-compressed 2D textures of 1024 and more a side are now made as reserved textures (tiles.rs, the machinery of VICTORY_LEVELS_ON_DEMAND) and, past a line of host-copy bytes, without their one or two most detailed levels. Their views keep the title's first level and clamp the level of detail, so the sizes shaders read stay the title's. Levels come back while there is room (VICTORY_TEXTURE_PROMOTE_MB).

VICTORY_TEXTURE_DROP_LEVELS=0 turns it off; force1 / force2 leave levels out whatever the room.

This is a different answer to the same shortage than spilling into system memory or the Series S profile, and it does not exclude either.

Commits

The first commit is #1218 (lists hold the textures they read); this branch is stacked on it, and it drops out of the diff once that one is merged. Then:

  1. Large title textures are made without their most detailed levels when the card is short of room. The feature itself. Also: show_from no longer lowers the title's level-of-detail clamp when it moves a view (the clamp counts the texture's levels, not the view's).
  2. Swept host textures and their staging are released off the submitting thread (host::retire_later): the sweep let go of hundreds of host copies in one call, 20 ms a frame of the submitting thread in the cutscene for reserved textures, 6 ms for staging state.
  3. Reserved textures and staging buffers are reused; left-out levels are not staged. With nothing held back for room the cutscene made twice as many host copies and uploaded three times as many: 210 ms a frame against 107. Staging buffers up to 64 MiB from a pool of VICTORY_STAGING_POOL_MB (1,024), a reused one zeroed only if nothing has filled it by its first check; reserved textures kept by description (VICTORY_RESERVED_REUSE); tiles mapped a heap at a time; only the levels an upload writes are staged (VICTORY_STAGE_LEFT_OUT=1: all). 210 -> 158 ms.
  4. Views of reduced textures follow their tiles after the landing; slots are remade with nothing in flight. The second cause of the device loss described in #1218: a view slot was rewritten from the texture pass while lists already sent might read it, and widened to a level whose tiles were mapped but whose upload had not run (15,000 such rewrites a run). A view now follows its tiles once the submission that gave them has landed (VICTORY_TILED_VIEW_PUBLISH=0: at once), slots are remade by the sweep when no submission is in flight, and a view of a reduced texture changes in its clamp alone (VICTORY_TEXTURE_DROP_VIEWS=keep|shift: the earlier ways).
  5. README entry.

Measured (in our tree, RTX 4070 Ti 12 GB, Ryzen 7 9800X3D)

  • Two runs with commit 1: both lit and complete, 17,458 title textures alive in 2,964 MB (9,521 in 3,932 MB before), no slot held back for room, the card at 8.5 of 10.3 GB.
  • A/B on the lighting: with the switch every run since came up lit; =0 is dark again.
  • First room 86.8 ms a frame with all of it; the room is bound by the card, so this is not a frame-rate change there.
  • Device: 3 losses in about 30 runs with commits 1 to 3 alone, none in nine runs through the fault point with commit 4 and #1218.

What I can and cannot say for this tree

  • Compiled and linted on 4aa6e8c: cargo clippy --workspace --all-targets --locked and the same with --all-features give exactly the warnings main gives (11 there, none new). cargo test --workspace --locked: the tests of the modules touched pass; indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields fails here on main as well, and two WARP tests in watch.rs / inplace.rs failed once in a full run and pass when run by name (other builds were running on the machine). The tests of tiles.rs cover the view shapes and the publish order on the software adapter.
  • Not run with the title on this base. The commits applied with one conflict, in texture.rs: this tree's VICTORY_STAGING_POOL=alt is kept, the pool's sizes are the new ones. In our tree commit 3 also carried hooks for placed textures (#903, not ours, still open here); they are taken out, so this stands without it.
  • Two things here touch choices this tree made on purpose, please look at them:
    • On by default. New paths here are usually off by default. It only acts past a line of host-copy bytes, but it does change how every large compressed texture is made (reserved instead of committed). Say so and I flip the default.
    • The staging pool grows from 256 MB / 8 MiB buffers to 1,024 MB / 64 MiB, and a buffer taken from it is no longer zeroed at once. The README says the pool is off in the test runs since run 224 lost the device with it; I have no evidence either way about that loss.
  • Shader cache: nothing in the translator changes.

🤖 Generated with Claude Code

**@⁠Steenax6** on GitHub · 2026-11-26 00:26 UTC · [original](https://github.com/fxceless/victory-fork/pull/1219) `Steenax6:pr/texture-drop-levels` → `main` · +1857 −129 · 8 files · 6 commits · open ## What On a 12 GB card the title's textures do not all fit beside the targets and the buffer copies. In our runs some 22,000 textures picked by index waited for room in every run, and which ones were there differed from run to run: the first room came up lit in one run and dark in the next. Placed, title-filled, block-compressed 2D textures of 1024 and more a side are now made as reserved textures (`tiles.rs`, the machinery of `VICTORY_LEVELS_ON_DEMAND`) and, past a line of host-copy bytes, **without their one or two most detailed levels**. Their views keep the title's first level and clamp the level of detail, so the sizes shaders read stay the title's. Levels come back while there is room (`VICTORY_TEXTURE_PROMOTE_MB`). `VICTORY_TEXTURE_DROP_LEVELS=0` turns it off; `force1` / `force2` leave levels out whatever the room. This is a different answer to the same shortage than spilling into system memory or the Series S profile, and it does not exclude either. ## Commits The first commit is #1218 (lists hold the textures they read); this branch is stacked on it, and it drops out of the diff once that one is merged. Then: 1. **Large title textures are made without their most detailed levels when the card is short of room.** The feature itself. Also: `show_from` no longer lowers the title's level-of-detail clamp when it moves a view (the clamp counts the texture's levels, not the view's). 2. **Swept host textures and their staging are released off the submitting thread** (`host::retire_later`): the sweep let go of hundreds of host copies in one call, 20 ms a frame of the submitting thread in the cutscene for reserved textures, 6 ms for staging state. 3. **Reserved textures and staging buffers are reused; left-out levels are not staged.** With nothing held back for room the cutscene made twice as many host copies and uploaded three times as many: 210 ms a frame against 107. Staging buffers up to 64 MiB from a pool of `VICTORY_STAGING_POOL_MB` (1,024), a reused one zeroed only if nothing has filled it by its first check; reserved textures kept by description (`VICTORY_RESERVED_REUSE`); tiles mapped a heap at a time; only the levels an upload writes are staged (`VICTORY_STAGE_LEFT_OUT=1`: all). 210 -> 158 ms. 4. **Views of reduced textures follow their tiles after the landing; slots are remade with nothing in flight.** The second cause of the device loss described in #1218: a view slot was rewritten from the texture pass while lists already sent might read it, and widened to a level whose tiles were mapped but whose upload had not run (15,000 such rewrites a run). A view now follows its tiles once the submission that gave them has landed (`VICTORY_TILED_VIEW_PUBLISH=0`: at once), slots are remade by the sweep when no submission is in flight, and a view of a reduced texture changes in its clamp alone (`VICTORY_TEXTURE_DROP_VIEWS=keep|shift`: the earlier ways). 5. README entry. ## Measured (in our tree, RTX 4070 Ti 12 GB, Ryzen 7 9800X3D) - Two runs with commit 1: both lit and complete, 17,458 title textures alive in 2,964 MB (9,521 in 3,932 MB before), no slot held back for room, the card at 8.5 of 10.3 GB. - A/B on the lighting: with the switch every run since came up lit; `=0` is dark again. - First room 86.8 ms a frame with all of it; the room is bound by the card, so this is not a frame-rate change there. - Device: 3 losses in about 30 runs with commits 1 to 3 alone, none in nine runs through the fault point with commit 4 and #1218. ## What I can and cannot say for this tree - Compiled and linted on 4aa6e8c: `cargo clippy --workspace --all-targets --locked` and the same with `--all-features` give exactly the warnings `main` gives (11 there, none new). `cargo test --workspace --locked`: the tests of the modules touched pass; `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields` fails here on `main` as well, and two WARP tests in `watch.rs` / `inplace.rs` failed once in a full run and pass when run by name (other builds were running on the machine). The tests of `tiles.rs` cover the view shapes and the publish order on the software adapter. - **Not run with the title on this base.** The commits applied with one conflict, in `texture.rs`: this tree's `VICTORY_STAGING_POOL=alt` is kept, the pool's sizes are the new ones. In our tree commit 3 also carried hooks for placed textures (#903, not ours, still open here); they are taken out, so this stands without it. - Two things here touch choices this tree made on purpose, please look at them: - **On by default.** New paths here are usually off by default. It only acts past a line of host-copy bytes, but it does change how every large compressed texture is made (reserved instead of committed). Say so and I flip the default. - **The staging pool** grows from 256 MB / 8 MiB buffers to 1,024 MB / 64 MiB, and a buffer taken from it is no longer zeroed at once. The README says the pool is off in the test runs since run 224 lost the device with it; I have no evidence either way about that loss. - Shader cache: nothing in the translator changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
texture.rs `upload` returns early when a texture's staging is uploaded and
not dirty. A list that uploads a texture holds its host copy through the
transition it records; a list that takes the early return recorded nothing
that holds it, though it reads the texture all the same (through a table
copied as it is recorded). Nothing but the sweep's idle time then kept the
host copy alive between the recording and the moment the list runs, and
with VICTORY_ASYNC_SUBMIT a list is sent later than it is recorded. A host
copy released under a list not yet sent is a read of memory that is gone
when the list runs.

The list now keeps the texture until it is reset. VICTORY_TEXTURE_HOLD_READS=0:
not held, as before.

Where this comes from: Steenax6/VIctory-NVID lost the device in the opening
cutscene, 102 to 108 s after the start, in 3 of about 30 runs on an
RTX 4070 Ti (the System event log, nvlddmkm id 13: "MMU Fault"). Two things
were closed there in one commit (0d45621), this one and a rewrite of view
slots under lists in flight that only textures made level by level have;
which of the two faulted is not known. A counter there saw 570,000 reads a
run of 185 s that no list held. Nine runs through the fault point after it
without a loss, frame times unchanged.

On this base: compiled, linted and tested (clippy with and without
diagnostics, cargo test), not run with the title.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The title's textures did not all fit on a 12 GB card beside the targets and
the buffer copies: some 22,000 picked by index waited for room in every run,
and which ones were there differed from run to run (the first room came up
lit in one run and dark in the next).

Placed, title-filled, block-compressed 2D textures of 1024 and more a side
are now made as reserved textures (tiles.rs) and, past a line of host-copy
bytes, without their one or two most detailed levels: their views keep the
title's first level and clamp the level of detail, so sizes read by shaders
stay the title's. Levels come back while there is room
(VICTORY_TEXTURE_PROMOTE_MB). VICTORY_TEXTURE_DROP_LEVELS=0 turns it off;
force1/force2 leave levels out whatever the room.

Two runs on an RTX 4070 Ti: both lit and complete, 17,458 title textures
alive in 2,964 MB (9,521 in 3,932 MB before), no slot held back for room,
the card at 8.5 of 10.3 GB, 11-11.8 fps in the first room.

show_from no longer lowers the title's level-of-detail clamp when it moves a
view: the clamp counts the texture's levels, not the view's.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The sweep let go of hundreds of host copies in one call and released each
there: for a reserved texture two calls into the kernel (its allocation, its
range of the card's address space), 20 ms a frame of the submitting thread
in the opening cutscene, and 6 ms for the staging state. They now wait for
the next landing and are dropped on the thread that buries
(host::retire_later).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
With nothing held back for room, the opening cutscene made twice as many
host copies and uploaded three times as many, and each cost calls into the
kernel: 210 ms a frame against 107 with the levels switch off.

- staging buffers up to 64 MiB come from a pool of VICTORY_STAGING_POOL_MB
  (1024); a reused one is zeroed only if nothing has filled it by its first
  check;
- a texture made without its top levels stages only the levels its upload
  writes (VICTORY_STAGE_LEFT_OUT=1: all);
- a reserved texture let go is unmapped in one call and kept by description
  for the next one of that shape (VICTORY_RESERVED_REUSE, 4096 kept);
- tiles are mapped a heap at a time, not a level at a time;
- a reduced texture's views are clamped from their making, so its first
  upload remakes no slot (slots rewritten under lists already sent are the
  likeliest cause of the one lost device seen with the levels switch on);
- copies without memory of their own wait VICTORY_TILED_IDLE_MS (5000)
  before the sweep lets them go.

Cutscene with the switch on: 210 -> 158 ms a frame (146,047 staging buffers
reused, 12,405 made; 12,479 reserved textures reused, 4,817 made).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Three runs in about thirty lost the device 102-108 s after the start, in
the opening cutscene, since textures are made level by level; the driver's
log says "MMU Fault": a shader read an address that was not there. Two ways
the code allowed that (which one faulted is not known). One is general and
is the commit before this series (lists hold the textures they read,
VICTORY_TEXTURE_HOLD_READS); the other belongs to textures made level by
level and is closed here:

a host view slot was rewritten from the texture pass while lists already
sent might read it, and widened to a level whose tiles were mapped but
whose upload had not run: 15,000 such rewrites a run. A view now follows
its tiles only once the submission that gave them has landed
(VICTORY_TILED_VIEW_PUBLISH=0: at once, as before), slots are remade by
the sweep when no submission is in flight, and a view of a reduced
texture changes in its clamp alone (VICTORY_TEXTURE_DROP_VIEWS=keep|shift:
the earlier ways).

The line "views of textures made level by level" counts the rewrites while
submissions were in flight (0 since) and the reads lists now hold.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:46 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/tiles.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/1219/head:github-bot/gh-1219'
git switch 'github-bot/gh-1219'

Merge

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