D3D12.X: multi-plane PresentX Compositor::record leaks DXGI back-buffer COM ref into RTVS (breaking ResizeBuffers) and strips _SRGB from concrete plane SRVs #2446
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 microwave805 on 2026-11-25T19:30:14Z.
Static audit on
main @ c7e1799found two bugs in the newly merged multi-planePresentXcompositor (#615) incrates/xcl/src/hle/d3d12x/present.rs. (Note: open PR #2418 addressesroot_sigManuallyDroprelease and upfront plane validation, but does not fix either bug below.)1. [Critical]
Compositor::recordleaks a COM ref to the DXGI back buffer into globalRTVS, permanently breakingResizeBuffersand leaking old swap chainscrates/xcl/src/hle/d3d12x/present.rs:208-221(note_rtv),261-266(note_rt0),848, 862(Compositor::record),976(ResizeBuffers),1061, andreal.rs:551-552, 2867, 6806Presenter::devwraps the adoptedKind::Device(real::device_raw()), whoseCreateRenderTargetViewvtable slot is unconditionally hooked byreal::dev_create_rtv(real.rs:2867). Every multi-plane frame,Compositor::record(present.rs:848) callsdev.CreateRenderTargetView(dst, Some(&rtv_desc), rtv_cpu)on the DXGI swap-chain back bufferbb.dev_create_rtv(real.rs:6806) callspresent::note_rtv(handle, res), which checks onlyif !enabled()— notIN_PRESENT— callsadd_ref(bb), and pins(rtv_cpu.ptr, bb)in globalRTVSforever. (list.OMSetRenderTargetsatpresent.rs:862similarly hitscl_om_set_render_targets→note_rt0, pollutingLISTS.)ResizeBuffers. BecauseRTVSstill holds anAddRefon the last compositedbb,sc.ResizeBuffers(present.rs:976) fails withDXGI_ERROR_INVALID_CALL(0x887A0001),ensure_swapchainreturnsfalse, andpresent_nowstops presenting permanently. On queue switch (*guard = Noneatpresent.rs:1061), the old swap chain's back buffer leaks forever. (Missed bycompositor_blends_ui_plane_over_scene_planebecause it uses an unadopted raw WARP device.)note_rtv(present.rs:209) andnote_rt0(present.rs:262) withif !enabled() || IN_PRESENT.with(|c| c.get()) { return; }.2. [High]
Compositor::recordstrips_SRGBfrom concrete*_UNORM_SRGBplane SRVscrates/xcl/src/hle/d3d12x/present.rs:854(withpresent.rs:269-277)Compositor::recordsets each plane SRV's format toswap_format(desc.Format).unwrap_or(desc.Format).swap_format(present.rs:271-272) mapsR8G8B8A8_UNORM_SRGB→R8G8B8A8_UNORMandB8G8R8A8_UNORM_SRGB→B8G8R8A8_UNORM. In D3D12, viewing a concrete (non-typeless)*_UNORM_SRGBtexture with a*_UNORMSRV is invalid (CREATESHADERRESOURCEVIEW_INVALIDFORMAT).PresentXframe whose scene or UI plane resource has concrete formatR8G8B8A8_UNORM_SRGBorB8G8R8A8_UNORM_SRGB.plane_srv_format(f)helper atpresent.rs:854that converts only*_TYPELESSformats to concrete formats and preserves concrete*_UNORM_SRGBformats asdesc.Format.AI use
main @ c7e1799and issue drafting.Imported from ivall/xcl. Originally posted by Creaa on 2026-11-25T19:44:32Z.
Taking the back-buffer reference and render-target tracking part. I will keep compositor-owned render targets out of the title tracking tables during presentation and test both paths. The separate sRGB view-format issue remains open. AI use: OpenAI Codex (GPT-6).
Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-27T03:28:57Z.
For item 2, I reapplied the archived sRGB follow-ups on current main
8b957bec6f82495aec940944c6bf47faa02db590. Both refreshed heads merge cleanly into that revision and retain main’s shader-startup documentation. The stack preserves ramon-victor’s #2537 SRV change and its authorship, replayed asa262974c624c29beabc7d0a2e4e7f4c313f28cfc. #2537 remains upstream’s prerequisite. Upstream SRV changef8c3c4fb6bc46b9a97da101d9301cff658562aa3[137, 161, 0, 255].92217cad04fd69bab29e9874fce59de2a57db0a5[188, 128, 0, 255].The serial offscreen runs each reported 1 passed, 0 failed, 0 ignored, and zero capability skips on a GeForce RTX 4080 with driver 621.01. Hardware and toolchain were Windows 11 25H2 build 26200.9974, Core i5-13600K, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. A test-only overlay selects the physical adapter, confirms its device LUID, and logs pixel readbacks. The production code and original fixture assertions match each clean head.
Both old heads and their matched smoke evidence are preserved. These refreshed heads still need their own same-title retail smoke. Xbox’s intended behavior for an opaque UNORM midtone over an sRGB primary also remains unverified. Output-encoding head · Primary-plane head · Mixed-format review
AI use
Clean-head workspace checks
The exact two clean heads also passed
cargo build --workspace --locked --offline -j 3andcargo test --workspace --locked --offline -j 3 --no-fail-fast -- --test-threads=1 --show-outputwithXCL_ADAPTER=4080 XCL_NETWORK=0. Each serial suite reported 1,447 passed, 0 failed, 47 ignored, with the same 29 explicit capability skips. These were 21 wave64 cases, three unsupported instructions, three D3D12 debug-layer cases, one driver-cache control, and one heap-window case. The stock compositor fixture also passed in each clean suite.For the output-encoding follow-up, a same-title, same-duration retail pair using
scripts/smoke.ps1on clean upstream main8b957bec6f82495aec940944c6bf47faa02db590and clean output headf8c3c4fb6bc46b9a97da101d9301cff658562aa3would supply the remaining retail evidence. If an independent runner can provide this comparison, the two rawxcl-smoke v1blocks can be posted here.Imported from ivall/xcl. Originally posted by Hash-0x on 2026-11-30T13:11:57Z.
On item 2: on this hardware a UNORM SRV on a concrete
R8G8B8A8_UNORM_SRGBtexture is valid, so currentmainis not doing anything undefined here. What differs is the space the planes are blended in.I did not run XCL. I reproduced the compositor's steps (present.rs#L1243: linear sampler at 1:1, premultiplied
ONE / INV_SRC_ALPHA) in my own D3D12 test bench, wave64-prefix-test, with my own shaders and synthetic data, and read back each stage. The compositing rows of--outputat commit16ba46breproduce it.View format
D3D12_FEATURE_DATA_D3D12_OPTIONS3::CastingFullyTypedFormatSupportedis TRUE on both adapters tested.R32_FLOATview of the same texture is rejected ("not a fully qualified format within the same family").Readback, two
R8G8B8A8_UNORM_SRGBplanes, base byte 188 under a black plane with alpha 0 / 128 / 255:main)The stored bytes are the same on both adapters. Each row is also checked over 262,144 random pixels against a CPU reference.
maingives today.Tested: GeForce RTX 4070 SUPER (driver 32.0.16.2124) and WARP, Windows 11 Pro 26300. 50 identical runs on the GPU and 2 on WARP.
Not tested: XCL itself, a retail title, scaled planes, other GPUs.
AI use