Skip to content

GPU: honor the staging spare limit when returned ranges become reusable - #1343

Open
ghptc wants to merge 1 commit into
trustno1-coder:mainfrom
ghptc:fix/staging-allocation-spare-limit
Open

ghptc wants to merge 1 commit into
trustno1-coder:mainfrom
ghptc:fix/staging-allocation-spare-limit

Conversation

@ghptc

@ghptc ghptc commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

The budget sweep allows one idle staging block under host pressure and zero under critical commit pressure. When returned ranges finish resting between sweeps, the next allocation reloads the texture spare limit. It can keep empty 64 MiB upload buffers beyond the staging budget until a later sweep gets the mutex.

Publish the staging limit before trying the pool lock. Each pool reads its own limit when allocating. With a zero limit, reserve a reusable range for the current request before dropping the other empty blocks. Texture allocations retain their existing trim order and ripe-block selection.

Measured on an RTX 5070

A synthetic fixture on Proton Experimental and NVIDIA 620.73.04 filled four 64 MiB D3D12 upload buffers through the production pool. It returned seven of the eight half-blocks, supplied the critical spare limit while they were resting, then advanced the allocator clock to the existing rest deadline and requested the other half of the still-live block. The growth callback refused new allocations.

After the request Main (two processes) Patch (two processes)
Blocks owning real upload buffers 3, 3 1, 1
Bytes in empty blocks 128, 128 MiB 0, 0 MiB
Successful reuses / new allocations per run 1 / 0 1 / 0

These bytes count D3D12 resources still owned by the pool. The fixture supplies the pressure state directly. Physical runs used a 1 GiB high watermark, 2 GiB hard cap and zero swap. The allocator regression failed on the base with two unexpected idle blocks. All 11 pool tests passed on the proposed source, including whole-block reuse at zero budget, recovery, delayed return and ripe texture selection. Reproduce the submitted regressions with cargo test --locked -p victory-gpu --lib pool::tests:: -- --test-threads=1 on Windows.

The duplicate check included the host texture sweep, the optional texture spare scaling, driver calls outside the pool lock, and reusable texture-budget accounting. Those changes address different paths. #394 · #784 · #816 · #1214

The diagnostic-feature cross-check and staged asset policy passed locally. Upstream Windows CI stopped at the same Clippy findings on the PR and its base, in victory-shader/src/emit/mod.rs:2768 and victory-gpu/src/shadow.rs:1708. PR check · Base check

MystifiedSky added a commit to MystifiedSky/VIctory-NVIDIA-Improved that referenced this pull request Nov 28, 2026
…1-coder#1343)

Reserve the requesting allocation before trimming at a zero cap and release detached staging blocks outside the pool lock. Preserve texture limits and allocation-failure backoff.

Upstream-PR: trustno1-coder#1343

Upstream-Commit: b43cd7a
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.

1 participant