D3D12.X: set the HDR colour space on an HDR swap chain (#103) #786
No reviewers
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!786
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-786"
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?
@Luxuryig on GitHub · 2026-11-24 05:23 UTC · original
Luxuryig:d3d12x-hdr-color-space→main· +158 −0 · 1 files · 1 commits · openPart of #103. An HDR swap chain was created as
R10G10B10A2_UNORMorR16G16B16A16_FLOATand left on DXGI's default colour space, so HDR10 is shown as gamma 2.2 / BT.709. The chain now callsSetColorSpace1: PQ / BT.2020 forR10G10B10A2, scRGB forRGBA16F. An output that cannot present that space keeps the default, and a resize back to an SDR format restores gamma 2.2 / BT.709.This is item 3 of #103 only. The multi-plane, frame-clock, and QPC-flag items are unchanged. ivall already fixed the presenter queue pin and the interval tolerance on main.
What is in it
crates/xcl/src/hle/d3d12x/present.rs:apply_hdr_color_spaceruns when the swap chain is created in an HDR format, and again afterResizeBufferswhen the format was or becomes HDR. Two tests cover the format map and a real swap chain on this output.Tested
hdr colour space support: HDR10 0x1 (set true), scRGB 0x1 (set true). That run was one log-line dash short of the committed text. The call and the asserts are the same.cargo test --workspace --offline -- --test-threads=1on the committed tree (parent6025201, then rebased ontod208e14, which only updatesREADME.mdand does not touch this code): 706 passed, 0 failed, 41 ignored, exit 0, 108.56s. Lib: 665 passed, 21 ignored, 61.49s. Package lines: 665/21, 0, 13, 3/4, 1, 3, 2, 7, 0/4, 1, 1, 2, 1, 1, 6/12, 0, 0.gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware.XCL_SAMPLE_*were unset; those tests are part of the 41 ignored.cargo build --release -p xcl --offlinesucceeded for maind208e14and for this head1430c16. The only warning is the pre-existingfetch_updatedeprecation inxgameruntime.Regression run
No retail title on this machine, and no HDR display check. Both runs are the in-tree test title with
--hello, for 20 seconds, each with its ownXCL_DATA_ROOT.scripts/smoke.ps1on main cannot pass title arguments, so these runs used a local-TitleArgsthat is not in this commit. A stocksmoke.ps1without--hellomakes the title exit 0x1, and that counts ascrashes: 1. Both logs sayprocess ends ((exit 0), at 1.953s on main and 1.927s on this head, which is before the 2s activity line, so presents and peak commit are empty. The earlyrust_panicis the title's expected caught C++ exception. The test title's swap chain is SDR, so this run does not exerciseSetColorSpace1.Not tested
scripts/test.ps1(--test-threads=4). On this machine that script fails inplaced_title_textures_share_vram_and_preserve_pixelson unmodified main (the #718 cubemap flake, then twoPoisonErrors). The serial run above is the result for this commit.AI use
Grok Build (Grok 4.7) wrote the colour-space call and its tests, ran the suite and both smoke runs, and opened this pull request.
@MesshM on GitHub · 2026-11-24 05:28 UTC · original
Test run of
1430c1633f309f044a12a3ff1e24898c070e60cdon AMD RDNA4. I merged it onto currentmaine50836blocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 706 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 665 passed, 0 failed, 21 ignoredSKIPPED;hdr_formats_map_to_pq_and_scrgb_sdr_does_notandswap_chain_takes_the_hdr_colour_space_this_output_can_presentpass (this output is SDR; the swap-chain test took the path it can present).Review: This addresses the two things I raised on #238 (open, same item of #103): a resize back to an SDR format now restores G22 / P709, and
CheckColorSpaceSupportis asked beforeSetColorSpace1. The other point still applies here: everyR10G10B10A2_UNORMswap chain is taken as HDR10 (PQ / BT.2020), but 10:10:10:2 is also used for 10-bit SDR, and nothing inpresent.rslearns from the title whether its output is PQ-encoded (XCL's own frame dump reads R10G10B10A2 as display-ready SDR). Unless the title's colour space can be read fromPresentXor its configuration, setting PQ only when the title asks for it would be safer. Overlap with #238: only one of the two should land.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@upipibi on GitHub · 2026-11-24 05:39 UTC · original
A question about
1430c16, from reading the code (not run):hdr_color_spacedecides from the swap-chain format alone, so everyR10G10B10A2_UNORMchain becomes PQ / BT.2020. That format is also a common 10-bit SDR output. A title that presents gamma-2.2 content in it (or one with HDR turned off in its own settings) would be shown as PQ on an HDR display, which is dim and badly wrong, wheremainshows it correctly. On an SDR displayCheckColorSpaceSupportrefuses PQ, so only HDR displays see the difference.Does the retail title switch its PresentX format between SDR and HDR modes? If it can present 10-bit SDR, the colour space needs to come from what the title asks for, not from the format. The PresentX plane records are 0x48 bytes and #615 reads only up to 0x20, so the title's colour space may be in the rest. Failing that, an
XCL_HDRopt-in would keep the default safe. TheRGBA16F→ scRGB mapping is fine either way, since an fp16 chain is almost always linear.AI-assisted (Claude Code), read-only review.
@Anon64 on GitHub · 2026-11-24 07:17 UTC · original
Regression runs for this PR's head
1430c16and for its basemaind208e14, on a retail title (same title, 60 s each), made withscripts/smoke.ps1(release, clean tree at each commit) and pasted unedited, for Regression run.main:
this PR:
Tested
Not tested
Report written with Claude Code (Claude Opus 5.5) from runs on this machine.
@iggyvilla on GitHub · 2026-11-24 07:34 UTC · original
Code read of
1430c16; nothing built or run. The format question (R10G10B10A2is also 10-bit SDR) is already raised by @upipibi and still needs an answer; I have nothing to add to it. Two code points:swap_chain_takes_the_hdr_colour_space_this_output_can_presentusesexpectfor the factory, WARP adapter, device, queue, window and swap chain (present.rs:1252-1301). AGENTS.md asks GPU tests to callgpu::recomp::runner::skip_test(reason)and return when the hardware is missing; #674's test does that.ensure_swapchain):ResizeBuffers(2, …)(:643) andBufferCount: 2(:666) would have to followPRESENT_SLOTS, and the test'sPresenter { alloc, list, copy_source, dumps, … }literal will not compile after #674'sslots. Whichever lands second needs the rebase. It also overlaps open #238 (same item of #103).AI use: Claude Code, Claude Sonnet 5.5, read the code at the head above and drafted this; a person checked it before posting.
@LANgmas on GitHub · 2026-11-24 11:59 UTC · original
Additional DXGI output-path validation on a hybrid NVIDIA/Intel laptop:
Hardware:
A temporary DXGI diagnostic found:
No SetColorSpace1 call was made by this probe, so this is not evidence of successful HDR10 or scRGB presentation, nor proof that SetColorSpace1 would fail for PQ.
This provides an additional hybrid-rendering/output-path datapoint for evaluating the output-specific color-space handling in this PR. It does not resolve the separate question of whether R10G10B10A2 content is actually HDR10 or 10-bit SDR; that distinction still needs to come from title intent or another reliable signal.
The temporary diagnostic was removed after the run. No XCL source files were modified.
@DavidM1911 on GitHub · 2026-11-25 11:08 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!
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.