D3D12.X: multi-plane PresentX Compositor::record leaks DXGI back-buffer COM ref into RTVS (breaking ResizeBuffers) and strips _SRGB from concrete plane SRVs #2456
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2456
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?
@microwave805 on GitHub · 2026-11-25 19:30 UTC · original
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.@Creaa on GitHub · 2026-11-25 19:44 UTC · original
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).