GPU, HLE: report host display HDR luminance and configure swap chain color space #212

Open
github-bot wants to merge 4 commits from github-bot/gh-212 into main AGit
Owner

@⁠n-romanovich on GitHub · 2026-11-24 01:28 UTC · original
n-romanovich:feat/gpu-hdr-output → main · +202 −12 · 3 files · 4 commits · open

Enables HDR display detection and swap-chain color space configuration when HDR is active on the Windows host:

  • victory-gpu:
    • Added display_hdr_info() (IDXGIOutput6::GetDesc1) returning HdrDisplayInfo { min_luminance, max_luminance, max_full_frame_luminance } when an output on the host adapter is in DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020.
    • Updated Presenter to check and apply IDXGISwapChain3::SetColorSpace1 (G2084_NONE_P2020 for R10G10B10A2_UNORM and G10_NONE_P709 for R16G16B16A16_FLOAT when HDR is active, falling back to G22_NONE_P709 otherwise).
  • victory-hle:
    • Updated try_enable_hdr (XDisplayTryEnableHdrMode) to populate XDisplayHdrModeInfo from victory_gpu::display_hdr_info() and return 1 (Enabled) when Windows HDR is active, or 2 (Disabled) in SDR.

Testing

  • cargo clippy -p victory-gpu --lib -- -D warnings: passed (0 warnings).
  • cargo xtask policy: passed (asset policy: 151 files ok).
  • cargo test -p victory-hle: 86 unit tests and 1 integration test passed (including modules::display::tests::hdr_and_display_deferrals).
**@⁠n-romanovich** on GitHub · 2026-11-24 01:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/212) `n-romanovich:feat/gpu-hdr-output` → `main` · +202 −12 · 3 files · 4 commits · open Enables HDR display detection and swap-chain color space configuration when HDR is active on the Windows host: - **`victory-gpu`**: - Added `display_hdr_info()` (`IDXGIOutput6::GetDesc1`) returning `HdrDisplayInfo { min_luminance, max_luminance, max_full_frame_luminance }` when an output on the host adapter is in `DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020`. - Updated `Presenter` to check and apply `IDXGISwapChain3::SetColorSpace1` (`G2084_NONE_P2020` for `R10G10B10A2_UNORM` and `G10_NONE_P709` for `R16G16B16A16_FLOAT` when HDR is active, falling back to `G22_NONE_P709` otherwise). - **`victory-hle`**: - Updated `try_enable_hdr` (`XDisplayTryEnableHdrMode`) to populate `XDisplayHdrModeInfo` from `victory_gpu::display_hdr_info()` and return `1` (`Enabled`) when Windows HDR is active, or `2` (`Disabled`) in SDR. ### Testing - `cargo clippy -p victory-gpu --lib -- -D warnings`: passed (0 warnings). - `cargo xtask policy`: passed (`asset policy: 151 files ok`). - `cargo test -p victory-hle`: 86 unit tests and 1 integration test passed (including `modules::display::tests::hdr_and_display_deferrals`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:55 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:59 UTC · original

Thanks @⁠n-romanovich for adding coverage for both HDR metadata reporting and display deferral.

I tested commit 9496821b838f7b2b4c2c2885e863c253e49a4251 with:

cargo test --locked -p victory-hle --lib hdr_and_display_deferrals -- --test-threads=1

The targeted test passed (1 passed, 0 failed; 85 filtered). hdr_and_display_deferrals checks that the HLE returns HDR luminance matching the GPU host report when HDR data is available, or the documented deferral result otherwise. It also acquires and closes the display shell handle.

This covers the HLE interface and capability-dependent HDR metadata branch. It does not validate swap-chain color output or a rendered title on an HDR display.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7122525987) Thanks @⁠n-romanovich for adding coverage for both HDR metadata reporting and display deferral. I tested commit `9496821b838f7b2b4c2c2885e863c253e49a4251` with: ``` cargo test --locked -p victory-hle --lib hdr_and_display_deferrals -- --test-threads=1 ``` The targeted test passed (1 passed, 0 failed; 85 filtered). [`hdr_and_display_deferrals`](https://github.com/Marvisak/VIctory/blob/9496821b838f7b2b4c2c2885e863c253e49a4251/crates/victory-hle/src/modules/display.rs#L207) checks that the HLE returns HDR luminance matching the GPU host report when HDR data is available, or the documented deferral result otherwise. It also acquires and closes the display shell handle. This covers the HLE interface and capability-dependent HDR metadata branch. It does not validate swap-chain color output or a rendered title on an HDR display.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:22 UTC · original · edited 2026-11-26 00:21 UTC

Automated triage for the maintainers.

Needs work. The rebase is clean, and the review points are addressed: the OnceLock cache in display_hdr_info(), the deterministic try_enable_hdr_with test, neutral field names in crates/victory-hle/src/modules/display.rs, and the test moved out of mod batch. But your own live run shows the HDR path is not ready to be on by default. With Windows HDR on, the title switches to R10G10B10A2 + PQ and then crashes (0xc0000005, read 0x30). The same build with Windows HDR off reaches frame 64+. With this PR, every user with HDR enabled in Windows gets that path, because try_enable_hdr returns 1 whenever display_hdr_info() finds an HDR output.

What would change the verdict:

  • Find the crash, or show it is unrelated to this change (for example, the same crash with this PR reverted and the title on HDR through another route).
  • Or keep 2 (SDR) as the default and put the HDR report behind an explicit opt-in until an HDR run of the title works.
  • The HdrModeInfo layout (three f32 luminance values) is still assumed. Say where it comes from, for example what the title reads back from it.

On your reply: the format-to-color-space mapping (R10G10B10A2_UNORM to G2084/P2020, R16G16B16A16_FLOAT to G10/P709) is the standard DXGI convention and looks right. The open question is what happens to the title once it is told HDR is on, and the run you posted answers that with a crash.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7148451324) · edited 2026-11-26 00:21 UTC <!-- victory-triage v1 head=58bdffe3b905a3bec02f2dc80ec89cad370e548c verdict=needs-work at=2026-11-26T00:21:20Z --> Automated triage for the maintainers. **Needs work.** The rebase is clean, and the review points are addressed: the `OnceLock` cache in `display_hdr_info()`, the deterministic `try_enable_hdr_with` test, neutral field names in `crates/victory-hle/src/modules/display.rs`, and the test moved out of `mod batch`. But your own live run shows the HDR path is not ready to be on by default. With Windows HDR on, the title switches to `R10G10B10A2` + PQ and then crashes (`0xc0000005`, read `0x30`). The same build with Windows HDR off reaches frame 64+. With this PR, every user with HDR enabled in Windows gets that path, because `try_enable_hdr` returns `1` whenever `display_hdr_info()` finds an HDR output. What would change the verdict: - Find the crash, or show it is unrelated to this change (for example, the same crash with this PR reverted and the title on HDR through another route). - Or keep `2` (SDR) as the default and put the HDR report behind an explicit opt-in until an HDR run of the title works. - The `HdrModeInfo` layout (three `f32` luminance values) is still assumed. Say where it comes from, for example what the title reads back from it. On your reply: the format-to-color-space mapping (`R10G10B10A2_UNORM` to G2084/P2020, `R16G16B16A16_FLOAT` to G10/P709) is the standard DXGI convention and looks right. The open question is what happens to the title once it is told HDR is on, and the run you posted answers that with a crash. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-25 01:00 UTC · original

@⁠Marvisak, thank you for the review.

Rebased onto main as a single commit (368a1bb) and addressed the code review items:

  • Repo rule 2: reworded the doc and safety comments in crates/victory-hle/src/modules/display.rs without naming the console API function or struct.
  • Per-frame DXGI cost & mid-run toggle: display_hdr_info() in crates/victory-gpu/src/host.rs now caches query_display_hdr_info() in a OnceLock, and Presenter::sync_color_space records self.color_space = wanted on unsupported or failed SetColorSpace1 calls as well, so DXGI is queried once at startup, try_enable_hdr and Presenter always agree throughout a run, and unsupported outputs are not retried every frame.
  • Deterministic tests: split out try_enable_hdr_with in crates/victory-hle/src/modules/display.rs so hdr_and_display_deferrals tests both HDR-enabled and SDR paths deterministically regardless of the host display, and added desired_color_space_matches_format_and_hdr_state in crates/victory-gpu/src/host.rs.
  • Unrelated diff: dropped the unrelated comment change on mod batch.

Re-ran on Windows 11 (NVIDIA GeForce RTX 5060 Ti):

  • cargo test -p victory-gpu --locked -- desired_color_space_matches_format_and_hdr_state: 1 passed, 0 failed
  • cargo test -p victory-hle --locked -- hdr_and_display_deferrals: 1 passed, 0 failed

For the swap-chain encoding, DXGI_FORMAT_R10G10B10A2_UNORM maps to HDR10 (DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) and DXGI_FORMAT_R16G16B16A16_FLOAT maps to scRGB (DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709) per standard D3D12/DXGI swap-chain conventions; live HDR-vs-SDR title capture is not yet included in this run.

**@⁠n-romanovich** on GitHub · 2026-11-25 01:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7149107446) @⁠Marvisak, thank you for the review. Rebased onto `main` as a single commit (`368a1bb`) and addressed the code review items: - **Repo rule 2:** reworded the doc and safety comments in `crates/victory-hle/src/modules/display.rs` without naming the console API function or struct. - **Per-frame DXGI cost & mid-run toggle:** `display_hdr_info()` in `crates/victory-gpu/src/host.rs` now caches `query_display_hdr_info()` in a `OnceLock`, and `Presenter::sync_color_space` records `self.color_space = wanted` on unsupported or failed `SetColorSpace1` calls as well, so DXGI is queried once at startup, `try_enable_hdr` and `Presenter` always agree throughout a run, and unsupported outputs are not retried every frame. - **Deterministic tests:** split out `try_enable_hdr_with` in `crates/victory-hle/src/modules/display.rs` so `hdr_and_display_deferrals` tests both HDR-enabled and SDR paths deterministically regardless of the host display, and added `desired_color_space_matches_format_and_hdr_state` in `crates/victory-gpu/src/host.rs`. - **Unrelated diff:** dropped the unrelated comment change on `mod batch`. Re-ran on Windows 11 (NVIDIA GeForce RTX 5060 Ti): - `cargo test -p victory-gpu --locked -- desired_color_space_matches_format_and_hdr_state`: `1 passed, 0 failed` - `cargo test -p victory-hle --locked -- hdr_and_display_deferrals`: `1 passed, 0 failed` For the swap-chain encoding, `DXGI_FORMAT_R10G10B10A2_UNORM` maps to HDR10 (`DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020`) and `DXGI_FORMAT_R16G16B16A16_FLOAT` maps to scRGB (`DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709`) per standard D3D12/DXGI swap-chain conventions; live HDR-vs-SDR title capture is not yet included in this run.
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-25 22:57 UTC · original

@⁠Marvisak Updated feat/gpu-hdr-output (58bdffe):

  • Moved desired_color_space_matches_format_and_hdr_state out of mod batch into mod hdr_tests (victory-gpu test and CI check pass).

Live run check on Windows 11 with HDR enabled (#212 + #2177 on NVIDIA):

  • victory_hle::modules::display reports HDR mode: enabled preference=0 min=0.0014 max=1015.27 max_ff=603.70.
  • The title switches the swap chain to format=24 (DXGI_FORMAT_R10G10B10A2_UNORM), and victory_gpu::host sets color_space=12 (DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020, PQ/BT.2020).
  • Note: that run hit an access violation shortly after (0xc0000005 at victory.exe+0x1f4473, read 0x30), whereas the same build with Windows HDR disabled reached frame=64+ without crashing, so in-game visual HDR-vs-SDR comparison is still blocked on that crash.
**@⁠n-romanovich** on GitHub · 2026-11-25 22:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7176984066) @⁠Marvisak Updated `feat/gpu-hdr-output` (`58bdffe`): - Moved `desired_color_space_matches_format_and_hdr_state` out of `mod batch` into `mod hdr_tests` (`victory-gpu` test and CI `check` pass). Live run check on Windows 11 with HDR enabled (`#212 + #2177` on NVIDIA): - `victory_hle::modules::display` reports `HDR mode: enabled preference=0 min=0.0014 max=1015.27 max_ff=603.70`. - The title switches the swap chain to `format=24` (`DXGI_FORMAT_R10G10B10A2_UNORM`), and `victory_gpu::host` sets `color_space=12` (`DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020`, PQ/BT.2020). - Note: that run hit an access violation shortly after (`0xc0000005` at `victory.exe+0x1f4473`, read `0x30`), whereas the same build with Windows HDR disabled reached `frame=64+` without crashing, so in-game visual HDR-vs-SDR comparison is still blocked on that crash.
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/212/head:github-bot/gh-212'
git switch 'github-bot/gh-212'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-212'
git switch 'github-bot/gh-212'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-212'
git switch 'github-bot/gh-212'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-212'
git switch 'main'
git merge --squash 'github-bot/gh-212'
git switch 'main'
git merge --ff-only 'github-bot/gh-212'
git switch 'main'
git merge 'github-bot/gh-212'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!212
No description provided.