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
This commit is contained in:
Brecht Van Lommel
2025-09-11 15:44:38 +02:00
parent 0bd3e7e213
commit 45dca5c994
5 changed files with 10 additions and 4 deletions

View File

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

View File

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

View File

@@ -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;
}

View File

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

View File

@@ -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) {