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

Closed
gefydev wants to merge 1 commit from upstream-pr/3194 into main
gefydev commented 2026-11-28 17:59:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-28T17:59:54Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:5543076403 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3194). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-28T17:59:54Z. --- 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.
Foniass commented 2026-12-01 05:08:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:08:14Z.


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

  • On current main this does nothing. Since f0e8fdd5 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 #3050 (XCL_UPLOAD_KEEP_MB) already bounds. The same merge deleted the GPU test this PR edits, which is the conflict. #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.

<!-- greyfinch-sync:ivall/xcl:comment:7301457869 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3194#issuecomment-7301457869). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:08:14Z. --- Review (head 39874bf7, diff read, not a merge-check; draft and conflicting, so not built or run): - **On current main this does nothing.** Since f0e8fdd5 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 #3050 (`XCL_UPLOAD_KEEP_MB`) already bounds. The same merge deleted the GPU test this PR edits, which is the conflict. #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 commented 2026-12-01 13:01:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T13:01:13Z.


Closing as superseded: this change is already on main (f0e8fdd5). 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.

<!-- greyfinch-sync:ivall/xcl:comment:7311985237 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3194#issuecomment-7311985237). Originally posted by [throny](https://github.com/throny) on 2026-12-01T13:01:13Z. --- Closing as superseded: this change is already on `main` (f0e8fdd5). 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3194
No description provided.