D3D12.X: clamp single-adapter nodeMask and console heap types in GetCustomHeapProperties #3403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3403"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T13:41:42Z.
Clamp multi-bit
nodeMaskvalues to single-adapter1and map console-only heap types aboveGPU_UPLOAD(5) toDEFAULTinget_custom_heap_properties_x.Previously,
device_x::get_custom_heap_properties_xforwardednodeMaskandheapTypeunchanged to PCGetCustomHeapProperties. On single-adapter PC D3D12, passing a multi-bit/all-nodesnodeMask > 1(for example0x3or0xFFFF_FFFF) or a console-only heap type (> 5) makes PCGetCustomHeapPropertiesreturn zeroedD3D12_HEAP_PROPERTIES(Type = D3D12_HEAP_TYPE_UNKNOWN (0),CPUPageProperty = UNKNOWN,MemoryPoolPreference = UNKNOWN), which subsequentCreateHeaporCreateCommittedResourcecalls reject withE_INVALIDARG.What is in it
crates/xcl/src/hle/d3d12x/device_x.rs:pc_custom_heap_query(mask, ty)clamping nonzeronodeMaskvalues to1(matchingpc_queue_descandcreate_list) and mapping console-only heap types (ty > D3D12_HEAP_TYPE_GPU_UPLOAD) toD3D12_HEAP_TYPE_DEFAULT(matchingdev_create_heap), while leaving invalid PC inputs (0=UNKNOWN,4=CUSTOM) untouched so PC still rejects them.pc_custom_heap_queryinget_custom_heap_properties_xbefore invoking PCGetCustomHeapProperties.pc_custom_heap_query_sanitizes_node_mask_and_console_heap_typeand child-process-isolated WARP testget_custom_heap_properties_x_sanitizes_node_mask_and_console_heap_typecoveringmask = 3(DEFAULT, C++ order),mask = u32::MAX(UPLOAD, C order), console heap type6, and preservation of rejection forCUSTOM (4).Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (XCL_DXC_DIR), debug for tests and release forxcl-smoke.cargo test -p xcl --lib -- hle::d3d12x::device_x::tests:: --nocapture):get_custom_heap_properties_x_sanitizes_node_mask_and_console_heap_typefailed before the fix (mask=3 DEFAULT,mask=MAX UPLOAD, andCONSOLE(6)all returned[0, 0, 0, 1, 1]instead ofD3D12_HEAP_TYPE_CUSTOM), and all 22device_xtests passed after (22 passed, 0 failed,0.18s,0skips).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.SKIPPEDGPU tests on this wave32 adapter (26 total across--nocaptureworkspace baseline): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426f16/cvt-f16 refusals, 2no heap windows(opt-inXCL_HEAP_WINDOWS=1).ea3b5e4d) 150 s regression run below (0device removals,0crashes,1583frames vs1695onmain,33990 MBpeak commit vs31546 MBonmain).Regression run
Not tested
nodeMask > 1is clamped to1for single-adapter PC D3D12 parity withpc_queue_descandcreate_list) and AMD RDNA / wave64 GPUs.uma_driver::tests::(skipped locally due to pre-existing0x7C10003exit on NVIDIA) andtest_title_runs_and_game_folder_is_untouched.AI use
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_typesilently returnsreturn;if DXGI/WARP device creation fails instead of callingcrate::gpu::recomp::runner::skip_test(...)like the other tests.Tested locally
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
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:18:42Z.
Review (head
b72b472b, diff read, not a merge-check: thePR descriptioncheck fails, so not built or run here yet):4a9d63ee, not the headb72b472b, which is whyPR descriptionfails. It needs a rerun on the head. The stale run is within the limits (93 % of main's frames, 108 % of its peak commit).test_title_runs_and_game_folder_is_untouchedanduma_driver::tests::, so the full suite wasn't run.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.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.custom_heap_properties_match_host_in_cpp_and_c_abiwould 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 throughthis_first. The child-process test follows theconsole_heap.rspattern withskip_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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T15:44:29Z.
Test report (not a merge-check:
PR descriptionred)base:
b2b1f109d2head:
b72b472b8fmerge: 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.
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.
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 1137Not 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_readbacksends to coherent RAM, and CUSTOM heaps get HEAP_UMA sparse-VRAM backing. It's worth checking before merge.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 1120Two 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.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 1121Not 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.
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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:39:44Z.
Closing: part of the
NodeMaskseries (0 safe checks) with smoke regression andGPU_UPLOADreview findings; will re-open cleanly oncanonical_node_maskonly if needed.Pull request closed