Skip to content

D3D12.X: cap title texture upload batches by count and 32 MiB - #1986

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:d3d12x/title-textures-batch-cap
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
zondy1i:d3d12x/title-textures-batch-cap

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 25, 2026

Copy link
Copy Markdown

Bound each title-texture upload batch in title_textures::upload_all to at most 256 textures and 32 MiB (down from 256 MiB with no item limit).

Previously, upload_all only split batches at 256 MiB (BATCH_BYTES = 256 << 20). During heavy streaming of small textures (4–64 KiB mip tails / UI / cubemaps), thousands of textures could accumulate below 256 MiB and be recorded into a single ExecuteCommandLists call (2 * N transitions + N * mips copies), risking a Windows 2 s WDDM TDR (DXGI_ERROR_DEVICE_HUNG). Because gpu::texture::Uploader::staging rounds the peak batch footprint up to a power of two and keeps that upload buffer permanently mapped, a single 256 MiB batch also pinned a 256–512 MiB persistent upload heap for the rest of the process lifetime.

What is in it

  • Lower BATCH_BYTES from 256 << 20 to 32 << 20 and add BATCH_ITEMS = 256 in crates/xcl/src/hle/d3d12x/title_textures.rs.
  • Extract batch_fits() with saturating_add so empty batches always accept their first upload (even if larger than BATCH_BYTES, preserving progress), while subsequent uploads split at BATCH_ITEMS, BATCH_BYTES, or device changes.
  • Skip subresources_of_all / upload dispatch when every remaining entry in a chunk was filtered out by unchanged_skip().
  • Add unit test batch_fits_caps_items_bytes_and_device covering oversized single textures, item-count splitting, exact/overflow byte bounds, and device switching.

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 621.01), AMD Ryzen 5 7500F, 64 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke.
  • cargo test -p xcl --lib title_textures -- --test-threads=1: 14 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib gpu::texture -- --test-threads=1: 12 passed, 0 failed, 0 ignored.

Regression run

main:

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16539 MB

PR:

xcl-smoke v1
commit: fb9d05910c783ee1999e5d57770ce37728d603fd
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1637 (PresentX 1637)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15315 MB

Not tested

  • Full workspace test suite; AMD / Intel GPUs; Linux / Wine + vkd3d-proton; multi-device batching.

AI use

  • Antigravity (Gemini 4 Neon) extracted batch_fits, added the unit test, ran the test/smoke verification, and drafted this description.

@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head fb9d059 (on its base 80f4819).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 983 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: batch_fits_caps_items_bytes_and_device.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 993 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 7994cd1 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@raylitebull

Copy link
Copy Markdown
Member

Code review on fb9d059:

  • Bounding title_textures.rs upload batches by count and total byte budget cleanly caps per-batch staging growth and copy bursts.
  • Diff audited and CI workflow approved (currently running).

Remaining before merge: Build and test (Windows, no GPU) finishing green plus an AMD verification pass on fb9d059.

@JJAutoCompare

JJAutoCompare commented Nov 25, 2026 •

Copy link
Copy Markdown

Empirical verification — PR #1986 (fb9d05910c783ee1999e5d57770ce37728d603fd)

Tested clean detached PR head fb9d05910c783ee1999e5d57770ce37728d603fd (git merge-tree --write-tree exited 0 against origin/main at 2bdf0477f84377d1b08e29424100c9bace4e530f and 8f5fca5bb9ad6e695093d75294ad2cec023bba60).

Environment

  • STOR-WINLAB, Windows 11 Enterprise Evaluation build 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 16 GiB (driver 32.0.101.9175, wave lanes 8–32, DoublePrecisionFloatShaderOps=0, XCL_ADAPTER=A770, d3d12SDKLayers.dll absent).
  • rustc 1.100.0 (0ef1bc386 2026-11-09) (CARGO_INCREMENTAL=0, debug info 0); DXC/DXIL 1.9.2609.5 on PATH.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both exited 0 outside the GPU lock.
  • cargo test -p xcl --lib batch_fits_caps_items_bytes_and_device: 1 passed, 0 failed, 0 ignored (969 filtered out; covers count/byte caps, oversized first upload, overflow, and device change).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output (under Invoke-ArcTest.ps1, exited 101): 968 passed, 26 failed, 45 ignored across 20 test binaries, with 26 SKIPPED lines across 16 distinct tests (excluded from coverage).
    • Failures (26): 25 in xcl --lib DXIL/recompiler GPU tests (21 CreateComputePipelineState 0x80070057 including FP64/fuzz/round/groupshared tests + 4 shader output assertions) and 1 in e2e (test_title_runs_and_game_folder_is_untouched, dynamic depth bias RSSetDepthBiasX Split wave64: masks read only lane by lane stay in their half #94 top-right blue vs expected green). None touch the texture upload batch path.
    • Skips (26 lines): wave64 unavailable, refused wave32 f16 per-lane lowerings, driver cache disable (0x887A002D), tiled tier < 2, missing D3D12 debug layer, and unavailable heap windows.

Not tested

  • Retail-title smoke runs (scripts/smoke.ps1), matched main baseline, XCL_SAMPLE_* data (unset), AMD/NVIDIA GPUs, native wave64, and hardware FP64.

AI use

  • T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and tests and drafted the report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1986-suite.log, published, and compacted this comment in place.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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