Skip to content

GPU: read watched texture memory through a shared scratch buffer - #495

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Nov 24, 2026

Copy link
Copy Markdown

Every texture the title samples through a watched pool stays in STAGING for the rest of the run, and each one kept a Vec the size of its title memory (Last::read). That buffer is only needed while the texture is detiled, so on a long world run it adds gigabytes of commit on top of the title's own, and when Windows runs out of commit a failed allocation aborts the process: no crashes.log entry, only memory allocation of N bytes failed.

What I saw

RTX 3070 Ti, 31 GB RAM, the world loaded (black, minimap only), diagnostics build with the host debug layer. Two aborts, in different places and at different sizes:

memory allocation of 7372800 bytes failed     (during D3D12 submissions)
memory allocation of 12582912 bytes failed    (during shader translation)

System commit was about 52 GB of a 48 to 54 GB limit for the whole run (a growing pagefile), with the process at about 21 GB private. Neither abort left anything in crashes.log.

Fix

The buffer is one per thread (READ), reused for every texture, and reserved with try_reserve_exact. If the reservation fails the upload is skipped with a one-time warning, and the texture still asks to be detiled next time (asked is only updated after the reservation succeeds). No behaviour change otherwise.

Verified

cargo test -p victory-gpu --lib    43 passed, 0 failed, 1 ignored
rustfmt --check texture.rs         clean
cargo clippy -p victory-gpu        nothing new in texture.rs
cargo xtask policy --staged        ok (commit hook)

On the machine above, with this change the abort did not come back over several later runs (one of 20+ minutes with the process flat at about 21 to 22 GB private). I also raised the pagefile to 32 GB at the same time, so I cannot separate the two effects from those runs. I did not test the try_reserve_exact failure branch under real memory pressure.

Not in this PR

The STAGING map itself is still never cleared, so the upload buffers stay for the run. That is a separate question and I left it alone.

🤖 Generated with Claude Code

Every texture ever sampled stays in STAGING, and each one kept a Vec the
size of its title memory (Last::read) for the rest of the run, though it is
only needed while the texture is detiled. On a long world run that adds up
to gigabytes on top of the title's own commit, and when the host runs out of
commit a failed allocation aborts the process: no crashes.log entry, no
message beyond "memory allocation of N bytes failed".

The buffer is now one per thread (READ), reused for every texture, and it is
reserved with try_reserve_exact: if that fails the upload is skipped with a
one-time warning, and the texture still asks to be detiled next time.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ghost

ghost commented Nov 24, 2026

Copy link
Copy Markdown
Author

Closing as a duplicate of #215, which makes the same change in texture.rs (one thread-local read buffer in place of Last::read), was opened first, and has tests and a measurement. I should have searched for existing PRs before opening this one. If you were including #495 in a test stack, please use #215 instead. The one difference, a try_reserve_exact fallback so a failed allocation skips the upload instead of aborting the process, is described in a comment on #215.

@ghost ghost closed this Nov 24, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants