display: HDR10 with the interface over the HDR scene #386
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!386
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-386"
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?
@Citizen07 on GitHub · 2026-12-03 23:24 UTC · original
Citizen07:feat/hdr-composed-output→main· +815 −25 · 7 files · 4 commits · openCause. With
VICTORY_HDR=1and a separate interface plane (VICTORY_UI_PLANE), the title presents two planes: its interface first, in sRGB (color space 0, R8G8B8A8, premultiplied alpha), and the scene second, in HDR10 (color space 12, PQ BT.2020, R10G10B10A2, opaque). The composer drew the second plane over the first into an RGBA8 swap chain, so the opaque scene covered the interface and its PQ values were shown as SDR. On the menus, where the scene plane is near-black, the whole screen was black. The log saidVICTORY_HDR=1, but the title presents in an SDR format: presented as SDR format=28.The color spaces were read from the retail PresentX plane parameters (
RetailPlane::color_space, which nothing used yet), and both planes were saved from a few frames to check what they hold. On a menu, plane 0 is the whole interface (opaque) and plane 1 a uniform PQ black. In play, plane 0 has alpha on 3–6% of the screen and plane 1 is the scene.Change.
queue::spaces(): the first two planes' color spaces from each present, logged when they change.compose::hdr_order). Both are taken to BT.2020 nits, the sRGB plane decoded un-premultiplied with its white atVICTORY_HDR_UI_NITS(203 by default, BT.2408 reference white). They are blended there, PQ encoded and presented through an R10G10B10A2 swap chain with the HDR10 color space (Composer::record_hdr).VICTORY_HDR_UI_NITSis inrun.conf.default(menu label "HDR interface brightness") anddocs/SETTINGS.md. TheVICTORY_HDRtext no longer points toxmem.sh hdr, which does not exist, and says how HDR is shown.VICTORY_PLANE_SHOT=<frame>[,<frame>...]withVICTORY_PLANE_SHOT_DIRsaves those frames' presented planes as PNG and logs each channel's range (docs/DIAGNOSTICS.md). It is how the planes above were read.Tested. RX 9070 XT, RADV (Mesa 26.3), KDE Plasma 6.8.3 (Wayland), gamescope 3.17.0, an HDR TV over HDMI.
compose::order_tests(plane order by color space) andcompose::tests::blends_an_srgb_interface_over_an_hdr10_scene_in_nits(diagnostics build, read back from the card). The HDR10 output is within 1/1023 of the expected PQ; the sRGB fallback is within 4/1023, because the card'spowdecodes PQ about 1% off at 100 nits.victory-coretests pass, including the menu's.gamescope -f --hdr-enabled -- ./run.sh play VICTORY_HDR=1:HDR: the swap chain presents in HDR, menus and play in HDR, and the interface over the scene.victory-gpusuite has the same failures with and without this change:descriptor::tests::views_die_with_their_resource(the process ends),indirect::tests::host_list_*(2) andwatch::tests (4, run alone).Limits.
bExposeHDRSupportis false and this falls back to tone-mapped SDR.VICTORY_FIDELITYFX_FRAMEGEN) needs an RGBA8 swap chain and presents without it in HDR, as before.🤖 Generated with Claude Code
@Kal0s-design on GitHub · 2026-12-04 06:45 UTC · original
Tried this natively on Windows 11 (MSVC build) with one NVIDIA desktop card and with WARP. No HDR display was used, so this covers the shader math and the swap chain checks only, not how it looks on a real HDR screen.
blends_an_srgb_interface_over_an_hdr10_scene_in_nitsandorder_testspass on both adapters, with identical HDR10 readback (0.5083, 0.5503, 0.5806). I also added a few throwaway cases locally (not pushed). A PQ scene at 0, 100, 1000 and 10000 nits with nothing over it comes back bit exact, and opaque sRGB red, green, blue and white over a black scene land within 0.6 of a 10-bit step of PQ(matrix column x 203), so the constants and the matrix orientation look right. The rest of the victory-gpu suite shows only the failures it already has natively on this machine, and clippy has nothing new in the changed code.A few things worth a look
IDXGIOutput6::GetDesc1reports ColorSpace 0), yet a flip-model R10G10B10A2 swap chain still reports PRESENT support forG2084_NONE_P2020on both adapters. Soset_hdr_spacegets past its support check andout_sdrwould stay false, handing PQ to an SDR desktop and leaving the conversion to Windows instead of your shoulder (I could not look at the result). Adding a check of the containing output'sGetDesc1().ColorSpaceon Windows, next to the existing one, would cover it. The choice is also only made at swap chain creation or resize, so turning Windows HDR on or off or moving the window to another display keeps the old one.c.a > 0 ? ... : 0branch innits_of, while the SDRpsadds it. Locally a (0.25, 0.25, 0.25, 0) texel over a 100 nit scene gives exactly the scene. Texels with rgb > a get clamped bysaturate(c.rgb / c.a)the same way. Your plane shots probably show whether the title's HUD does this.compose::viewpasses_SRGBformats through, andnits_ofthen decodes sRGB a second time. An_SRGBplane holding linear 0.5 came out at about 43 nits instead of 101.5. Only matters if the title ever hands the UI plane as_SRGB.AI-assisted: yes
@Citizen07 on GitHub · 2026-12-04 08:31 UTC · original
Thanks for running it natively. All four are in
1af6fd9:GetDesc1().ColorSpaceto be G2084; otherwise the swap chain is set back to G22 and the blend is tone mapped. Under Wine that check is skipped (the dxgi there doesn't report the desktop's colour space). The choice is still only made at creation or resize, so turning Windows HDR on or off or moving the window to another display isn't followed yet. Linux is the target, so I left that out for now._SRGBinterface planes are now taken as already linear.The readback test now also covers a glow texel and an
_SRGBinterface.@Kal0s-design on GitHub · 2026-12-04 09:36 UTC · original
Checked
1af6fd9natively on Windows 11 again, one NVIDIA desktop card and WARP, debug layer on. All four look fixed to me.set_hdr_spacenow asksdisplay_in_hdrafter the support check and goes back to G22 when it says no (host.rs:7735-7744). The desktop here is not in HDR mode. With a throwaway local test (not pushed) that makes a small window and a flip R10G10B10A2 swap chain on the real adapter and calls the same functions with VICTORY_HDR=1, the NVIDIA card givesCheckColorSpaceSupport= PRESENT as before, but the output reports colour space 0,display_in_hdrisSome(false)andhdr_shown()stays false afterset_hdr_space, soout_sdrwould be true (host.rs:8618). The Wine check (host.rs:7671-7681) looks upwine_get_versionin ntdll, which Windows' ntdll doesn't export, so it came back false here and I don't see how it could misfire natively. The other way round, a Wine build set to hide its exports would look native, but that's for the Linux side.One small thing. On WARP
GetContainingOutputfails with DXGI_ERROR_UNSUPPORTED, sodisplay_in_hdrreturnsNoneand HDR stays on (hdr_shown()true). WARP doesn't matter for playing, but any native setup where the output can't be read the same way ends up on the old path. If you care, treatingNonelikeSome(false)on native Windows, or finding the output fromMonitorFromWindowacross the factory's adapters, would cover it. I haven't tried that on a laptop with two GPUs.Glow.
nits_ofnow adds the part above alpha, decoded on its own (compose.rs:75-82). The (0.25, 0.25, 0.25, 0) texel over the 100 nit scene reads 530/1023 on both adapters. pq(100 + 0.0509 x 203 = 110.3 nits) is 529.9, and the scene alone is 520.SDR fallback. The scene is tone mapped alone and the UI goes over it (compose.rs:111-119). White UI reads 1023, half white 885 (expected 0.5 + 0.5 x srgb(100/203) = 885.1) and the glow 1005 (expected 1003.0, with 0.25 kept as 64/255).
_SRGB.decodes_srgbcovers R8G8B8A8 and B8G8R8A8 _SRGB (compose.rs:161-166, passed in at compose.rs:337), which are the _SRGB colour formatsviewpasses through (compose.rs:482), andnits_ofskips the decode for them. The _SRGB glow in HDR reads 563 (expected pq(100 + 0.25 x 203) = 562.5) and half white 564/563 against 563.0. In the SDR fallback the _SRGB row is 748, 1023, 1023, 1023, as expected after re-encoding.Test results.
composefilter is 3/3 on both adapters, readbacks above are the same on both apart from 1 step. The debug layer had no messages after them. The whole victory-gpu lib suite is 388 passed, 6 failed on each adapter. All six are in indirect, pipeline::host, watch and descriptor::host, nothing this PR touches, and the ones I reran on the base commit fail there too or pass on rerun (watch).I also reverted each shader fix alone locally to see whether the new test catches it. Putting back
saturate(c.rgb / a)without the added part fails at the glow texel (520 against 530). Tone mapping the whole blend again fails at half white in the SDR fallback (white UI goes back to 0.967). Ignoringover_linearfails at the _SRGB glow in HDR. So the test covers all three.AI-assisted: yes
@Luxuride on GitHub · 2026-12-04 11:28 UTC · original
I could not find a defect in the paths I can check statically: the composer is created with the already-computed
R10G10B10A2format at both sites and remade when it changes (host.rs:8379-8385,:8448,:8469-8478), the five root constants matchnum32BitConstants=5and the cbuffer order (compose.rs:22-33vs:332-338), andover_linearis taken fromplanes[1]after the swap.One contradiction to settle:
docs/SETTINGS.md:21says ofVICTORY_HDR"Frame generation is off with it", and nothing enforces that —hdr()is read only in the swap-chain colour space and the plane blend (host.rs:7651,:7713,:8311),framegen.rsnever mentions HDR. What the code does is skip the proxy's interface plane (host.rs:8560-8562). Either add the guard or drop the sentence; as written the table promises behaviour the code does not have.Smaller:
sdr_white_nits()silently becomes 203 outside 10..=1000 (compose.rs:171-177) while the menu offers 100..400 — a typo reads as "6x too dim" with no log line; andhdr_order(compose.rs:152-158) also fires its arms when both planes are PQ, which the doc does not cover.plane_shotreads back a buffer inside the presenter borrow (bench.rs:242-300) — diagnostic-only, but worth a comment so nobody copies it.@Citizen07 on GitHub · 2026-12-04 12:00 UTC · original
Thanks both. In
5fb2dd4:@Kal0s-design: thanks for checking again. On native Windows an output that can't be read (WARP, or anything where
GetContainingOutput/GetDesc1fails) now counts as SDR, with a warning, so it goes to the tone mapped path instead of handing PQ to an unknown display. Under Wine nothing changes. I can't run that branch here (it's skipped under Wine), so a native run on WARP would confirmhdr_shown()is now false there.@Luxuride:
SETTINGS.mdnow says that instead.VICTORY_HDR_UI_NITSoutside 10..=1000 (or not a number) now logs a warning once and uses 203. It's read once rather than every frame.VICTORY_HDR_NITSwarns the same way when it falls back to 1000.hdr_order's doc now covers both planes being HDR10: the first is the scene, the second goes over it, each decoded from PQ.plane_shotnow has a comment saying it waits for the card inside the presenter borrow and stalls that present, so it's for diagnostics only.The compose tests (
order_testsplus the diagnostics readback tests) pass, 3/3, under Wine on the real GPU.@Kal0s-design on GitHub · 2026-12-04 12:05 UTC · original
Checked
5fb2dd4natively on Windows 11, one NVIDIA desktop card and WARP, debug layer on, with the same throwaway local test as before and VICTORY_HDR=1.On WARP
GetContainingOutputstill fails with DXGI_ERROR_UNSUPPORTED, but now the warning at host.rs:7714 is logged,display_in_hdrgivesSome(false)andhdr_shown()is false afterset_hdr_space. The NVIDIA card is unchanged, false as before since the desktop here is not in HDR mode, and the Wine early return (host.rs:7701) isn't touched. Small cosmetic thing, on WARP it's followed by the "Windows HDR is off for it" warning (host.rs:7749-7752), a bit odd with no display at all.VICTORY_HDR_UI_NITSout of range or not a number warns once and gives 203,VICTORY_HDR_NITSwarns and gives 1000, valid values are kept (compose.rs:175-185, host.rs:7642-7651).composewith--features diagnosticsis 3/3 on both adapters and the debug layer had no messages.AI-assisted: yes
5fb2dd4391to329c5ce7af@Citizen07 on GitHub · 2026-12-04 12:15 UTC · original
@Kal0s-design thanks for checking again on both adapters. The double warning is fixed in
329c5ce:display_in_hdrnow logs the one reason the display counts as SDR (not set to HDR, or its colour space can't be read), andset_hdr_spaceno longer adds "Windows HDR is off for it" after it.I've also rebased the branch onto current
main. The only conflict washdr_nitsagainst #427, which now keeps that PR'sis_finite()rule as well as the warning. The compose tests are 3/3 under Wine. The rest of the victory-gpu lib suite fails the same 6 tests asmain(indirect,watch), anddescriptor::tests::views_die_with_their_resourcecrashes the test process onmaintoo.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.