Texture and staging blocks made with the pool's lock let go #816
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/816"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T06:49:29Z.
Replaces #683, #684 and #685 with one smaller change. It is based directly on
mainand doesn't depend on #630.Why
A new 64 MiB block of textures, or of staging memory, is created, made resident and waited for until it is mapped. Usually that is a tenth of a millisecond, but near the card's budget
MakeResidentwaits for the system to evict first. One play log had a wait of 1,128 ms with 13.3 of 14.0 GB in use. Each block was made inside the pool's lock, so every thread that took or gave back a texture piece waited behind it. WithVICTORY_RIPE_BLOCKSabove 0, up to 12 blocks made ahead were made there too.What
take_fromcuts pieces under the lock and makes blocks outside it, both the needed ones and those made ahead. Both pools, textures and staging, use it.main's pool census.Pool::take/take_ripestay, test-only, for the tests of the cutting rules.Clippy: the four findings that stop CI on main: the same commit as in #630. Without it,mainitself fails clippy on Rust 1.98. Drop it ifmainfixes them first.Before / after
cargo test --release -p victory-gpu --lib -- bench_ --ignored --nocapturewithVICTORY_RIPE_BLOCKS=0(the launcher's setting). It ran on an RTX card, with themainand branch binaries run alternately, three runs each.mainwas measured with the bench commit added on top of it.bench_textures_placed_while_another_thread_makes_blocks: one thread places 256 KiB textures, which blocks that already hold pieces have room for. Another places 24 MiB textures, which need a new block every second one. Times for placing the small textures:mainbench_staging_while_another_thread_makes_blocks: one thread stages 64 KiB pieces. Another stages 8 MiB pieces and keeps 64 of them, so new staging blocks keep being made. Times for staging the small pieces:mainThe branch's longest staging time, about 40 ms, is a small piece that also found no room and made a block of its own.
Correctness
blocks_are_made_with_the_pool_let_go(unit test, no GPU) checks four things:makenever runs with the pool's lock held.threads_that_place_textures_at_once_make_blocks_and_keep_their_pieces_apart: eight threads place 192 textures of 4 MiB at once, several of them making blocks. Every texture is placed and the pieces held cover all of them. The device isn't removed, and the debug layer reports nothing.threads_that_stage_at_once_get_zeroed_pieces_of_their_own: eight threads stage 64 MiB each at once, making new blocks. Every piece starts as zeros and holds only what its own thread wrote. It is sampled every 4 KiB, because the CPU reads write-combined memory slowly.VICTORY_RIPE_BLOCKSunset and set to 0. They also pass withVICTORY_D3D12_DEBUG=1in a diagnostics build.-D warningspasses.cargo test --workspace --lockedpasses (1,129 tests, none failed).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nick0451 on 2026-11-28T09:21:43Z.
Tested in the game: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. Release builds, each of #797, #801, #814 and #816 merged on its own onto main at
63b902f.How: the same frozen save, outdoors on a balcony by the water, about 5,900-6,100 draws a frame (corrected: I first wrote "an interior"). Series S, DLSS Performance, frame generation off, standing still. Each build is started once first as a warm-up (a new build's first start is slow), then the five builds are run in turn, three rounds. Each run is 40 s to settle, then 60 s measured, and the figures are medians of the frame lines. An A/A run of main against itself the same way differed by 2-3%, so smaller differences are noise.
63b902fFor this PR: about 3.6% lower fps here (24.2 against 25.1). That is just past the noise of this setup, but one of its three runs was at main's level (25.4), so I would read it as "no clear gain, maybe a small cost" rather than a regression. Preparing is unchanged. The long
MakeResidentwaits it fixes come near the card's budget, and with 24 GB this scene never gets near it.In this scene the card is about 95% busy, so the frame is the card's. Work saved on the CPU side would show in "preparing" more than in fps.
No crashes, device losses or
ERRORlines in any build: about 7 minutes in the world each, warm-up included.Tested with an AI assistant (Claude Code); results are from this PC.