Skip to content

D3D12.X: clamp single-adapter NodeMask and guard null riid in CreateCommandSignature - #3400

Merged
throny merged 1 commit into
xcl-dev:mainfrom
Kalmarv:samplers/command-signature-nodemask-sanitize
Dec 1, 2026
Merged

throny merged 1 commit into
xcl-dev:mainfrom
Kalmarv:samplers/command-signature-nodemask-sanitize

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Clamp multi-bit D3D12_COMMAND_SIGNATURE_DESC::NodeMask values to single-adapter 1 and guard null riid in create_command_signature_x.

Previously, device_x::create_command_signature_x forwarded D3D12_COMMAND_SIGNATURE_DESC::NodeMask unchanged to PC CreateCommandSignature (and copied it into the DISPATCH_MESH companion DISPATCH signature). On single-adapter PC D3D12, any NodeMask > 1 (for example 0x3 or 0xFFFF_FFFF) is rejected with E_INVALIDARG (0x80070057), unlike pc_queue_desc and create_list in the same module which already clamp nonzero node masks to 1. It also did not guard a null riid pointer before forwarding to the PC runtime.

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs:
    • Add pc_command_signature_node_mask clamping nonzero NodeMask values to 1 while keeping 0 as 0.
    • Apply pc_command_signature_node_mask to pc[16..20] in create_command_signature_x before calling real::dev_create_command_signature (so both the main signature and any DISPATCH_MESH companion signature use the clamped mask), log both original and clamped masks on failure, guard riid.is_null() alongside desc.is_null() || ppv.is_null(), and check !(*ppv).is_null() before recording companion state.
    • Add unit test pc_command_signature_node_mask_clamps_to_single_adapter and child-process-isolated WARP test create_command_signature_x_clamps_node_mask_and_guards_null_args verifying console DispatchX with NodeMask = 0x3, DRAW with NodeMask = 0xFFFF_FFFF, null desc/riid/ppv handling, and rejection of undersized ByteStride.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (build 26200), rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (XCL_DXC_DIR), debug for tests and release for xcl-smoke.
  • Targeted tests (cargo test -p xcl --lib -- hle::d3d12x::device_x::tests:: --nocapture): create_command_signature_x_clamps_node_mask_and_guards_null_args failed before the fix (NodeMask 0x3 must clamp to 1 on single-adapter PC D3D12, got 0x80070057), and all 22 device_x tests passed after (22 passed, 0 failed, 0.14s, 0 skips).
  • Full workspace (cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::): 2663 passed, 0 failed, 49 ignored, 9 filtered across 41 test binaries.
  • SKIPPED GPU tests on this wave32 adapter (26 total across --nocapture workspace baseline): 21 no wave64 (RTX 5070 Ti is wave32), 3 wave32 per-lane #1426 f16/cvt-f16 refusals, 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1).
  • Retail title (ea3b5e4d) 150 s regression run below (0 device removals, 0 crashes, 1620 frames vs 1695 on main, 33840 MB peak commit vs 31546 MB on main).

Regression run

xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB
xcl-smoke v1
commit: c586fbbadfcef075e3ecff67450525ebbd5fb87c
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1620 (PresentX 1620)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33840 MB

Not tested

  • Multi-adapter / mGPU configurations (NodeMask > 1 is clamped to 1 for single-adapter PC D3D12 parity with pc_queue_desc and create_list) and AMD RDNA / wave64 GPUs.
  • uma_driver::tests:: (skipped locally due to pre-existing 0x7C10003 exit on NVIDIA) and test_title_runs_and_game_folder_is_untouched.

AI use

  • Antigravity (Gemini) used for root-cause verification, implementation, test authoring, and local verification; all diffs, tests, and smoke outputs reviewed and run locally.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@Kalmarv Kalmarv closed this Nov 29, 2026
@Kalmarv Kalmarv reopened this Nov 29, 2026
@saintwolf

Copy link
Copy Markdown
Contributor

