D3D12.X: sanitize display target desc/clear/state and committed console heap flags #3376
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3376"
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-29T11:14:02Z.
What is in it
Sanitize console resource, clear-value, initial-state, heap-flag, and heap-property arguments on the PC
CreateCommittedResourcepaths incrates/xcl/src/hle/d3d12x/real.rs:create_display_targetnow converts the console resource description withpc_resource_desc_for_device(this, &x)(matchingdev_create_committed_resource_xandcreate_placed_resource_x), aligns any optimizedD3D12_CLEAR_VALUEformat viapc_clear_for_desc, strips console-only initial state bits and dropped-UAV states viapc_initial_state_for_desc, and maps console-only heap types (!(1..=5)) toD3D12_HEAP_TYPE_DEFAULTviapc_heap_properties.dev_create_committed_resource_xnow sanitizes consoleD3D12_HEAP_FLAGSviapc_committed_heap_flags(droppingALLOW_DISPLAY, tier-1DENY_*flags, and console-only bits that PCCreateCommittedResourcerejects withE_INVALIDARG) and console-only heap types viapc_heap_propertieson its PC committed-resource fallback path.hle::d3d12x::real::committed_display_target_sanitize_testscoveringpc_committed_heap_flags,pc_heap_properties, display targets with promoted console formats (116->R16G16B16A16_FLOAT,B8G8R8X8_UNORM + UAV->B8G8R8A8_UNORM) and optimized clear values, stripped-UAV sRGB display targets inUNORDERED_ACCESS, console state bit0x10_0000, anddev_create_committed_resource_xwith console heap flags and heap type.Tested
display target format 116 with clear value failed: 0x80070057) and passed after (2 passed, 0 failed, including verifying case 5 exercises the PCCreateCommittedResourcefallback rather than UMA placement).cargo test -p xcl --lib -j 4 -- hle::d3d12x::real:: --skip failed_binding_keeps_indirect_commands_until_allocator_reset --test-threads=4:167 passed, 0 failed.cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::with DXC 1.9 on NVIDIA GeForce RTX 5070 Ti, wave32):2611 passed, 0 failed, 49 ignoredacross 41 test suites (26runtimeSKIPPEDmessages:21wave64-only checks on wave32 hardware,3per-lane-form#1426refusals forV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32, and2XCL_HEAP_WINDOWS=1opt-in checks).Regression run
Not tested
test_title_runs_and_game_folder_is_untouchedanduma_driver::tests::were skipped in the workspace run; wave64 GPU tests were skipped on this wave32 RTX 5070 Ti.AI use
Assisted with auditing the unsanitized
create_display_targetanddev_create_committed_resource_xPC fallback paths, writing the helpers and synthetic unit/WARP tests, and running the workspace and smoke verification; all diffs and results were reviewed directly.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:15:09Z.
merge-check
base:
d0832e614fhead:
3ba24ec541merge: 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, +237/-3, ~45 lines outside tests). It changes the default path: every display target and every committed resource that falls back to the PC path now has its heap flags masked, and heap types outside 1-5 become DEFAULT. Inputs the PC already accepts look unaffected (SHARED, CREATE_NOT_ZEROED and ALLOW_SHADER_ATOMICS are kept). Findings: (1) the comment at ~3808 says the PC rejects ALLOW_DISPLAY and the DENY_* flags, but no test sets them on their own. Case 5 (~15224) combines them with the console-only 0x2 bit and heap type 6, either of which fails alone, yet they're now stripped unconditionally, unlike
dev_create_heap, which strips only after the PC refuses. (2) Case 4 (~15209) tests state 0x100000 increate_display_target, which its only caller can't pass (layout_statenever produces it). (3) Case 5'sconsole_buffer(...).is_none()assert (~15238) checks nothing for a texture (only buffers are tracked). (4) Display-target sanitizing and committed heap flags/type are two changes. (5) #3418 switchesdev_create_committed_resource_xto a newpc_clear_for_resource_desc, while display targets here keeppc_clear_for_desc; no textual conflict, but they can drift. (6) AI use names no tool or model; no what-and-why paragraph or issue link; the suite run skipped the e2e test anduma_driver::tests::; both of the PR's smoke runs end at 0 presents per 2 s, so they don't show the title reaching these paths. Fine: main already promoted 116 -> 10 and 88 -> 87 for display targets, so presenting and RTV use are unchanged; the helpers match the committed and placed paths; the child test usesskip_testand forwards SKIPPED.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (2c6b1a00): 1516 -> 1685 frames shown (111 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 16862 MB, 0 device removals, 0 crashes. git diff --check flags a new blank line at the end of real.rs.verdict: safe to merge (splitting display targets from committed heap flags, and a test that sets ALLOW_DISPLAY / DENY_* alone, would make it stronger)
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-02T02:44:30Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 3926dev_create_committed_resource_x(slots 27/76) now strips ALLOW_DISPLAY so the call succeeds as a plain PC resource, instead of sending it tocreate_display_targetthe waydev_create_committed_resource_layout_xdoes. Display targets created here never get title memory fromruntime_alloc(D3D_DISPLAY_TARGET)ornote_title_address. A title that creates its back buffers via CreateCommittedResource with ALLOW_DISPLAY, when UMA placement doesn't take them, used to get a loud E_INVALIDARG. Now it gets S_OK with no title-side allocation, so the title's assert that its back-buffer block is used up fires, or console code reads the target at an address that was never registered. Test case 5 (~15224) asserts the plain-PC result, which locks this in.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:30Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 3828pc_heap_propertiesreplaces any console-only heap type (outside 1..=5) with a fresh DEFAULT heap and clears CPUPageProperty, MemoryPoolPreference and both node masks. A committed buffer/texture in a CPU-visible console heap type (e.g. 6), created when UMA placement is off or full, is now GPU-only on the PC. Map() then fails or returns null, and the title's CPU writes or readback crash or are lost, where before the creation failed outright. Mapping CPU-visible console types to a CPU-visible PC heap (or a custom heap with the same CPU page property) would keep access.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:30Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 3815PC_COMMITTED_HEAP_FLAGSkeeps ALLOW_WRITE_WATCH (0x200), HARDWARE_PROTECTED (0x100) and ALLOW_SHADER_ATOMICS, which are invalid on plain CreateCommittedResource once the type has been rewritten to DEFAULT, or without a protected session. Console flags 0x2C2 with console heap type 6 become DEFAULT + 0x200, which PC D3D12 rejects with E_INVALIDARG, so the cleanup only half-fixes the failure it targets. The failure log (~3934) also still prints the console's raw flags and type, not the cleaned-up values actually rejected.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:30Z.
Review: COMMENTED
Review of
3ba24ec5: 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 Kalmarv on 2026-12-02T20:49:04Z.
Consolidated into and superseded by #3729 (https://github.com/xcl-dev/xcl/pull/3729), which combines #3291, #3414, #3418, and #3376 and addresses all open review findings in one PR. Closing this one.
Pull request closed