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

Open
n-romanovich wants to merge 4 commits from upstream-pr/212 into main
n-romanovich commented 2026-11-24 01:28:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-24T01:28:28Z.


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).
<!-- greyfinch-sync:Marvisak/VIctory:issue:6572517145 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/212). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-24T01:28:28Z. --- 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`).
jeremygold02 commented 2026-11-24 06:55:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:59:46Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122525987 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7122525987). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:59:46Z. --- 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.
Marvisak commented 2026-11-25 01:07:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:22:58Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148451324 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7148451324). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:22:58Z. --- <!-- 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)_
n-romanovich commented 2026-11-25 01:08:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-25T01:00:16Z.


@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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149107446 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7149107446). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-25T01:00:16Z. --- @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.
DenRakEiw commented 2026-11-25 03:33:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T03:33:56Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle --lib display:: — 1 passed, 0 failed
  • cargo test -p victory-gpu — all 142 baseline passing tests pass on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (0 new failures; the 2 HEAP_VIEWS failures reproduce identically on untouched origin/main 940d32f on NVIDIA)
  • cargo clippy -p victory-gpu -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean host display HDR luminance reporting and swap chain color space configuration. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051466291 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/212#pullrequestreview-6051466291). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T03:33:56Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-hle --lib display::` — 1 passed, 0 failed - `cargo test -p victory-gpu` — all 142 baseline passing tests pass on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (0 new failures; the 2 `HEAP_VIEWS` failures reproduce identically on untouched `origin/main` `940d32f` on NVIDIA) - `cargo clippy -p victory-gpu -p victory-hle --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean host display HDR luminance reporting and swap chain color space configuration. Looks good. AI-assisted (Gemini 4 Neon).
n-romanovich commented 2026-11-25 23:06:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-25T22:57:36Z.


@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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7176984066 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/212#issuecomment-7176984066). Originally posted by [n-romanovich](https://github.com/n-romanovich) on 2026-11-25T22:57:36Z. --- @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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/212:upstream-pr/212'
git switch 'upstream-pr/212'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/212'
git switch 'upstream-pr/212'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/212'
git switch 'upstream-pr/212'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/212'
git switch 'main'
git merge --squash 'upstream-pr/212'
git switch 'main'
git merge --ff-only 'upstream-pr/212'
git switch 'main'
git merge 'upstream-pr/212'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!212
No description provided.