Reviewed and tested at c586fbba.

Looks clean and tightly scoped — NodeMask clamping, null-riid guard, and isolated WARP child-process test all look good.

Tested locally

  • Windows 11 (build 26300), NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.2140), AMD Ryzen 7 7800X3D, rustc 1.100.0.
  • cargo test -p xcl --lib hle::d3d12x::device_x::tests::pc_command_signature_node_mask -- --test-threads=1: 1 passed, 0 failed.
  • cargo test -p xcl --lib hle::d3d12x::device_x::tests::create_command_signature_x_clamps_node_mask -- --test-threads=1: 1 passed, 0 failed.

AI use

  • Antigravity (Gemini 4 Neon) assisted with code review and drafting; all builds and tests were executed locally on the hardware above.

@ClosetPie107

Copy link
Copy Markdown

Test report for #3400 at c586fbbadfcef075e3ecff67450525ebbd5fb87c, against its merge-base with main, 7a649b0e, under Wine on AMD.

Tested

Not tested

  • native Windows
  • NVIDIA
  • the gpu:: tests in the suite runs
  • the workspace's other crates and integration tests (only -p xcl --lib)
  • a game run (no regression block)

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: c586fbb
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (device_x.rs, +108/-5). Masks 0 and 1 reach the PC unchanged, and the DISPATCH companion signature copies the clamped mask. Findings: (1) the WARP test (~1527-1535) returns silently when there is no factory, WARP adapter or device; it should call skip_test like the test at ~1930. (2) The null-riid guard (~1406) and the !(*ppv).is_null() check (~1432) are separate changes from the clamp, and only the NodeMask assertion is shown failing without the fix. (3) This is another copy of the "nonzero becomes 1" clamp (pc_queue_desc, create_list, #3387, #3385, #3403); one shared helper would be better. (4) AI use says "Antigravity (Gemini)" with no exact model; the suite run skipped uma_driver::tests:: and test_title_runs_and_game_folder_is_untouched; the subject is ~84 characters; no title is cited that passes NodeMask > 1. Fine: the clamp matches pc_queue_desc / create_list, the failure log keeps the original mask, and the mask-0x3 test drives the real create_command_signature_x in a child process.
performance: 60 s smoke of a retail title, main d0832e6 vs this merge (e09962c8): 1516 -> 1679 frames shown (110 %; last presents per 2 s: 61 60 60), peak commit 18133 -> 16994 MB, 0 device removals, 0 crashes.
verdict: safe to merge (the WARP test should call skip_test instead of returning; a shared node-mask helper across this series would be better)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@throny

throny commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

merge-check
base: d0832e6
head: c586fbb
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; failing: none (25 SKIPPED lines, all GPU tests on this adapter, e.g. no wave64)
review: Read the whole diff (1 file, device_x.rs). CreateCommandSignature now clamps a multi-bit NodeMask to 1 for the single-adapter PC runtime, rejects a null riid, and checks *ppv before noting the signature; the warning log prints both masks. The new unit test covers the clamp helper, and a WARP-device test (run in a child process of the test binary, which is the only process code in the diff) checks masks 0x3 and 0xFFFFFFFF, the null arguments and an undersized stride. The child returns silently when there is no WARP adapter, so the parent shows no SKIPPED line then. Scope is one function.
performance: no cost by default: one mask compare per CreateCommandSignature call, which is a creation-time call, not per frame; reasoned, not measured.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report (the diff review is Sonnet's)

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@throny
throny merged commit 7367136 into xcl-dev:main Dec 1, 2026
5 of 6 checks passed
@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Merged at the checked head after a combined trial of #3400, #3386, #3393 and #3535 on main d0832e61 (RTX 4080 16 GB, cargo test --workspace --no-fail-fast -- --test-threads=4: 2896 passed, 0 failed, 51 ignored, 25 SKIPPED lines). Two merge checks: Foniass and ours.

AI use: Claude Code (Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants