Skip to content

HDR: Per-mode capability detection, menu visibility, and internal shader fixes#18777

Merged
LibretroAdmin merged 2 commits intolibretro:masterfrom
MajorPainTheCactus:fix-vulkan-hdr-first-frame-renderpass-mismatch
Feb 27, 2026
Merged

HDR: Per-mode capability detection, menu visibility, and internal shader fixes#18777
LibretroAdmin merged 2 commits intolibretro:masterfrom
MajorPainTheCactus:fix-vulkan-hdr-first-frame-renderpass-mismatch

Conversation

@MajorPainTheCactus
Copy link
Contributor

@MajorPainTheCactus MajorPainTheCactus commented Feb 26, 2026

Summary

  • Adds separate VIDEO_FLAG_HDR10_SUPPORT and VIDEO_FLAG_SCRGB_SUPPORT flags so the HDR menu only shows modes the driver actually supports
  • Vulkan enumerates surface formats individually: HDR10 (A2B10G10R10 + ST.2084) and scRGB (R16G16B16A16_SFLOAT + EXTENDED_SRGB_LINEAR) are checked separately
  • DXGI sets both flags when the display reports PQ/ST.2084 support (Windows HDR compositor guarantees both paths)
  • The HDR mode selector range is dynamically capped via video_driver_hdr_max_mode() — if only HDR10 is available, scRGB is hidden; if neither is available, the entire HDR menu is hidden
  • Unsupported modes are clamped at Vulkan swapchain creation time with a warning logged
  • Port Sony Megatron v2 scanline chromaticity fix to internal HDR shaders (hdr.frag and hdr_sm5.hlsl.h): scanlines computed in Rec.709 space to prevent chromaticity shift from per-channel beam widths
  • Switch internal scanline from gamma-space to linear-space to match Megatron v2 (fixes darker/narrower scanlines vs external shader)
  • Add scRGB mask softening warning to HDR mode menu sublabel

Context

Fixes an issue on Linux where VK_EXT_swapchain_colorspace is available but no HDR surface formats are enumerated, causing the menu to offer HDR modes that produce a washed-out display. Previously, the extension presence alone was enough to advertise HDR support unconditionally.

The internal shader scanline fix brings hdr.frag (Vulkan) and hdr_sm5.hlsl.h (D3D11/D3D12) in line with the Sony Megatron v2 refactor: scanlines are generated in Rec.709 space using SourceSDR directly (linear), avoiding chromaticity shift and gamma-space brightness mismatch.

Files changed

  • gfx/video_driver.h/.c — New flags and accessor functions
  • gfx/common/vulkan_common.c — Per-format HDR capability scan and mode clamping
  • gfx/common/dxgi_common.c — Set both HDR10 and scRGB flags at detection time
  • gfx/drivers/d3d11.c, gfx/drivers/d3d12.c, gfx/drivers/vulkan.c — Clear flags on cleanup
  • menu/menu_setting.c — Dynamic range cap for HDR mode selector
  • gfx/drivers/vulkan_shaders/hdr.frag + hdr.frag.inc — Scanline chromaticity fix (Vulkan)
  • gfx/drivers/d3d_shaders/hdr_sm5.hlsl.h — Scanline chromaticity fix (D3D11/D3D12)
  • intl/msg_hash_us.h — scRGB mask softening warning in HDR mode sublabel

Add separate HDR10 and scRGB support flags so the menu only
shows HDR modes that the driver actually supports. Vulkan
enumerates surface formats to set each flag independently;
DXGI sets both when the display reports PQ/ST.2084 (Windows
HDR compositor guarantees both paths). The HDR mode selector
range is dynamically capped and unsupported modes are clamped
at swapchain creation time.
…ning

- Port Sony Megatron v2 scanline chromaticity fix to internal shaders
  (hdr.frag and hdr_sm5.hlsl.h): scanlines now computed in Rec.709
  space to prevent chromaticity shift from per-channel beam widths
- Switch internal scanline from gamma-space to linear-space to match
  Megatron v2 (fixes darker/narrower scanlines vs external shader)
- Add scRGB mask softening warning to HDR mode sublabel
@MajorPainTheCactus MajorPainTheCactus changed the title HDR: Per-mode capability detection and menu visibility HDR: Per-mode capability detection, menu visibility, and internal shader fixes Feb 27, 2026
@LibretroAdmin LibretroAdmin merged commit 88f74ed into libretro:master Feb 27, 2026
35 checks passed
@MajorPainTheCactus MajorPainTheCactus deleted the fix-vulkan-hdr-first-frame-renderpass-mismatch branch February 27, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants