diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp index e7c8ca45..9adf5ec1 100644 --- a/OptiScaler/Config.cpp +++ b/OptiScaler/Config.cpp @@ -18,6 +18,11 @@ static inline bool isInteger(const std::string& str, int& value) { return (iss >> value) && iss.eof(); } +static inline bool isUInt(const std::string& str, uint32_t& value) { + std::istringstream iss(str); + return (iss >> value) && iss.eof(); +} + static inline bool isFloat(const std::string& str, float& value) { std::istringstream iss(str); return (iss >> value) && iss.eof(); @@ -690,6 +695,32 @@ std::optional Config::readInt(std::string section, std::string key) } } +std::optional Config::readUInt(std::string section, std::string key) +{ + auto value = readString(section, key); + try + { + uint32_t result; + + if (value.has_value() && isUInt(value.value(), result)) + return result; + + return std::nullopt; + } + catch (const std::bad_optional_access&) // missing or auto value + { + return std::nullopt; + } + catch (const std::invalid_argument&) // invalid float string for std::stof + { + return std::nullopt; + } + catch (const std::out_of_range&) // out// out of range for 32 bit float + { + return std::nullopt; + } +} + std::optional Config::readBool(std::string section, std::string key) { auto value = readString(section, key, true); diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index 847fe558..f3b66fa9 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -48,12 +48,12 @@ public: std::optional DLSSLibrary; std::optional NVNGX_DLSS_Library; std::optional RenderPresetOverride; - std::optional RenderPresetDLAA; - std::optional RenderPresetUltraQuality; - std::optional RenderPresetQuality; - std::optional RenderPresetBalanced; - std::optional RenderPresetPerformance; - std::optional RenderPresetUltraPerformance; + std::optional RenderPresetDLAA; + std::optional RenderPresetUltraQuality; + std::optional RenderPresetQuality; + std::optional RenderPresetBalanced; + std::optional RenderPresetPerformance; + std::optional RenderPresetUltraPerformance; // CAS std::optional RcasEnabled; @@ -222,5 +222,6 @@ private: std::optional readString(std::string section, std::string key, bool lowercase = false); std::optional readFloat(std::string section, std::string key); std::optional readInt(std::string section, std::string key); + std::optional readUInt(std::string section, std::string key); std::optional readBool(std::string section, std::string key); }; diff --git a/OptiScaler/backends/dlss/DLSSFeature.cpp b/OptiScaler/backends/dlss/DLSSFeature.cpp index 6856512f..bd0a7f2a 100644 --- a/OptiScaler/backends/dlss/DLSSFeature.cpp +++ b/OptiScaler/backends/dlss/DLSSFeature.cpp @@ -179,12 +179,12 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters) LOG_INFO("Render Size: {}x{}, Target Size: {}x{}, Display Size: {}x{}", RenderWidth(), RenderHeight(), TargetWidth(), TargetHeight(), DisplayWidth(), DisplayHeight()); - unsigned int RenderPresetDLAA = 0; - unsigned int RenderPresetUltraQuality = 0; - unsigned int RenderPresetQuality = 0; - unsigned int RenderPresetBalanced = 0; - unsigned int RenderPresetPerformance = 0; - unsigned int RenderPresetUltraPerformance = 0; + uint32_t RenderPresetDLAA = 0; + uint32_t RenderPresetUltraQuality = 0; + uint32_t RenderPresetQuality = 0; + uint32_t RenderPresetBalanced = 0; + uint32_t RenderPresetPerformance = 0; + uint32_t RenderPresetUltraPerformance = 0; if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_DLAA, &RenderPresetDLAA) != NVSDK_NGX_Result_Success) InParameters->Get("RayReconstruction.Hint.Render.Preset.DLAA", &RenderPresetDLAA); @@ -253,6 +253,12 @@ void DLSSFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters) LOG_DEBUG("Preset_Performance {}", RenderPresetPerformance); InParameters->Set(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_UltraPerformance, RenderPresetUltraPerformance); LOG_DEBUG("Preset_UltraPerformance {}", RenderPresetUltraPerformance); + InParameters->Set("RayReconstruction.Hint.Render.Preset.DLAA", RenderPresetDLAA); + InParameters->Set("RayReconstruction.Hint.Render.Preset.UltraQuality", RenderPresetUltraQuality); + InParameters->Set("RayReconstruction.Hint.Render.Preset.Quality", RenderPresetQuality); + InParameters->Set("RayReconstruction.Hint.Render.Preset.Balanced", RenderPresetBalanced); + InParameters->Set("RayReconstruction.Hint.Render.Preset.Performance", RenderPresetPerformance); + InParameters->Set("RayReconstruction.Hint.Render.Preset.UltraPerformance", RenderPresetUltraPerformance); LOG_FUNC_RESULT(0); } diff --git a/OptiScaler/backends/dlss/DLSSFeature_Vk.h b/OptiScaler/backends/dlss/DLSSFeature_Vk.h index 474fcf67..20ee95db 100644 --- a/OptiScaler/backends/dlss/DLSSFeature_Vk.h +++ b/OptiScaler/backends/dlss/DLSSFeature_Vk.h @@ -10,7 +10,6 @@ private: protected: - public: bool Init(VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, VkCommandBuffer InCmdList, PFN_vkGetInstanceProcAddr InGIPA, PFN_vkGetDeviceProcAddr InGDPA, NVSDK_NGX_Parameter* InParameters) override; bool Evaluate(VkCommandBuffer InCmdBuffer, NVSDK_NGX_Parameter* InParameters) override; diff --git a/OptiScaler/backends/dlssd/DLSSDFeature.cpp b/OptiScaler/backends/dlssd/DLSSDFeature.cpp index ee724899..cfa0d98b 100644 --- a/OptiScaler/backends/dlssd/DLSSDFeature.cpp +++ b/OptiScaler/backends/dlssd/DLSSDFeature.cpp @@ -170,12 +170,12 @@ void DLSSDFeature::ProcessInitParams(NVSDK_NGX_Parameter* InParameters) InParameters->Set(NVSDK_NGX_Parameter_OutWidth, TargetWidth()); InParameters->Set(NVSDK_NGX_Parameter_OutHeight, TargetHeight()); - unsigned int RenderPresetDLAA = 0; - unsigned int RenderPresetUltraQuality = 0; - unsigned int RenderPresetQuality = 0; - unsigned int RenderPresetBalanced = 0; - unsigned int RenderPresetPerformance = 0; - unsigned int RenderPresetUltraPerformance = 0; + uint32_t RenderPresetDLAA = 0; + uint32_t RenderPresetUltraQuality = 0; + uint32_t RenderPresetQuality = 0; + uint32_t RenderPresetBalanced = 0; + uint32_t RenderPresetPerformance = 0; + uint32_t RenderPresetUltraPerformance = 0; if (InParameters->Get(NVSDK_NGX_Parameter_DLSS_Hint_Render_Preset_DLAA, &RenderPresetDLAA) != NVSDK_NGX_Result_Success) InParameters->Get("RayReconstruction.Hint.Render.Preset.DLAA", &RenderPresetDLAA); diff --git a/OptiScaler/imgui/imgui_common.h b/OptiScaler/imgui/imgui_common.h index 2dc6c60b..9c0e62d5 100644 --- a/OptiScaler/imgui/imgui_common.h +++ b/OptiScaler/imgui/imgui_common.h @@ -761,7 +761,7 @@ public: } } - static void AddRenderPreset(std::string name, std::optional* value) + static void AddRenderPreset(std::string name, std::optional* value) { const char* presets[] = { "DEFAULT", "PRESET A", "PRESET B", "PRESET C", "PRESET D", "PRESET E", "PRESET F", "PRESET G" }; const char* presetsDesc[] = { "Whatever the game uses",