Add native HDR10/scRGB, flip-model VRR tearing, high-refresh modes, and DPI/resize handling #288

Open
github-bot wants to merge 1 commit from github-bot/gh-288 into main AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-27 13:43 UTC · original
Vladimir-Human:feat/native-hdr-vrr → main · +3502 −112 · 9 files · 1 commits · open

Summary

Adds three independently switchable native PC display capabilities — all defaulting to 0 (off) so SDR / 2-buffer / 60 Hz / baseline windowing stays the untouched control path for isolated A/B comparison:

  1. Native HDR10 ST.2084 PQ & scRGB (VICTORY_HDR=0|auto|hdr10|scrgb, default 0 = SDR control):

    • Probes IDXGIOutput6::GetDesc1() in crates/victory-gpu/src/display_output.rs for active HDR state, bit depth, luminance bounds, and primaries, returning accurate HDR capabilities (1 + 12-byte luminance info) or SDR (2) from crates/victory-hle/src/modules/display.rs.
    • Configures IDXGISwapChain4 for HDR10 PQ (R10G10B10A2_UNORM + G2084_NONE_P2020 + SetHDRMetaData(HDR10)) or extended-linear scRGB (R16G16B16A16_FLOAT + G10_NONE_P709) when opted in, skipping SetColorSpace1/SetHDRMetaData on SDR control.
    • Updates crates/victory-gpu/src/compose.rs so HDR highlights (> 1.0) are preserved uncrushed while compositing sRGB HUD/overlay planes scaled to VICTORY_HDR_PAPER_WHITE_NITS (default 200 nits, clamped [80, 1000]), with a dedicated UI_FORMAT PSO for Picture::Overlay and paired format/color-space validation (format_matches_color_space, Composer::format(), Composer::record() rejecting format/color-space mismatches with E_INVALIDARG).
  2. Flip-Model VRR Tearing, Waitable Latency & High-Refresh Modes (VICTORY_VRR=0|1, default 0 = baseline 2-buffer / 60 Hz):

    • Under VICTORY_VRR=0: preserves baseline 2-buffer swap chain (Flags == 0, no tearing/waitable), single 60 Hz mode in crates/victory-gpu/src/dxgi.rs, and SIXTIETH default pacing in crates/victory-gpu/src/frame.rs.
    • Under VICTORY_VRR=1: enumerates progressive high-refresh host modes (120/144/180/240 Hz), adopts the active host refresh interval, and enables 3-buffer flip-model swap chains with ALLOW_TEARING (DXGI_PRESENT_ALLOW_TEARING when sync_interval == 0 and windowed/borderless) and FRAME_LATENCY_WAITABLE_OBJECT (SetMaximumFrameLatency(1)), with per-option overrides (VICTORY_SWAP_BUFFERS, VICTORY_TEARING, VICTORY_WAITABLE_SWAP, VICTORY_VSYNC).
  3. Per-Monitor V2 DPI Awareness & Deferred Resize/Occlusion Handling (VICTORY_NATIVE_RESIZE=0|1, default 0 = baseline):

    • Gates Per-Monitor V2 DPI setup (ensure_dpi_awareness()), WM_SIZE / WM_DPICHANGED / WM_DISPLAYCHANGE tracking in host.rs and lifecycle.rs, and DXGI_STATUS_OCCLUDED PRESENT_TEST probing behind VICTORY_NATIVE_RESIZE=1.
    • Keeps safe non-zero resize checks, Host::drain_queue() before ResizeBuffers, and swap-chain buffer_count/swap_flags preservation active unconditionally.

Independent A/B Comparison Guide

Start from the default SDR baseline (all switches unset or 0), then enable one switch at a time on the same output and scene:

  • Control (SDR / baseline): VICTORY_HDR=0 VICTORY_VRR=0 VICTORY_NATIVE_RESIZE=0
  • HDR10 PQ vs SDR: VICTORY_HDR=hdr10 (optional VICTORY_HDR_PAPER_WHITE_NITS=200)
  • scRGB vs SDR: VICTORY_HDR=scrgb (optional VICTORY_HDR_PAPER_WHITE_NITS=200)
  • VRR / high-refresh only: VICTORY_VRR=1
  • DPI / deferred resize / occlusion only: VICTORY_NATIVE_RESIZE=1

Verification

  • cargo run --locked -p xtask -- policy (314 files ok) and cargo test --locked -p xtask (11/11)
  • cargo clippy -p victory-gpu -p victory-hle --all-targets --locked -- -D warnings (default and --all-features: 0 warnings)
  • Real GPU (VICTORY_D3D12_DEBUG=1, --test-threads=1, 0 D3D12/GBV errors):
    • victory-gpu default (26/26), --features diagnostics (32/32), VICTORY_VRR=1 VICTORY_NATIVE_RESIZE=1 (17/17), GBV (VICTORY_D3D12_GBV=1, 16/16)
    • victory-hle default (21/21) and --features diagnostics (21/21)
  • WARP (VICTORY_D3D12_WARP=1, --test-threads=1): --features diagnostics + VICTORY_D3D12_DEBUG=1 (32/32), CI parity without debug layer default (18/18) and --features diagnostics (19/19)
**@⁠Vladimir-Human** on GitHub · 2026-11-27 13:43 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/288) `Vladimir-Human:feat/native-hdr-vrr` → `main` · +3502 −112 · 9 files · 1 commits · open ## Summary Adds three independently switchable native PC display capabilities — all defaulting to `0` (off) so SDR / 2-buffer / 60 Hz / baseline windowing stays the untouched control path for isolated A/B comparison: 1. **Native HDR10 ST.2084 PQ & scRGB (`VICTORY_HDR=0|auto|hdr10|scrgb`, default `0` = SDR control):** - Probes `IDXGIOutput6::GetDesc1()` in `crates/victory-gpu/src/display_output.rs` for active HDR state, bit depth, luminance bounds, and primaries, returning accurate HDR capabilities (`1` + 12-byte luminance info) or SDR (`2`) from `crates/victory-hle/src/modules/display.rs`. - Configures `IDXGISwapChain4` for HDR10 PQ (`R10G10B10A2_UNORM` + `G2084_NONE_P2020` + `SetHDRMetaData(HDR10)`) or extended-linear scRGB (`R16G16B16A16_FLOAT` + `G10_NONE_P709`) when opted in, skipping `SetColorSpace1`/`SetHDRMetaData` on SDR control. - Updates `crates/victory-gpu/src/compose.rs` so HDR highlights (`> 1.0`) are preserved uncrushed while compositing sRGB HUD/overlay planes scaled to `VICTORY_HDR_PAPER_WHITE_NITS` (default `200` nits, clamped `[80, 1000]`), with a dedicated `UI_FORMAT` PSO for `Picture::Overlay` and paired format/color-space validation (`format_matches_color_space`, `Composer::format()`, `Composer::record()` rejecting format/color-space mismatches with `E_INVALIDARG`). 2. **Flip-Model VRR Tearing, Waitable Latency & High-Refresh Modes (`VICTORY_VRR=0|1`, default `0` = baseline 2-buffer / 60 Hz):** - Under `VICTORY_VRR=0`: preserves baseline 2-buffer swap chain (`Flags == 0`, no tearing/waitable), single 60 Hz mode in `crates/victory-gpu/src/dxgi.rs`, and `SIXTIETH` default pacing in `crates/victory-gpu/src/frame.rs`. - Under `VICTORY_VRR=1`: enumerates progressive high-refresh host modes (120/144/180/240 Hz), adopts the active host refresh interval, and enables 3-buffer flip-model swap chains with `ALLOW_TEARING` (`DXGI_PRESENT_ALLOW_TEARING` when `sync_interval == 0` and windowed/borderless) and `FRAME_LATENCY_WAITABLE_OBJECT` (`SetMaximumFrameLatency(1)`), with per-option overrides (`VICTORY_SWAP_BUFFERS`, `VICTORY_TEARING`, `VICTORY_WAITABLE_SWAP`, `VICTORY_VSYNC`). 3. **Per-Monitor V2 DPI Awareness & Deferred Resize/Occlusion Handling (`VICTORY_NATIVE_RESIZE=0|1`, default `0` = baseline):** - Gates Per-Monitor V2 DPI setup (`ensure_dpi_awareness()`), `WM_SIZE` / `WM_DPICHANGED` / `WM_DISPLAYCHANGE` tracking in `host.rs` and `lifecycle.rs`, and `DXGI_STATUS_OCCLUDED` `PRESENT_TEST` probing behind `VICTORY_NATIVE_RESIZE=1`. - Keeps safe non-zero resize checks, `Host::drain_queue()` before `ResizeBuffers`, and swap-chain `buffer_count`/`swap_flags` preservation active unconditionally. ## Independent A/B Comparison Guide Start from the default SDR baseline (all switches unset or `0`), then enable one switch at a time on the same output and scene: - **Control (SDR / baseline):** `VICTORY_HDR=0` `VICTORY_VRR=0` `VICTORY_NATIVE_RESIZE=0` - **HDR10 PQ vs SDR:** `VICTORY_HDR=hdr10` (optional `VICTORY_HDR_PAPER_WHITE_NITS=200`) - **scRGB vs SDR:** `VICTORY_HDR=scrgb` (optional `VICTORY_HDR_PAPER_WHITE_NITS=200`) - **VRR / high-refresh only:** `VICTORY_VRR=1` - **DPI / deferred resize / occlusion only:** `VICTORY_NATIVE_RESIZE=1` ## Verification - `cargo run --locked -p xtask -- policy` (`314 files ok`) and `cargo test --locked -p xtask` (`11/11`) - `cargo clippy -p victory-gpu -p victory-hle --all-targets --locked -- -D warnings` (default and `--all-features`: 0 warnings) - Real GPU (`VICTORY_D3D12_DEBUG=1`, `--test-threads=1`, 0 D3D12/GBV errors): - `victory-gpu` default (`26/26`), `--features diagnostics` (`32/32`), `VICTORY_VRR=1 VICTORY_NATIVE_RESIZE=1` (`17/17`), GBV (`VICTORY_D3D12_GBV=1`, `16/16`) - `victory-hle` default (`21/21`) and `--features diagnostics` (`21/21`) - WARP (`VICTORY_D3D12_WARP=1`, `--test-threads=1`): `--features diagnostics` + `VICTORY_D3D12_DEBUG=1` (`32/32`), CI parity without debug layer default (`18/18`) and `--features diagnostics` (`19/19`)
- Probe host output HDR capabilities and luminance/primaries via IDXGIOutput6::GetDesc1() in victory-gpu::display_output and expose active HDR status (1) and XDisplayHdrModeInfo from victory-hle display::try_enable_hdr when HDR is enabled on the target display (preserving SDR fallback and VICTORY_HDR=0/hdr10/scrgb overrides).
- Upgrade swap-chain creation and presentation to IDXGISwapChain4 with BUFFERS=3 (VICTORY_SWAP_BUFFERS), DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING (checked via IDXGIFactory5), DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT (SetMaximumFrameLatency(1)), SetColorSpace1 (HDR10 G2084_NONE_P2020 and scRGB G10_NONE_P709), and SetHDRMetaData(HDR10).
- Update compose.rs shader and Composer to preserve >1.0 HDR highlights without saturate() clipping, composite sRGB UI overlays at configurable paper-white nits (VICTORY_HDR_PAPER_WHITE_NITS, default 200 nits) in linear/PQ/scRGB space, and keep a matching UI_FORMAT PSO for separate FrameGen UI composition without using HLSL [RootSignature].
- Enumerate real progressive high-refresh monitor display modes (including 120/144/180/240 Hz) in dxgi.rs and use the active host monitor refresh interval as the default in frame.rs.
- Enable Per-Monitor V2 DPI awareness, handle WM_SIZE/WM_DPICHANGED/WM_DISPLAYCHANGE via a thread-safe deferred WindowResizeState, probe DXGI_STATUS_OCCLUDED with DXGI_PRESENT_TEST (without ALLOW_TEARING), drain the direct queue via Host::drain_queue() before ResizeBuffers/teardown, and preserve creation swap-chain flags on ResizeBuffers to prevent 0x887A0001.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:47:56 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 13:48 UTC · original

