D3D12.X: preserve the sRGB base with linear overlays #2801
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2811"
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 CryingLaughing on 2026-11-26T14:07:07Z.
Stacked on #2763, which follows #2537. The top commit
96b0b189fd0a8991c8e7883823191cf54d896223is the change under review.An UNORM overlay could force an sRGB scene to be stored as linear bytes. The primary plane already selects the SDR swap-chain format. Use it to select the compositor’s output transfer too, and keep each input plane’s own SRV format.
What is in it
present.rs.Tested
96b0b189fd0a8991c8e7883823191cf54d896223, with #2763 head0d380f427797fb91a07512d074a5f6f4e1892674as its parent. RTX 4080 driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11, debug.[128,55,0,255]. The native RTX 4080 fixture on the new production revision passed 1/0/0 with no capability skips over five offscreen cases. With an sRGB base and transparent UNORM overlay, it read[188,128,0,255]. A fractional overlay read[137,161,0,255]. The reverse case read[0,64,127,255]for the fractional sample. The BGRA case also passed.compositor_blends_ui_plane_over_scene_planetest passed 1/0/0.cargo build --workspace --locked -j 4succeeded.cargo test --workspace --locked -j 4 -- --test-threads=4 --show-outputreported 1,436 passed, 0 failed, 47 ignored across 37 harnesses. The pass count includes 29 capability skips.Regression run
Independent retail smoke by Anon64 compared release builds of main and this exact head on an RTX 3060 12 GB (driver 581.80), Core i9-14900KF, and Windows 11 build 26200. The 60-second runs used the same title. The head retained 101.4% of the baseline frames and used 97.7% of its peak commit, with zero crashes or device removals. The run did not establish whether the title reached the changed code.
main:
PR:
Not tested
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-26T14:55:48Z.
RX 9070 / Wine offscreen verification of the mixed sRGB/UNORM compositor change.
Tested
96b0b189fd0a8991c8e7883823191cf54d896223against its exact parent, #2763 head0d380f427797fb91a07512d074a5f6f4e1892674. This isolates the top commit of this stacked PR; main at the time of these runs wasb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.8293130ebe370b1+(local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, releasex86_64-pc-windows-gnu.1002:7550, LUID00000000:000003ef.XCL_NETWORK=0, private caches.Fixtures and controls
Both source copies receive the same current-head blend fixture and existing single-plane fixture with the hardware selector and sample logging. An identical local clone,
compositor_mixed_formats_collects_all_native_pixels, collects every pixel of each 8x8 output over all five format cases before asserting. It retains the upstream exact transparent/opaque/alpha expectations and RGB tolerance of 2 for fractional blending.All production bytes remain original to each revision. Removing the documented test replacements/addition reconstructs the exact original source files.
Results
Three fresh serial processes per fixture/revision:
For both affected format families, stored bytes are:
[128,55,0,255][188,128,0,255][64,91,0,255][137,161,0,255][255,0,0,255][255,0,0,255]The UNORM/UNORM, sRGB/sRGB and reverse UNORM-base/sRGB-overlay controls match on both. In the reverse case the fractional sample is
[0,64,127,255].The complete
hle::d3d12x::present::frame_dump_tests::module with four test threads gives head 5 passed / 0 failed versus parent 3 passed / 2 failed, with only the two mixed-format fixtures failing on the parent. Both frame-dump/report controls also pass separately on each revision; the mapped-buffer decoder control retains its original WARP device.The final matrix contains 24 verified invocations. One earlier passing head module invocation was repeated with
--show-outputbecause concurrent stdout/stderr interleaved its diagnostics; both gave 5/0. One additional Wine launch failed withrecvmsg: Connection reset by peerbefore libtest started; its exact retry passed. Raw logs for both observations are retained. No runtime skips or ignored tests in the completed selections. Independently checked all 2560 raw pixels from the final serial/concurrent clone runs, adapter/device identities, summaries, source reconstruction and executable hashes.Build:
cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run. GE-Proton Wine:<libtest.exe> hle::d3d12x::present::frame_dump_tests::<fixture> --exact --nocapture --test-threads=1; full module filter without--exact, with four threads. Final concurrent verification uses--show-output.Not tested
Console presentation-plane transfer semantics as an independent oracle. The expected values above come from the committed test; these measurements establish the stored bytes produced by each implementation, not which interpretation of mixed UNORM/sRGB planes matches a console.
Physical display/swap-chain output, HDR, overlays beyond these five synthetic cases, native Windows, other GPUs, full workspace suite, retail workload,
scripts/smoke.ps1, performance or FPS.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the stacked delta, adapted the native fixtures and all-pixel collection, ran and independently verified the paired evidence, and drafted this report. Publication authorized by the account owner.
Scope wording clarified after the discussion about the console transfer assumption; no additional hardware measurements were made.
Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-26T14:44:15Z.
Regression run of
96b0b18on a newer retail title: no device removal, no crash, frames and commit within the limits.Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main
b49be18(this PR's base) and of this PR's exact head,scripts/smoke.ps1 -Game <title>for 60 s withXCL_NETWORK=0and A pressed every 4 s from 20 s. Main ran before and after a batch of 11 PRs and peaked at 23,855 and 23,844 MB, so the baseline held steady over the batch.main:
this PR:
101 % of main's frames, 97 % of its peak commit. One run each.
Not tested: the suite on this head; whether the title reaches the code this PR changes in its first 60 s; AMD.
AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:06:27Z.
Question on the mixed-format rule in present.rs:851-863 (
96b0b189). With an sRGB base the RTV is sRGB, but a UNORM overlay keeps its UNORM SRV (plane_srv_format), so its bytes are sampled as linear and then sRGB-encoded on write: an opaque UNORM overlay texel of 64 is stored as ~137. Flip-model scanout treats UNORM bytes as already encoded (_SRGB only changes shader reads/writes), so I'd expect a UNORM UI plane holding 64 to stay 64. The new row (sRGB scene, UNORM UI, [0,64,0,128] -> green 161) asserts the linear reading; treating the overlay as encoded gives ~128. The opaque-overlay check uses only 255/0, which is the same in both transfers, so the tests can't see the shift. The reverse row (UNORM base, sRGB UI: 137 -> 64) darkens the overlay the same way. Before, the base was wrong in the mixed case; now the overlay is. Would sampling each plane through a view whose transfer matches the RTV (the typeless case already allows it), or blending in encoded space with UNORM views, keep both? Caveat: this assumes the console's planes scan out UNORM bytes as encoded, the way DXGI does.AI-assisted (Claude Code, Claude Opus 5.5): read the diff and the tests; nothing was run for this.
Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-26T16:26:15Z.
The opaque midtone does distinguish the two interpretations. I ran the same five-case offscreen fixture on exact parent
0d380f427797fb91a07512d074a5f6f4e1892674and head96b0b189fd0a8991c8e7883823191cf54d896223. The only source overlay adds the native readback test. Both passed 1/0/0 with no capability skips on the RTX 4080 / 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11, debug.For an sRGB base and UNORM overlay, input
[0,64,0,255]stored[0,64,0,255]on the parent and[0,137,0,255]on the head, for RGBA and BGRA. A transparent overlay over the same scene read back[128,55,0,255]on the parent and[188,128,0,255]on the head. In the reverse-format case, the same 64 input in an sRGB overlay stored 13 on both revisions.The readback confirms the chosen SRV/RTV transfer on Windows. It leaves the Xbox overlay interpretation open. This GDK example sets
ColorSpaceindependently for each submitted plane. XCL currently uses the resource format here and does not read that field. A verified per-plane color-space capture for the mixed-format case would help establish whether to use an encoded view or keep the linear overlay. D3D12 can support typed sibling views through relaxed casting; a valid cast alone does not establish which transfer the title intended.Pull request closed