D3D12.X: preserve concrete sRGB plane formats in PresentX compositor SRVs #2537

Open
github-bot wants to merge 1 commit from github-bot/gh-2537 into main AGit
Owner

@⁠ramon-victor on GitHub · 2026-11-25 22:04 UTC · original
ramon-victor:fix/compositor-srgb-plane-srv → main · +149 −1 · 1 files · 1 commits · open

Preserves concrete *_UNORM_SRGB resource formats when creating shader-resource views for composited PresentX planes in Compositor::record, resolving only *_TYPELESS formats to concrete SRV formats.

Previously Compositor::record passed swap_format(desc.Format).unwrap_or(desc.Format) to CreateShaderResourceView. Because swap_format maps DXGI_FORMAT_R8G8B8A8_UNORM_SRGB and DXGI_FORMAT_B8G8R8A8_UNORM_SRGB to *_UNORM for flip-model swap-chain creation, concrete sRGB plane textures received an invalid non-sRGB SRV format (CREATESHADERRESOURCEVIEW_INVALIDFORMAT in D3D12) and skipped sRGB-to-linear decoding on WARP.

Part of #2456 (specifically the sRGB plane SRV format issue left open by #2480).

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs:
    • Add plane_srv_format(f) resolving only *_TYPELESS formats (R8G8B8A8_TYPELESS, B8G8R8A8_TYPELESS, R10G10B10A2_TYPELESS, R16G16B16A16_TYPELESS) to concrete SRV formats while preserving concrete formats (including *_UNORM_SRGB).
    • Use plane_srv_format(desc.Format) in Compositor::record when building D3D12_SHADER_RESOURCE_VIEW_DESC.
    • Add frame_dump_tests::compositor_preserves_concrete_srgb_plane_srv_format verifying plane_srv_format across concrete sRGB, typeless, and UNORM/float formats and exercising Compositor::record on WARP with a concrete DXGI_FORMAT_R8G8B8A8_UNORM_SRGB plane texture.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3070 8 GiB (driver 621.24, wave32), AMD Ryzen 7 5700X, 32 GiB RAM, Windows 11 Pro (26300), rustc 1.99.0 (x86_64-pc-windows-msvc), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0).
  • Failing-first before fix: cargo test -p xcl --lib compositor_preserves_concrete_srgb_plane_srv_format -- --nocapture failed (0 passed, 1 failed: expected sRGB-decoded concrete plane sample ~[128, 55, 0, 255], got [188, 128, 0, 255]).
  • After fix: cargo test -p xcl --lib hle::d3d12x::present -- --test-threads=1 --nocapture: 10 passed, 0 failed, 0 ignored.
  • Full workspace suite (.\scripts\test.ps1, debug): 1424 passed, 0 failed, 46 ignored (skipped on this adapter: wave64-only GPU tests, unsupported per-lane semantics variants, no heap windows).
  • Release build (cargo build --release -p xcl) and clean 60 s retail smoke run (.\scripts\smoke.ps1).

Regression run

Baseline (main):

xcl-smoke v1
commit: f087b998d0d51a9f11bbfa0761967a63e778edd9
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14467 MB

PR (e8d2258):

xcl-smoke v1
commit: e8d2258c5af20f108770ad8e0e983e9ecba8581e
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14037 MB

Not tested

  • Multi-plane retail title with concrete *_UNORM_SRGB planes (the retail smoke title presents a single plane; multi-plane concrete sRGB compositing is covered by the WARP regression test).
  • AMD / Intel GPUs and Wine / macOS hosts.

AI use

  • Antigravity (Gemini 4 Neon): analyzed #2456 item 2, implemented plane_srv_format and its WARP regression test, ran .\scripts\test.ps1, release build, and the 60 s smoke.ps1 run, and drafted this PR description.
