Skip to content

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

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

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

Conversation

@rdj415

@rdj415 rdj415 commented Nov 24, 2026 •

Copy link
Copy Markdown

What is in it

Merged upstream/main (06c9f55) into d3d12x-console-vtable-slots at f3d1c40, resolving conflicts in crates/xcl/src/hle/d3d12x/list_x.rs and crates/xcl/src/hle/d3d12x/real.rs while preserving both the PR's console slots/tests and upstream/main's (129, 127) DispatchMesh mapping, occlusion tracking, and sampler-heap tests:

  • Command allocator slot #9 (real.rs): SetAllocationCallbackX(callback, context) validates this and logs/returns S_OK on valid allocators (E_INVALIDARG on null).
  • Command queue slot #29 older / #31 newer (real.rs, device_x.rs): widened queue_dispatch / QUEUE_SLOTS to 5 arguments after this and wired slot 29 (31 under QUEUE_SHIFTED) to device_x::update_page_mappings_x for 64 KiB VA page-pool mapping/unmapping and parameter validation.
  • Command list slots (real.rs, list_x.rs, device_x.rs):
    • #124 / #126 RSSetShadingRate and #125 / #127 RSSetShadingRateImage: clamp base shading rate / combiners, query D3D12_FEATURE_DATA_D3D12_OPTIONS6 VSR caps (variable_shading_rate_caps) and ID3D12GraphicsCommandList5 support, track state in Bindings, and restore across KickoffX.
    • #131 FlushGpuCacheRangeX and #132 FlushShaderCacheRangeX: emit global UAV barriers when flags and size are non-zero.
    • #73 / #75, #99 / #101, #140 / #142 state/hint slots recorded in command-list bindings and NEWER_LIST_SLOTS.

Tested

All checks run on commit f3d1c40 (Windows 11, NVIDIA GeForce RTX 5060 Ti, 0 compiler warnings):

  • ./scripts/test.ps1 --skip test_title_runs_and_game_folder_is_untouched --skip fuzz_validate_and_gpu: xcl --lib 1198 passed; 0 failed; 26 ignored; 4 filtered out, plus all workspace test binaries passed (0 failures: bcpack_parity 1, console_dlls_e2e 13, console_shaders 3 / 4 ignored, d3d12_mesh_stream 3, d3d12_resource_and_sync 3, disasm_e2e 7, e2e 2 / 1 filtered out, gpu_compute_e2e 4, gpu_pso_e2e 7, heap_probe 0 / 4 ignored, launcher_e2e 6, low_va 1, pls_quota 1, predication_e2e 1, rpf_e2e 2, shaders_e2e 6, sparse_reinit 1, texture_states 1, xg_oracle 6 / 12 ignored).
  • XCL_ADAPTER=warp cargo test -p xcl --lib -- --test-threads=4: 1202 passed; 0 failed; 26 ignored.
  • cargo build --release -p xcl: clean build (0 warnings).

Regression run

Head (f3d1c40, cargo build --release -p xcl):

xcl-smoke v1
commit: f3d1c4008d86913d7125d02b3908b9335715fc77
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1454 (PresentX 1454)
presents per 2 s (last 3): 60 60 53
device removals: 0
crashes: 0
peak commit: 10696 MB

Main (06c9f55, upstream/main ancestor):

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1418 (PresentX 1418)
presents per 2 s (last 3): 42 61 52
device removals: 0
crashes: 0
peak commit: 10622 MB

Not tested

  • test_title_runs_and_game_folder_is_untouched (proprietary test-title fixture) and fuzz_validate_and_gpu (0x8007000E pre-existing on local RTX 5060 Ti driver) were skipped in ./scripts/test.ps1.
  • Optional sample-pack tests (XCL_SAMPLE_RPF, XCL_SAMPLE_DLLS, XCL_SAMPLE_TTPF, XCL_SAMPLE_BCPACK, XCL_SAMPLE_BK2, XCL_SAMPLE_BVH4, XCL_SAMPLE_AWC, XCL_SAMPLE_XG, XCL_SAMPLE_DXC) were skipped because sample env vars are unset.
  • Wave64-only GPU shader tests skipped on RTX 5060 Ti (no wave64).

