Skip to content

D3D12.X: XCL_UPLOAD_KEEP_MB sets the idle texture upload buffers kept - #3050

Draft
Prime1997 wants to merge 1 commit into
xcl-dev:nvidia-devfrom
Prime1997:contrib/nv-upload-keep
Draft

Prime1997 wants to merge 1 commit into
xcl-dev:nvidia-devfrom
Prime1997:contrib/nv-upload-keep

Conversation

@Prime1997

@Prime1997 Prime1997 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

XCL_UPLOAD_KEEP_MB bounds completed texture-upload buffers retained for reuse (0–4096 MiB, default 512). Active buffers remain owned until completion. The activity log separates idle upload memory from submitted buffers awaiting reclaim. This addresses retained system-memory upload heaps; it does not cap live textures, VRAM or total process commit.

Part of #2688; related to #2912's in-flight upload reclamation. This refreshes the existing proposal on nvidia-dev 54225f5884a94cd23b7aab3f703a7c975070aa77 rather than opening another PR. Current main e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd uses a different uploader and does not contain this idle-pool switch.

What is in it

  • Preserve the existing configurable cap and upload diagnostics, resolve the activity-loop rebase, and document the switch.
  • Add a functional test using isolated WARP processes: allocate 6 MiB, exercise zero and 2 MiB idle caps, preserve checked-out contents, discard the largest idle buffer, and reuse retained buffers. No command queue or GPU submission is used.

Tested

  • Clean head cbb909c08ca786b4ddfeaf95b686aa105bec43e4; Windows x64, debug Rust tests, software WARP device. Commands below use the actual arguments with only the private build-cache path abbreviated as <target>.
  • cargo test --locked -p xcl --lib --target-dir <target> hle::d3d12x::texture_upload::tests::the_idle_upload_buffers_kept_follow_the_switch -- --exact --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored, 0 explicit skips.
  • cargo test --locked -p xcl --lib --target-dir <target> hle::d3d12x::texture_upload::tests::idle_upload_limit_releases_buffers_and_keeps_reusable_ones -- --exact --nocapture --test-threads=1: 1 top-level test passed, 0 failed, 0 ignored, 0 explicit skips; two child cases each passed separately. Nested summaries are not added to the top-level count.

Regression run
Pending for this head. Previous-head smoke blocks and whole-suite results are historical and do not establish validation of this revision. Keep this PR a draft.

Not tested

  • Current-head full workspace suite, hardware GPU behavior, paired current-main/title regression, and release gameplay.
  • Frame-time cost of low retention limits, overall process-memory reduction, and AMD hardware.

AI use
Original implementation by Claude Code (Claude Opus 5.5), as recorded in the previous revision. Codex (GPT-6) rebased it, added the functional fixture/documentation, reviewed current-main overlap, and ran the focused checks above. Earlier contributors' results are not presented as new runs.

Optional temporary contributor/testing coordination: https://discord.gg/gK3y7WRRY

@Prime1997 Prime1997 self-assigned this Nov 27, 2026
@Gevroska

Copy link
Copy Markdown

I tested the idle upload-buffer cap at d6d529c2 on Windows 11 with Microsoft WARP. I ran the same test binary in three fresh processes. Each run submitted two RGBA8 upload jobs, waited for their completion fences, then returned the 1 MiB buffer to the idle pool followed by the 2 MiB buffer.

Configured cap Idle after first return Idle after both returns
Default (512 MiB) 1 MiB 3 MiB
0 MiB 0 MiB 0 MiB
1 MiB 1 MiB 1 MiB

With the 1 MiB cap, the next small upload reused the same buffer. Idle capacity dropped to zero while it was checked out and returned to 1 MiB after its fence completed. All three runs passed byte-for-byte readback checks for both textures and the subsequent refresh, with zero skips. These measurements cover idle buffer capacity on WARP. I didn’t measure process memory, physical GPU performance, or GTA VI loading.

I used OpenAI Codex with GPT-6.2 Sol to write and run the test. A separate GPT-6.2 Sol agent verified the artifact and logs. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@pickles976

