From 7ac148ee6500a5416f092dcf5c14c4ac485ddc73 Mon Sep 17 00:00:00 2001 From: jasaaved Date: Wed, 18 Mar 2026 23:36:53 -0700 Subject: [PATCH] AutoHDR now uses queried or user settings for HDR If the user hasn't set a HDR DISPLAY MAX NITS, the first time a game is launched using DirectX11 or 12, the queried display values are saved in the ini Of course user settings always take preference. But for someone that doesn't have the HDR settings set, the correct default value should be set so clipping and those bright neon/fluorescent colors can be avoided. --- Data/Sys/Shaders/AutoHDR.glsl | 3 +-- Source/Core/VideoCommon/PostProcessing.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Data/Sys/Shaders/AutoHDR.glsl b/Data/Sys/Shaders/AutoHDR.glsl index 65a7579cd1..b806d65838 100644 --- a/Data/Sys/Shaders/AutoHDR.glsl +++ b/Data/Sys/Shaders/AutoHDR.glsl @@ -54,8 +54,7 @@ void main() // Find the color luminance (it works better than average) float sdr_ratio = luminance(color.rgb); - const float display_max_nits = hdr_max_luminance_nits > 0.0 ? hdr_max_luminance_nits : HDR_DISPLAY_MAX_NITS; - const float auto_hdr_max_white = max(display_max_nits / (hdr_paper_white_nits / hdr_sdr_white_nits), hdr_sdr_white_nits) / hdr_sdr_white_nits; + const float auto_hdr_max_white = max(HDR_DISPLAY_MAX_NITS / (hdr_paper_white_nits / hdr_sdr_white_nits), hdr_sdr_white_nits) / hdr_sdr_white_nits; if (sdr_ratio > AUTO_HDR_SHOULDER_START_ALPHA && AUTO_HDR_SHOULDER_START_ALPHA < 1.0) { const float auto_hdr_shoulder_ratio = 1.0 - (max(1.0 - sdr_ratio, 0.0) / (1.0 - AUTO_HDR_SHOULDER_START_ALPHA)); diff --git a/Source/Core/VideoCommon/PostProcessing.cpp b/Source/Core/VideoCommon/PostProcessing.cpp index f3ec68b1f6..140b9d0c3e 100644 --- a/Source/Core/VideoCommon/PostProcessing.cpp +++ b/Source/Core/VideoCommon/PostProcessing.cpp @@ -259,6 +259,7 @@ void PostProcessingConfiguration::LoadOptionsConfiguration() Common::IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); std::string section = m_current_shader + "-options"; + bool needs_save = false; // We already expect all the options to be marked as "dirty" when we reach here for (auto& it : m_options) @@ -295,10 +296,24 @@ void PostProcessingConfiguration::LoadOptionsConfiguration() it.second.m_float_values = float_values; } } + else if (it.second.m_option_name == "HDR_DISPLAY_MAX_NITS" && + g_backend_info.hdr_max_luminance_nits > 0.f) + { + it.second.m_float_values[0] = g_backend_info.hdr_max_luminance_nits; + it.second.m_dirty = true; + std::ostringstream queried_value; + queried_value.imbue(std::locale("C")); + queried_value << g_backend_info.hdr_max_luminance_nits; + ini.GetOrCreateSection(section)->Set(it.second.m_option_name, queried_value.str()); + needs_save = true; + } } break; } } + + if (needs_save) + ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); } void PostProcessingConfiguration::SaveOptionsConfiguration()