Skip to content

Memory: defer GPU tiles for private physical page storage - #1916

Open
CallMeBrado wants to merge 1 commit into
xcl-dev:mainfrom
CallMeBrado:perf/defer-private-home-tiles
Open

CallMeBrado wants to merge 1 commit into
xcl-dev:mainfrom
CallMeBrado:perf/defer-private-home-tiles

Conversation

@CallMeBrado

Copy link
Copy Markdown
Contributor

A DirectStorage transfer can fill a physical page before the title maps it anywhere the GPU can use it. XCL currently allocates a GPU tile at the page's home address as soon as the CPU needs backing. In two 60-second runs on the same title, the sparse pool peaked at 896 MiB on main and 320 MiB with deferred tiles enabled. Peak process commit fell from 14,596 to 13,947 MiB.

What is in it

  • Add an opt-in setting, XCL_DEFER_PRIVATE_HOME_TILES=1. Keep CPU-only sparse page homes private until mapped. When exposing a page, upload its existing bytes even if an earlier write-watch scan already consumed the write.
  • Add a GPU regression test with two populated pages and an untouched page between them. It covers mapping a single page, then a mixed range, and checks the bytes after GPU readback.

Tested

  • Windows 11 Pro build 26200, Ryzen 9 9950X3D, GeForce RTX 5090, NVIDIA driver 621.24, rustc 1.96.0 MSVC. Release title runs and debug workspace tests.
  • cargo build --locked --workspace and cargo build --locked --release -p xcl passed. cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output reported 972 passed, 4 failed and 45 ignored.
  • The four failures were gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 through _3. The same seeds (70, 545, 1019, 1507) fail on clean main 689f2db on this adapter. All four report 0x8007000E from CreateComputePipelineState.
  • With the option enabled for the entire process, the kernelx and sparse-memory test groups had 50 passes, 0 failures and 2 ignored.
  • The regression test failed against the old implementation at the first allocation check. Two writes had mapped two 64 KiB GPU tiles. The patch mapped zero before exposure. GPU readback matched the two payloads and zero-filled middle page after resetting write-watch.
  • Matching 60-second release runs, each with its own copy of the same title profile and an empty shader cache. Peak mapped sparse memory was 838 MiB on main and 314 MiB on this branch. Both had zero failed DirectStorage requests.
Adapter skips reported by the workspace tests
  • gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64)
  • gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64)
  • gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64)
  • gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64)
  • gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64)
  • gpu::recomp::lower_dxil::tests::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 arithmetic, wave64: no wave64 / 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 packed, wave64: no wave64)
  • gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64 / f32 compares, wave64: no wave64 / 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 conversions, wave64: no wave64 / f32 rounding, wave64: no wave64 / f32 three-source, wave64: no wave64 / f32 transcendentals, wave64: no wave64)
  • gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu (f64, wave64: no wave64)
  • gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64 / integer carries, wave64: no wave64)
  • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask (no wave64)
  • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)
  • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • test_title_draws_with_a_root_signature_under_the_debug_layer (no xgameruntime.dll)

Regression run

Main

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 5090
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1553 (PresentX 1553)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14596 MB

This branch, with deferred tiles enabled

xcl-smoke v1
commit: e2aa856010a637d33adc2cf8b49766da91574747
gpu: NVIDIA GeForce RTX 5090
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1595 (PresentX 1595)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13947 MB

Not tested

AMD and Intel GPUs, Wine, title-specific XCL_SAMPLE_* fixtures, and gameplay beyond the 60-second startup run.

AI use

OpenAI Codex (GPT-6) isolated the change from a local build, wrote the test, ran the checks, and drafted this description.

@Melow-code Melow-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

896→320 MiB peak sparse pool is a strong win. The opt-in flag is the right approach since deferred allocation changes the fault pattern.

@Filip722

Copy link
Copy Markdown

On an RTX 5060 Laptop GPU (8 GiB, driver 615.78.08), the Series S startup trace shows a smaller sparse pool with this option. Bazzite 44, Proton Experimental 11.0-20261112, XCL main 20cf130 plus the two-plane presenter from #615. The second executable added e2aa856 and used XCL_DEFER_PRIVATE_HOME_TILES=1. The runs started with separate copies of the same title settings and caches. No compiler ran alongside either title process.

Observed before the VRAM cutoff Control Deferred
Peak sparse pool 4,736 MiB 4,288 MiB
Peak mapped sparse memory 4,734 MiB 4,266 MiB
Storage requests 9,764 9,767
Failed requests 0 0

Both runs composited two planes. I stopped both when free VRAM stayed below 640 MiB for two samples. The window captures were still black. Neither run logged an NVIDIA Xid. This pair covers startup on one low-VRAM setup. Separately, the CPU-write / map / GPU-readback regression passed on this adapter in a composite build of the earlier main.

OpenAI Codex assisted with the builds, tests and report.

