You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
Static audit on main @ c7e1799 found two bugs in the newly merged multi-plane PresentX compositor (#615) in crates/xcl/src/hle/d3d12x/present.rs. (Note: open PR #2418 addresses root_sigManuallyDrop release and upfront plane validation, but does not fix either bug below.)
1. [Critical] Compositor::record leaks a COM ref to the DXGI back buffer into global RTVS, permanently breaking ResizeBuffers and leaking old swap chains
Root cause:Presenter::dev wraps the adopted Kind::Device (real::device_raw()), whose CreateRenderTargetView vtable slot is unconditionally hooked by real::dev_create_rtv (real.rs:2867). Every multi-plane frame, Compositor::record (present.rs:848) calls dev.CreateRenderTargetView(dst, Some(&rtv_desc), rtv_cpu) on the DXGI swap-chain back buffer bb. dev_create_rtv (real.rs:6806) calls present::note_rtv(handle, res), which checks only if !enabled() — notIN_PRESENT — calls add_ref(bb), and pins (rtv_cpu.ptr, bb) in global RTVS forever. (list.OMSetRenderTargets at present.rs:862 similarly hits cl_om_set_render_targets → note_rt0, polluting LISTS.)
Trigger: Any multi-plane title that later changes plane count, resolution, or format (e.g. 2-plane UI + scene menu → 1-plane gameplay): DXGI requires all outstanding references to swap-chain back buffers to be released before ResizeBuffers. Because RTVS still holds an AddRef on the last composited bb, sc.ResizeBuffers (present.rs:976) fails with DXGI_ERROR_INVALID_CALL (0x887A0001), ensure_swapchain returns false, and present_now stops presenting permanently. On queue switch (*guard = None at present.rs:1061), the old swap chain's back buffer leaks forever. (Missed by compositor_blends_ui_plane_over_scene_plane because it uses an unadopted raw WARP device.)
Fix: Guard note_rtv (present.rs:209) and note_rt0 (present.rs:262) with if !enabled() || IN_PRESENT.with(|c| c.get()) { return; }.
2. [High] Compositor::record strips _SRGB from concrete *_UNORM_SRGB plane SRVs
Root cause:Compositor::record sets each plane SRV's format to swap_format(desc.Format).unwrap_or(desc.Format). swap_format (present.rs:271-272) maps R8G8B8A8_UNORM_SRGB → R8G8B8A8_UNORM and B8G8R8A8_UNORM_SRGB → B8G8R8A8_UNORM. In D3D12, viewing a concrete (non-typeless) *_UNORM_SRGB texture with a *_UNORM SRV is invalid (CREATESHADERRESOURCEVIEW_INVALIDFORMAT).
Trigger: Any multi-plane PresentX frame whose scene or UI plane resource has concrete format R8G8B8A8_UNORM_SRGB or B8G8R8A8_UNORM_SRGB.
Fix: Use a plane_srv_format(f) helper at present.rs:854 that converts only *_TYPELESS formats to concrete formats and preserves concrete *_UNORM_SRGB formats as desc.Format.
AI use
Antigravity (Gemini 4 Neon): static code audit on main @ c7e1799 and issue drafting.
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).
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 as a262974c624c29beabc7d0a2e4e7f4c313f28cfc. #2537 remains upstream’s prerequisite. Upstream SRV change
Refreshed fork head
Focused native results
f8c3c4fb6bc46b9a97da101d9301cff658562aa3
All-UNORM and all-sRGB pairs both matched. The fractional sRGB pixel was [137, 161, 0, 255].
92217cad04fd69bab29e9874fce59de2a57db0a5
All five matching and mixed RGBA/BGRA pairs matched the fixture. A transparent UNORM overlay over an sRGB primary preserved [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
OpenAI Codex assisted with the original follow-ups and synthetic tests. Codex (GPT-6 family, exact serving variant unavailable) reapplied the patches, adapted the measurement fixture, ran the local checks, and drafted this report. The SRV prerequisite and linked independent checks are credited to their authors.
Clean-head workspace checks
The exact two clean heads also passed cargo build --workspace --locked --offline -j 3 and cargo test --workspace --locked --offline -j 3 --no-fail-fast -- --test-threads=1 --show-output with XCL_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.ps1 on clean upstream main 8b957bec6f82495aec940944c6bf47faa02db590 and clean output head f8c3c4fb6bc46b9a97da101d9301cff658562aa3 would supply the remaining retail evidence. If an independent runner can provide this comparison, the two raw xcl-smoke v1 blocks can be posted here.
On item 2: on this hardware a UNORM SRV on a concrete R8G8B8A8_UNORM_SRGB texture is valid, so current main is 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 --output at commit 16ba46b reproduce it.
View format
D3D12_FEATURE_DATA_D3D12_OPTIONS3::CastingFullyTypedFormatSupported is TRUE on both adapters tested.
Debug layer: 0 errors and 0 warnings with the UNORM view. As a control, an R32_FLOAT view of the same texture is rejected ("not a fully qualified format within the same family").
An adapter without that feature would still be a problem; I had none to test.
Readback, two R8G8B8A8_UNORM_SRGB planes, base byte 188 under a black plane with alpha 0 / 128 / 255:
Rows 1 and 4 store the same bytes; only the sampled value tells them apart. For 1:1 compositing, re-encoding in the shader therefore gives what main gives today.
So the open question is whether the console blends its display planes encoded (94) or in linear (137). A PC GPU cannot answer that. Is there a console readback or public documentation for it?
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
Claude Code (Claude Opus 5.5) wrote the test, ran it and drafted this comment.
Activity
Creaa commentedon Nov 25, 2026
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).
D3D12.X: clear LAST_CONTENT on unmap/remap and guard present RTV trac…
CryingLaughing commentedon Nov 27, 2026
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.Hash-0x commentedon Nov 30, 2026
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