Skip to content

D3D12.X: allow title texture pages in system memory - #1702

Open
rrrarrra9 wants to merge 1 commit into
xcl-dev:mainfrom
rrrarrra9:codex/texture-pages-system-memory
Open

rrrarrra9 wants to merge 1 commit into
xcl-dev:mainfrom
rrrarrra9:codex/texture-pages-system-memory

Conversation

@rrrarrra9

@rrrarrra9 rrrarrra9 commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of #1773 and related to #640 and #1452. Keep title texture heaps on the default D3D12 heap unless XCL_TEXTURE_PAGES_SYSTEM_MEMORY=1 selects GPU-only L0. This rebase preserves #1747's per-heap tile batching, rollback, cooling, and mapping fences.

What is in it

  • vram.rs passes the device's selected heap properties to the allocator. The tests cover the opt-in properties and map a two-tile texture through the batch allocator, check its actual heap, and verify that the tiles return to the pool after unmapping.
  • README.md documents the opt-in flag and its memory trade-off.

Tested

  • Clean head 670a0f926b14f628349ab1f7be0ad7e85977b3af on Windows, GTX 1650 (4 GB), Rust 1.100.0. Ran cargo build --locked --offline --workspace and cargo test --locked --offline --workspace --no-fail-fast -- --test-threads=4 --show-output in an isolated target directory. Both flag modes returned 977 passed, 0 failed, 45 ignored, and both new tests ran. Each run logged 24 skips (18 for wave64, 3 unsupported DXIL operations, one each for driver-cache control, reserved cube mips, and disabled heap windows).
  • The release smoke pair below uses L0 off and a fresh XCL data root for each run. The head retained 86.8% of main's frames and 99.4% of its peak process commit, with no device removal or crash.
  • In two additional offline starts on the same release head (separate cold XCL data roots), activity samples near 119 s measured 6,515 / 2,932 MiB local and 1,364 / 4,945 MiB non-local (default / L0), with 3,584 MiB of texture pool heaps in both runs. The default window closed at 145.7 s after 1,425 PresentX calls recorded in the report. The L0 run completed 150 s with 1,486 presents and no device removal or crash. The separate 150 s main run completed with 1,500 presents.
  • An independent RTX 3090 pixel readback validated L0 on the previous head. Test report

Regression run

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce GTX 1650
title: retail-series-x-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 499 (PresentX 499)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 11698 MB
xcl-smoke v1
commit: 670a0f926b14f628349ab1f7be0ad7e85977b3af
gpu: NVIDIA GeForce GTX 1650
title: retail-series-x-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 433 (PresentX 433)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 11622 MB

Not tested

  • Story-mode play, per-frame latency, or the rebased runtime on other adapters. The startup runs did not measure DXGI budgets.

AI use

  • OpenAI Codex (gpt-6.2-sol) rebased the change, wrote the batch-allocation test, ran the validation, and drafted this report.

@WebIdentity1

Copy link
Copy Markdown

Independent RTX 3090 check of exact head d19ae2e (24 November). I compared clean parent 9e3831e1f570d3646e53ab753b19ec07eb8f1485 and head d19ae2e70e22b159300e7f80db301885a0c71e6c on Windows 10 19045, RTX 3090 driver 591.74, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, Agility 1.620.2 x64. Each 227-file source archive matched its SHA256 manifest on Windows before and after. Serial desktop Session 1 runs used XCL_ADAPTER=3090, XCL_REQUIRE_GPU=mesh, XCL_HEAP_WINDOWS=1, direct DXIL unset. cargo build --locked --workspace exited 0 for all three configurations. cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output across 20 targets:

Configuration Passed / failed / ignored
Parent, L0 flag absent 775 / 1 / 41
Head, L0 flag absent 776 / 1 / 41
Head, XCL_TEXTURE_PAGES_SYSTEM_MEMORY=1 776 / 1 / 41

The head's extra pass is its new heap-properties test. All three runs failed only the existing gpu_clamp_and_omod_per_instruction lane-0 v_pk_add_i16 clamp case (separate #202); each printed two explicit debug-layer SKIPPED lines; no timeout. Neither full suite passed.

For direct NVIDIA coverage of the changed path, I used a local test-only fixture on the exact head in two fresh SSH Session 0 processes, flag absent versus 1: cargo test --locked -p xcl --lib texture_page_pool_reads_back_on_selected_adapter -- --test-threads=1 --show-output --nocapture. It selected adapter=NVIDIA GeForce RTX 3090, placed two four-tile R32_UINT reserved textures through place_pages, checked the actual 64 MiB pool heap descriptor, and uploaded/read back all eight 64 KiB tiles. Both runs 1 passed / 0 failed / 0 ignored, no skip or wrong words. Flag absent: DEFAULT heap, DXGI local/nonlocal usage delta +70.46/+14.91 MiB. Flag 1: CUSTOM heap with L0, CPU page unavailable, delta +6.46/+78.91 MiB. The snapshot includes D3D12 overhead, but the ~64 MiB segment shift matches Microsoft's L0/nonlocal mapping on discrete GPUs. The test-only overlay was just a four-line vram.rs registration plus synthetic fixture; Windows SHA256 after the runs matched local (vram.rs b03175aba088cac2b781139e38d2174604f8e27c9287eaae5ad10005deee924d, fixture e5954677705451fe8fbd1820e0c0a532923633a132fcfb2ebfb31c7cd4be3836).

This verifies L0 selection and GPU-byte readback on a 3090, not title performance, longer churn, shader sampling or gameplay. I used no proprietary title files; I cannot provide the required exact-head retail smoke. The author's GTX 1650 title runs still ended in device removal. No code from this probe was committed or pushed.

AI use: Codex (GPT-6) prepared and ran the exact-revision Windows comparisons and synthetic GPU fixture, checked the hashes and logs, and drafted this report.

@ofc0urse

Copy link
Copy Markdown
Contributor

Tested d19ae2e on an 8 GB NVIDIA card in the retail title. The switch moves the texture pages out of VRAM as described: 3.9 GB local instead of 13.9 GB, with about the same number of frames.

Tested: main 85e3826 with d19ae2e merged (no conflicts), release, no local patches. RTX 4060 Ti 8 GB, driver 621.24, i5-14400F, 32 GB, Windows 11 Pro 26300, retail 1.0.2.1. XCL_NETWORK=0, XCL_ACTIVITY=1, A pressed at 115, 125 and 150 s, 600 s per run. The same binary for both runs, XCL_TEXTURE_PAGES_SYSTEM_MEMORY=1 first, unset second.

=1 (1st run) unset (2nd run)
video memory, local, at 200 / 300 / 580 s 3,836 / 3,843 / 3,882 MB 13,928 / 13,956 / 13,956 MB
video memory, non-local, at 300 s 14,960 MB 4,872 MB
process commit at 300 s 31,241 MB 32,970 MB
frames in the run 4,307 4,413
last 2 s window with presents ends 200 s ends 182 s
compute pipelines built by the driver 35 61
device removals 0 0
  • Neither run had a device removal in 600 s. With the switch off, local video memory went well past the card's 8 GB and nothing hung either, so on this machine the switch is not needed to avoid a hang.
  • Both runs stop presenting at about the same point and then build compute pipelines one after the other until the end. The switch does not change that wall.
  • The second run was ended at 584 s by my own guard (free commit under 5 GB): the process went from 35 to 51 GB of commit in 20 s while the driver built a 805 KB DXIL compute program. The first run had not reached that program (35 builds against 61, colder cache), so I don't count it against either setting.

Not tested: one run per setting, not repeated in swapped order. Frame times after the stall, since there were none. AMD or Intel.

AI use: Claude Code (Claude Opus 5.5) built the test binary, ran both runs, read the logs and wrote this comment.

@rrrarrra9

Copy link
Copy Markdown
Author

Exact-head GTX 1650 follow-up

Windows and GTX 1650 (4 GB), clean d19ae2e, with XCL_TEXTURE_PAGES_SYSTEM_MEMORY unset or 1. The release workspace suite reported 777 passed, 0 failed, 41 ignored in both modes. Four tests printed SKIPPED (two wave64 cases, reserved cube mips, and heap windows disabled), plus a junction subcase. Command: cargo test --locked --offline --workspace --release --no-fail-fast -- --test-threads=4 --show-output.

Both 150 s offline startup smoke runs completed without device removal. PresentX counts were 2,329 / 1,886 and sampled peak local DXGI usage was 8,263 / 3,133 MiB (DEFAULT / L0). At the comparable 59 s samples, L0 moved about 3.5 GiB to the non-local segment with the same texture pool capacity. The sample breakdown and the synthetic transfer result are in #1773. Story mode remains unverified.

The current allocator in #1747 conflicts with this branch. A rebased run needs a new matched workload before review.

AI use: OpenAI Codex with gpt-6.2-sol ran the tests and summarized the results.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

Keep the per-heap batching, rollback, and mapping fences from xcl-dev#1747. Pass the per-device heap properties to the new pool allocation and verify that a two-tile batch uses the selected heap and returns its tiles after unmapping.

Assisted-by: OpenAI Codex (gpt-6.2-sol)
@rrrarrra9
rrrarrra9 force-pushed the codex/texture-pages-system-memory branch from d19ae2e to 670a0f9 Compare November 24, 2026 22:37
@rrrarrra9
rrrarrra9 marked this pull request as ready for review November 24, 2026 22:56
@NAbobo101

NAbobo101 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested the head 670a0f9 (on main 689f2db) on an 8 GB NVIDIA card with the retail title in Series X mode: XCL_TEXTURE_PAGES_SYSTEM_MEMORY=1, XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_PSO_WAIT_MS=2000, scripted presses into the world load.

Tested

  • RTX 5060 8 GB (wave32 only), driver 621.40; Ryzen 7 5700G, 32 GB RAM, 48–64 GB page file; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.8.2502.11; release.
  • The log says title texture page pools use system memory (D3D12_MEMORY_POOL_L0), and local video memory stays at 4.0–4.2 GB, with 13.8 GB non-local. That matches the 13.9 → 3.9 GB reported above.
run end local / non-local video memory skipped draws / dispatches slowest compute PSO in the driver
1 device removed (0x887a0006), 559.9 s 4.2 / 13.8 GB 256 / 2 178 s
2 title watchdog (+0x23cf683), 470.9 s 4.0 / 13.8 GB 158 / 7 216 s
3 (window kept in the foreground) title watchdog (+0x23cf683), 319.0 s 4.0 / 13.7 GB 0 / 0 152 s
4 (window kept in the foreground) device removed (0x887a0006), 384.3 s 4.6 / 14.6 GB 128 / 0 151 s

In runs 3 and 4 the game window was brought to the foreground every 30 s, and each check found it in the foreground and never hung (IsHungAppWindow 0 in 23 checks). That rules out a background window as the reason the picture goes away. Its title shows the frame rate falling from 30 to 6, 1 and then 0 fps, while the background pool reports compiling shaders: 0 running, 0 done, ~57 000 pipelines queued for most of the run.

For comparison, the same settings without this PR on main 1d027e5, the same machine, gave 13.7–14.4 GB local. One run reached the 900 s cap without a removal, and one had a device removal at 670 s.

So on this card the switch moves the texture pages out of video memory as described, but it does not prevent the device removal in the world load: run 1 lost the device with only 2 dispatches skipped and 4.2 GB of local video memory in use, and run 4 with no dispatch skipped at all. Whatever hangs the GPU there isn't video memory overcommit, at least not alone. In runs 1 and 2 the loading screen kept presenting until about 290 s and 350 s; after that the window showed no image.

Not tested

  • The test suite on this head; the switch without the bounded wait; AMD.
  • Whether frame times changed: the runs don't reach rendered gameplay.

AI use

  • Claude Code (Claude Opus 5.5) scripted and ran the runs, read the logs and drafted this comment. I checked the results.

Edit: the driver for all these runs was 621.40 (Windows updated it before them), not 621.14 as first written.

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