Skip to content

D3D12.X: fill memory from the list's upload memory, not a pattern buffer per value - #838

Open
mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/d3d12x-fill-memory-upload-arena
Open

mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/d3d12x-fill-memory-upload-arena

Conversation

@mastrr9

@mastrr9 mastrr9 commented Nov 24, 2026 •

Copy link
Copy Markdown

Replaces the leaked 32-entry PATTERNS upload buffer cache in list_x::fill() (FillMemoryWith{32,64,128}BitValueX) with the command list's own upload arena (bind::allocate_upload_memory), copying over the destination in FILL_CHUNK (ARENA_BLOCK / 2, 128 KiB) chunks with the same state transitions CopyMemoryToMemoryX uses.

  • Previously, each distinct (pattern, size) allocated a committed upload buffer rounded up to a power of two (up to 256 MiB) and kept it forever; after 32 entries, fills with any new value were dropped with a warning.
  • Now, pattern memory is released automatically when the list's command allocator resets, and arbitrary numbers of distinct fill values work without leaking upload memory.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: ba1f7e888b8c1c0386ce62edd3c3b1509a5348f2
  • cargo build --workspace: clean (only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored (new test hle::d3d12x::list_x::tests::fill_copies_cover_the_range_once passed)
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Regression run
Smoke run by @CuteBooty in comment below: #838 (comment)
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.

main:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1466 (PresentX 1466)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15248 MB

PR:

xcl-smoke v1
commit: 3784317880c0cff8954a161b33629233d8e9cbb8
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1519 (PresentX 1519)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15432 MB

Tester's setup: RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build.

Tester's method: scripts\smoke.ps1 -Game <folder> -Seconds 60, no input, on this PR's head as it is and on main beaa245, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The main block is shared with the tester's reports on other PRs of the same base.

Tester's AI use: Claude Code (Claude Opus 5.5) made the runs with the tester present and wrote the report from the script's output.

Not tested

  • No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
  • Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.

@futurepro62

Copy link
Copy Markdown

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

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: fill_copies_cover_the_range_once.

Not tested

  • AMD, 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.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head ba1f7e8 onto main a1672ef, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 706 passed, 10 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Upload-memory fill tests green; no new failures.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#851, xcl-dev#864, xcl-dev#875-xcl-dev#876 and Wine raw fences

Integrate clean upstream PRs on top of upstream/main (1ec4c98):
- xcl-dev#849: direct move_away for remapped physical pages (avoids 4x sparse tile-mapping round-trips)
- xcl-dev#838: FillMemoryWith*BitValueX uses list upload arena instead of leaked pattern buffers
- xcl-dev#840: merge released ranges of the shared descriptor heap
- xcl-dev#839: map queue-specific D3D12_BARRIER_LAYOUT values to legacy resource states
- xcl-dev#841: preserve due frame-clock events when schedule changes at deadline
- xcl-dev#851: split wrapped command lists before Wait64 GE after ordinary GPU work
- xcl-dev#864: export XMemIsToolsMemAvailable returning 0 on retail
- xcl-dev#875: tbuffer_load_format_* uses identity DST_SEL instead of V# DST_SEL
- xcl-dev#876: implement IDXGIDevice2::EnqueueSetEvent

Also add real::create_raw_fence for internal fences (late_release and EnqueueSetEvent) so Wine/vkd3d-proton never receives a FenceProxy on unadopted internal queues or SetEventOnMultipleFenceCompletion, and wrap list_x test exec with UnadoptGuard.

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
… Linux PRs ivall#867/ivall#871/ivall#877

Update fork README for upstream/main 1ec4c98 (fenced late_release and queue-wait diagnostics), newly integrated PRs (ivall#838-ivall#841, ivall#849, ivall#851, ivall#864, ivall#875, ivall#876), live gameplay audio progress, and our three open upstream Linux PRs (ivall#867, ivall#871, ivall#877).

Assisted-by: Antigravity (Google DeepMind)
…fer per value

FillMemoryWith{32,64,128}BitValueX copied from an upload buffer of the
pattern, one per value and size (rounded up to a power of two, up to
256 MiB each), kept for good. After 32 of them every fill of a new value
was dropped with a warning, and a large fill of each value kept that much
upload memory for the rest of the run.

The pattern is now written into the list's own upload memory
(AllocateUploadMemory's arena, released with the list's allocator) and
copied over the destination in chunks of half an arena block.

Assisted-by: Claude Code (Claude Opus 5.5)
@mastrr9
mastrr9 force-pushed the fix/d3d12x-fill-memory-upload-arena branch from ba1f7e8 to 3784317 Compare November 24, 2026 07:58
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#864, xcl-dev#875-xcl-dev#876

Re-apply the 8 non-merged upstream PRs from our previous fork main onto upstream/main (930e8b4): xcl-dev#838 (upload-arena fills), xcl-dev#839 (queue-specific barrier layouts), xcl-dev#840 (coalesced shared descriptor heap), xcl-dev#841 (frame clock deadline reschedule), xcl-dev#851 (split before Wait64 GE after ordinary work), xcl-dev#864 (XMemIsToolsMemAvailable), xcl-dev#875 (tbuffer_load_format identity DST_SEL), and xcl-dev#876 (IDXGIDevice2::EnqueueSetEvent with create_raw_fence).

Assisted-by: Antigravity (Google DeepMind)
@mastrr9
mastrr9 marked this pull request as ready for review November 24, 2026 16:42
@CuteBooty

Copy link
Copy Markdown

Regression run on a retail title for 3784317: pass (no device removal, no crash, frames and peak commit within the check's limits).

Tested

  • RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build.
  • scripts\smoke.ps1 -Game <folder> -Seconds 60, no input, on this PR's head as it is and on main beaa245, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The main block is shared with my reports on other PRs of the same base.

main:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1466 (PresentX 1466)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15248 MB

this PR:

xcl-smoke v1
commit: 3784317880c0cff8954a161b33629233d8e9cbb8
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1519 (PresentX 1519)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15432 MB

Not tested

  • Whether the 60 s reach the code this PR changes, the world load, the test suite, current main merged in, AMD and Intel GPUs.

AI use

  • Claude Code (Claude Opus 5.5) made the runs with me present and wrote this from the script's output.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (3784317)

Verified PR #838 at detached head 3784317880c0cff8954a161b33629233d8e9cbb8.

Hardware / environment

  • Windows x64, build 26200, on an AMD x64 CPU (family 23, model 113).
  • Rust 1.100.0 (0ef1bc386 2026-11-09) and DXC 1.9.2609.5 (01b62ad47). Cargo used the unoptimized test profile with debug information and incremental compilation disabled.
  • The focused fixture ran on CPU outside Invoke-ArcTest.ps1 with XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1.

Commands and results

  • cargo test --workspace --no-run exited 0 and built the workspace test binaries.
  • cargo test -p xcl --lib hle::d3d12x::list_x::tests::fill_copies_cover_the_range_once -- --exact exited 0 with 1 passed, 0 failed, 0 ignored, and 0 skipped. The exact filter excluded 693 other library tests.
  • Cargo emitted a deprecation warning for AtomicU32::fetch_update in XGameRuntime.

Observed behavior

The fixture passed its assertions for a fill smaller than one chunk, exactly one chunk, and two full chunks followed by a 36-byte tail. For six representative sizes from 4 bytes up to the 256 MiB fill limit, it checked contiguous offsets, positive copy lengths bounded by the chunk size and divisible by four, and an end offset equal to the requested size.

Not tested

The full GPU workspace suite and game smoke runs were omitted. This run covered CPU chunk planning. GPU copy execution, resource transitions, and the lifetime of the upload allocation were outside the fixture's coverage.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr838-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@ClosetPie107

Copy link
Copy Markdown

Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head 3784317880c0cff8954a161b33629233d8e9cbb8 (merged cleanly onto main 2898511).

Hardware & environment

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1, native wave64), Ryzen 5 9600X, 30 GiB RAM, CachyOS Linux
  • Proton Experimental (experimental-11.0-20261112), vkd3d-proton master ec207194 (3.2.0) + dxil-spirv b540c8a2 + relaxed-vtable patch (-Db_ndebug=true), DXVK v3.1.1-209, DXC 1.9.2609.5, Rust x86_64-pc-windows-gnu (debug for tests, release for retail)

Unit / GPU tests (XCL_REQUIRE_GPU=wave64, XCL_DXC_DIR, VKD3D_CONFIG=ignore_shared_fence, --test-threads=1 --nocapture)

  • hle::d3d12x::list_x::: 37 passed, 0 failed, 0 ignored (0 skipped)

Combined retail sanity run (main 2898511 + #2103, #838, #1250, #1733 merged together; XCL_DIRECT_DXIL=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PSO_WAIT_MS=50, XCL_SPLIT_MIDLIST_WAIT=0, XCL_COHERENT_MB=1024, VKD3D_CONFIG=ignore_shared_fence, XCL_PSO_PRELOAD=0, XCL_NETWORK=0, warm PSO cache)

  • Ran 268 s with 0 device removals, 45,841 translated draws, 154,125 dispatches (+ 4,634 chained split-compute), 47,255 Opus packets (0 errors), 13.2 GiB peak VRAM (0 GTT spill), 15.1 GiB peak RSS (vs 19.3 GiB on clean main 2898511).
  • Ended at 268.4 s on the same pre-existing main 0xc0000005 TOCTOU race in title_textures::subresources (copy_nonoverlapping reading 0x793a08000) also reproduced on clean main 2898511 (161.8 s).

Not tested

  • Full workspace test suite, native Windows, or an isolated single-PR retail run (retail sanity run above was on the 4-PR batch).

AI use

  • T3 Code / Antigravity (Gemini 4 Neon) merged the PR onto main, ran the tests and combined retail run under Proton on this machine, and drafted this report.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: new d==s path violates D3D12 resource state. as_copy_dest transitions entire buffer resource to COPY_DEST, then CopyBufferRegion reads source s from the same resource/another offset without COPY_SOURCE. Buffers are state-tracked per resource, not byte range; non-overlap does not permit simultaneous source COPY_SOURCE/dest COPY_DEST because COPY_DEST is write-only. Use a distinct source resource/window/staging/GPU-fill path and add a debug-layer case where arena allocation/destination share a window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants