D3D12.X: encode sRGB compositor output for presentation #2763

Open
github-bot wants to merge 3 commits from github-bot/gh-2763 into main AGit
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 10:57 UTC · original
CryingLaughing:fix/present-srgb-output-encoding → main · +208 −83 · 1 files · 3 commits · open

Stacked on #2537. The follow-up is 0d380f427797fb91a07512d074a5f6f4e1892674, verified with b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 and the exact #2537 head e8d2258c5af20f108770ad8e0e983e9ecba8581e as its integration base. Part of #2456.

With concrete sRGB SRVs, the compositor reads linear values. An ordinary UNORM render target then stores those values directly, making midtones too dark on the SDR swap chain.

What is in it

  • Selects the matching sRGB RTV and pipeline state for 8-bit SDR output when every drawn plane explicitly carries sRGB. The compositor blends in linear space and stores encoded RGB.
  • Extends the compositor readback test with transparent, opaque, and fractional-alpha regions for sRGB and UNORM planes.

Tested

  • Windows 11 25H2 build 26200.9974, Intel Core i5-13600K, RTX 4080 driver 621.01, Rust 1.100.0 x64 MSVC, and DXC 1.8.2502.11.

  • cargo test -p xcl --lib --locked -j 4 compositor_blends_ui_plane_over_scene_plane -- --show-output --test-threads=1 passed 1/1 on this head using an offscreen RGBA8 target on WARP. The same fixture on the integration base failed at the intended assertion. The transparent pixel was [128, 55, 0, 255] before the fix and matched [188, 128, 0, 255] afterward.

  • cargo build --workspace --locked -j 4 passed. The four-thread workspace run stopped in the library harness at a_dispatch_with_a_pipeline_still_building_waits_at_the_submit with 1,309 passed, 1 failed, and 27 ignored. The compositor regression passed in that run. 25 capability skips were logged before it stopped.

  • The serial repeat, cargo test --workspace --locked -j 4 -- --test-threads=1 --show-output, finished with 1,436 passed, 0 failed, and 47 ignored across 37 harnesses. The pass count includes 29 capability skips.

  • The independent RX 9070 Wine comparison verified the all-sRGB result in 3/3 fresh head processes. The same hardware-selection test overlay passed 0/3 on main and 0/3 on the #2537 integration base. The corrected fractional-alpha pixel was [137,161,0,255].

Regression run

Independent report by Anon64 on RTX 3060 12 GB, driver 581.80, Core i9-14900KF, and Windows 11 build 26200. Both release builds used the same retail title for 60 seconds. The head showed 94.1% of the paired main run’s frames and 119.8% of its peak commit, with zero crashes and device removals. A later main run peaked at 23,242 MB, showing run-to-run memory variation.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1587)
presents per 2 s (last 3): 60 47 54
device removals: 0
crashes: 0
peak commit: 19185 MB

PR:

xcl-smoke v1
commit: 0d380f427797fb91a07512d074a5f6f4e1892674
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1492 (PresentX 1492)
presents per 2 s (last 3): 33 2 2
device removals: 0
crashes: 0
peak commit: 22989 MB

Known limitation

  • A separate WARP diagnostic on this head still reproduced [128, 55, 0, 255] with a transparent UNORM UI plane over an sRGB scene. The expected pixel was [188, 128, 0, 255].

Not tested

  • Physical display output, BGRA8 output, and mixed-format hardware behavior on AMD remain untested.
**@⁠CryingLaughing** on GitHub · 2026-11-26 10:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/2763) `CryingLaughing:fix/present-srgb-output-encoding` → `main` · +208 −83 · 1 files · 3 commits · open Stacked on #2537. The follow-up is `0d380f427797fb91a07512d074a5f6f4e1892674`, verified with `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7` and the exact #2537 head `e8d2258c5af20f108770ad8e0e983e9ecba8581e` as its integration base. Part of #2456. With concrete sRGB SRVs, the compositor reads linear values. An ordinary UNORM render target then stores those values directly, making midtones too dark on the SDR swap chain. **What is in it** - Selects the matching sRGB RTV and pipeline state for 8-bit SDR output when every drawn plane explicitly carries sRGB. The compositor blends in linear space and stores encoded RGB. - Extends the compositor readback test with transparent, opaque, and fractional-alpha regions for sRGB and UNORM planes. **Tested** - Windows 11 25H2 build 26200.9974, Intel Core i5-13600K, RTX 4080 driver 621.01, Rust 1.100.0 x64 MSVC, and DXC 1.8.2502.11. - `cargo test -p xcl --lib --locked -j 4 compositor_blends_ui_plane_over_scene_plane -- --show-output --test-threads=1` passed 1/1 on this head using an offscreen RGBA8 target on WARP. The same fixture on the integration base failed at the intended assertion. The transparent pixel was `[128, 55, 0, 255]` before the fix and matched `[188, 128, 0, 255]` afterward. - `cargo build --workspace --locked -j 4` passed. The four-thread workspace run stopped in the library harness at `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit` with 1,309 passed, 1 failed, and 27 ignored. The compositor regression passed in that run. 25 capability skips were logged before it stopped. - The serial repeat, `cargo test --workspace --locked -j 4 -- --test-threads=1 --show-output`, finished with 1,436 passed, 0 failed, and 47 ignored across 37 harnesses. The pass count includes 29 capability skips. - The [independent RX 9070 Wine comparison](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2763) verified the all-sRGB result in 3/3 fresh head processes. The same hardware-selection test overlay passed 0/3 on `main` and 0/3 on the #2537 integration base. The corrected fractional-alpha pixel was `[137,161,0,255]`. **Regression run** [Independent report by Anon64](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2763) on RTX 3060 12 GB, driver 581.80, Core i9-14900KF, and Windows 11 build 26200. Both release builds used the same retail title for 60 seconds. The head showed 94.1% of the paired main run’s frames and 119.8% of its peak commit, with zero crashes and device removals. A later main run peaked at 23,242 MB, showing run-to-run memory variation. main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1586 (PresentX 1587) presents per 2 s (last 3): 60 47 54 device removals: 0 crashes: 0 peak commit: 19185 MB ``` PR: ``` xcl-smoke v1 commit: 0d380f427797fb91a07512d074a5f6f4e1892674 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1492 (PresentX 1492) presents per 2 s (last 3): 33 2 2 device removals: 0 crashes: 0 peak commit: 22989 MB ``` **Known limitation** - A separate WARP diagnostic on this head still reproduced `[128, 55, 0, 255]` with a transparent UNORM UI plane over an sRGB scene. The expected pixel was `[188, 128, 0, 255]`. **Not tested** - Physical display output, BGRA8 output, and mixed-format hardware behavior on AMD remain untested.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:15:01 +00:00
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 11:35 UTC · original

I verified a follow-up for the mixed-format case described above. Commit 96b0b189fd0a8991c8e7883823191cf54d896223 is based on this exact draft head 0d380f427797fb91a07512d074a5f6f4e1892674. It uses the opaque base plane to choose 8-bit SDR output encoding and keeps each input plane’s own SRV format.

  • With an sRGB base and a transparent UNORM UI, the draft produced [128, 55, 0, 255] on the WARP negative control. The follow-up read back [188, 128, 0, 255] on the RTX 4080. Native checks also covered fractional-alpha UI, BGRA, and the reverse mix with a UNORM base and an sRGB UI. All five offscreen checks ran in one focused test, with 1 passed, 0 failed, 0 ignored, 0 capability skips.
  • The portable test also passed 1/0/0 on the exact follow-up commit. cargo build --workspace --locked -j 4 and cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output passed with 1,436 passed, 0 failed, 47 ignored across 37 harnesses, including 29 capability skips in the pass count.

RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. The native test was hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane with an adapter-selection and readback-logging overlay. Physical display output and retail smoke remain untested.

**@⁠CryingLaughing** on GitHub · 2026-11-26 11:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2763#issuecomment-7190916358) I verified a follow-up for the mixed-format case described above. Commit [`96b0b189fd0a8991c8e7883823191cf54d896223`](https://github.com/CryingLaughing/xcl/commit/96b0b189fd0a8991c8e7883823191cf54d896223) is based on this exact draft head `0d380f427797fb91a07512d074a5f6f4e1892674`. It uses the opaque base plane to choose 8-bit SDR output encoding and keeps each input plane’s own SRV format. - With an sRGB base and a transparent UNORM UI, the draft produced `[128, 55, 0, 255]` on the WARP negative control. The follow-up read back `[188, 128, 0, 255]` on the RTX 4080. Native checks also covered fractional-alpha UI, BGRA, and the reverse mix with a UNORM base and an sRGB UI. All five offscreen checks ran in one focused test, with **1 passed, 0 failed, 0 ignored, 0 capability skips**. - The portable test also passed **1/0/0** on the exact follow-up commit. `cargo build --workspace --locked -j 4` and `cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output` passed with **1,436 passed, 0 failed, 47 ignored** across 37 harnesses, including 29 capability skips in the pass count. RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and DXC 1.8.2502.11. The native test was `hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane` with an adapter-selection and readback-logging overlay. Physical display output and retail smoke remain untested.
Author
Owner

@⁠Anon64 on GitHub · 2026-11-26 12:10 UTC · original · edited 2026-11-26 12:16 UTC

Regression run of 0d380f4 on a newer retail title: no device removal, no crash, but peak commit close to the 125 % limit in both runs.

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 with XCL_NETWORK=0 and A pressed every 4 s from 20 s.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1587)
presents per 2 s (last 3): 60 47 54
device removals: 0
crashes: 0
peak commit: 19185 MB

this PR, second run (the first had 1481 frames and peak commit 23754 MB):

xcl-smoke v1
commit: 0d380f427797fb91a07512d074a5f6f4e1892674
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1492 (PresentX 1492)
presents per 2 s (last 3): 33 2 2
device removals: 0
crashes: 0
peak commit: 22989 MB

94 % of main's frames, 120 % of its peak commit (124 % in the first run). Peak commit varies on this title: on the same machine today, other builds whose runtime matches main or an older main peaked at 17.4–21.1 GB, so this may be noise, but both runs of this head are above all of those.
Update: main b49be18 run again later in the day on the same machine peaked at 23242 MB (1476 frames), so the commit on this title drifts up over the day here. Against that run this PR is at 99–102 % of main's peak commit and 100–101 % of its frames: no sign the PR raises commit.

Not tested: the suite on this head; the colours on screen; AMD.

AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.

**@⁠Anon64** on GitHub · 2026-11-26 12:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/2763#issuecomment-7191667968) · edited 2026-11-26 12:16 UTC **Regression run of `0d380f4` on a newer retail title: no device removal, no crash, but peak commit close to the 125 % limit in both runs.** **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 with `XCL_NETWORK=0` and A pressed every 4 s from 20 s. main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1586 (PresentX 1587) presents per 2 s (last 3): 60 47 54 device removals: 0 crashes: 0 peak commit: 19185 MB ``` this PR, second run (the first had 1481 frames and peak commit 23754 MB): ``` xcl-smoke v1 commit: 0d380f427797fb91a07512d074a5f6f4e1892674 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1492 (PresentX 1492) presents per 2 s (last 3): 33 2 2 device removals: 0 crashes: 0 peak commit: 22989 MB ``` 94 % of main's frames, 120 % of its peak commit (124 % in the first run). Peak commit varies on this title: on the same machine today, other builds whose runtime matches main or an older main peaked at 17.4–21.1 GB, so this may be noise, but both runs of this head are above all of those. **Update:** main `b49be18` run again later in the day on the same machine peaked at **23242 MB** (1476 frames), so the commit on this title drifts up over the day here. Against that run this PR is at 99–102 % of main's peak commit and 100–101 % of its frames: no sign the PR raises commit. **Not tested:** the suite on this head; the colours on screen; AMD. AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.
Author
Owner

@⁠SzczepanGrela on GitHub · 2026-11-26 12:26 UTC · original

Physical RX 9070 offscreen readback under Wine confirms the all-sRGB blend case, using a test-only hardware-adapter overlay.

Tested

  • Production code from head 0d380f427797fb91a07512d074a5f6f4e1892674, main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, and the pinned #2537 integration base e8d2258c5af20f108770ad8e0e983e9ecba8581e.
  • RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, Mesa 26.3.1-arch3.5, GE-Proton11-12 Wine 11.0 Staging, vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, release x86_64-pc-windows-gnu.
  • Copied the head's compositor_blends_ui_plane_over_scene_plane fixture to both controls. In all three, replaced its forced WARP adapter with explicit RX 9070 selection and logged the readback pixels. Production code was unchanged in each tree. The head's separate concrete-sRGB view test also selected hardware.
  • Direct Wine invocation of the libtest binary with --exact hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane --nocapture --test-threads=1. Three fresh processes per revision, no skip markers or ignored tests.

Both input planes are RGBA8 sRGB in this case. The pixels below were identical in all three repetitions:

Production revision Transparent UI pixel Fractional-alpha pixel Fixture passes
main + fixture [188,128,0,255] [94,201,0,255] 0/3
#2537 + fixture [128,55,0,255] [64,91,0,255] 0/3
#2763 + native overlay [188,128,0,255] [137,161,0,255] 3/3

The UNORM case produced its expected transparent, opaque and fractional-alpha pixels on every revision. The opaque sRGB UI pixel was [255,0,0,255] throughout. On the head, compositor_preserves_concrete_srgb_plane_srv_format also passed 1/0/0 with the hardware-adapter overlay. All ten raw test summaries, pixel logs and source hashes were checked after testing.

Not tested

The unmodified WARP fixtures, mixed sRGB/UNORM inputs, BGRA/HDR, physical display output, retail smoke, full workspace suite, or performance. This is offscreen synthetic coverage with a documented test overlay.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the changes, prepared the test-only overlay, ran and checked the comparisons, and drafted this report. Publication authorized by the account owner.

**@⁠SzczepanGrela** on GitHub · 2026-11-26 12:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/2763#issuecomment-7192006713) Physical RX 9070 offscreen readback under Wine confirms the all-sRGB blend case, using a test-only hardware-adapter overlay. **Tested** - Production code from head `0d380f427797fb91a07512d074a5f6f4e1892674`, main `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`, and the pinned #2537 integration base `e8d2258c5af20f108770ad8e0e983e9ecba8581e`. - RX 9070 16 GB (RADV GFX1201), Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, Mesa 26.3.1-arch3.5, GE-Proton11-12 Wine 11.0 Staging, vkd3d-proton `8293130ebe370b1+` (local asserts-disabled build), DXC/DXIL 1.9.2602.17, Rust 1.97.1, release `x86_64-pc-windows-gnu`. - Copied the head's `compositor_blends_ui_plane_over_scene_plane` fixture to both controls. In all three, replaced its forced WARP adapter with explicit RX 9070 selection and logged the readback pixels. Production code was unchanged in each tree. The head's separate concrete-sRGB view test also selected hardware. - Direct Wine invocation of the libtest binary with `--exact hle::d3d12x::present::frame_dump_tests::compositor_blends_ui_plane_over_scene_plane --nocapture --test-threads=1`. Three fresh processes per revision, no skip markers or ignored tests. Both input planes are RGBA8 sRGB in this case. The pixels below were identical in all three repetitions: | Production revision | Transparent UI pixel | Fractional-alpha pixel | Fixture passes | | --- | --- | --- | --- | | main + fixture | `[188,128,0,255]` | `[94,201,0,255]` | 0/3 | | #2537 + fixture | `[128,55,0,255]` | `[64,91,0,255]` | 0/3 | | #2763 + native overlay | `[188,128,0,255]` | `[137,161,0,255]` | 3/3 | The UNORM case produced its expected transparent, opaque and fractional-alpha pixels on every revision. The opaque sRGB UI pixel was `[255,0,0,255]` throughout. On the head, `compositor_preserves_concrete_srgb_plane_srv_format` also passed 1/0/0 with the hardware-adapter overlay. All ten raw test summaries, pixel logs and source hashes were checked after testing. **Not tested** The unmodified WARP fixtures, mixed sRGB/UNORM inputs, BGRA/HDR, physical display output, retail smoke, full workspace suite, or performance. This is offscreen synthetic coverage with a documented test overlay. **AI use** OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the changes, prepared the test-only overlay, ran and checked the comparisons, and drafted this report. Publication authorized by the account owner.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2763/head:github-bot/gh-2763'
git switch 'github-bot/gh-2763'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2763'
git switch 'github-bot/gh-2763'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2763'
git switch 'github-bot/gh-2763'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2763'
git switch 'main'
git merge --squash 'github-bot/gh-2763'
git switch 'main'
git merge --ff-only 'github-bot/gh-2763'
git switch 'main'
git merge 'github-bot/gh-2763'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.