diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp index b61451b0..27a0b5e1 100644 --- a/OptiScaler/Config.cpp +++ b/OptiScaler/Config.cpp @@ -101,9 +101,13 @@ bool Config::Reload() JitterCancellation = readBool("MotionVectors", "JitterCancellation"); DisplayResolution = readBool("MotionVectors", "DisplayResolution"); + + // DRS + DrsMinOverrideEnabled = readBool("DRS", "DrsMinOverrideEnabled"); + DrsMaxOverrideEnabled = readBool("DRS", "DrsMaxOverrideEnabled"); + //Upscale Ratio Override UpscaleRatioOverrideEnabled = readBool("UpscaleRatio", "UpscaleRatioOverrideEnabled"); - DrsMaxOverrideEnabled = readBool("UpscaleRatio", "DrsMaxOverrideEnabled"); UpscaleRatioOverrideValue = readFloat("UpscaleRatio", "UpscaleRatioOverrideValue"); // Quality Overrides @@ -117,6 +121,7 @@ bool Config::Reload() // hotfixes DisableReactiveMask = readBool("Hotfix", "DisableReactiveMask"); + RoundInternalResolution = readInt("Hotfix", "RoundInternalResolution"); MipmapBiasOverride = readFloat("Hotfix", "MipmapBiasOverride"); if (MipmapBiasOverride.has_value() && (MipmapBiasOverride.value() > 15.0 || MipmapBiasOverride.value() < -15.0)) diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index 5ba5b423..98003c36 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -67,9 +67,12 @@ public: // Upscale Ratio Override std::optional UpscaleRatioOverrideEnabled; - std::optional DrsMaxOverrideEnabled; std::optional UpscaleRatioOverrideValue; + // DRS + std::optional DrsMinOverrideEnabled; + std::optional DrsMaxOverrideEnabled; + // Quality Overrides std::optional QualityRatioOverrideEnabled; std::optional QualityRatio_DLAA; @@ -81,6 +84,7 @@ public: //Hotfixes std::optional DisableReactiveMask; + std::optional RoundInternalResolution; std::optional MipmapBiasOverride; std::optional RestoreComputeSignature; std::optional RestoreGraphicSignature; diff --git a/OptiScaler/NVNGX_Parameter.h b/OptiScaler/NVNGX_Parameter.h index bc670ef6..5d164c38 100644 --- a/OptiScaler/NVNGX_Parameter.h +++ b/OptiScaler/NVNGX_Parameter.h @@ -41,6 +41,7 @@ inline std::optional GetQualityOverrideRatio(const NVSDK_NGX_PerfQuality_ output = Config::Instance()->QualityRatio_Balanced.value_or(1.7); break; } + return output; } @@ -121,12 +122,19 @@ inline NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetOptimalSettingsCallback(NVS } } + if (Config::Instance()->RoundInternalResolution.has_value()) + { + OutHeight -= OutHeight % Config::Instance()->RoundInternalResolution.value(); + OutWidth -= OutWidth % Config::Instance()->RoundInternalResolution.value(); + } + InParams->Set(NVSDK_NGX_Parameter_Scale, scalingRatio); InParams->Set(NVSDK_NGX_Parameter_SuperSampling_ScaleFactor, scalingRatio); InParams->Set(NVSDK_NGX_Parameter_OutWidth, OutWidth); InParams->Set(NVSDK_NGX_Parameter_OutHeight, OutHeight); - if (Config::Instance()->QualityRatioOverrideEnabled.value_or(false) || Config::Instance()->UpscaleRatioOverrideEnabled.value_or(false)) + // DRS minimum resolution + 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); @@ -138,10 +146,23 @@ inline NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_DLSS_GetOptimalSettingsCallback(NVS } else { - InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width, (unsigned int)((float)Width / 3.0f)); - InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height, (unsigned int)((float)Height / 3.0f)); + // DLSS normally only supports DRS in range of 0.5 and 1.0 + auto drsMinWidth = (unsigned int)((float)Width * 0.5f); + auto drsMinHeight = (unsigned int)((float)Height * 0.5f); + + if (OutWidth < drsMinWidth || OutHeight < drsMinHeight) + { + InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width, OutWidth); + InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height, OutHeight); + } + else + { + InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width, drsMinWidth); + InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height, drsMinHeight); + } } + // DRS maximum resolution if (Config::Instance()->DrsMaxOverrideEnabled.value_or(false)) { InParams->Set(NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Width, OutWidth); diff --git a/OptiScaler/imgui/Imgui_Base.cpp b/OptiScaler/imgui/Imgui_Base.cpp index 670b6f20..c0ba782a 100644 --- a/OptiScaler/imgui/Imgui_Base.cpp +++ b/OptiScaler/imgui/Imgui_Base.cpp @@ -890,6 +890,21 @@ void Imgui_Base::RenderMenu() ImGui::EndDisabled(); + // DRS ----------------------------- + ImGui::SeparatorText("DRS (Dynamic Resolution Scaling)"); + if (ImGui::BeginTable("drs", 2)) + { + ImGui::TableNextColumn(); + if (bool drsMin = Config::Instance()->DrsMinOverrideEnabled.value_or(false); ImGui::Checkbox("Override Minimum", &drsMin)) + Config::Instance()->DrsMinOverrideEnabled = drsMin; + + ImGui::TableNextColumn(); + if (bool drsMax = Config::Instance()->DrsMaxOverrideEnabled.value_or(false); ImGui::Checkbox("Override Maximum", &drsMax)) + Config::Instance()->DrsMaxOverrideEnabled = drsMax; + + ImGui::EndTable(); + } + // INIT ----------------------------- ImGui::SeparatorText("Init Flags"); if (ImGui::BeginTable("init", 2)) @@ -1188,7 +1203,7 @@ bool Imgui_Base::IsHandleDifferent() { DWORD procId; - HWND frontWindow = GetForegroundWindow(); // Util::GetProcessWindow(); -- for linux compatibility + HWND frontWindow = GetForegroundWindow(); GetWindowThreadProcessId(frontWindow, &procId); if (processId != procId) diff --git a/nvngx.ini b/nvngx.ini index e70e6d38..27909716 100644 --- a/nvngx.ini +++ b/nvngx.ini @@ -176,10 +176,6 @@ DisplayResolution=auto ; true or false - Default (auto) is false UpscaleRatioOverrideEnabled=auto -; Set this to true to enable limiting DRS max resolution to overriden ratio -; true or false - Default (auto) is false -DrsMaxOverrideEnabled=auto - ; Set the forced upscale ratio value ; Default (auto) is 1.3 UpscaleRatioOverrideValue=auto @@ -205,6 +201,15 @@ QualityRatioBalanced=auto QualityRatioPerformance=auto QualityRatioUltraPerformance=auto +[DRS] +; Set this to true to enable limiting DRS min resolution to rendering resolution +; true or false - Default (auto) is false +DrsMinOverrideEnabled=auto + +; Set this to true to enable limiting DRS max resolution to rendering resolution +; true or false - Default (auto) is false +DrsMaxOverrideEnabled=auto + [Hotfix] ; Force remove RESPONSIVE_PIXEL_MASK from init flags ; true or false - Default (auto) is true @@ -214,6 +219,10 @@ DisableReactiveMask=auto ; -15.0 - 15.0 - Default (auto) is disabled MipmapBiasOverride=auto +; Rounds internal resolutions width and height to multiple of this value +; 2, 4, 8, 16 ... - Default (auto) is disabled +RoundInternalResolution=auto + ; Restore last used compute signature after upscaling ; true or false - Default (auto) is false RestoreComputeSignature=auto @@ -229,23 +238,18 @@ RestoreGraphicSignature=auto ; Default (auto) is state correction disabled ColorResourceBarrier=auto -; MotionVector texture resource state, from this to D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE (for mostly debugging) ; Default (auto) is state correction disabled MotionVectorResourceBarrier=auto -; Depth texture resource state, from this D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE (for mostly debugging) ; Default (auto) is state correction disabled DepthResourceBarrier=auto -; Color mask texture resource state, from this D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE (for mostly debugging) ; Default (auto) is state correction disabled ColorMaskResourceBarrier=auto -; Exposure texture resource state, from this D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE (for mostly debugging) ; Default (auto) is state correction disabled ExposureResourceBarrier=auto -; Output texture resource state, from this D3D12_RESOURCE_STATE_UNORDERED_ACCESS (for mostly debugging) ; Default (auto) is state correction disabled OutputResourceBarrier=auto