@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

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

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::dxil::fuzz_tests: 967 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: private_physical_pages_reach_the_gpu_on_mapping.
  • 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: 976 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 62265d3 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) and the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests (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.

@thehollowedone

Copy link
Copy Markdown

Independent check of e2aa856 on an RTX 3080 Ti (621.35), Windows 11 build 26300 and Rust 1.99.1 MSVC. I extended only the synthetic test. A 64 KiB storage write allocated no GPU tile before mapping. The first map used an explicit sparse address distinct from the page’s home, and all 65,536 bytes matched GPU readback there. I then wrote a different pattern through the mapped page, moved it home, reset write-watch there, and verified all 65,536 updated bytes by GPU readback again.

cargo test --offline --locked --release -p xcl --lib private_physical_pages_reach_the_gpu_on_mapping -- --nocapture --test-threads=1 passed 1/1 with zero skips. The original home-only assertions ran as well. This check used no retail input and did not measure title memory or world-load time.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended the fixture, ran the test, and drafted this report.

@raylitebull

Copy link
Copy Markdown
Member

Code review on e2aa856:

  • DEFER_PRIVATE_HOME_TILES (XCL_DEFER_PRIVATE_HOME_TILES=1) cleanly tracks SparseHome::CpuOnly vs Exposed in Away::sparse_homes, commits tiles and queues title_textures::rescan_cpu_backing for contiguous private runs on MapTitlePhysicalPages, and deduplicates the rescanned dirty pages in refresh_once. Default behavior when unset is unchanged.
  • Both CI checks are green, @Melow-code has approved, and multiple NVIDIA GPUs have verified e2aa856.

What is still needed before merge: Independent AMD verification on e2aa856 (private_physical_pages_reach_the_gpu_on_mapping + smoke) to satisfy dual-vendor coverage.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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

Copy link
Copy Markdown

Independent Wine verification on unmodified PR head e2aa856010a637d33adc2cf8b49766da91574747. No other PRs or local source patches were included in this check.

Tested

  • RTX 4060 Laptop, 8 GiB VRAM; Intel i7-13620H; 16 GiB system RAM; NVIDIA 590.48.01; Linux 6.17.0-40-generic, Wine 11.0, DXVK 3.1.1-209 and stock vkd3d-proton 3.2.0 (2576c0b4adfae4a, vtable assertions not disabled).
  • Rust 1.98.1, debug test build, cross-compiled for x86_64-pc-windows-msvc with Windows SDK libraries and executed through the Wine Cargo runner:
    XCL_REQUIRE_GPU=mesh cargo +1.98.1 test -p xcl --lib --target x86_64-pc-windows-msvc private_physical_pages_reach_the_gpu_on_mapping -- --test-threads=1 --nocapture
  • 1 passed, 0 failed, 0 ignored; no GPU skip. The nested process reports the same test, not a second independent case. The NVIDIA adapter was selected. The fixture's deferred-allocation and GPU-readback assertions passed, including the populated pages/zero-filled middle page after consumed write-watch notifications.

Not tested
Full workspace suite, native Windows, AMD/Intel, or a title on this exact head. This is synthetic memory-correctness coverage, not a claim of title VRAM savings or playability.

AI use
omp with openai-codex/gpt-6-astra prepared the isolated checkout, cross-built and ran the test, and drafted this report from its output.

@crastinator crastinator left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AMD run, as asked: RX 6700 XT (RDNA2) under Wine. With XCL_DEFER_PRIVATE_HOME_TILES=1, the sparse pools stay at 320 MB through a retail title's world load. On main they grow from 896 MB to 1856 MB. The texture pages still fill the 12 GB card, so it alone does not get through.

main this PR, knob on
sparse pools at 24 s / 60 s / last 896 / 1152 / 1856 MB 320 / 320 / 320 MB
local at 60 s 8693 MB 8106 MB
card full 87 s 73 s (texture pages grew faster in this run; not from this PR as far as I can tell)

Stacked with #1182 and #2306, the load stays at 5.8 GB local. The README conflict with main was the only one, and I kept both texts. Head e2aa856.

Tested (head e2aa856, merged onto main 06c9f55, no conflicts unless noted)

  • AMD Radeon RX 6700 XT 12 GB (RDNA2, gfx1031, RADV, Mesa 26.3.1), Ryzen 7 5700X, 16 GB RAM, Linux 7.3.5 (CachyOS)
  • proton-cachyos 11.0-20261015 Wine, vkd3d-proton v3.1 + #257's patch (dxil-spirv 53aac418 from #775), DXVK v3.1.1-97 dxgi
  • release build, XCL_COHERENT_MB=512 (the 4095 MB learned window is ~1 fps here, #284), XCL_ACTIVITY=1
  • A retail title from a cold start: it goes from the menus into its world load at about 50 s. Numbers are the activity log's memory: line; "card full" means sysfs mem_info_vram_used reached 11.5 GB, where my guard stops the run (a full card has crashed the compositor here before).

Not tested

  • cargo test under Wine: these were title runs only.
  • Storage I/O correctness beyond "no new warning kinds compared with main".

AI use

  • Claude Code (Claude Opus 5.5) merged, built and ran this and wrote the report; I checked the results.

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.

10 participants