**@⁠ramon-victor** on GitHub · 2026-11-25 22:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2537) `ramon-victor:fix/compositor-srgb-plane-srv` → `main` · +149 −1 · 1 files · 1 commits · open Preserves concrete `*_UNORM_SRGB` resource formats when creating shader-resource views for composited `PresentX` planes in `Compositor::record`, resolving only `*_TYPELESS` formats to concrete SRV formats. Previously `Compositor::record` passed `swap_format(desc.Format).unwrap_or(desc.Format)` to `CreateShaderResourceView`. Because `swap_format` maps `DXGI_FORMAT_R8G8B8A8_UNORM_SRGB` and `DXGI_FORMAT_B8G8R8A8_UNORM_SRGB` to `*_UNORM` for flip-model swap-chain creation, concrete sRGB plane textures received an invalid non-sRGB SRV format (`CREATESHADERRESOURCEVIEW_INVALIDFORMAT` in D3D12) and skipped sRGB-to-linear decoding on WARP. Part of #2456 (specifically the sRGB plane SRV format issue left open by #2480). **What is in it** - `crates/xcl/src/hle/d3d12x/present.rs`: - Add `plane_srv_format(f)` resolving only `*_TYPELESS` formats (`R8G8B8A8_TYPELESS`, `B8G8R8A8_TYPELESS`, `R10G10B10A2_TYPELESS`, `R16G16B16A16_TYPELESS`) to concrete SRV formats while preserving concrete formats (including `*_UNORM_SRGB`). - Use `plane_srv_format(desc.Format)` in `Compositor::record` when building `D3D12_SHADER_RESOURCE_VIEW_DESC`. - Add `frame_dump_tests::compositor_preserves_concrete_srgb_plane_srv_format` verifying `plane_srv_format` across concrete sRGB, typeless, and UNORM/float formats and exercising `Compositor::record` on WARP with a concrete `DXGI_FORMAT_R8G8B8A8_UNORM_SRGB` plane texture. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 3070 8 GiB (driver `621.24`, wave32), AMD Ryzen 7 5700X, 32 GiB RAM, Windows 11 Pro (`26300`), `rustc 1.99.0` (`x86_64-pc-windows-msvc`), DXC/DXIL `1.8.2502.11` (Windows SDK `10.0.26100.0`). - Failing-first before fix: `cargo test -p xcl --lib compositor_preserves_concrete_srgb_plane_srv_format -- --nocapture` failed (`0 passed, 1 failed`: `expected sRGB-decoded concrete plane sample ~[128, 55, 0, 255], got [188, 128, 0, 255]`). - After fix: `cargo test -p xcl --lib hle::d3d12x::present -- --test-threads=1 --nocapture`: `10 passed, 0 failed, 0 ignored`. - Full workspace suite (`.\scripts\test.ps1`, debug): `1424 passed, 0 failed, 46 ignored` (skipped on this adapter: wave64-only GPU tests, unsupported per-lane semantics variants, `no heap windows`). - Release build (`cargo build --release -p xcl`) and clean 60 s retail smoke run (`.\scripts\smoke.ps1`). **Regression run** Baseline (`main`): ``` xcl-smoke v1 commit: f087b998d0d51a9f11bbfa0761967a63e778edd9 gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14467 MB ``` PR (`e8d2258`): ``` xcl-smoke v1 commit: e8d2258c5af20f108770ad8e0e983e9ecba8581e gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1622 (PresentX 1622) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14037 MB ``` **Not tested** - Multi-plane retail title with concrete `*_UNORM_SRGB` planes (the retail smoke title presents a single plane; multi-plane concrete sRGB compositing is covered by the WARP regression test). - AMD / Intel GPUs and Wine / macOS hosts. **AI use** - Antigravity (Gemini 4 Neon): analyzed #2456 item 2, implemented `plane_srv_format` and its WARP regression test, ran `.\scripts\test.ps1`, release build, and the 60 s `smoke.ps1` run, and drafted this PR description.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:14 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 22:17 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 22:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2537#issuecomment-7176184663) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 22:24 UTC · original

Independent AMD RDNA4 (native wave64) test report on exact head e8d2258c5af20f108770ad8e0e983e9ecba8581e (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1422 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's test passed: hle::d3d12x::present::frame_dump_tests::compositor_preserves_concrete_srgb_plane_srv_format.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: e8d2258c5af20f108770ad8e0e983e9ecba8581e
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1591 (PresentX 1591)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13937 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 22:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2537#issuecomment-7176320499) Independent AMD RDNA4 (native wave64) test report on exact head `e8d2258c5af20f108770ad8e0e983e9ecba8581e` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1422 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - The PR's test passed: `hle::d3d12x::present::frame_dump_tests::compositor_preserves_concrete_srgb_plane_srv_format`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: e8d2258c5af20f108770ad8e0e983e9ecba8581e gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1591 (PresentX 1591) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13937 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 23:24 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of compositor_preserves_concrete_srgb_plane_srv_format: passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-25 23:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2537#issuecomment-7177526692) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `compositor_preserves_concrete_srgb_plane_srv_format`: passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:04 UTC · original · reviewed

Could the compositor re-encode its linear result for the SDR swap chain? This change correctly decodes a concrete sRGB plane through its SRV, but the compositor shader writes the linear sample directly to the UNORM RTV/PSO selected by swap_format. The swap chain still presents those integer bytes as sRGB. For an opaque midtone encoded as 188, the new test expects about 128 in the UNORM target; that is the decoded linear value, so a real SDR presentation would appear darker. The test confirms decoding but not the display-space round trip.

A two-plane case with an opaque sRGB base and a transparent overlay could compare the presented color with the existing single-plane copy path. Microsoft's color-space guidance says that linear shader output must be converted back to sRGB for integer screen presentation, for example through an sRGB RTV. Exact-head source review of e8d2258c5af20f108770ad8e0e983e9ecba8581e; I did not run a display capture or title. AI-assisted review with Codex.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/2537#pullrequestreview-6069815489) · **reviewed** Could the compositor re-encode its linear result for the SDR swap chain? This change correctly decodes a concrete sRGB plane through its SRV, but the compositor shader writes the linear sample directly to the UNORM RTV/PSO selected by `swap_format`. The swap chain still presents those integer bytes as sRGB. For an opaque midtone encoded as 188, the new test expects about 128 in the UNORM target; that is the decoded linear value, so a real SDR presentation would appear darker. The test confirms decoding but not the display-space round trip. A two-plane case with an opaque sRGB base and a transparent overlay could compare the presented color with the existing single-plane copy path. [Microsoft's color-space guidance](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/converting-data-color-space) says that linear shader output must be converted back to sRGB for integer screen presentation, for example through an sRGB RTV. Exact-head source review of `e8d2258c5af20f108770ad8e0e983e9ecba8581e`; I did not run a display capture or title. AI-assisted review with Codex.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2537/head:github-bot/gh-2537'
git switch 'github-bot/gh-2537'

Merge

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