Repository navigation
Conversation
…ploads Title texture batch uploads created and tore down a D3D12 command allocator, command list, fence, wait event, and one upload buffer per texture on every ExecuteCommandLists refresh (hundreds of times per second during video playback and streaming). Add gpu::texture::BatchUploader to reuse the allocator, list, fence, event, and a persistently-mapped upload staging buffer (capped at 64 MiB; larger one-off batches use a temporary buffer) per device, with contiguous copies when row pitch matches. Assisted-by: Antigravity (Gemini 4 Neon)
|
Test report on AMD RDNA3: RX 7800 XT (16 GB, wave32 and wave64), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used. The PR's own runs are all on NVIDIA, so this adds an AMD GPU with 64-lane waves. Tested: the PR head
Not tested: a regression run on a title, a release build, the head merged onto current AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above. |
|
One upload-lifetime issue in 1152852. The fence helper can return a timeout with the submitted copy still pending. The caller logs the error and keeps the uploader cached. A later upload can then overwrite the staging buffer or reset the allocator before the previous copy has finished. Staging and allocator reuse · D3D12 allocator reset requirements Could the uploader retain the submitted batch and gate reuse on confirmed fence completion, with device removal handled separately? A focused test could check that a timed-out batch keeps its staging allocation and blocks reuse until completion. I verified this path by reading the source and D3D12 contract. I did not induce a GPU timeout. AI use |
If fence::wait times out while a submitted texture copy is still in flight, BatchUploader previously dropped any temporary staging buffer and allowed the next upload_batch call to overwrite staging or reset the command allocator before the GPU finished. Retain the pending fence target and temporary staging allocation across timeouts, gate subsequent uploads on confirmed completion, handle device removal separately, and add a focused GPU test covering pending-batch retention and recovery. Assisted-by: Antigravity (Gemini 4 Neon)
|
Good catch @thehollowedone! Fixed in 13aa0ac: BatchUploader now keeps a PendingBatch (fence target + any temporary staging buffer) across timeouts and checks inish_pending before touching staging or resetting the command allocator, while handling FenceError::Removed separately by releasing pending staging and marking the uploader removed. Added gpu_batch_uploader_retains_pending_batch_and_blocks_reuse_until_completion covering pending-batch retention across timeout and recovery once the fence completes, plus a fresh 30s smoke run. |
|
Tested on an RTX 3080 against Setup: RTX 3080 10 GB, driver 610.88, 32 GB RAM with ~15–17 GB used by other programs. Release builds of
All smoke runs reported Not tested:
The same numbers are posted on the other PRs: #451, #455. Test runs and this report: Claude Code (Claude Opus 5.5). |
|
I noticed that #465 included a contiguous staging copy for tightly packed texture subresources, but this specific optimization does not appear to be present in current main. Would you be open to revisiting that isolated change, with credit to the original implementation? I would benchmark actual D3D12 upload memory on an RTX 4060, use WARP as an additional correctness control, and proceed only if the improvement is repeatable, with byte-exact GPU readback and no regression for padded layouts. No runtime changes have been made yet. |
What is in it
gpu::texture::BatchUploaderincrates/xcl/src/gpu/texture.rsto reuse a per-deviceID3D12CommandAllocator,ID3D12GraphicsCommandList,ID3D12Fence, waitHANDLE, and a persistently-mapped upload staging buffer (capped at 64 MiB; larger one-off batches fall back to a temporary staging buffer).fence::waittimeouts so a laterupload_batchcall cannot overwrite staging or reset the command allocator while an earlier copy is still in flight; clear pending state and mark the uploader unusable on device removal.row_bytes == RowPitch, falling back to row-by-row copies otherwise.hle::d3d12x::title_textures::upload_allto keep oneBatchUploaderper device inUPLOADERSinstead of creating and destroying an allocator, command list, fence, event, and one upload buffer per texture on everyExecuteCommandListsrefresh.gpu_batch_uploader_reuses_staging_and_reports_partial_failuresandgpu_batch_uploader_retains_pending_batch_and_blocks_reuse_until_completionincrates/xcl/src/gpu/texture.rs.Tested
32.0.16.1714, wave32-only), DXC1.9.2609.5.cargo test -p xcl --lib gpu::texture -- --nocapture: 13 passed, 0 failed (includinggpu_batch_uploader_reuses_staging_and_reports_partial_failures,gpu_batch_uploader_retains_pending_batch_and_blocks_reuse_until_completion, andgpu_console_textures_upload_every_mip_and_sliceon the RTX 3090).cargo test -p xcl --lib title_textures -- --nocapture: 7 passed, 0 failed (includinggpu_mirror_upload_follows_cpu_writes_and_later_mapping_changesandplaced_title_textures_share_vram_and_preserve_pixelson the RTX 3090).cargo test --workspace -- --test-threads=4(lib, on base1152852): 636 passed, 1 failed (hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory, pre-existing failure in this environment; confirmed passing on RDNA3 by reviewer), 21 ignored; 2 GPU tests reportedSKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64andgpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64.cargo test --workspace --test "*" -- --test-threads=4: 40 passed, 0 failed across all 12 integration test binaries.Regression run
Not tested
gpu_batch_uploader_retains_pending_batch_and_blocks_reuse_until_completion).hle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memoryfailed in this environment (unrelated to this PR).AI use