mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-26 08:06:33 +00:00
added limit checks
This commit is contained in:
@@ -7,9 +7,11 @@ inline std::optional<float> GetQualityOverrideRatio(const NVSDK_NGX_PerfQuality_
|
||||
{
|
||||
std::optional<float> output;
|
||||
|
||||
if (Config::Instance()->UpscaleRatioOverrideEnabled.value_or(false))
|
||||
if (Config::Instance()->UpscaleRatioOverrideEnabled.value_or(false) &&
|
||||
Config::Instance()->UpscaleRatioOverrideValue.value_or(1.3f) >= 1.0f)
|
||||
{
|
||||
output = Config::Instance()->UpscaleRatioOverrideValue.value_or(1.3f);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -19,26 +21,43 @@ inline std::optional<float> GetQualityOverrideRatio(const NVSDK_NGX_PerfQuality_
|
||||
switch (input)
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:
|
||||
output = Config::Instance()->QualityRatio_UltraPerformance.value_or(3.0);
|
||||
if (Config::Instance()->QualityRatio_UltraPerformance.value_or(3.0) >= 1.0f)
|
||||
output = Config::Instance()->QualityRatio_UltraPerformance.value_or(3.0);
|
||||
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:
|
||||
output = Config::Instance()->QualityRatio_Performance.value_or(2.0);
|
||||
if (Config::Instance()->QualityRatio_Performance.value_or(2.0) >= 1.0f)
|
||||
output = Config::Instance()->QualityRatio_Performance.value_or(2.0);
|
||||
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:
|
||||
output = Config::Instance()->QualityRatio_Balanced.value_or(1.7);
|
||||
if (Config::Instance()->QualityRatio_Balanced.value_or(1.7) >= 1.0f)
|
||||
output = Config::Instance()->QualityRatio_Balanced.value_or(1.7);
|
||||
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:
|
||||
output = Config::Instance()->QualityRatio_Quality.value_or(1.5);
|
||||
if (Config::Instance()->QualityRatio_Quality.value_or(1.5) >= 1.0f)
|
||||
output = Config::Instance()->QualityRatio_Quality.value_or(1.5);
|
||||
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:
|
||||
output = Config::Instance()->QualityRatio_UltraQuality.value_or(1.3);
|
||||
if (Config::Instance()->QualityRatio_UltraQuality.value_or(1.3) >= 1.0f)
|
||||
output = Config::Instance()->QualityRatio_UltraQuality.value_or(1.3);
|
||||
|
||||
break;
|
||||
|
||||
case NVSDK_NGX_PerfQuality_Value_DLAA:
|
||||
output = Config::Instance()->QualityRatio_DLAA.value_or(1.0);
|
||||
if (Config::Instance()->QualityRatio_DLAA.value_or(1.0) >= 1.0f)
|
||||
output = Config::Instance()->QualityRatio_DLAA.value_or(1.0);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
spdlog::warn("GetQualityOverrideRatio: Unknown quality: {0}", (int)input);
|
||||
output = Config::Instance()->QualityRatio_Balanced.value_or(1.7);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -65,13 +84,13 @@ inline NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetOptimalSettingsCallback(NVS
|
||||
|
||||
const std::optional<float> QualityRatio = GetQualityOverrideRatio(enumPQValue);
|
||||
|
||||
if (QualityRatio.has_value())
|
||||
if (QualityRatio.has_value())
|
||||
{
|
||||
OutHeight = (unsigned int)((float)Height / QualityRatio.value());
|
||||
OutWidth = (unsigned int)((float)Width / QualityRatio.value());
|
||||
scalingRatio = 1.0f / QualityRatio.value();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
spdlog::debug("NVSDK_NGX_DLSS_GetOptimalSettingsCallback Quality: {0}", PerfQualityValue);
|
||||
|
||||
@@ -134,7 +153,7 @@ inline NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetOptimalSettingsCallback(NVS
|
||||
InParams->Set(NVSDK_NGX_Parameter_OutHeight, OutHeight);
|
||||
|
||||
// DRS minimum resolution
|
||||
if (Config::Instance()->DrsMinOverrideEnabled.value_or(false))
|
||||
if (Config::Instance()->DrsMinOverrideEnabled.value_or(false))
|
||||
{
|
||||
InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width, OutWidth);
|
||||
InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height, OutHeight);
|
||||
|
||||
@@ -10,11 +10,11 @@ void IFeature::SetHandle(unsigned int InHandleId)
|
||||
|
||||
bool IFeature::SetInitParameters(const NVSDK_NGX_Parameter* InParameters)
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int outWidth;
|
||||
unsigned int height;
|
||||
unsigned int outHeight;
|
||||
int pqValue;
|
||||
unsigned int width = 0;
|
||||
unsigned int outWidth = 0;
|
||||
unsigned int height = 0;
|
||||
unsigned int outHeight = 0;
|
||||
int pqValue = 1;
|
||||
|
||||
InParameters->Get(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, &_featureFlags);
|
||||
|
||||
@@ -24,6 +24,22 @@ bool IFeature::SetInitParameters(const NVSDK_NGX_Parameter* InParameters)
|
||||
InParameters->Get(NVSDK_NGX_Parameter_OutHeight, &outHeight) == NVSDK_NGX_Result_Success &&
|
||||
InParameters->Get(NVSDK_NGX_Parameter_PerfQualityValue, &pqValue) == NVSDK_NGX_Result_Success)
|
||||
{
|
||||
// Thanks to Crytek added these checks
|
||||
if (width > 16384 || width < 0)
|
||||
width = 0;
|
||||
|
||||
if (height > 16384 || height < 0)
|
||||
height = 0;
|
||||
|
||||
if (outWidth > 16384 || outWidth < 0)
|
||||
outWidth = 0;
|
||||
|
||||
if (outHeight > 16384 || outHeight < 0)
|
||||
outHeight = 0;
|
||||
|
||||
if (pqValue > 5 || pqValue < 0)
|
||||
pqValue = 1;
|
||||
|
||||
_displayWidth = width > outWidth ? width : outWidth;
|
||||
_displayHeight = height > outHeight ? height : outHeight;
|
||||
_targetWidth = _displayWidth;
|
||||
|
||||
Reference in New Issue
Block a user