Skip to content

D3D12.X: sanitize display target desc/clear/state and committed console heap flags - #3376

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:samplers/committed-display-target-sanitize
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:samplers/committed-display-target-sanitize

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

What is in it
Sanitize console resource, clear-value, initial-state, heap-flag, and heap-property arguments on the PC CreateCommittedResource paths in crates/xcl/src/hle/d3d12x/real.rs:

  • create_display_target now converts the console resource description with pc_resource_desc_for_device(this, &x) (matching dev_create_committed_resource_x and create_placed_resource_x), aligns any optimized D3D12_CLEAR_VALUE format via pc_clear_for_desc, strips console-only initial state bits and dropped-UAV states via pc_initial_state_for_desc, and maps console-only heap types (!(1..=5)) to D3D12_HEAP_TYPE_DEFAULT via pc_heap_properties.
  • dev_create_committed_resource_x now sanitizes console D3D12_HEAP_FLAGS via pc_committed_heap_flags (dropping ALLOW_DISPLAY, tier-1 DENY_* flags, and console-only bits that PC CreateCommittedResource rejects with E_INVALIDARG) and console-only heap types via pc_heap_properties on its PC committed-resource fallback path.
  • Added unit and child-process WARP tests in hle::d3d12x::real::committed_display_target_sanitize_tests covering pc_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 in UNORDERED_ACCESS, console state bit 0x10_0000, and dev_create_committed_resource_x with console heap flags and heap type.

Tested

  • Verified the new WARP test failed before the fix (display target format 116 with clear value failed: 0x80070057) and passed after (2 passed, 0 failed, including verifying case 5 exercises the PC CreateCommittedResource fallback 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.
  • Full workspace (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 ignored across 41 test suites (26 runtime SKIPPED messages: 21 wave64-only checks on wave32 hardware, 3 per-lane-form #1426 refusals for V_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32, and 2 XCL_HEAP_WINDOWS=1 opt-in checks).

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: 3ba24ec54168192856c057471265779af59a66b3
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1975 (PresentX 1975)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33596 MB

Not tested

  • Retail titles creating HDR/console-format display targets or committed resources with console heap flags on AMD/Intel drivers (verified on WARP and RTX 5070 Ti only).
  • test_title_runs_and_game_folder_is_untouched and uma_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_target and dev_create_committed_resource_x PC fallback paths, writing the helpers and synthetic unit/WARP tests, and running the workspace and smoke verification; all diffs and results were reviewed directly.

@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
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: 3ba24ec
merge: 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 in create_display_target, which its only caller can't pass (layout_state never produces it). (3) Case 5's console_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 switches dev_create_committed_resource_x to a new pc_clear_for_resource_desc, while display targets here keep pc_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 and uma_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 uses skip_test and forwards SKIPPED.
performance: 60 s smoke of a retail title, main d0832e6 vs 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.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
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) needs:amd-test Needs a test report or merge-check on an AMD GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants