Skip to content

d3d12x: implement console command allocator, queue, and command list slots - #1274

Open
rdj415 wants to merge 5 commits into
xcl-dev:mainfrom
rdj415:d3d12x-console-vtable-slots
Open

rdj415 wants to merge 5 commits into
xcl-dev:mainfrom
rdj415:d3d12x-console-vtable-slots

Conversation

@rdj415

@rdj415 rdj415 commented Nov 24, 2026 •

Copy link
Copy Markdown

Implement missing d3d12_xs.dll console command list, command queue, and command allocator vtable slots encountered during retail title bring-up, eliminating ~9,500 runtime stub hits per run while keeping XCL_ASYNC_PSO, driver_cache, and existing VRS / barrier state intact.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: map shifted NEWER_LIST_SLOTS entries (75/101/126/127/131/132/142), queue layout dispatch (#29 older / #31 shifted UpdatePageMappingsX, 5-arg queue_dispatch), and a single S_OK/E_INVALIDARG handler for command allocator slot #9 (SetAllocationCallbackX).
  • crates/xcl/src/hle/d3d12x/device_x.rs: validate UpdatePageMappingsX descriptors (RegisterPagePoolX / UnregisterPagePoolX / 64 KiB pool bounds) without unused tracking state, keeping both update_page_mappings_x_maps_unmaps_and_validates and allocation_info_of_several_is_padded_to_the_largest_alignment after merging upstream/main.
  • crates/xcl/src/hle/d3d12x/list_x.rs: implement flush_gpu_cache_range_x (#131), flush_shader_cache_range_x (#132), rs_set_shading_rate_x (#124/#126), rs_set_shading_rate_image_x (#125/#127) with D3D12 VRS capability gating and Reset/KickoffX restoration, plus no-op stubs for set_pipeline_flag_x (#73/#75), set_clear_batch_hint_x (#99/#101), and set_quad_sample_mask_x (#140/#142).

Tested

  • hardware & toolchain: NVIDIA GeForce RTX 5060 Ti (driver 616.64 / 32.0.16.1664), 12th Gen Intel(R) Core(TM) i5-12400F, rustc 1.98.0-nightly (096694416 2026-06-29), release builds and debug unit tests on Windows.
  • cargo test -p xcl --lib -- --nocapture (merge commit 15fab80): 733 passed, 0 failed, 21 ignored (SKIPPED GPU tests on 32-lane hardware: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64).
  • Retail smoke comparison via scripts/smoke.ps1 -Seconds 60 on clean 9e3831e (upstream/main) and clean 15fab80 (d3d12x-console-vtable-slots).

Regression run

main:

xcl-smoke v1
commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1013 (PresentX 1014)
presents per 2 s (last 3): 20 6 0
device removals: 0
crashes: 0
peak commit: 11409 MB

PR:

xcl-smoke v1
commit: 15fab80c503a17c55da32ce735cc992f938b3d48
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1006 (PresentX 1006)
presents per 2 s (last 3): 21 1 23
device removals: 0
crashes: 0
peak commit: 10446 MB

Not tested

  • cargo test --workspace -- --test-threads=4, cargo test -p xcl --test gpu_compute_e2e, cargo test -p xcl --test shaders_e2e, and Python helper tests after merge commit 15fab80.
  • Wave64 AMD GPUs, Linux (Wine + vkd3d-proton), and multi-title runtime runs beyond

AI use

  • Gemini 4 neon: assisted with PR review state cleanup, merging upstream/main into d3d12x-console-vtable-slots, resolving the device_x.rs test conflict, running cargo test -p xcl --lib, and running the paired scripts/smoke.ps1 verification.

@DavidM1911

Copy link
Copy Markdown
Contributor

Heads-up: this currently conflicts with main in crates/xcl/src/hle/d3d12x/list_x.rs (main moved under it — e.g. the copy-scratch/allocator changes). Needs a rebase before it can merge; the diff itself is large (~576 lines) so a split may also help review.

@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 839f4bc (on its base 930e8b4).

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: 757 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: update_page_mappings_x_maps_unmaps_and_validates, shading_rate_and_combiner_sanitization, console_list_state_slots_track_and_reset, queue_slot_31_on_newer_layout_dispatches_update_page_mappings, allocator_slot_9_registers_and_clears_callback, newer_list_slots_cover_shifted_console_methods.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 757 passed, 0 failed, 41 ignored, no skips.

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.

@rdj415

rdj415 commented Nov 24, 2026

Copy link
Copy Markdown
Author

resolved the conflict in list_x.rs (839f4bc) and updated the PR description with the smoke logs. thanks for running the full test suite @futurepro62! @DavidM1911 let me know if you still want me to split this into two PRs or if it's good to review as-is.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of 839f4bc on main 930e8b4 + #684, 2 runs of 140 s each way of a retail title: all eight d3d12_xs.dll stubs these runs call (about 9,500 calls a run) were gone with it, and the runs were otherwise the same, ending at the title's watchdog near 131 s as without it.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09, 32-lane waves), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), DXC 1.9.2609.5, XCL_NETWORK=0, XCL_PSO_PRELOAD=0. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s through XCL_PRESS_AT. 839f4bc merged onto main 930e8b4 + #684 (e56dbc3) without conflicts; #684 is there because main alone faults in copy_from before this point.