Copy link
Copy Markdown

Exact production d6d529c verified on RTX 4060 Laptop/Wine 11, with only a local test fixture added to texture_upload.rs.

cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib idle_upload -- --nocapture --test-threads=1: 2/2 pass, 0 ignored, 2.53 s after fresh intended-worktree compile32.86 s. Includes the owner's parser/policy test and a new three-child real-GPU consumer fixture. Each child independently initializes the once-read setting and requires NVIDIA vendor0x10de/non-software through the actual D3D12 device's adapter LUID.

A 64x64 R8 upload plus 1024x1024 RGBA8 burst allocate 1 MiB and4 MiB staging jobs, neither counted idle while checked out. Both jobs are returned only after real queue-fence completion:

XCL_UPLOAD_KEEP_MB Completed idle buffer capacity
0 0 MiB
2 1 MiB
8 5 MiB

All GPU texels remain correct after trimming. A second differently patterned small upload reuses the original smallest-fitting buffer when retained; with zero retention it still returns every correct byte. The large texture remains intact after this subsequent upload. Device remains healthy in all three fresh processes. No fake fence completion or shader dispatch.

This verifies the actual allocated idle-pool cap and data correctness, not OS resident-RAM reduction, in-flight retirement under a stalled GPU, native Windows, title memory peaks, or improved frame times. Lowering the cap can increase allocation churn/stutter; no new default recommended without matched real loading measurements. The fixture's retained-capacity figures are not RSS.

Linux6.17/i7-13620H/16 GiB RAM/8 GiB VRAM, NVIDIA590.48.1, masking disabled; diagnostic-relaxed-vtable vkd3d2576c0b4adfae4a+, not stock certification. All guards unchanged. GPUpeak238 MiB, availableRAM minimum9120.3 MiB. Evidence .compat-runtime/logs/verify-xcl3050-idle-pool-texels-20261127T184950Z/.

Next useful owner measurement: matched burst/reuse workload or loading trace with allocation count and frame-time tails at a smaller retention cap, separating idle capacity from pending uploads and actual resident memory.

@andrewDoing

Copy link
Copy Markdown

I checked the activity-line wording on RTX 5070 / NVIDIA 616.92 at head d6d529c2f7d725f12b157aeb25fe59513dc390f4 with a test-only fixture using the production upload queue and upload_line.

A queue fence held the upload until released. While its upload fence was incomplete, the line reported 0 MB idle / 1 MB the GPU has not read yet. After signaling the gate and waiting for the actual upload fence to complete, but before another upload or reclamation, the line was unchanged. The texture readback matched all 4,096 expected bytes. After invoking the production reclaim function, the line changed to 1 MB idle / 0 MB the GPU has not read yet.

The focused test passed with no skips. The queued count therefore includes completed staging buffers awaiting reclamation; it is not an exact measure of bytes the GPU still has to read. Wording such as “submitted upload buffers awaiting reclamation” would distinguish that accounting from fence progress. This is an activity-reporting observation, not an upload corruption or process-memory measurement.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

Prime1997 added a commit to Prime1997/xcl that referenced this pull request Nov 27, 2026
The line said its second number was what the GPU had not read yet, but the
count includes buffers whose upload finished and that wait for the next
reclaim (andrewDoing's fixture on xcl-dev#3050: unchanged after the fence until
reclaim ran). It now says what it counts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Prime1997

Copy link
Copy Markdown
Collaborator Author

Thanks to all three of you. @Gevroska and @pickles976: agreed, the default stays at 512 MiB until a loading run with a smaller cap measures allocation churn and frame-time tails. The run in the description only measured what's kept idle (378 MB at 277 s).

@andrewDoing: right, the second number includes finished uploads that are waiting for the next reclaim. 94b7a07 now words it as "submitted and not taken back yet". The new head's suite and smoke are in the description.

AI use: Claude Code (Claude Opus 5.5) wrote this reply; Prime posted it.

