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

Closed
Kalmarv wants to merge 1 commit from upstream-pr/3403 into main
Kalmarv commented 2026-11-29 13:41:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T13:41:42Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5551284179 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T13:41:42Z. --- 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.
saintwolf commented 2026-11-29 14:20:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-29T14:20:48Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7257231279 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7257231279). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-29T14:20:48Z. --- 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.
Foniass commented 2026-12-01 03:18:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:18:42Z.


Review (head b72b472b, 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 4a9d63ee, not the head b72b472b, 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 #3400, #3385 and #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.

<!-- greyfinch-sync:ivall/xcl:comment:7299569937 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7299569937). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:18:42Z. --- Review (head b72b472b, 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 4a9d63ee, not the head b72b472b**, 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 #3400, #3385 and #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 commented 2026-12-01 15:44:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T15:44:29Z.


Test report (not a merge-check: PR description red)
base: b2b1f109d2
head: b72b472b8f
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 https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7299569937, 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.

<!-- greyfinch-sync:ivall/xcl:comment:7316427457 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7316427457). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T15:44:29Z. --- Test report (not a merge-check: `PR description` red) base: b2b1f109d27e746a62ec95b04dd1f9924452e682 head: b72b472b8f18362c274b903dbf5793976c79ae1f 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 https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7299569937, 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.
bmjask commented 2026-12-02 03:45:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T03:45:46Z.

Review: COMMENTED


Review of b72b472b: 3 finding(s). 3 are inline.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6144417799 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#pullrequestreview-6144417799). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T03:45:46Z. **Review:** COMMENTED --- Review of `b72b472b`: 3 finding(s). 3 are inline. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 03:45:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T03:45:47Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 1137

@@ -1111,15 +1111,30 @@ pub(super) unsafe extern "system" fn get_resource_allocation_info2_x(a: *mut c_v
     ret
 }
 
+/// Sanitize `GetCustomHeapProperties(nodeMask, heapType)` arguments for single-adapter PC D3D12:
+/// nonzero `nodeMask` values clamp to `1`, and console-only heap types above `GPU_UPLOAD` (`5`)
+/// fall back to `DEFAULT` (matching `dev_create_heap`), while invalid PC inputs (`0`, `4`) stay
+/// untouched so the runtime still rejects them.
+fn pc_custom_heap_query(mask: u32, ty: u32) -> (u32, u32) {
+    let pc_mask = if mask == 0 { 0 } else { 1 };
+    let pc_ty = if ty > D3D12_HEAP_TYPE_GPU_UPLOAD.0 as u32 {
+        D3D12_HEAP_TYPE_DEFAULT.0 as u32
+    } else {
+        ty
+    };
+    (pc_mask, pc_ty)
+}
+
 /// device #26 GetCustomHeapProperties(node mask, heap type) -> D3D12_HEAP_PROPERTIES (20 bytes),
 /// returned through a hidden pointer - like #25 called the C way (a retail game: return buffer, device,
 /// ...) or the C++ way.
 pub(super) unsafe extern "system" fn get_custom_heap_properties_x(a: *mut c_void, b: *mut c_void, mask: u32, ty: u32) -> *mut [u32; 5] {
     let (this, ret) = if real::this_first(a, b) { (a, b as *mut [u32; 5]) } else { (b, a as *mut [u32; 5]) };
     type F = unsafe extern "system" fn(*mut c_void, *mut [u32; 5], u32, u32) -> *mut [u32; 5];
     let pc: F = std::mem::transmute(real::orig_fn(this, 26));
+    let (pc_mask, pc_ty) = pc_custom_heap_query(mask, ty);
     let mut r = [0u32; 5];
-    pc(this, &mut r, mask, ty);
+    pc(this, &mut r, pc_mask, pc_ty);

Not certain about this one: this changes what the retail title gets (CUSTOM props where it used to get zeroed ones), and the PR's own smoke run regressed without explanation: 1583 vs 1695 frames (-6.6%) and 33990 vs 31546 MB peak commit (+2.4 GB). A plausible cause: before, zeroed props made CreateHeap fall back to a plain DEFAULT heap in dev_create_heap. Now READBACK with mask > 1 comes back as CUSTOM + WRITE_BACK, which is_cpu_readback sends to coherent RAM, and CUSTOM heaps get HEAP_UMA sparse-VRAM backing. It's worth checking before merge.

<!-- greyfinch-sync:ivall/xcl:review-comment:4764443078 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#discussion_r4764443078). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T03:45:47Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 1137 ~~~~diff @@ -1111,15 +1111,30 @@ pub(super) unsafe extern "system" fn get_resource_allocation_info2_x(a: *mut c_v ret } +/// Sanitize `GetCustomHeapProperties(nodeMask, heapType)` arguments for single-adapter PC D3D12: +/// nonzero `nodeMask` values clamp to `1`, and console-only heap types above `GPU_UPLOAD` (`5`) +/// fall back to `DEFAULT` (matching `dev_create_heap`), while invalid PC inputs (`0`, `4`) stay +/// untouched so the runtime still rejects them. +fn pc_custom_heap_query(mask: u32, ty: u32) -> (u32, u32) { + let pc_mask = if mask == 0 { 0 } else { 1 }; + let pc_ty = if ty > D3D12_HEAP_TYPE_GPU_UPLOAD.0 as u32 { + D3D12_HEAP_TYPE_DEFAULT.0 as u32 + } else { + ty + }; + (pc_mask, pc_ty) +} + /// device #26 GetCustomHeapProperties(node mask, heap type) -> D3D12_HEAP_PROPERTIES (20 bytes), /// returned through a hidden pointer - like #25 called the C way (a retail game: return buffer, device, /// ...) or the C++ way. pub(super) unsafe extern "system" fn get_custom_heap_properties_x(a: *mut c_void, b: *mut c_void, mask: u32, ty: u32) -> *mut [u32; 5] { let (this, ret) = if real::this_first(a, b) { (a, b as *mut [u32; 5]) } else { (b, a as *mut [u32; 5]) }; type F = unsafe extern "system" fn(*mut c_void, *mut [u32; 5], u32, u32) -> *mut [u32; 5]; let pc: F = std::mem::transmute(real::orig_fn(this, 26)); + let (pc_mask, pc_ty) = pc_custom_heap_query(mask, ty); let mut r = [0u32; 5]; - pc(this, &mut r, mask, ty); + pc(this, &mut r, pc_mask, pc_ty); ~~~~ --- Not certain about this one: this changes what the retail title gets (CUSTOM props where it used to get zeroed ones), and the PR's own smoke run regressed without explanation: 1583 vs 1695 frames (-6.6%) and 33990 vs 31546 MB peak commit (+2.4 GB). A plausible cause: before, zeroed props made CreateHeap fall back to a plain DEFAULT heap in dev_create_heap. Now READBACK with mask > 1 comes back as CUSTOM + WRITE_BACK, which `is_cpu_readback` sends to coherent RAM, and CUSTOM heaps get HEAP_UMA sparse-VRAM backing. It's worth checking before merge.
bmjask commented 2026-12-02 03:45:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T03:45:47Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 1120

@@ -1111,15 +1111,30 @@ pub(super) unsafe extern "system" fn get_resource_allocation_info2_x(a: *mut c_v
     ret
 }
 
+/// Sanitize `GetCustomHeapProperties(nodeMask, heapType)` arguments for single-adapter PC D3D12:
+/// nonzero `nodeMask` values clamp to `1`, and console-only heap types above `GPU_UPLOAD` (`5`)
+/// fall back to `DEFAULT` (matching `dev_create_heap`), while invalid PC inputs (`0`, `4`) stay
+/// untouched so the runtime still rejects them.
+fn pc_custom_heap_query(mask: u32, ty: u32) -> (u32, u32) {
+    let pc_mask = if mask == 0 { 0 } else { 1 };
+    let pc_ty = if ty > D3D12_HEAP_TYPE_GPU_UPLOAD.0 as u32 {

Two heap types still return zeroed props, which is what this PR sets out to fix. GPU_UPLOAD (5) goes to PC unchanged, so on adapters or runtimes without GPU upload heap support (ReBAR off, older runtimes, possibly WARP) GetCustomHeapProperties(0, 5) still gives {Type=0, UNKNOWN, UNKNOWN}, and the next CreateCommittedResource fails with E_INVALIDARG. UNKNOWN (0) is also left as is, although the doc says the mapping matches dev_create_heap, which maps anything outside 1..=5 (0 included) to DEFAULT. The new test checks neither type.

<!-- greyfinch-sync:ivall/xcl:review-comment:4764443082 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#discussion_r4764443082). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T03:45:47Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 1120 ~~~~diff @@ -1111,15 +1111,30 @@ pub(super) unsafe extern "system" fn get_resource_allocation_info2_x(a: *mut c_v ret } +/// Sanitize `GetCustomHeapProperties(nodeMask, heapType)` arguments for single-adapter PC D3D12: +/// nonzero `nodeMask` values clamp to `1`, and console-only heap types above `GPU_UPLOAD` (`5`) +/// fall back to `DEFAULT` (matching `dev_create_heap`), while invalid PC inputs (`0`, `4`) stay +/// untouched so the runtime still rejects them. +fn pc_custom_heap_query(mask: u32, ty: u32) -> (u32, u32) { + let pc_mask = if mask == 0 { 0 } else { 1 }; + let pc_ty = if ty > D3D12_HEAP_TYPE_GPU_UPLOAD.0 as u32 { ~~~~ --- Two heap types still return zeroed props, which is what this PR sets out to fix. GPU_UPLOAD (5) goes to PC unchanged, so on adapters or runtimes without GPU upload heap support (ReBAR off, older runtimes, possibly WARP) `GetCustomHeapProperties(0, 5)` still gives {Type=0, UNKNOWN, UNKNOWN}, and the next CreateCommittedResource fails with E_INVALIDARG. UNKNOWN (0) is also left as is, although the doc says the mapping matches dev_create_heap, which maps anything outside 1..=5 (0 included) to DEFAULT. The new test checks neither type.
bmjask commented 2026-12-02 03:45:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T03:45:47Z.

Code review location: crates/xcl/src/hle/d3d12x/device_x.rs; line 1121

@@ -1111,15 +1111,30 @@ pub(super) unsafe extern "system" fn get_resource_allocation_info2_x(a: *mut c_v
     ret
 }
 
+/// Sanitize `GetCustomHeapProperties(nodeMask, heapType)` arguments for single-adapter PC D3D12:
+/// nonzero `nodeMask` values clamp to `1`, and console-only heap types above `GPU_UPLOAD` (`5`)
+/// fall back to `DEFAULT` (matching `dev_create_heap`), while invalid PC inputs (`0`, `4`) stay
+/// untouched so the runtime still rejects them.
+fn pc_custom_heap_query(mask: u32, ty: u32) -> (u32, u32) {
+    let pc_mask = if mask == 0 { 0 } else { 1 };
+    let pc_ty = if ty > D3D12_HEAP_TYPE_GPU_UPLOAD.0 as u32 {
+        D3D12_HEAP_TYPE_DEFAULT.0 as u32

Not certain about this one: console-only heap types (> 5) are mapped to DEFAULT, so the title gets CUSTOM + CPU_PAGE_PROPERTY_NOT_AVAILABLE back even when that console type is CPU-visible on the console's UMA memory. A title that queries a type it uses for CPU-written data (e.g. 6), creates a CUSTOM heap or resource from the result and calls Map() gets E_INVALIDARG with a null pointer and dereferences it. Before, CreateHeap's own fallback handled the zeroed props instead.

<!-- greyfinch-sync:ivall/xcl:review-comment:4764443087 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#discussion_r4764443087). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T03:45:47Z. **Code review location:** `crates/xcl/src/hle/d3d12x/device_x.rs`; line 1121 ~~~~diff @@ -1111,15 +1111,30 @@ pub(super) unsafe extern "system" fn get_resource_allocation_info2_x(a: *mut c_v ret } +/// Sanitize `GetCustomHeapProperties(nodeMask, heapType)` arguments for single-adapter PC D3D12: +/// nonzero `nodeMask` values clamp to `1`, and console-only heap types above `GPU_UPLOAD` (`5`) +/// fall back to `DEFAULT` (matching `dev_create_heap`), while invalid PC inputs (`0`, `4`) stay +/// untouched so the runtime still rejects them. +fn pc_custom_heap_query(mask: u32, ty: u32) -> (u32, u32) { + let pc_mask = if mask == 0 { 0 } else { 1 }; + let pc_ty = if ty > D3D12_HEAP_TYPE_GPU_UPLOAD.0 as u32 { + D3D12_HEAP_TYPE_DEFAULT.0 as u32 ~~~~ --- Not certain about this one: console-only heap types (> 5) are mapped to DEFAULT, so the title gets CUSTOM + CPU_PAGE_PROPERTY_NOT_AVAILABLE back even when that console type is CPU-visible on the console's UMA memory. A title that queries a type it uses for CPU-written data (e.g. 6), creates a CUSTOM heap or resource from the result and calls Map() gets E_INVALIDARG with a null pointer and dereferences it. Before, CreateHeap's own fallback handled the zeroed props instead.
bmjask commented 2026-12-02 14:14:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:14:32Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7348219319 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7348219319). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:14:32Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Kalmarv commented 2026-12-02 19:39:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:39:44Z.


Closing: part of the NodeMask series (0 safe checks) with smoke regression and GPU_UPLOAD review findings; will re-open cleanly on canonical_node_mask only if needed.

<!-- greyfinch-sync:ivall/xcl:comment:7356525290 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3403#issuecomment-7356525290). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T19:39:44Z. --- Closing: part of the `NodeMask` series (0 safe checks) with smoke regression and `GPU_UPLOAD` review findings; will re-open cleanly on `canonical_node_mask` only if needed.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3403
No description provided.