From 45dca5c994081867a11d15dbc82042a3a30c8a0b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 11 Sep 2025 15:44:38 +0200 Subject: [PATCH] Vulkan: Enable wide gamut colors on Windows when HDR mode is off Only use when Windows Automatic Color Management (ACM) is enabled. That way we know Windows will automatically convert from extended sRGB linear to the appropriate color space for the display. When we previously tried this there were some issues, but I think it was due to ACM being off. This has been confirmed to work on NVIDIA and AMD, and Intel is not expected to support this (yet) for the same reasons there is no HDR. Pull Request: https://projects.blender.org/blender/blender/pulls/146041 --- intern/ghost/GHOST_Types.h | 4 +++- intern/ghost/intern/GHOST_ContextVK.cc | 3 ++- intern/ghost/intern/GHOST_WindowCocoa.mm | 1 + intern/ghost/intern/GHOST_WindowWayland.cc | 1 + intern/ghost/intern/GHOST_WindowWin32.cc | 5 +++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index d8e57ce7712..d096cc7a109 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -860,13 +860,15 @@ typedef struct { typedef struct { /* Is HDR enabled for this Window? */ bool hdr_enabled; + /* Is wide gamut enabled for this Window? */ + bool wide_gamut_enabled; /* Scale factor to display SDR content in HDR. */ float sdr_white_level; } GHOST_WindowHDRInfo; #define GHOST_WINDOW_HDR_INFO_NONE \ { \ - /*hdr_enabled*/ false, /*sdr_white_level*/ 1.0f, \ + /*hdr_enabled*/ false, /*wide_gamut_enabled*/ false, /*sdr_white_level*/ 1.0f, \ } #ifdef WITH_VULKAN_BACKEND diff --git a/intern/ghost/intern/GHOST_ContextVK.cc b/intern/ghost/intern/GHOST_ContextVK.cc index 66aeb68211b..c79990ac6d8 100644 --- a/intern/ghost/intern/GHOST_ContextVK.cc +++ b/intern/ghost/intern/GHOST_ContextVK.cc @@ -729,7 +729,8 @@ GHOST_TSuccess GHOST_ContextVK::swapBufferAcquire() } submission_frame_data.discard_pile.destroy(vk_device); - const bool use_hdr_swapchain = hdr_info_ && hdr_info_->hdr_enabled && + const bool use_hdr_swapchain = hdr_info_ && + (hdr_info_->wide_gamut_enabled || hdr_info_->hdr_enabled) && device_vk.use_vk_ext_swapchain_colorspace; if (use_hdr_swapchain != use_hdr_swapchain_) { /* Re-create swapchain if HDR mode was toggled in the system settings. */ diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index b821fd13c4b..31b6d010c44 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -404,6 +404,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa, /* For Blender to know if this window supports HDR. */ hdr_info_.hdr_enabled = true; + hdr_info_.wide_gamut_enabled = true; hdr_info_.sdr_white_level = 1.0f; } diff --git a/intern/ghost/intern/GHOST_WindowWayland.cc b/intern/ghost/intern/GHOST_WindowWayland.cc index db92925e72b..3d3fd0fe50a 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cc +++ b/intern/ghost/intern/GHOST_WindowWayland.cc @@ -1996,6 +1996,7 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system, * consider it always enabled. But may still get disabled if Vulkan has no * appropriate surface format. */ hdr_info_.hdr_enabled = true; + hdr_info_.wide_gamut_enabled = true; hdr_info_.sdr_white_level = 1.0f; } #endif diff --git a/intern/ghost/intern/GHOST_WindowWin32.cc b/intern/ghost/intern/GHOST_WindowWin32.cc index 2e15690cce6..91ec101df0a 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cc +++ b/intern/ghost/intern/GHOST_WindowWin32.cc @@ -1328,8 +1328,9 @@ void GHOST_WindowWin32::updateHDRInfo() if (::DisplayConfigGetDeviceInfo(&color_info.header) == ERROR_SUCCESS) { /* This particular combination indicates HDR mode is enabled. This is undocumented but * used by WinRT. When wideColorEnforced is true we are in SDR mode with advanced color. */ - info.hdr_enabled = color_info.advancedColorSupported && color_info.advancedColorEnabled && - !color_info.wideColorEnforced; + info.wide_gamut_enabled = color_info.advancedColorSupported && + color_info.advancedColorEnabled; + info.hdr_enabled = info.wide_gamut_enabled && !color_info.wideColorEnforced; } if (info.hdr_enabled) {