hdr: opt-in HDR10 output (VICTORY_HDR) #93

Open
github-bot wants to merge 19 commits from github-bot/gh-92 into main AGit
Owner

@⁠rgroenewoudt on GitHub · 2026-12-05 10:43 UTC · original
rgroenewoudt:hdr-output → main · +1271 −36 · 17 files · 19 commits · draft

Summary

Opt-in HDR10 output (VICTORY_HDR=1, the launcher's HDR output switch, F1 → Display, or play.ps1 -Hdr). Off by default. With it on and Windows HDR on, the title renders HDR itself, as on the console. We only tell it about the display, pick the swap chain's colour space and compose its planes.

title: XDisplayTryEnableHdrMode
  hdr_display_info()                  # the window's display, among the DXGI outputs of every card
    Windows HDR off / no HDR display  → 2: disabled, SDR (warning in F1 and the launcher)
    Windows HDR on                    → 1: enabled, the display's min / max / max full-frame nits
title presents
  scene plane      HDR10 (colour space 12, PQ BT.2020)
  interface plane  SDR (colour space 0)
compose (PQ)
  scene + interface at paper white (Windows' SDR content brightness of the display)
  F1 / F3 overlay at paper white, blended in linear light
swap chain R10G10B10A2, G2084 / P2020
  refused → the title is told disabled, SDR, warning in F1
watch thread (1 s)
  Windows HDR switched, window moved to another display, SDR brightness slider moved → follows while playing

With HDR on, the title's own Display settings show HDR Calibration. That is where the peak is set: the calibration image goes fully white above what the display can show (400 nits here). So there is no VICTORY_HDR_MAX_NITS or VICTORY_HDR_PAPER_WHITE: the peak is the title's calibration, and paper white is the Windows setting.

Where this comes from

A port of the HDR10 output I worked on in Darner, without its two settings:

  • Darner #114: FSR 4 frame generation on an HDR10 output
  • Darner #119: README rows for DARNER_HDR_MAX_NITS and DARNER_HDR_PAPER_WHITE (not ported: see above)

Darner's later fix #130 (a card with no display of its own asks the displays of every card) is already covered: the display is looked up among the outputs of every card.

Evidence

Tested on a Dell Alienware AW3423DWF (34" QD-OLED, 3440×1440, VESA DisplayHDR True Black 400; Windows reports a 400-nit peak) with an AMD Radeon RX 9070.

  • Before: XDisplayTryEnableHdrMode always returns disabled; the title renders SDR on an HDR desktop.
    After: with HDR on, the log shows HDR mode: enabled ... max=400, the title's Display settings show HDR on and HDR Calibration, and above 400 nits the calibration image clips to full white (PQ reaches the display as absolute nits). Bright skies keep their detail where the SDR picture clips to white.
  • cargo test -p victory-gpu --lib hdr: 10 passed
pq_matches_st_2084
the_gamut_matrix_follows_from_the_primaries
the_shaders_carry_the_same_numbers
the_scene_plane_picks_the_colour_space
the_windows_display_is_picked_then_one_in_hdr_then_the_first
the_windows_white_level_is_80_nits_a_thousand
windows_advanced_colour_bits_say_what_the_display_does
missing_luminance_gets_a_fallback
the_variable_goes_before_what_the_menu_saved
the_hdr_rows_say_what_is_shown_and_why_not

Merge Danger

Door: two-way

Off by default. Turning it off (or reverting) gives the SDR path as before.

Blast Radius: present

The compose and present path (compose.rs, queue.rs, present.rs) is shared with SDR. With HDR off, the title is told disabled as before and the swap chain stays SDR. Hybrid graphics may refuse HDR10 on the swap chain. That falls back to SDR with a warning.

**@⁠rgroenewoudt** on GitHub · 2026-12-05 10:43 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/92) `rgroenewoudt:hdr-output` → `main` · +1271 −36 · 17 files · 19 commits · draft ## Summary Opt-in HDR10 output (`VICTORY_HDR=1`, the launcher's **HDR output** switch, F1 → Display, or `play.ps1 -Hdr`). Off by default. With it on and Windows HDR on, the title renders HDR itself, as on the console. We only tell it about the display, pick the swap chain's colour space and compose its planes. ```text title: XDisplayTryEnableHdrMode hdr_display_info() # the window's display, among the DXGI outputs of every card Windows HDR off / no HDR display → 2: disabled, SDR (warning in F1 and the launcher) Windows HDR on → 1: enabled, the display's min / max / max full-frame nits title presents scene plane HDR10 (colour space 12, PQ BT.2020) interface plane SDR (colour space 0) compose (PQ) scene + interface at paper white (Windows' SDR content brightness of the display) F1 / F3 overlay at paper white, blended in linear light swap chain R10G10B10A2, G2084 / P2020 refused → the title is told disabled, SDR, warning in F1 watch thread (1 s) Windows HDR switched, window moved to another display, SDR brightness slider moved → follows while playing ``` With HDR on, the title's own Display settings show **HDR Calibration**. That is where the peak is set: the calibration image goes fully white above what the display can show (400 nits here). So there is no `VICTORY_HDR_MAX_NITS` or `VICTORY_HDR_PAPER_WHITE`: the peak is the title's calibration, and paper white is the Windows setting. ### Where this comes from A port of the HDR10 output I worked on in Darner, without its two settings: - Darner #114: FSR 4 frame generation on an HDR10 output - Darner #119: README rows for `DARNER_HDR_MAX_NITS` and `DARNER_HDR_PAPER_WHITE` (not ported: see above) Darner's later fix #130 (a card with no display of its own asks the displays of every card) is already covered: the display is looked up among the outputs of every card. ## Evidence Tested on a **Dell Alienware AW3423DWF** (34" QD-OLED, 3440×1440, VESA DisplayHDR True Black 400; Windows reports a 400-nit peak) with an **AMD Radeon RX 9070**. - **Before:** `XDisplayTryEnableHdrMode` always returns disabled; the title renders SDR on an HDR desktop. **After:** with HDR on, the log shows `HDR mode: enabled ... max=400`, the title's Display settings show HDR on and HDR Calibration, and above 400 nits the calibration image clips to full white (PQ reaches the display as absolute nits). Bright skies keep their detail where the SDR picture clips to white. - `cargo test -p victory-gpu --lib hdr`: 10 passed ```text pq_matches_st_2084 the_gamut_matrix_follows_from_the_primaries the_shaders_carry_the_same_numbers the_scene_plane_picks_the_colour_space the_windows_display_is_picked_then_one_in_hdr_then_the_first the_windows_white_level_is_80_nits_a_thousand windows_advanced_colour_bits_say_what_the_display_does missing_luminance_gets_a_fallback the_variable_goes_before_what_the_menu_saved the_hdr_rows_say_what_is_shown_and_why_not ``` ## Merge Danger **Door:** two-way Off by default. Turning it off (or reverting) gives the SDR path as before. **Blast Radius:** present The compose and present path (`compose.rs`, `queue.rs`, `present.rs`) is shared with SDR. With HDR off, the title is told disabled as before and the swap chain stays SDR. Hybrid graphics may refuse HDR10 on the swap chain. That falls back to SDR with a warning.
Ported from Darner (a215e8c, ec9cb74, f21c907, f53086c, 8b17d2c, 45faf75).

- host/hdr.rs: the display's luminance (IDXGIOutput6::GetDesc1, the
  displays of every card when ours has none, VICTORY_HDR_MAX_NITS), and
  the swap chain's colour space (SetColorSpace1) from the scene plane's.
  HDR only when Windows HDR is on for the display (G2084/P2020).
- display.rs: XDisplayTryEnableHdrMode reports enabled with that
  luminance.
- queue.rs: each plane's colour space is read from the retail PresentX.
  With HDR on the title passes the interface (SDR, colour space 0) first
  and the scene (PQ, colour space 12) second; they are shown as
  [scene, interface].
- present.rs: two planes over a 10-bit PQ scene keep a 10-bit swap chain.
Ported from Darner (ec9cb74, 0c5888c).

The composer blends in linear light for an HDR10 output: the scene
decoded from PQ, the interface from gamma 2.2 BT.709 to BT.2020 at paper
white (VICTORY_HDR_PAPER_WHITE, 80 to 500 nits, default 203 as ITU-R
BT.2408 gives it). Tests check the PQ curve against ST 2084's table, the
BT.709 to BT.2020 matrix against the primaries, and that the shader
carries the same numbers.
Ported from Darner (d416116), for the egui painter.

On an HDR10 back buffer the overlay's colours go to BT.2020 in PQ at
paper white, not at a full code (10,000 nits). On a float back buffer
in scRGB they are scaled to paper white; an SDR float buffer keeps
1.0 at 80 nits as before.
Ported from Darner (bea8e76, e4749eb), with the launcher's own switch.

- VICTORY_HDR (1 on, 0 off), else what the menu saved (hdr), else off.
- Launcher, Settings -> Display & Output: an "HDR output" switch, kept
  in the menu's file with the other settings both change. The output
  summary box moves down to make room for the row.
- F1 -> Display: the same switch, for the next start.
- play.ps1 -Hdr; README rows for -Hdr, VICTORY_HDR_PAPER_WHITE and
  VICTORY_HDR_MAX_NITS.
Ported from Darner (b9b6ce5, 9efa717, 8b17d2c), for the egui overlay.

- host/hdr.rs: display_hdr, Windows' own advanced colour state of the
  display (DisplayConfigGetDeviceInfo, asked again at most every 2 s;
  DXGI keeps the colour space it first saw), with its peak in nits.
- F1 -> Display: the HDR row says whether Windows HDR is on for the
  display (with its peak), off, or not possible. The session summary
  has an HDR row: HDR10 with the peak the game was told, or why not.
- HUD: "HDR" after the output height while the swap chain shows HDR.
The swap chain is asked only for a colour space it says it can present
(CheckColorSpaceSupport). One it cannot present, or refuses, is not asked
for again until another is wanted. The picture then stays in SDR: a PQ
scene that is composed is tone mapped to SDR (BT.2020 to BT.709, paper
white at 1, a knee at 0.75), not shown washed out.
XDisplayTryEnableHdrMode reports enabled only while HDR can be shown: on
a display in HDR, and until the swap chain refuses the PQ colour space.
A title that asks again after that renders SDR.
The fixed-function blend mixed the overlay's PQ colour with the PQ scene
in signal space, so translucent panels and text edges came out lighter or
darker than the title's interface. On an HDR10 back buffer the overlay
is now drawn into a texture of its own (8-bit, as on SDR) and composed
over a copy of the back buffer by the plane composer, in linear light at
paper white. Frame generation's overlay textures keep the PQ painter.
A test on the card checks a half transparent black over paper white
gives half the light.
- The display asked is the one the window is on (MonitorFromWindow,
  matched to DXGI_OUTPUT_DESC1.Monitor among the outputs of every card),
  not the first output of the card: on a PC with more displays the title
  was told about the wrong one. Before there is a window: the primary
  display.
- The display is no longer asked once for the whole run. A thread looks
  every second whether the DXGI factory is still current (it is not
  after Windows HDR is switched or the displays change) and whether the
  window moved to another display, and only then asks again. The swap
  chain's colour space follows at the next present; the frame only
  reads what was found.
- A PQ colour space the swap chain takes again clears the refusal the
  title is told about.
The HDR row in F1 -> Display says, in red with a WARNING badge, when HDR
is asked for (for the next start or this run) but Windows HDR is off for
the display the game is on, the display cannot show HDR, or the swap
chain refused HDR10 this run. The session summary's HDR row names the
refusal too.
With the HDR output switch on, its row in Settings -> Display & Output
says, in red, when Windows HDR is off for the display the game starts on
or the display cannot show HDR (DisplayConfigGetDeviceInfo, asked at most
every 2 seconds while the page is drawn). A refused HDR10 can only be
known in the game: the F1 menu says that.
The title is told the peak the display reports (DXGI), with the fallback
of 1000 nits where it leaves it out. The game's own HDR calibration sets
the peak it tonemaps to, so an override here only changed its default.
The game's interface and the overlay on an HDR output are as bright as
Windows shows SDR content on the display the window is on
(DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL, 1000 = 80 nits), so as
bright as the desktop. The display watch thread asks it every second
while the display is in HDR, so moving the slider shows while playing;
where Windows does not say, 203 nits. VICTORY_HDR_PAPER_WHITE is gone.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 10:46:22 +00:00
Author
Owner

@⁠ReTerryDavis on GitHub · 2026-12-05 17:39 UTC · original

This looks very solid overall — thanks for the real-hardware testing on HDR10 + fallback tone-mapping! Marking as draft for one small fix (and one note) before merge:

  1. Avoid eager ~64 MB overlay VRAM allocation when the overlay is closed (crates/victory-gpu/src/host/panel.rs / host/hdr.rs): Panel::draw currently calls hdr.draw(...) -> Overlay::make (allocating full-screen ui R8G8B8A8 + scene R10G10B10A2 textures and a second Composer PSO) before draw_onto checks self.showing(). Adding an early if !self.showing() { return; } at the top of Panel::draw avoids allocating those permanently on frame 1 for users who never open F1/F3.
  2. Frame-gen + HDR overlay banding (non-blocking / optional): When FSR FG (fg.overlay) or single-plane DLSS-G renders egui directly into an offscreen R10G10B10A2_UNORM texture (out_mode == 2), blending into 2-bit alpha bands translucent panels/text. Either switching the FG HDR UI target to R16G16B16A16_FLOAT or noting it as a known FG+HDR limitation is fine.

Once #1 is in (and rebased if #95 lands alongside it on launcher/window.rs), mark ready and we'll get it merged!

**@⁠ReTerryDavis** on GitHub · 2026-12-05 17:39 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/92#issuecomment-7442370140) This looks very solid overall — thanks for the real-hardware testing on HDR10 + fallback tone-mapping! Marking as draft for one small fix (and one note) before merge: 1. **Avoid eager ~64 MB overlay VRAM allocation when the overlay is closed (`crates/victory-gpu/src/host/panel.rs` / `host/hdr.rs`):** `Panel::draw` currently calls `hdr.draw(...)` -> `Overlay::make` (allocating full-screen `ui` `R8G8B8A8` + `scene` `R10G10B10A2` textures and a second `Composer` PSO) *before* `draw_onto` checks `self.showing()`. Adding an early `if !self.showing() { return; }` at the top of `Panel::draw` avoids allocating those permanently on frame 1 for users who never open F1/F3. 2. **Frame-gen + HDR overlay banding (non-blocking / optional):** When FSR FG (`fg.overlay`) or single-plane DLSS-G renders egui directly into an offscreen `R10G10B10A2_UNORM` texture (`out_mode == 2`), blending into 2-bit alpha bands translucent panels/text. Either switching the FG HDR UI target to `R16G16B16A16_FLOAT` or noting it as a known FG+HDR limitation is fine. Once #1 is in (and rebased if #95 lands alongside it on `launcher/window.rs`), mark ready and we'll get it merged!
github-bot force-pushed github-bot/gh-92 from 22f4940c4f to a65ed873fd 2026-12-05 18:55:44 +00:00 Compare
Author
Owner

@⁠rgroenewoudt on GitHub · 2026-12-05 18:54 UTC · original

Good catch about the overlay translucency. I've documented it as a known limitation in code.

**@⁠rgroenewoudt** on GitHub · 2026-12-05 18:54 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/92#issuecomment-7443533318) Good catch about the overlay translucency. I've documented it as a known limitation in code.
github-bot force-pushed github-bot/gh-92 from a65ed873fd to 8479a5c464 2026-12-05 19:24:35 +00:00 Compare
Author
Owner

@⁠rgroenewoudt on GitHub · 2026-12-05 19:27 UTC · original

I've gotten rid of the 2 sec timer and updated overlay to handle translucency. Waiting for other PR to merge.

**@⁠rgroenewoudt** on GitHub · 2026-12-05 19:27 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/92#issuecomment-7444002164) I've gotten rid of the 2 sec timer and updated overlay to handle translucency. Waiting for other PR to merge.
Author
Owner

@⁠rgroenewoudt on GitHub · 2026-12-05 23:50 UTC · original

Found an issue with HDR + frame generation: HUD/subtitles is included in frame gen.

**@⁠rgroenewoudt** on GitHub · 2026-12-05 23:50 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/92#issuecomment-7447876096) Found an issue with HDR + frame generation: HUD/subtitles is included in frame gen.
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/93/head:github-bot/gh-92'
git switch 'github-bot/gh-92'

Merge

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