Textures: let go of the staging buffer of a texture that stays unchanged (16 GB machines) #23
No reviewers
Labels
No labels
accessibility
bench-bm-v1
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/PastiiJay--klbf-lab!23
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-23"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@spy0eye-beep on GitHub · 2026-11-25 17:03 UTC · original
spy0eye-beep:klbf-staging-ram→beta· +208 −16 · 2 files · 2 commits · openWhat
Aimed at 16 GB machines (the guide says a run commits about 20 GB).
A texture's staging buffer is system memory the size of the texture (an upload heap). It is kept for every texture sampled in the last
idle_ms, so every texture in view costs its size twice: once on the card, once in the PC's memory. A tester's memory map on fxceless/victory-fork#54 shows 7 GB of write-combined memory at 19.7 GB private, 146 × 32 MB of it.The buffer's contents are only needed between a detiling and the upload that copies it. Whether a texture changed is decided by the hash and the write watch in
Last, not by those bytes.Change
let_go_idlealso drops the buffer (not the record) of a texture that:Arc::strong_count == 1),The record (hash,
uploaded,dirty) stays, so the texture is neither uploaded nor detiled again until its memory changes. When it does,Staging::mappedmakes a buffer anew, under the same lock the detiling writes under. A list recording an upload gets the buffer throughStaging::buffer(), which makes one if needed.VICTORY_STAGING_KEEP=1keeps every buffer, as before.staging buffers of unchanged textures ... (N made again ...), so a run shows how much this frees and what it costs.This complements the existing
let_go_idle(which drops the whole record of textures no longer sampled, and re-uploads them later). This one only drops the bytes of textures still sampled but unchanged.Testing
cargo test --workspace --all-featuresonbeta(c71c7d6) with this change and the discrete-GPU PR together, on the RTX 4060 Laptop (587 passed, 2 failed: therecttests, failing onbetatoo) and on the Intel UHD (the same 9 failures asbeta). This branch alone was built and checked, not run separately.cargo check/cargo build --release -p victory: OK. Clippy: same two pre-existing errors asbeta.AI-assisted (Claude).
🤖 Generated with Claude Code
@HandshakeHackin on GitHub · 2026-11-25 17:38 UTC · original
I tested the sweep on Windows WARP at
fc0480bwith two real 256-byte staging allocations. Both textures were recently sampled, unchanged long enough, previously uploaded and clean. One still had a mip waiting for tiles.s.waiting.load(Relaxed) == 0in the eviction conditionThe retry in
upload()setsdirtywhen the card has room again. It relies on the previous detiled bytes, and an unchanged texture can pass its refresh without detiling again. Keeping the pending buffer preserves those bytes while still reclaiming the settled texture. The fixture checked buffer residency. Rendering after a retry on hardware is still unverified.One related diagnostic: the “staging of textures … alive” line counted 512 bytes before and after even when both allocations had been released. Counting resident buffers separately from staging records would let a 16 GB tester see what the sweep reclaimed. Windows comparison and exact fixture.
@PastiiJay on GitHub · 2026-11-25 18:38 UTC · original
Thanks a lot @spy0eye-beep! Noted. It goes into tonight's RX 9070 XT test queue and I'll report the result here.
@spy0eye-beep on GitHub · 2026-11-25 21:05 UTC · original
Thanks @HandshakeHackin, that fixture caught a real gap. Both points are in
cbeed1e:waiting == 0, as you proposed. The decision is a small pure function (buffer_may_go), with tests for a settled texture (released) and for each reason that keeps the buffer, the waiting case among them.… with a buffer N MBfrom a separate resident counter (up on creation and re-creation, down on release and on dropping a record that still has one), so a 16 GB run shows what the sweep actually reclaimed.cargo test -p victory-gpu --all-featureson an RTX 4060 Laptop: 164 passed, 0 failed. Clippy shows onlybeta's existing two errors; rustfmt shows no new differences. Rendering after a retry is still untested in game, as you note.@PastiiJay on GitHub · 2026-11-25 21:08 UTC · original
Thanks @spy0eye-beep, and thanks @HandshakeHackin for catching the waiting-tiles case. The
buffer_may_gotests and the separate "with a buffer" counter are exactly what we need to see the gain on a 16 GB machine. It goes into our in-game test queue on the RX 9070 XT, with a check that the picture after a retry stays intact.@HandshakeHackin on GitHub · 2026-11-26 03:22 UTC · original
I reran the two-texture fixture against
cbeed1eon Windows WARP. The texture waiting for tiles kept all 256 original bytes across two sweeps. With default eviction, resident staging memory went from 512 to 256 bytes after the sweep, returned to 512 when the settled buffer was requested again, and fell to zero when both records dropped. WithVICTORY_STAGING_KEEP=1, both allocations stayed resident until drop. A second lookup of the settled buffer counted no extra allocation in either mode.That verifies the waiting-buffer fix and the resident counter through release, recreation, and drop. Rendering after a tile retry still needs the in-game run. Fixture and both passing runs
@PastiiJay on GitHub · 2026-11-26 10:42 UTC · original
Thanks for rerunning the eviction fixture. We'll see how it behaves on a 16 GB machine in game.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.