Refresh the existing PR xcl-dev#3050 on nvidia-dev. Preserve its configurable idle cap and submitted-versus-idle diagnostics, and cover actual allocation, trimming and reuse in isolated WARP processes without submitting GPU work. Keep active buffers alive and document that this limits system-memory upload heaps, not live textures or total process commit.

Original implementation: d6d529c and 94b7a07 (Prime / Claude Code). Refreshed and tested with Codex (GPT-6).
@Prime1997
Prime1997 force-pushed the contrib/nv-upload-keep branch from 94b7a07 to cbb909c Compare November 28, 2026 08:38
@JJAutoCompare

Copy link
Copy Markdown

Tested

Exact cbb909c08ca786b4ddfeaf95b686aa105bec43e4 on native Windows 11 x64 build 26200.9974, Ryzen 7 3800X, and Rust 1.100.1 MSVC debug. I reran the pinned libtest after verifying all 386 original Git blobs and reconstructing the private test insertion in memory.

I ran <libtest.exe> hle::d3d12x::title_textures::tests::warp_upload_accounting_until_reclaim --exact --nocapture --test-threads=1 in two fresh processes with XCL_ADAPTER=warp, XCL_NETWORK=0, and XCL_UPLOAD_KEEP_MB=0 then 2. Both processes identified Microsoft Basic Render Driver (1414:008c) with the DXGI software flag and matching adapter and D3D12 device LUIDs.

  • On one DIRECT queue, the gated reclaim poll and the completed fence before explicit reclaim both left 1,048,576 bytes submitted and zero idle. The activity line reported 0 MB idle, 1 MB submitted and not taken back yet.
  • Explicit reclaim reduced submitted bytes to zero in both runs. Idle stayed at zero with cap 0 and rose to 1,048,576 bytes with cap 2. Both readbacks matched all 4,096 bytes against 0x77, and both device health checks returned S_OK.

2 passed, 0 failed, 0 ignored, 0 runtime skips. Both native processes exited 0, with 1,808 tests filtered out each.

Not tested

Physical GPUs, cross-queue or queue-release behavior, pool reuse, process memory, timing, retail smoke, or the full suite.

AI use

T3 Code through the Codex harness (gpt-6.2-sol) verified the source and executable, reran the two tests, and wrote this report.

@Gevroska

Copy link
Copy Markdown

Thanks, Prime. On my RTX 3080, lowering the cap from 512 to 128 MiB reduced peak sampled idle upload capacity from 504 to 124 MiB and increased staging-buffer allocations from 15 to 64 during loading. I’d keep the 512 MiB default. The allocation trade-off showed up clearly, but the two runs didn’t isolate the cap’s effect on frame times.

I used the same instrumented build based on 94b7a070, identical starting DXIL caches, and a 20-minute window after Confirm in each run. The PR has since advanced to cbb909c0. The timing samples below are intervals between host presents during loading.

After Confirm 512 MiB 128 MiB
Staging allocations / idle-buffer reuses 15 / 1,270 64 / 1,320
Cap evictions 3 59
Peak sampled idle upload capacity 504 MiB 124 MiB
Host-present intervals measured 766 672
p95 / p99 interval 172.7 / 1,116.4 ms 290.1 / 2,198.5 ms
Time from last host present to end of window 1,109.4 s 1,054.0 s

All 59 evictions at 128 MiB occurred about 60–140 seconds after Confirm. Present intervals were already longer in that run during the first 45 seconds, before its first eviction. The p99 ordering also changed with the observation window: over the first 90 seconds, p99 was 657.1 ms at 128 MiB and 1,116.4 ms at 512 MiB. I wouldn’t attribute the higher full-window p99 to the smaller cap from this pair alone.

An initial 512 MiB attempt hit DXGI_ERROR_DEVICE_HUNG about 48 seconds after Confirm. The completed pair was the 128 MiB run followed by a fresh 512 MiB repeat. Both completed runs exited on schedule without a crash or device removal. Both stopped presenting during loading, and neither showed gameplay.

I used OpenAI Codex with GPT-6.2 Sol to implement and calibrate the measurement and run the comparison. A separate GPT-6.2 Sol agent verified the saved evidence. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

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.

5 participants