AI use

Merge conflict resolution, verification, and PR description updated with Gemini 4 Hydrogen.

@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.

@thiagocalile

Copy link
Copy Markdown

Independent test report for head f3d1c4008d86913d7125d02b3908b9335715fc77 on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- list_x --test-threads=4: 36 passed, 0 failed, 0 ignored (0 skipped).

Regression run (scripts/smoke.ps1 -Seconds 60, release builds, XCL_ADAPTER=radeon)

main (06c9f55):

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1469 (PresentX 1469)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13436 MB

PR #1274 (f3d1c40):

xcl-smoke v1
commit: f3d1c4008d86913d7125d02b3908b9335715fc77
gpu: AMD Radeon RX 6600
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1573 (PresentX 1573)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17730 MB

Not tested: full workspace test suite on this head, NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

AMD run on f3d1c400 (PR head, merges cleanly into main 68a284a; I tested the head as it is, not the merge).

Machine: AMD Radeon RX 7800 XT (RDNA3, native wave64), driver 32.0.31035.1003, Windows 11 Pro 10.0.26200, Rust 1.100.0 x86_64-pc-windows-msvc, DXC 1.8.2502.11 (Windows SDK 10.0.26100.0), debug build, clean checkout, no XCL_SAMPLE_*.

Tested

  • cargo test -p xcl --lib d3d12x: 223 passed, 0 failed, 2 ignored.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1269 passed, 2 failed, 46 ignored, 7 SKIPPED lines (f16 and f32 conversion per-lane forms refused, and one test with no heap windows).
  • The 2 failures:
    • gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff) fails the same way on main 68a284a, so it is not this PR's.
    • hle::kernelx::tests::fine_timer_makes_short_sleeps_short failed in the parallel run and passed when I reran it alone on this head and on main; it looks like a timing flake under load.

Not tested

  • No retail title and no scripts/smoke.ps1 pair, so the PR's xcl-smoke regression run is not covered here.
  • Other GPUs. Only the d3d12x and unit-test paths ran; nothing here confirms the changed vtable slots in a real title.

AI use: Claude Code (Claude Sonnet 5.5) ran the commands and wrote this report for oni-swr.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 26, 2026
CharlyRien added a commit to CharlyRien/xcl that referenced this pull request Nov 28, 2026
…AMPLE_MASK=1)

The newer layout's command list xcl-dev#142, SetQuadSampleMaskX(u64), takes the two
PA_SC_AA_MASK registers: 16 sample bits for each pixel of a 2x2 quad (X0Y0, X1Y0,
X0Y1, X1Y1 from bit 0). A retail title sets it per draw from dithered fade tables
(0 to 4 pixels of the quad, each 0 or 0xFFFF, and the complement for the other
side of a cross-fade). As a stub every pixel is drawn, so LOD cross-fades draw
both levels whole. The name is the one xcl-dev#1274 gives the slot (a no-op there).

Host (hle/d3d12x/quad_mask.rs, bind.rs): the handler keeps the mask per list as
the samples it takes away; bind_abi writes them into io slots 117 / 118
(recomp::IO_QUAD_KILL) of graphics draws, only when the mask is partial; reset and
ClearState go back to all ones, a mid-list split inherits it. Older layout: xcl-dev#142
is another method, answered as the stub did. Off unless XCL_SAMPLE_MASK=1: off,
the io slots stay 0 and nothing is discarded.

Translator: every pixel shader starts (before its EXEC is taken) with the test.
HLSL: one uniform branch on the two io words, then a discard of the pixel whose
quad word is all ones. Direct DXIL: the same straight-line, one conditional
discard. No pixel shader on main has early depth; one that gets it must not get
this test (the discarded pixels' depth would still be written).

Tests: mask decoding and the title's masks, the slot, the io wiring across
reset / ClearState / split, the HLSL text and the direct path's discards, and a
GPU draw through both paths with each kind of mask.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

8 participants