diff --git a/OmniScaler/Config.h b/OmniScaler/Config.h index 3f6bd86c..2e8f2620 100644 --- a/OmniScaler/Config.h +++ b/OmniScaler/Config.h @@ -97,6 +97,7 @@ public: NVNGX_Api Api = NVNGX_NOT_SELECTED; NVSDK_NGX_LoggingInfo NVSDK_Logger{ nullptr, NVSDK_NGX_LOGGING_LEVEL_OFF, false }; IFeature* CurrentFeature = nullptr; + int ActiveFeatureCount = 0; // for realtime changes bool changeBackend = false; diff --git a/OmniScaler/NVNGX_DLSS_Dx11.cpp b/OmniScaler/NVNGX_DLSS_Dx11.cpp index 7f53d3c8..b306eaf7 100644 --- a/OmniScaler/NVNGX_DLSS_Dx11.cpp +++ b/OmniScaler/NVNGX_DLSS_Dx11.cpp @@ -91,6 +91,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Shutdown(void) Dx11Contexts.clear(); D3D11Device = nullptr; + Config::Instance()->ActiveFeatureCount = 0; return NVSDK_NGX_Result_Success; } @@ -240,7 +241,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_CreateFeature(ID3D11DeviceContext } if (deviceContext->Init(D3D11Device, InDevCtx, InParameters)) + { + Config::Instance()->ActiveFeatureCount++; return NVSDK_NGX_Result_Success; + } spdlog::error("NVSDK_NGX_D3D11_CreateFeature: CreateFeature failed"); return NVSDK_NGX_Result_Fail; @@ -264,6 +268,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_ReleaseFeature(NVSDK_NGX_Handle* Dx11Contexts.erase(it); } + Config::Instance()->ActiveFeatureCount--; + return NVSDK_NGX_Result_Success; } diff --git a/OmniScaler/NVNGX_DLSS_Dx12.cpp b/OmniScaler/NVNGX_DLSS_Dx12.cpp index 9843d9a4..9849a77b 100644 --- a/OmniScaler/NVNGX_DLSS_Dx12.cpp +++ b/OmniScaler/NVNGX_DLSS_Dx12.cpp @@ -296,9 +296,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void) NVSDK_NGX_D3D12_ReleaseFeature(val->Handle()); Dx12Contexts.clear(); - D3D12Device = nullptr; + Config::Instance()->ActiveFeatureCount = 0; + UnhookAll(); return NVSDK_NGX_Result_Success; @@ -475,6 +476,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsComma if (deviceContext->Init(D3D12Device, InParameters)) { + Config::Instance()->ActiveFeatureCount++; HookToCommandList(InCmdList); return NVSDK_NGX_Result_Success; } @@ -500,6 +502,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle* else spdlog::error("NVSDK_NGX_D3D12_ReleaseFeature can't release feature with id {0}!", handleId); + Config::Instance()->ActiveFeatureCount--; + return NVSDK_NGX_Result_Success; } diff --git a/OmniScaler/NVNGX_DLSS_Vk.cpp b/OmniScaler/NVNGX_DLSS_Vk.cpp index 2f31c6a1..296c4f04 100644 --- a/OmniScaler/NVNGX_DLSS_Vk.cpp +++ b/OmniScaler/NVNGX_DLSS_Vk.cpp @@ -204,7 +204,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_CreateFeature1(VkDevice InDevice *OutHandle = deviceContext->Handle(); if (deviceContext->Init(vkInstance, vkPD, InDevice, InCmdList, vkGIPA, vkGDPA, InParameters)) + { + Config::Instance()->ActiveFeatureCount++; return NVSDK_NGX_Result_Success; + } spdlog::error("NVSDK_NGX_VULKAN_CreateFeature1 CreateFeature failed"); return NVSDK_NGX_Result_FAIL_PlatformError; @@ -232,6 +235,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_ReleaseFeature(NVSDK_NGX_Handle* VkContexts.erase(it); } + Config::Instance()->ActiveFeatureCount--; + return NVSDK_NGX_Result_Success; } @@ -344,6 +349,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Shutdown(void) vkPD = nullptr; vkDevice = nullptr; + Config::Instance()->ActiveFeatureCount = 0; + return NVSDK_NGX_Result_Success; } diff --git a/OmniScaler/imgui/Imgui_Base.cpp b/OmniScaler/imgui/Imgui_Base.cpp index fa64f03f..669cb490 100644 --- a/OmniScaler/imgui/Imgui_Base.cpp +++ b/OmniScaler/imgui/Imgui_Base.cpp @@ -144,9 +144,12 @@ extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg //Win32 message handler LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { + if(Config::Instance()->ActiveFeatureCount == 0) + return CallWindowProc(_oWndProc, hWnd, msg, wParam, lParam); + ImGuiIO& io = ImGui::GetIO(); (void)io; - // CTRL + HOME + // HOME if (msg == WM_KEYDOWN && wParam == VK_HOME) // && (GetKeyState(VK_SHIFT) & 0x8000)) { _isVisible = !_isVisible;