@⁠Vladimir-Human HDR tone mapping, VRR and resize each need a separate comparison. Start with SDR as the control, then check HDR10 or scRGB on the same output and scene, including the HUD and highlight detail. Keep the composer and swap-chain format checks paired with the display mode.

**@⁠TaynanGT** on GitHub · 2026-11-27 13:48 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/288#issuecomment-7219966132) @⁠Vladimir-Human HDR tone mapping, VRR and resize each need a separate comparison. Start with SDR as the control, then check HDR10 or scRGB on the same output and scene, including the HUD and highlight detail. Keep the composer and swap-chain format checks paired with the display mode.
github-bot force-pushed github-bot/gh-288 from f467770f02 to e29ec500a1 2026-11-27 14:19:35 +00:00 Compare
github-bot force-pushed github-bot/gh-288 from e29ec500a1 to 01f74b90a7 2026-11-27 14:25:20 +00:00 Compare
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-27 14:25 UTC · original

@⁠TaynanGT Updated #288 (01f74b90, rebased cleanly onto main e45051af) so HDR, VRR, and native DPI/resize are each independently switchable and default to 0 (SDR / baseline control), with paired composer and swap-chain format checks:

Comparison Switch Default (0) Opted-in behavior
SDR control -> HDR10 / scRGB VICTORY_HDR 0 (SDR, skips HDR metadata/color-space changes) hdr10, scrgb, or auto; optional VICTORY_HDR_PAPER_WHITE_NITS=200 for HUD luminance
Baseline 60 Hz -> VRR / high-refresh VICTORY_VRR 0 (2-buffer swap chain, Flags == 0, 60 Hz mode/pacing) 1 (3-buffer flip-model, ALLOW_TEARING, waitable latency 1, progressive host refresh modes)
Baseline windowing -> DPI / resize / occlusion VICTORY_NATIVE_RESIZE 0 (baseline DPI/resize/occlusion behavior) 1 (Per-Monitor V2 DPI, deferred WM_SIZE/WM_DPICHANGED/WM_DISPLAYCHANGE, DXGI_STATUS_OCCLUDED PRESENT_TEST)

Paired composer / swap-chain format checks and test pointers:

  • display_output.rs: format_matches_color_space, independent_switches_default_off_and_toggle_without_crosstalk, plan_present_always_pairs_swap_format_with_color_space, swap_chain_tearing_waitable_resize_and_present_on_gpu (covers both baseline 2-buffer SDR control and 3-buffer VRR + HDR10/scRGB ResizeBuffers pairing).
  • compose.rs: Composer::format() + Composer::record() reject mismatched target RTV format or display color space with E_INVALIDARG (composer_rejects_mismatched_target_format_or_display_color_space), alongside HUD/highlight readbacks (hdr10_pq_preserves_peak_luminance_and_maps_paper_white_ui, hdr_scrgb_preserves_highlights_above_one_and_scales_paper_white_ui).
  • host.rs::present_planes: keeps p.color_space paired with the active swap-chain format (format_matches_color_space) and rebuilds p.composer whenever the swap format changes.
**@⁠Vladimir-Human** on GitHub · 2026-11-27 14:25 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/288#issuecomment-7220763549) @⁠TaynanGT Updated #288 (`01f74b90`, rebased cleanly onto `main` `e45051af`) so HDR, VRR, and native DPI/resize are each independently switchable and default to `0` (SDR / baseline control), with paired composer and swap-chain format checks: | Comparison | Switch | Default (`0`) | Opted-in behavior | | --- | --- | --- | --- | | SDR control -> HDR10 / scRGB | `VICTORY_HDR` | `0` (SDR, skips HDR metadata/color-space changes) | `hdr10`, `scrgb`, or `auto`; optional `VICTORY_HDR_PAPER_WHITE_NITS=200` for HUD luminance | | Baseline 60 Hz -> VRR / high-refresh | `VICTORY_VRR` | `0` (2-buffer swap chain, `Flags == 0`, 60 Hz mode/pacing) | `1` (3-buffer flip-model, `ALLOW_TEARING`, waitable latency 1, progressive host refresh modes) | | Baseline windowing -> DPI / resize / occlusion | `VICTORY_NATIVE_RESIZE` | `0` (baseline DPI/resize/occlusion behavior) | `1` (Per-Monitor V2 DPI, deferred `WM_SIZE`/`WM_DPICHANGED`/`WM_DISPLAYCHANGE`, `DXGI_STATUS_OCCLUDED` `PRESENT_TEST`) | Paired composer / swap-chain format checks and test pointers: - `display_output.rs`: `format_matches_color_space`, `independent_switches_default_off_and_toggle_without_crosstalk`, `plan_present_always_pairs_swap_format_with_color_space`, `swap_chain_tearing_waitable_resize_and_present_on_gpu` (covers both baseline 2-buffer SDR control and 3-buffer VRR + HDR10/scRGB `ResizeBuffers` pairing). - `compose.rs`: `Composer::format()` + `Composer::record()` reject mismatched target RTV format or display color space with `E_INVALIDARG` (`composer_rejects_mismatched_target_format_or_display_color_space`), alongside HUD/highlight readbacks (`hdr10_pq_preserves_peak_luminance_and_maps_paper_white_ui`, `hdr_scrgb_preserves_highlights_above_one_and_scales_paper_white_ui`). - `host.rs::present_planes`: keeps `p.color_space` paired with the active swap-chain format (`format_matches_color_space`) and rebuilds `p.composer` whenever the swap format changes.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 14:38 UTC · original

@⁠Vladimir-Human The paired format checks cover the swap-chain and composer mismatch I was looking for. Start with HDR alone on the same display, using the same settled scene. Watch the highlight ramps and HUD brightness. VRR and resize can use their own runs.

**@⁠TaynanGT** on GitHub · 2026-11-27 14:38 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/288#issuecomment-7221048679) @⁠Vladimir-Human The paired format checks cover the swap-chain and composer mismatch I was looking for. Start with HDR alone on the same display, using the same settled scene. Watch the highlight ramps and HUD brightness. VRR and resize can use their own runs.
github-bot force-pushed github-bot/gh-288 from 01f74b90a7 to 37dbb899b9 2026-11-27 20:41:50 +00:00 Compare
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/288/head:github-bot/gh-288'
git switch 'github-bot/gh-288'

Merge

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