GS: Cleanup ini ranges for some values.

Use clamp instead of min max for OSD and Shade Boost.
Don't allow negative value for upscale multiplier.
This commit is contained in:
lightningterror 2021-10-02 00:35:08 +02:00
parent 603537719e
commit 5e481951ea
4 changed files with 15 additions and 15 deletions

View File

@ -69,14 +69,14 @@ GSOsdManager::GSOsdManager()
{ {
m_monitor_enabled = theApp.GetConfigB("osd_monitor_enabled"); m_monitor_enabled = theApp.GetConfigB("osd_monitor_enabled");
m_log_enabled = theApp.GetConfigB("osd_log_enabled"); m_log_enabled = theApp.GetConfigB("osd_log_enabled");
m_size = std::max(1, std::min(theApp.GetConfigI("osd_fontsize"), 100)); m_size = std::clamp(1, theApp.GetConfigI("osd_fontsize"), 100);
m_opacity = std::max(0, std::min(theApp.GetConfigI("osd_color_opacity"), 100)); m_opacity = std::clamp(0, theApp.GetConfigI("osd_color_opacity"), 100);
m_log_timeout = std::max(2, std::min(theApp.GetConfigI("osd_log_timeout"), 10)); m_log_timeout = std::clamp(2, theApp.GetConfigI("osd_log_timeout"), 10);
m_max_onscreen_messages = std::max(1, std::min(theApp.GetConfigI("osd_max_log_messages"), 20)); m_max_onscreen_messages = std::clamp(1, theApp.GetConfigI("osd_max_log_messages"), 20);
int r = std::max(0, std::min(theApp.GetConfigI("osd_color_r"), 255)); int r = std::clamp(0, theApp.GetConfigI("osd_color_r"), 255);
int g = std::max(0, std::min(theApp.GetConfigI("osd_color_g"), 255)); int g = std::clamp(0, theApp.GetConfigI("osd_color_g"), 255);
int b = std::max(0, std::min(theApp.GetConfigI("osd_color_b"), 255)); int b = std::clamp(0, theApp.GetConfigI("osd_color_b"), 255);
m_color = r | (g << 8) | (b << 16) | (255 << 24); m_color = r | (g << 8) | (b << 16) | (255 << 24);

View File

@ -29,7 +29,7 @@ GSDevice11::GSDevice11()
m_state.bf = -1; m_state.bf = -1;
m_mipmap = theApp.GetConfigI("mipmap"); m_mipmap = theApp.GetConfigI("mipmap");
m_upscale_multiplier = theApp.GetConfigI("upscale_multiplier"); m_upscale_multiplier = std::max(0, theApp.GetConfigI("upscale_multiplier"));
const BiFiltering nearest_filter = static_cast<BiFiltering>(theApp.GetConfigI("filter")); const BiFiltering nearest_filter = static_cast<BiFiltering>(theApp.GetConfigI("filter"));
const int aniso_level = theApp.GetConfigI("MaxAnisotropy"); const int aniso_level = theApp.GetConfigI("MaxAnisotropy");
@ -306,9 +306,9 @@ bool GSDevice11::Create(const std::shared_ptr<GSWnd>& wnd)
ShaderMacro sm_sboost(m_shader.model); ShaderMacro sm_sboost(m_shader.model);
sm_sboost.AddMacro("SB_SATURATION", std::max(0, std::min(theApp.GetConfigI("ShadeBoost_Saturation"), 100))); sm_sboost.AddMacro("SB_SATURATION", std::clamp(0, theApp.GetConfigI("ShadeBoost_Contrast"), 100));
sm_sboost.AddMacro("SB_BRIGHTNESS", std::max(0, std::min(theApp.GetConfigI("ShadeBoost_Brightness"), 100))); sm_sboost.AddMacro("SB_BRIGHTNESS", std::clamp(0, theApp.GetConfigI("ShadeBoost_Brightness"), 100));
sm_sboost.AddMacro("SB_CONTRAST", std::max(0, std::min(theApp.GetConfigI("ShadeBoost_Contrast"), 100))); sm_sboost.AddMacro("SB_CONTRAST", std::clamp(0, theApp.GetConfigI("ShadeBoost_Saturation"), 100));
memset(&bd, 0, sizeof(bd)); memset(&bd, 0, sizeof(bd));

View File

@ -34,7 +34,7 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
, m_lod(GSVector2i(0, 0)) , m_lod(GSVector2i(0, 0))
{ {
m_mipmap = theApp.GetConfigI("mipmap_hw"); m_mipmap = theApp.GetConfigI("mipmap_hw");
m_upscale_multiplier = theApp.GetConfigI("upscale_multiplier"); m_upscale_multiplier = std::max(0, theApp.GetConfigI("upscale_multiplier"));
m_conservative_framebuffer = theApp.GetConfigB("conservative_framebuffer"); m_conservative_framebuffer = theApp.GetConfigB("conservative_framebuffer");
m_accurate_date = theApp.GetConfigB("accurate_date"); m_accurate_date = theApp.GetConfigB("accurate_date");

View File

@ -471,9 +471,9 @@ bool GSDeviceOGL::Create(const std::shared_ptr<GSWnd>& wnd)
{ {
GL_PUSH("GSDeviceOGL::Shadeboost"); GL_PUSH("GSDeviceOGL::Shadeboost");
const int ShadeBoost_Contrast = std::max(0, std::min(theApp.GetConfigI("ShadeBoost_Contrast"), 100)); const int ShadeBoost_Contrast = std::clamp(0, theApp.GetConfigI("ShadeBoost_Contrast"), 100);
const int ShadeBoost_Brightness = std::max(0, std::min(theApp.GetConfigI("ShadeBoost_Brightness"), 100)); const int ShadeBoost_Brightness = std::clamp(0, theApp.GetConfigI("ShadeBoost_Brightness"), 100);
const int ShadeBoost_Saturation = std::max(0, std::min(theApp.GetConfigI("ShadeBoost_Saturation"), 100)); const int ShadeBoost_Saturation = std::clamp(0, theApp.GetConfigI("ShadeBoost_Saturation"), 100);
std::string shade_macro = format("#define SB_SATURATION %d.0\n", ShadeBoost_Saturation) std::string shade_macro = format("#define SB_SATURATION %d.0\n", ShadeBoost_Saturation)
+ format("#define SB_BRIGHTNESS %d.0\n", ShadeBoost_Brightness) + format("#define SB_BRIGHTNESS %d.0\n", ShadeBoost_Brightness)
+ format("#define SB_CONTRAST %d.0\n", ShadeBoost_Contrast); + format("#define SB_CONTRAST %d.0\n", ShadeBoost_Contrast);