Skip to content

D3D12.X: release large texture upload buffers after idle - #3194

Closed
gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:texture-staging-retention
Closed

gefydev wants to merge 1 commit into
xcl-dev:mainfrom
gefydev:texture-staging-retention

Conversation

@gefydev

@gefydev gefydev commented Nov 28, 2026

Copy link
Copy Markdown
Member

Release completed texture-upload staging allocations of at least 64 MiB after 20 seconds of inactivity. Small staging allocations and uploader command objects remain cached.

Related to #3050, which bounds idle upload buffers in the title texture uploader (hle/d3d12x/texture_upload.rs). This change is in gpu/texture.rs and does not overlap its files.

What is in it

  • Sweep only uploaders currently in the cache. Checked-out or in-flight work is ineligible. Detach the allocation under the cache lock, then release it outside the lock.

Tested

  • GeForce GTX 1650 (621.24), Ryzen 5 1600, Windows 11 Pro build 26300, Rust 1.100.0 MSVC, release.
  • cargo build --workspace --release -j 6 passed.
  • cargo test --workspace --release --no-fail-fast -j 6 -- --test-threads=4 reported 2145 passed, 0 failed and 48 ignored, with 28 SKIPPED reports inside the passed total.
  • The mixed RGBA8/BC7 GPU regression verifies exact pixels, reuse across active batches, and detachment of 144 MiB at the idle threshold. The next small allocation stays cached.

Regression run

Same title, 45 seconds, shader preparation disabled in both runs.

xcl-smoke v1
commit: db3921dcc69a32be381a17b6a81c944617338c9f
gpu: NVIDIA GeForce GTX 1650
title: eddfb802
seconds: 45
exit: 0x0
frames shown: 664 (PresentX 664)
presents per 2 s (last 3): 58 35 29
device removals: 0
crashes: 0
peak commit: 10047 MB
xcl-smoke v1
commit: 39874bf73f5a1d0e8428b4455956b246610067c0
gpu: NVIDIA GeForce GTX 1650
title: eddfb802
seconds: 45
exit: 0x0
frames shown: 748 (PresentX 749)
presents per 2 s (last 3): 36 1 0
device removals: 0
crashes: 0
peak commit: 11447 MB

Not tested

The 45-second retail smoke did not log an eligible idle release. Runtime peak savings under sustained retail streaming and AMD behavior were not measured. AMD and other adapters were not tested.

AI use

Codex (gpt-6.2-sol) implemented the change, wrote and ran the tests, and drafted this description.

Retain the uploader and its synchronization objects, but release staging allocations of at least 64 MiB after 20 seconds with no successful batch. A checked-out uploader stays outside the cache until its copy fence passes.

Assisted-by: Codex (gpt-6.2-sol)
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 39874bf, diff read, not a merge-check; draft and conflicting, so not built or run):

  • On current main this does nothing. Since f0e8fdd nothing calls gpu::texture::upload_batch / upload_batch_with_zero_mips from outside gpu/texture.rs; title texture uploads go through hle/d3d12x/texture_upload.rs (title_textures.rs ~2675). So the UPLOADERS cache this PR trims is never filled. The idle buffers kept today are texture_upload.rs's FREE pool (fixed 512 MiB cap, ~795 / ~839), which D3D12.X: XCL_UPLOAD_KEEP_MB sets the idle texture upload buffers kept #3050 (XCL_UPLOAD_KEEP_MB) already bounds. The same merge deleted the GPU test this PR edits, which is the conflict. D3D12.X: XCL_UPLOAD_KEEP_MB sets the idle texture upload buffers kept #3050 also touches host.rs, so the "does not overlap" note isn't accurate.
  • Re-creating the buffer isn't measured: main's own comment (gpu/texture.rs ~207-209) puts these D3D12 calls at 200-650 ms while streaming, so bursts more than ~20 s apart could stall each time.
  • The test drives release_idle_staging with synthetic times but not the trim_idle_staging sweep, and the PR's smoke run ends at "36 1 0" presents per 2 s without explanation.

Fine: the release is safe against the GPU (only cached uploaders are trimmed, and they enter the cache only after a successful fence wait), and the allocation is detached under the lock and dropped outside it. Given the first point, I'd close this or redo it in texture_upload.rs together with #3050.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Closing as superseded: this change is already on main (f0e8fdd). main gpu::texture upload_batch is not called outside texture.rs, so UPLOADERS is never filled at runtime (uploads moved to texture_upload.rs); the PR trims an empty cache

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

@throny throny added the duplicate This issue or pull request already exists label Dec 1, 2026
@throny throny closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants