Skip to content

D3D12.X / kernelx: CommandList slots 131/132, synchronized sparse commit/decommit, and intro pool reservation - #236

Open
utkarshxdev wants to merge 1 commit into
ivall:mainfrom
utkarshxdev:intro-render-fixes-latest
Open

utkarshxdev wants to merge 1 commit into
ivall:mainfrom
utkarshxdev:intro-render-fixes-latest

Conversation

@utkarshxdev

Copy link
Copy Markdown

Summary

Addresses intro rendering stalls, missing GPU tile samplings, and CommandList dispatch crashes:

  1. CommandList Slots 131 & 132 (list_x.rs, real.rs):

    • Adds ABI-safe 4-parameter stubs (RCX, RDX, R8, R9) returning 0 to prevent null vtable crashes during intro command list recording.
  2. Synchronized Sparse Commit & Decommit (sparse.rs, kernelx.rs, placeholders.rs):

    • Centralizes host VirtualAlloc(..., MEM_COMMIT) and VirtualFree(..., MEM_DECOMMIT) under STATE.lock() alongside GPU tile bookkeeping.
    • Eliminates the crash race where the upload thread (before_execute) scans and reads CPU pages mid-decommit.
    • Enforces strict commit range bounds checks (ERROR_INVALID_ADDRESS) before calling host Windows memory APIs.
    • free_reserved guarantees decommit succeeds under STATE.lock() before releasing sparse UMA reservations.
    • Isolates the early_commit_timing benchmark to pure BTreeMap operations without making host memory calls.
  3. Intro Streaming Pool Reservation (kernelx.rs):

    • Scopes the 4.88 GB (0x1_3800_0000) uncommitted pool reservation strictly to game_scarlett_master.exe, raw MEM_RESERVE, and PAGE_NOACCESS.
    • Maps the pool into sparse video memory windows so GPU shaders sample valid textures instead of unmapped/black surfaces. Falls back cleanly to ordinary host VirtualAlloc if sparse space is exhausted.

Validation

  • git apply --check --whitespace=error-all passed cleanly on latest origin/main (60565c4).
  • cargo check --target x86_64-pc-windows-msvc --offline --all-targets passed with 0 errors.
  • Unit tests (intro_sparse_reservation_matches_the_observed_request, sparse_commit_rejects_invalid_ranges, command_list_slots_include_131_and_132, and early_commit_timing through 32,768 ranges) all passed.

@srcamarda

Copy link
Copy Markdown

AMD run of 03d4a86 merged onto main 0e946cf (clean merge), with a retail title, plus a few points from reading the diff.

Tested

  • RX 7800 XT (RDNA3, driver 32.0.32029.2010), Ryzen 5 5600G, 32 GB, Windows 11 26300, Rust 1.100.0 MSVC
  • The PR's tests pass (command_list_slots_include_131_and_132, intro_sparse_reservation_matches_the_observed_request, sparse_commit_rejects_invalid_ranges, the early-commit ones)
  • cargo test --workspace -- --test-threads=4: 655 passed, 0 failed, 40 ignored, no SKIPPED
  • scripts/smoke.ps1, 90 s, six runs of each binary (two batches of three, each starting with a cold translation cache): main 738 / 1 100 / 892 / 1 035 / 1 216 / 1 134 frames, this PR 1 052 / 1 026 / 947 / 948 / 1 194 / 976. Mean ~1 020 for both; no crash or device removal; the same peak commit (~17.2 GB).

What the title does with it

  • #131 and Add synthetic Cargo benchmark suite #132 are called once each early in loading. The PR's log lines:
    D3D12.X: ID3D12GraphicsCommandList #132 (0x75d42a70, 0x700000, 0x0, 0x0)
    D3D12.X: ID3D12GraphicsCommandList #131 (0x75d42a70, 0xc3c0, 0x80020000, 0x0)
    
    On main the same calls already reach the guard's stub (ID3D12GraphicsCommandList10::#131 (not on PC), 4 + 3 calls; Add synthetic Cargo benchmark suite #132 4 + 1), which returns 0 as well. So on this title the new handlers change nothing but the log, and main does not crash there. Which title or build showed the null-vtable crash?
  • The intro pool reservation never fires here. With XCL_TRACE_MEM, the title's reservations in 90 s are these, and none is 0x1_3800_0000 with plain MEM_RESERVE / PAGE_NOACCESS; every one carries extra flag bits:
    VirtualAlloc(0x0, 0x600000000, flags 0x20402000, protect 0x4)
    VirtualAlloc(0x0, 0x600000000, flags 0x20402000, protect 0x801)
    VirtualAlloc(0x0, 0x49400000, flags 0x20003000, protect 0x22004)
    VirtualAlloc(0x0, 0x89700000, flags 0x20003000, protect 0x2404)
    VirtualAlloc(0x0, 0x23300000, flags 0x20003000, protect 0x22004)
    VirtualAlloc(0x0, 0x25400000, flags 0x20003000, protect 0x22004)
    VirtualAlloc(0x0, 0x185c00000, flags 0x20402000, protect 0x2004)
    
    (plus three 64K-page / coherent-window ones and the placeholders). No VirtualAlloc (sparse commit) line either, so the reworked commit path is not reached by this title. A different build of the game?

Points from reading the diff

  1. An unannounced behaviour change in VirtualAlloc: on main a call on an address in a sparse window without MEM_COMMIT (e.g. MEM_RESET / MEM_RESET_UNDO) goes on to the normal path. With this PR it now fails with ERROR_INVALID_ADDRESS. Intended? It isn't in the description and has no test.
  2. Scope: three unrelated changes (list slots, sparse commit locking, the intro pool). CONTRIBUTING asks for one per PR, and the description needs Tested with the suite counts and the two xcl-smoke blocks for PR checks.

Regression run (gpu: names a virtual display adapter here, but XCL ran on the RX 7800 XT). The second run of the second batch for each:

main:

xcl-smoke v1
commit: 0e946cfc68244edee1fba6e0425371f687a05ccd
gpu: SudoMaker Virtual Display Adapter
title: RetailGame_Dump
seconds: 90
exit: 0x0
frames shown: 1216 (PresentX 1216)
presents per 2 s (last 3): 26 25 26
device removals: 0
crashes: 0
peak commit: 17191 MB

this PR merged onto main (local merge commit):

xcl-smoke v1
commit: 22db4c62b726dee1fb28a1ddba55d3a3b67378ec
gpu: SudoMaker Virtual Display Adapter
title: RetailGame_Dump
seconds: 90
exit: 0x0
frames shown: 1194 (PresentX 1194)
presents per 2 s (last 3): 18 19 18
device removals: 0
crashes: 0
peak commit: 17173 MB

Not tested

  • The intro pool path and the new sparse commit path (this title reaches neither), whether it hits the new ERROR_INVALID_ADDRESS path, the PR on its own, NVIDIA.

AI use

  • Claude Code with Claude Opus 5.5: ran the tests and the smoke runs, read the logs, the memory trace and the diff, wrote this report.

@ryosen0

ryosen0 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Test report on our machine with this PR's head (03d4a86) stacked on current main (db1ddb2) + #300 + #294 + #273 + #304: Ryzen 7 9800X3D, RTX 3060 Ti 8 GB (wave32), driver 32.0.16.1742, Windows 11.

XCL_NETWORK=0 XCL_RUN_SECONDS=240 XCL_ACTIVITY=1 xcl run <retail folder>: clean exit at the timer, 3987 frames shown, no crash, no device removal. Intro stretch ~t=60-165 s at 4.9-6.4 fps, then a steady 30.0 fps to the end; the character loading screen is reached. BCPack refusals in the same run: BC5 44, BC7 20 requests (BC1 unpacked). The 41 console-MS-in-AS-slot refusals are unchanged.

The same run without this PR (main + #300 + #294 + #273 + #304, 180 s): the same shape - dip 4.4-8.6 fps at t=44-166 s, 29.9 fps after. So on this hardware the PR neither helped nor hurt the intro pace measurably; the slow stretch looks bounded by something else (we see 6.5 GB local + 4.6 GB non-local video memory on the 8 GB card during it).

Not tested: the command-list slots 131/132 paths in isolation; no unit-test run for this report (run-only data point).

AI use: GPT-6.2 Astra (API model selector) ran the builds and runs and wrote this report; the human contributor watched the screen and reviewed it.

@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks for this, and thanks @srcamarda and @ryosen0 for the runs. Not merged yet - what would get it in, in this PR:

  1. Drop the intro pool reservation. It is keyed to the title's executable name, and fixes here have to model the console for any title, not one game (the repository also does not name the game). srcamarda's memory trace shows the title never makes a plain MEM_RESERVE / PAGE_NOACCESS reservation of 0x1_3800_0000, so the path never runs; if a real reservation needs to be in the sparse windows, the rule should come from what the reservation is (its flags / protection), not who makes it.
  2. The command-list slots #131 / Add synthetic Cargo benchmark suite #132: on main these calls already reach the guard's stub, which returns 0 too, so the new handlers only change the log, and no run showed the null-vtable crash they are meant to prevent. Either drop them, or say which title/build crashed there and with what log.
  3. The sparse commit / decommit under STATE.lock() is the part worth having. Two things for it: say in the description (and cover with a test) the behaviour change srcamarda found - VirtualAlloc without MEM_COMMIT (MEM_RESET / MEM_RESET_UNDO) on an address in a sparse window now fails with ERROR_INVALID_ADDRESS instead of taking the normal path; and add a test that shows the race it closes (the upload scan reading a page mid-decommit), failing without the change.

The two A/B runs above found no difference on a retail title either way, so with 1 and 2 gone and 3 tested this is a small, safe change. Please keep Tested (suite counts) and the xcl-smoke pair in the description.

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.

4 participants