Skip to content

D3D12.X: clamp single-adapter nodeMask and console heap types in GetCustomHeapProperties - #3403

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:samplers/custom-heap-properties-sanitize
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:samplers/custom-heap-properties-sanitize

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Clamp multi-bit nodeMask values to single-adapter 1 and map console-only heap types above GPU_UPLOAD (5) to DEFAULT in get_custom_heap_properties_x.

Previously, device_x::get_custom_heap_properties_x forwarded nodeMask and heapType unchanged to PC GetCustomHeapProperties. On single-adapter PC D3D12, passing a multi-bit/all-nodes nodeMask > 1 (for example 0x3 or 0xFFFF_FFFF) or a console-only heap type (> 5) makes PC GetCustomHeapProperties return zeroed D3D12_HEAP_PROPERTIES (Type = D3D12_HEAP_TYPE_UNKNOWN (0), CPUPageProperty = UNKNOWN, MemoryPoolPreference = UNKNOWN), which subsequent CreateHeap or CreateCommittedResource calls reject with E_INVALIDARG.

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs:
    • Add pc_custom_heap_query(mask, ty) clamping nonzero nodeMask values to 1 (matching pc_queue_desc and create_list) and mapping console-only heap types (ty > D3D12_HEAP_TYPE_GPU_UPLOAD) to D3D12_HEAP_TYPE_DEFAULT (matching dev_create_heap), while leaving invalid PC inputs (0 = UNKNOWN, 4 = CUSTOM) untouched so PC still rejects them.
    • Call pc_custom_heap_query in get_custom_heap_properties_x before invoking PC GetCustomHeapProperties.
    • Add unit test pc_custom_heap_query_sanitizes_node_mask_and_console_heap_type and child-process-isolated WARP test get_custom_heap_properties_x_sanitizes_node_mask_and_console_heap_type covering mask = 3 (DEFAULT, C++ order), mask = u32::MAX (UPLOAD, C order), console heap type 6, and preservation of rejection for CUSTOM (4).

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): get_custom_heap_properties_x_sanitizes_node_mask_and_console_heap_type failed before the fix (mask=3 DEFAULT, mask=MAX UPLOAD, and CONSOLE(6) all returned [0, 0, 0, 1, 1] instead of D3D12_HEAP_TYPE_CUSTOM), and all 22 device_x tests passed after (22 passed, 0 failed, 0.18s, 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, 1583 frames vs 1695 on main, 33990 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: 4a9d63ee695a3cfc31bb7041672a2a68e431ec0d
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1583 (PresentX 1583)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33990 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 4a9d63ee.

Looks clean and well-tested (both C and C++ calling conventions covered on WARP). One small nit: get_custom_heap_properties_x_sanitizes_node_mask_and_console_heap_type silently returns return; if DXGI/WARP device creation fails instead of calling crate::gpu::recomp::runner::skip_test(...) like the other tests.

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:: -- --test-threads=1: 22 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.

…ustomHeapProperties

The test reports SKIPPED through runner::skip_test when it gets no DXGI factory, WARP adapter or WARP device, and the parent passes the child's SKIPPED lines on, instead of passing silently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kalmarv
Kalmarv force-pushed the samplers/custom-heap-properties-sanitize branch from 42fbd67 to b72b472 Compare December 1, 2026 00:29
@github-actions github-actions Bot removed the needs-rebase Has merge conflicts with its base branch label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head b72b472, diff read, not a merge-check: the PR description check fails, so not built or run here yet):

  • The PR's smoke block is on 4a9d63e, not the head b72b472, which is why PR description fails. It needs a rerun on the head. The stale run is within the limits (93 % of main's frames, 108 % of its peak commit).
  • AI use says "Antigravity (Gemini)", with no exact model name.
  • Tested skipped test_title_runs_and_game_folder_is_untouched and uma_driver::tests::, so the full suite wasn't run.
  • Nothing shows a title calling this with a node mask above 1 or a heap type above 5. Worth naming the title or issue if there is one.
  • Console heap types above 5 become DEFAULT (GPU-only, device_x.rs ~1119-1124). If a console-only type is CPU-visible, a committed resource made from these properties is created but can't be mapped, where before it was refused. dev_create_heap (real.rs ~4657) makes the same choice, so this is consistent, but unverified without the console's type table.
  • The single-adapter node-mask clamp is now written separately in pc_queue_desc (~75), create_list (~106), here, and in D3D12.X: clamp single-adapter NodeMask and guard null riid in CreateCommandSignature #3400, D3D12.X: sanitize descriptor heap flags and NodeMask on CreateDescriptorHeap #3385 and D3D12.X: clamp single-adapter NodeMask on CreateRootSignature #3387, with no shared helper. One helper used by all of them would be easier to keep right.
  • The WARP test asserts that the PC refuses CUSTOM (4), which is Microsoft's behaviour and could change with an Agility SDK update; extending custom_heap_properties_match_host_in_cpp_and_c_abi would test XCL's side instead.

Fine: the change is limited to get_custom_heap_properties_x, and masks 0/1 and types 1-5 behave as before. Both argument orders go through this_first. The child-process test follows the console_heap.rs pattern with skip_test, there is no #[ignore], and the WARP test fails without the fix if the PC returns zeros as described.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Test report (not a merge-check: PR description red)
base: b2b1f10
head: b72b472
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2904 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: not repeated here; my review of this same head is at #3403 (comment), and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main; the findings in my review stand
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.

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants