D3D12.X: sanitize descriptor heap flags and NodeMask on CreateDescriptorHeap #3385
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3385"
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-29T12:02:15Z.
What is in it
D3D12_DESCRIPTOR_HEAP_DESCfields that PC D3D12 rejects withE_INVALIDARGindev_create_descriptor_heap_xandpc_descriptor_heap_desc(crates/xcl/src/hle/d3d12x/real.rs):CBV_SRV_UAV(including console extra type4) andSAMPLERheaps: strip console-onlyFlagsbits outsideD3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE(clearingFlagsto0when hosted in a shared heap) and clamp single-adapterNodeMaskvalues above1to1, while keeping the title's original description inCONSOLE_HEAP_DESCSsoID3D12DescriptorHeap::GetDescstill reports what the title requested.RTVandDSVheaps: clear non-zeroFlagstoD3D12_DESCRIPTOR_HEAP_FLAG_NONE(0) and clampNodeMask > 1to1.hle::d3d12x::real::descriptor_heap_tests(pc_descriptor_heap_desc_sanitizes_flags_and_node_maskanddev_create_descriptor_heap_x_sanitizes_console_flags_and_node_mask).Tested
pc_descriptor_heap_desc_sanitizes_flags_and_node_maskfailed on preserved console flag bits andNodeMask = 2;dev_create_descriptor_heap_x_sanitizes_console_flags_and_node_maskfailed on WARP with0x80070057(E_INVALIDARG)).cargo test -p xcl --lib -j 4 -- hle::d3d12x::real::descriptor_heap_tests:: --nocapture): 5 passed, 0 failed, 0 ignored.cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::withXCL_DXC_DIRset to DXC 1.9 on RTX 5070 Ti): 41 test binaries, 2611 passed, 0 failed, 49 ignored, 9 filtered out.SKIPPEDbreakdown (26 total): 21no wave64(RTX 5070 Ti is wave32), 3refused(V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32#1426semantics), 2no heap windows(XCL_HEAP_WINDOWS=1opt-in).Regression run
Not tested
NodeMaskvalues onCreateDescriptorHeapwere not run directly; those paths are covered by the synthetic unit and WARP tests.test_title_runs_and_game_folder_is_untouched,uma_driver::tests::, wave64 GPU tests, andXCL_HEAP_WINDOWS=1opt-in unit tests were not run in the workspace suite.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:38:01Z.
merge-check
base:
d0832e614fhead:
3f3c02abc3merge: 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 (real.rs, +93/-5). Flags 0 or SHADER_VISIBLE with mask 0 or 1 reach the PC unchanged. Findings: (1) the test comment (~12575) says shared heaps are off, but only
XCL_SHARED_SAMPLER_HEAP=0is set (~12588), so the CBV and type-4 cases take the shared path when WARP makes the global heap, and the non-shared branch that keeps SHADER_VISIBLE (~1752) is only covered by the unit test. (2) RTV and DSV heaps made from a sanitized description aren't inCONSOLE_HEAP_DESCS, soGetDescreturns Flags 0 and the clamped mask rather than the title's values (these creations failed before, so not a regression). (3)sanitize_descriptor_heap_node_mask(~1737) is another copy of the node-mask clamp next tocanonical_node_mask; one shared helper for this series would be better. (4) The console flag bits in the tests (0x10002, 0x20, 0x40) are made up and no title is cited; the description has no what-and-why paragraph or issue link; AI use names no tool or model; the suite run skippeduma_driver::tests::andtest_title_runs_and_game_folder_is_untouched. Fine: it matches D3D12 (only SHADER_VISIBLE exists on the PC, invalid for RTV/DSV), nulldescand unknown heap types pass through untouched, and the title's description is kept forGetDescon view and sampler heaps.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (6d9f3929): 1516 -> 1669 frames shown (110 %; last presents per 2 s: 60 61 60), peak commit 18133 -> 17087 MB, 0 device removals, 0 crashes.verdict: safe to merge (fix the test comment about shared heaps; 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.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T01:28:14Z.
merge-check claim
head:
3f3c02abc3Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T01:33:32Z.
merge-check
base:
1c8b551475head:
3f3c02abc3merge: clean (merged tree 154c64bd,
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2911 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same set as on the base; failing: none. Base alone, same machine: 2909 passed, 0 failed, 51 ignored. Both new tests pass (
pc_descriptor_heap_desc_sanitizes_flags_and_node_mask,dev_create_descriptor_heap_x_sanitizes_console_flags_and_node_mask; the second runs itself in a child process on WARP).review: whole diff read (one file, real.rs, +93/-5). No finding. For view and sampler heaps the PC description keeps only
SHADER_VISIBLEof the title's flags (none when the heap is hosted in the shared one, as before) and clamps a NodeMask above 1 to 1; the title's own description is still whatGetDescreturns, which the test checks. RTV and DSV heaps get flags 0 and the same clamp; a null description and unknown heap types go through untouched, so an invalid type still fails. A title that passes only valid PC values gets the same description as on main. Not checked here: which console-only bits real titles pass; the test uses made-up ones.performance: 60 s smoke of the same title, release, default settings, same machine, one run each. Base
1c8b5514: 1608 frames shown, presents per 2 s (last 3) 60 60 61, 0 device removals, 0 crashes, peak commit 19911 MB. Merge result (local merge commit): 1625 frames shown, 60 60 60, 0 device removals, 0 crashes, peak commit 19988 MB. No difference outside the spread. A few integer operations per descriptor heap creation.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0, debug suite and release smoke / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:34Z.
Review: COMMENTED
Review of
3f3c02ab: 2 finding(s). 2 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-02T02:44:35Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 1779RTV/DSV heaps get Flags and NodeMask rewritten but aren't recorded in CONSOLE_HEAP_DESCS, so heap #8 GetDesc (
heap_get_desc_x) now returns the cleaned-up PC desc instead of what the title asked for, while CBV/SRV/UAV and sampler heaps keep the title's desc. A title that creates an RTV heap with {Flags=0x10, NodeMask=2} and compares GetDesc with its request, or copies it to make a matching heap, sees {Flags=0, NodeMask=1}, values it never passed.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:35Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 1737Not certain about this one:
sanitize_descriptor_heap_node_maskclamps any NodeMask above 1 to 1 without checking the device's node count, though the doc says it only clamps single-adapter values. On a linked-node PC device NodeMask 2 is valid, but it's silently moved to node 0, and node-1 commands that reference the heap fail. CheckingGetNodeCount() == 1first would match the doc.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.