D3D12.X: harden PresentX compositor and single-plane sub-rect scaling #2408
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2418"
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 Decodere on 2026-11-25T18:19:21Z.
What is in it
Follow-up hardening to #615's
PresentXmulti-plane compositor incrates/xcl/src/hle/d3d12x/present.rs(+135/-6lines, single file):ManuallyDrop<Option<ID3D12RootSignature>>viaManuallyDrop::into_inner(pd.pRootSignature)afterCreateGraphicsPipelineStateinCompositor::psos_foron both success and failure paths, fixing a 2-ref COM leak onself.root_sigper RTV format.Compositor::record(D3D12_RESOURCE_DIMENSION_TEXTURE2D,SampleDesc.Count == 1, noD3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE, andswap_format(desc.Format).is_some()) before compiling PSOs, mutating RTV/SRV descriptors, or recording draws, returningfalsecleanly sopresent_nowfalls back to plane-0 copy.plane_counttoMAX_PLANESinpresent_x_frame's raw-word logging helper (raw_plane_words), matchingextract_planesand avoiding overflow or oversized reads on large guest counts.PresentXframes with a non-fulluv_rect != [0.0, 0.0, 1.0, 1.0]throughCompositorvianeeds_compositor(with plane-0 copy fallback) so single-plane dynamic-resolution sub-rects scale to fill the target, while keeping the full-rect 1-planeCopyResourcefast path intact.#[cfg(test)]-only fix (b80aa57c,0production lines changed vs3f4a1291): switch thepsos_forfailure-path test format fromDXGI_FORMAT_BC1_UNORM(whichvkd3d-protonaccepts as a NULL color attachment) toDXGI_FORMAT_R8G8B8A8_UINT(blending on an integer RTV format withSV_Target0returnsE_INVALIDARGon both Windows D3D12/WARP andvkd3d-proton), check the success-pathroot_sigrefcount before the failure-path check, and serialize the three WARPCompositor::newtests with a test-onlyMutexbecause D3D12's process-wide WARP singleton device deduplicates identicalID3D12RootSignatureCOM objects across parallel test threads.Part of #1452
Part of #1333
Tested
68a284a5:cargo test -p xcl --lib hle::d3d12x::present -- --test-threads=1 --nocapturefailed2of11(compositor_psos_for_preserves_root_sig_refcountleakedID3D12RootSignaturerefs7 != 3;compositor_record_rejects_unreadable_planes_without_mutating_statereturnedtrueand mutated compositor state on invalid planes).hle::d3d12x::presenton headb80aa57ca11950951114ce12ba05f2e9b8b37518(0new warnings inpresent.rsunderrustcandcargo clippy --tests -p xcl):cargo test -p xcl --lib hle::d3d12x::present:: -- --nocapture,3xruns):11 passed; 0 failed; 0 ignored(0.04 s–0.05 s,0skipped).cargo test --release -p xcl --lib hle::d3d12x::present:: -- --nocapture,3xruns):11 passed; 0 failed; 0 ignored(0.04 s–0.05 s,0skipped).cargo build --release -p xcl):exit 0(1m 56s,0new warnings inpresent.rs).3f4a1291,cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture, RTX 4060):23test binaries,1291 passed; 1 failed; 46 ignored(sole failure is pre-existing68a284a5failurea_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, tracked by #2379;29pre-existingSKIPPEDlines on this RTX 4060 host,0skipped inhle::d3d12x::present).Regression run
Paired 60 s RTX 4060 smoke (
scripts/smoke.ps1 -Seconds 60) on base68a284a5vs PR headb80aa57c(exercises the preserved full-rect single-planePresentXfast path;1536vs1557frames =98.7%,13977vs14017 MBpeak commit,0device removals,0crashes):Base (
68a284a5):PR head (
b80aa57c):Not tested
PresentXplanes or a single-plane dynamic-resolutionpSourceRect(the smoke title uses a full-rect single plane; single-plane sub-rect scaling, refcount cleanup, and invalid-plane fallback are covered by WARP unit tests).vkd3d-proton) execution directly on this host (DXGI_FORMAT_R8G8B8A8_UINTblend rejection onSV_Target0was checked againstvkd3d-proton'slibs/vkd3d/state.cvalidation and tested on native Windows WARP).d3d12SDKLayers.dllnot installed on this host).AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All changes were validated locally with failing-first WARP tests, parallel Debug and Release
hle::d3d12x::present::runs, full release workspace tests on the identical production diff (3f4a1291), and paired 60 s RTX 4060 smoke runs.Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-25T18:40:24Z.
Ran the PresentX compositor tests at
3f4a129:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All eleven tests pass here, including the three new ones for the root-signature refcount, invalid-plane rejection and single-plane
[0, 0, 0.5, 0.5]sub-rect scaling. As the description says, these are WARP-backed tests, so they do not measure the real adapter's PresentX path.What this adds: the thread has no report from another machine. This host has a different GPU/driver (RTX 5070 Ti, 32.0.16.2124) and DXC 1.9.2609.5 from the author's RTX 4060 run, but the tests themselves use WARP on both.
Not tested: a live retail title presenting multiple planes or a dynamic-resolution sub-rect, the D3D12 debug layer, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, release profile, title data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:47:38Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1, 1219/1):The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.
— Devin
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T19:53:30Z.
Thanks for testing! That
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierfailure comes from a pre-#2420mainbase (#2074) and was fixed onmainin#2420(c56e7448).This PR (
#2418) only touchescrates/xcl/src/hle/d3d12x/present.rs, and CIBuild and teston currentmainis green (0failures).Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:16:32Z.
Review: COMMENTED
No concrete correctness defect found. The COM ownership and validation ordering look sound, and the single-plane UV path is covered. Nonblocking validation gap: the new sub-rect test is square-to-square RGBA8 only. Please consider an accepted non-square destination/target aspect ratio or another accepted format to validate the compositor scaling path more broadly.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-27T12:51:53Z.
Update for head
b80aa57c(addsb80aa57con top of3f4a1291, which the results below are for). Same machine and setup as below (RX 9070 16 GB / Mesa 26.3.1 RADV / Proton Experimentalexperimental-11.0-20261112, vkd3d-proton masterec207194without the allocator / command-listlpVtblchecks, DXC 1.9.2609.5, Rust 1.96.0,x86_64-pc-windows-gnudebug build). The head itself (base68a284a5), with its base the same session as the baseline.Tests (
XCL_REQUIRE_GPU=wave64,--test-threads=1)cargo test -p xcl --lib -- hle::d3d12x::present::: 11 passed, 0 failed, 0 ignored, in 4 of 4 runs.compositor_releases_root_sig_and_rejects_invalid_planesandcompositor_scales_single_plane_sub_rectpass here now.compositor_releases_root_sig_and_rejects_invalid_planesfails, 4 of 4 times (1 run with--test-threads=1, 3 with 4), atpresent.rs:1886,assertion failed: comp.psos_for(&dev, DXGI_FORMAT_R8G8B8A8_UINT).is_none(). Right before it the log hasgraphics PSO rejected by the driver (0x80070057) – fallback shaders used (#1): the driver does refuse the pipeline, and it looks like XCL's fallback shaders, set up by tests that ran earlier in the same process, hand a pipeline back.--skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole(the first loses the RADV device here, the other two run out of memory under Wine),--test-threads=1: 1212 passed, 9 failed, 26 ignored; base68a284a5the same way: 1211 passed, 8 failed, 26 ignored. The extra failure is the test above. With 4 threads: 1212 passed, 9 failed and 1211 passed, 10 failed (the other extra,xapu_connect_returns_oom_and_cleans_up_on_failure, also fails at times on other trees here); the base had 18–19 failures in both of its 4-thread runs, after a device removal.The CS has been rejected) and the lib binary ended; this did not happen in the two later 4-thread runs. The other binaries fail the same 3 tests as on the base (e2e,pls_quota,predication_e2e).d3d12_resource_and_syncended the process, as it does on most trees here.Not tested: native Windows, NVIDIA / Intel; a retail run.
AI use: Claude Code (Claude Opus 5.5) ran the builds and tests on my machine and wrote this update.
Independent test report under Wine/Proton (not native Windows) for head
3f4a1291.Setup
experimental-11.0-20261112, vkd3d-proton masterec207194with a local patch dropping thelpVtblchecks ind3d12_command_allocator_from_iface/d3d12_command_list_from_iface, DXC1.9.2609.5, Rust 1.96.0,x86_64-pc-windows-gnumain83b00818, test commitd6eb56bfTests (debug,
XCL_REQUIRE_GPU=wave64,--test-threads=1)hle::d3d12x::present::: 14 passed, 1 failed (main: 13 passed, 0 failed).compositor_scales_single_plane_sub_rectpasses.compositor_releases_root_sig_and_rejects_invalid_planesfails atpresent.rs:1886,assertion failed: comp.psos_for(&dev, DXGI_FORMAT_BC1_UNORM).is_none(): vkd3d-proton creates a graphics pipeline with a BC1 render-target format instead of refusing it. So the assertion holds only where the runtime refuses that format, and the rest of the test (the root signature reference count, the plane checks) does not run here. Perhaps the failing format could be one every runtime refuses, or the reference-count check could come before it.cargo test --workspace --no-fail-fast -- --test-threads=4, lib binary: 1321 passed, 10 failed, 27 ignored (mainthe same run: 1320 passed, 9 failed, 27 ignored):main's 9 and the test above.Retail title, 300 s (release, from a copy of the same warm-cache snapshot;
XCL_DIRECT_DXIL=1 XCL_PREPARE=1 XCL_PSO_PRELOAD=1 XCL_PSO_WAIT_MS=50 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=1024 VKD3D_CONFIG=ignore_shared_fence,Apressed every 10 s)main, 4 runs: all clean, 1,892–2,122.Not tested
AI use
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T13:41:27Z.
Thanks for testing this on RX 9070 /
vkd3d-protonand catching theDXGI_FORMAT_BC1_UNORMassumption incompositor_releases_root_sig_and_rejects_invalid_planes!Pushed follow-up
#[cfg(test)]-only commitb80aa57c(+12/-2lines incrates/xcl/src/hle/d3d12x/present.rs,0production lines changed vs3f4a1291):DXGI_FORMAT_R8G8B8A8_UNORMsuccess-pathroot_sigrefcount before exercising the failure path.DXGI_FORMAT_BC1_UNORMwithDXGI_FORMAT_R8G8B8A8_UINT: becausepsos_forbuilds a blended PSO (BlendEnable = true) whose pixel shader writesSV_Target0, integer RTV blending returnsE_INVALIDARGon both Windows D3D12/WARP andvkd3d-proton(libs/vkd3d/state.c), while also exercising cleanup of the first (opaque) PSO plusManuallyDrop::into_inner(pd.pRootSignature).Compositor::newtests with a test-onlyMutex(COMPOSITOR_TEST_LOCK), since D3D12's process-wide WARP singleton device deduplicates identicalID3D12RootSignatureCOM objects and could otherwise shiftcomp.root_sigrefcounts under parallelcargo test.Verified locally on Windows 11 / RTX 4060 (
3xparallel Debug +3xparallel Releasehle::d3d12x::present::11 passed; 0 failed; 0 ignored, plus fresh 60 s smoke onb80aa57c). Wine/Proton was not run directly on this host, so re-testingb80aa57con RADV /vkd3d-protonwould confirm the fix end-to-end.(AI disclosure: Google Antigravity / Gemini 4 Neon inspected the
vkd3d-protonvalidation path, wrote the#[cfg(test)]-only fix, and ran the local Windows verification.)Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T19:03:17Z.
Independent Windows check of #2418 head
b80aa57con RTX 3080 Ti / driver 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1 MSVC; debug tests and release smoke.Tested
cargo test --offline --locked -j 4 -p xcl --lib 'hle::d3d12x::present::' -- --test-threads=1on the exact head: 11 passed, 0 failed, 0 ignored, zero skips.cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4on the exact head: 1,290 passed, 2 failed, 46 ignored, 25 explicit GPU skips. The failures area_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(the PR's old base predates #2420) andconsole_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk(DXIL not compiled).10d27297had no conflicts. The same workspace command on the unmodified trial merge gave 2,153 passed, 1 failed, 48 ignored, 25 explicit GPU skips. The barrier test passed. The mesh DXIL cache failure also occurs on unmodified main with this sandbox's default cache path. On exact main10d27297, the focused test passed 1/1 unchanged whenXCL_DXIL_CACHEpointed to a writable local directory; this local cache-path failure is not evidence against the PR.Paired 60-second regression run —
scripts/smoke.ps1 -Seconds 60, same title label, adapter,XCL_PREPARE=0, and retained cache. Both executables were release builds from clean commits. The exact merge base is main68a284a5; the PR showed 875/898 frames (97.4%) and 14,726/14,728 MB peak commit. A second head run showed 884 frames, zero crashes and zero device removals.Parent:
PR head:
Not tested: a title path that uses single-plane sub-rect scaling; AMD, Intel, or Wine. The current-main trial merge had tests only, not a title smoke. The PR branch should be rebased before its clean-head smoke is used for a merge decision.
AI use: Codex (GPT-6.2 Sol) ran the tests and smoke checks, checked the results, and wrote this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T21:07:34Z.
merge-check claim
head:
b80aa57ca1Imported from ivall/xcl. Originally posted by throny on 2026-11-28T21:36:53Z.
merge-check
base:
beeb81behead:
b80aa57ca1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2596 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
beeb81be(main after the merge of nvidia-dev): 2594 passed, 0 failed, 49 ignored. The three-way merge into current main is clean (two hunks no longer apply as a plain patch because main moved those lines).review: no blocking finding on Windows; all hunks read. The leak fix for the compositor's root signature is right, and main still has that leak. To know: single-plane frames with a sub-rectangle now go through the compositor, which changes the picture path for titles that present that way, and no title that does was run by anyone. Open from the thread: under vkd3d one of the PR's tests failed in a whole-lib run because pipelines set up by earlier tests are found; on Windows the whole suite passes here and in another tester's run. The smoke pair in the description is on an old base.
performance: none expected. No translator source.
verdict: safe to merge (Windows; the vkd3d test-order point is open for someone on Linux)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-29T06:16:39Z.
merge-check
base:
fa204595a4head:
b80aa57ca1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2607 passed, 3 failed, 49 ignored; failing: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, test_title_runs_and_game_folder_is_untouched (e2e), two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs. All three fail the same way on the base (
mq-base, same sha, run on their own). The log has a 4thFAILEDresult line; it is the two-pass test's child process summary, not a 4th test.review: single-plane PresentX frames with a non-full uv_rect are now routed through the Compositor instead of the plane-0 copy path; no live title exercising that path was run by anyone (covered only by the new WARP pixel test compositor_scales_single_plane_sub_rect, which passed). If comp.record() rejects such a frame at runtime it silently falls back to the plane-0 full copy, which ignores the uv sub-rect (same as the old behaviour, but now a silent quality regression rather than the previous always-behaviour). The psos_for ManuallyDrop::into_inner fix is correct on both paths (release runs before the Option is returned, test asserts refcount unchanged on success and on the R8G8B8A8_UINT failure path). record() validates dimensions/emptiness/all planes before psos_for, so a rejected frame neither compiles PSOs nor mutates heaps (test asserts psos.is_empty()). raw_plane_words caps at MAX_PLANES and keeps the readable() guard. The test-only COMPOSITOR_TEST_LOCK serialises the three WARP Compositor tests against the process-wide WARP singleton's root-signature dedup. Pre-existing, untouched: resolved[0] would still panic on an empty plane list; an MSAA/DENY_SHADER_RESOURCE source rejected by record() falls back to a plane-0 copy that is itself unsuitable for such sources.
performance: no new per-frame cost by default: multi-plane path unchanged, full-rect single-plane keeps the CopyResource fast path; only single-plane sub-rect frames (previously copied unscaled) now pay one compositor pass, which is the intended scaling work. Fixes a 2-ref COM leak per RTV format (one-time, tiny).
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6650 XT, Windows 10.0.26300; Muse Spark 1.3 (via pi) ran the build and tests in a prepared trial-merge worktree and drafted the review/performance lines; Claude Sonnet 5.5 (Claude Code) prepared the merge worktrees, read every hunk of the diff, checked the test counts and that the PR's own tests ran and passed in the logs, edited this text and posted it.
AI use: the two models above did all of this; the account owner did not read the diff or write this text. Claude Sonnet 5.5 read the whole diff; Muse Spark 1.3 only ran the commands and drafted lines. What was not done: no game run, NVIDIA or Intel GPU, or Linux.