Tested

  • The six tests the pull request adds, under Wine, on the merge: 6 passed, 0 failed.
930e8b4 + #684, run 1 / 2 the same + 839f4bc, run 1 / 2
calls to unimplemented d3d12_xs.dll slots 9542 / 9502, on 8 slots 0 / 0
frames presented 2163 / 2152 2221 / 2149
last 2 s with a present 102.6 s / 102.2 s 102.6 s / 102.2 s
the title's null write at game+0x23cf683 132.6 s / 131.6 s 132.5 s / 130.5 s
UpdatePageMappingsX warnings – 0 / 0
DirectStorage requests failed (0x89240009) 1 / 1 2140 / 13

The eight slots were allocator #9 (2323 calls in the second run), queue #31 (339), and list #75 (2210), #101 (10), #126 (2209), #131 (9), #132 (5) and #142 (2397). With the change the log has, once each:

D3D12.X: ID3D12CommandAllocator::SetAllocationCallbackX (callback 0xe4adf10, context 0xb041e47c0)
D3D12.X: variable shading rate (OPTIONS6): tier 2, additional rates true
D3D12.X: UpdatePageMappingsX (1 mapping(s), pool 0x7ff000000000, 99776 pages, flags 0x0)

A third run with it (75 s, frames kept) showed the same loading picture at 65 s as a run of main at the same second. These runs do not reach the world, so they do not show what the shading rate does to a rendered scene.

The failed DirectStorage requests come in bursts from 78 s and their count differs from run to run on main too (3 to 2032 in five 100 s runs of 67a3735 + #684 here; #549 is about them). I do not put the 2140 down to this change.

Read

Not tested: past 140 s and the world (this 12 GB card is full from 76 s); a card without variable rate shading; the preload of #690 on; the rest of the test suite; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the trees, ran the tests and the runs with XCL_PRESS_AT, compared the logs and frames and wrote this report.

@rdj415

rdj415 commented Nov 24, 2026 •

Copy link
Copy Markdown
Author

@Royalflamejlh Thanks for the thorough review and the Wine + vkd3d-proton comparison!

Addressed the feedback in ce54621 and merged upstream/main (9e3831e) in 15fab80:

  • Removed write-only stub state (no runtime reader planned):
    • crates/xcl/src/hle/d3d12x/device_x.rs: dropped GPU_PAGE_MAPPINGS and the test-only gpu_page_mapping_for_test helper while keeping RegisterPagePoolX / UnregisterPagePoolX pool tracking and full descriptor / 64 KiB pool-range validation (S_OK / E_INVALIDARG) in update_page_mappings_x.
    • crates/xcl/src/hle/d3d12x/list_x.rs: dropped pipeline_flag, quad_sample_mask, and clear_batch_hint from Bindings; set_pipeline_flag_x (#73/#75), set_clear_batch_hint_x (#99/#101), and set_quad_sample_mask_x (#140/#142) are now plain no-op stubs without locking LISTS.
    • crates/xcl/src/hle/d3d12x/real.rs: dropped ALLOC_CALLBACKS and its cleanup from alloc_release.
  • Allocator #9 (#1109): alloc_set_allocation_callback_x is now reduced to the same minimal E_INVALIDARG/S_OK + log-once stub (Kind::CommandAllocator => vec![(9, alloc_set_allocation_callback_x as usize)]). Happy to drop allocator #9 from this PR altogether if #1109 is going to land first—let me know your preference.
  • Rebase / merge & checks: merged upstream/main (9e3831e) cleanly in 15fab80 (keeping both update_page_mappings_x_maps_unmaps_and_validates and allocation_info_of_several_is_padded_to_the_largest_alignment in device_x.rs), re-ran cargo test -p xcl --lib -- --nocapture (733 passed, 0 failed, 21 ignored; 2 wave64 tests skipped on RTX 5060 Ti), and updated the PR description with paired 60 s scripts/smoke.ps1 runs.
  • Note on progression past loading: on a stacked local Windows branch building on top of these vtable slots (past the 131 s watchdog window), the title also reaches ~144 s and starts playing the first cutscene's Opus audio (xapu / MSOpusDecoder).

@humsterbumster

humsterbumster commented Nov 24, 2026 •

Copy link
Copy Markdown

Linux (Wine + vkd3d-proton) + NVIDIA test of 15fab80 (current head) on its base 9e3831e, two runs each way of a retail title: the seven d3d12_xs.dll slots these runs call are gone with it, and the runs are otherwise unchanged — menus at 30 fps, then the title's own exit at game+0x22106e0 at 10.1–11.8 s.

Setup: Ubuntu 24.04.2 LTS, kernel 7.3.5-arch1-1; Wine 11.0 (Proton Experimental 11.0-20261014) with the vkd3d-proton it ships, DXVK dxgi, WINEDLLOVERRIDES=d3d12,d3d12core,dxgi,d3d11,d3d10core=n,b, VKD3D_CONFIG=ignore_shared_fence. NVIDIA GeForce RTX 5090 (32,607 MiB, waves of 32 lanes), driver 620.73.04. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.100.0), DXC 1.9.2609.5, XCL_NETWORK=0, XCL_RUN_SECONDS=900, XCL_ACTIVITY=1; no other XCL_* knobs. Retail title 1.0.2.1 (930.048.020-vb_sub_story, TitleID 7952987a), Series X, no input sent. Each build: two runs, cold then warm, one data directory each.

Tested

9e3831e (base), run 1 / 2 15fab80 (this PR), run 1 / 2
calls to unimplemented d3d12_xs.dll slots 77 / 77, on 7 slots 0 / 0
frames presented 135 / 90 75 / 128
presents in the last 2 s logged before the exit 60 / 60 60 / 60
title exit (0x80000003) game+0x22106e0, 10.1 s / 11.7 s game+0x22106e0, 10.1 s / 11.6 s
DirectStorage requests failed (0x89240032) 49 / 49 49 / 49

The seven slots are allocator #9 (17 calls a run), list #75 (16), #126 (16), #142 (16), #131 (6), #132 (5) and queue #31 (1). called_stubs in report.json lists all seven without the change and is empty with it. Plain main 689f2db runs the same way as the base: 133 / 120 frames presented, 7 slots, same exit site at 10.2 s / 11.8 s.

Read

Not tested: the six tests this pull request adds; any run past the exit; the world; Windows, AMD and Intel; Series S mode; the rest of the suite.

AI use: pi (Qwen3.8-27B) built both trees, ran the six runs and read the logs and report.json; the numbers above are from those logs.

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