better init/shutdown handling for nvngx

This commit is contained in:
cdozdil
2024-07-01 11:28:51 +03:00
parent 1dec39d578
commit 35823d6aa8
4 changed files with 29 additions and 23 deletions
+7 -5
View File
@@ -42,7 +42,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Init_Ext(unsigned long long InApp
spdlog::info("NVSDK_NGX_D3D11_Init_Ext calling NVNGXProxy::D3D11_Init_Ext result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetDx11Inited();
NVNGXProxy::SetDx11Inited(true);
}
}
@@ -105,7 +105,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Init(unsigned long long InApplica
spdlog::info("NVSDK_NGX_D3D11_Init calling NVNGXProxy::D3D11_Init result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetDx11Inited();
NVNGXProxy::SetDx11Inited(true);
}
}
@@ -130,7 +130,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Init_ProjectID(const char* InProj
spdlog::info("NVSDK_NGX_D3D11_Init_ProjectID calling NVNGXProxy::D3D11_Init_ProjectID result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetDx11Inited();
NVNGXProxy::SetDx11Inited(true);
}
}
@@ -186,9 +186,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Shutdown()
if (Config::Instance()->OverlayMenu.value_or(true) && ImGuiOverlayDx11::IsInitedDx11())
ImGuiOverlayDx11::ShutdownDx11();
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::D3D11_Shutdown() != nullptr)
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::IsDx11Inited() && NVNGXProxy::D3D11_Shutdown() != nullptr)
{
auto result = NVNGXProxy::D3D11_Shutdown()();
NVNGXProxy::SetDx11Inited(false);
spdlog::info("NVSDK_NGX_D3D11_Shutdown D3D11_Shutdown result: {0:X}", (UINT)result);
}
@@ -199,9 +200,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Shutdown1(ID3D11Device* InDevice)
{
spdlog::info("NVSDK_NGX_D3D11_Shutdown1");
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::D3D11_Shutdown1() != nullptr)
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::IsDx11Inited() && NVNGXProxy::D3D11_Shutdown1() != nullptr)
{
auto result = NVNGXProxy::D3D11_Shutdown1()(InDevice);
NVNGXProxy::SetDx11Inited(false);
spdlog::info("NVSDK_NGX_D3D11_Shutdown1 D3D11_Shutdown1 result: {0:X}", (UINT)result);
}
+7 -5
View File
@@ -180,7 +180,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_Ext(unsigned long long InApp
spdlog::info("NVSDK_NGX_D3D12_Init_Ext calling NVNGXProxy::D3D12_Init_Ext result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetDx12Inited();
NVNGXProxy::SetDx12Inited(true);
}
else
{
@@ -246,7 +246,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init(unsigned long long InApplica
spdlog::info("NVSDK_NGX_D3D12_Init calling NVNGXProxy::D3D12_Init result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetDx12Inited();
NVNGXProxy::SetDx12Inited(true);
}
}
@@ -272,7 +272,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Init_ProjectID(const char* InProj
spdlog::info("NVSDK_NGX_D3D12_Init_ProjectID calling NVNGXProxy::D3D12_Init_ProjectID result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetDx12Inited();
NVNGXProxy::SetDx12Inited(true);
}
}
@@ -329,10 +329,11 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void)
if (Config::Instance()->OverlayMenu.value_or(true) && ImGuiOverlayDx12::IsInitedDx12())
ImGuiOverlayDx12::ShutdownDx12();
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::D3D12_Shutdown() != nullptr)
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::IsDx12Inited() && NVNGXProxy::D3D12_Shutdown() != nullptr)
{
spdlog::info("NVSDK_NGX_D3D12_Shutdown D3D12_Shutdown");
auto result = NVNGXProxy::D3D12_Shutdown()();
NVNGXProxy::SetDx12Inited(false);
spdlog::info("NVSDK_NGX_D3D12_Shutdown D3D12_Shutdown result: {0:X}", (UINT)result);
}
@@ -343,10 +344,11 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown1(ID3D12Device* InDevice)
{
spdlog::info("NVSDK_NGX_D3D12_Shutdown1");
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::D3D12_Shutdown1() != nullptr)
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::IsDx12Inited() && NVNGXProxy::D3D12_Shutdown1() != nullptr)
{
spdlog::info("NVSDK_NGX_D3D12_Shutdown1 D3D12_Shutdown1");
auto result = NVNGXProxy::D3D12_Shutdown1()(InDevice);
NVNGXProxy::SetDx12Inited(false);
spdlog::info("NVSDK_NGX_D3D12_Shutdown1 D3D12_Shutdown1 result: {0:X}", (UINT)result);
}
+9 -7
View File
@@ -44,7 +44,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_Ext(unsigned long long InAp
spdlog::info("NVSDK_NGX_VULKAN_Init_Ext calling NVNGXProxy::VULKAN_Init_Ext result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetVulkanInited();
NVNGXProxy::SetVulkanInited(true);
}
}
@@ -68,7 +68,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_Ext2(unsigned long long InA
spdlog::info("NVSDK_NGX_VULKAN_Init_Ext2 calling NVNGXProxy::VULKAN_Init_Ext2 result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetVulkanInited();
NVNGXProxy::SetVulkanInited(true);
}
}
@@ -167,7 +167,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_ProjectID_Ext(const char* I
spdlog::info("NVSDK_NGX_VULKAN_Init_ProjectID_Ext calling NVNGXProxy::VULKAN_Init_ProjectID_Ext result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetVulkanInited();
NVNGXProxy::SetVulkanInited(true);
}
}
@@ -200,7 +200,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init(unsigned long long InApplic
spdlog::info("NVSDK_NGX_VULKAN_Init calling NVNGXProxy::VULKAN_Init result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetVulkanInited();
NVNGXProxy::SetVulkanInited(true);
}
}
@@ -225,7 +225,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Init_ProjectID(const char* InPro
spdlog::info("NVSDK_NGX_VULKAN_Init_ProjectID calling NVNGXProxy::VULKAN_Init_ProjectID result: {0:X}", (UINT)result);
if (result == NVSDK_NGX_Result_Success)
NVNGXProxy::SetVulkanInited();
NVNGXProxy::SetVulkanInited(true);
}
}
@@ -714,9 +714,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Shutdown(void)
ImGuiOverlayVk::ShutdownVk();
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::VULKAN_Shutdown() != nullptr)
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::IsVulkanInited() && NVNGXProxy::VULKAN_Shutdown() != nullptr)
{
auto result = NVNGXProxy::VULKAN_Shutdown()();
NVNGXProxy::SetVulkanInited(false);
spdlog::info("NVSDK_NGX_VULKAN_Shutdown VULKAN_Shutdown result: {0:X}", (UINT)result);
}
@@ -727,9 +728,10 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_VULKAN_Shutdown1(VkDevice InDevice)
{
spdlog::debug("NVSDK_NGX_VULKAN_Shutdown1");
if (NVNGXProxy::VULKAN_Shutdown1() != nullptr)
if (Config::Instance()->DLSSEnabled.value_or(true) && NVNGXProxy::IsVulkanInited() && NVNGXProxy::VULKAN_Shutdown1() != nullptr)
{
auto result = NVNGXProxy::VULKAN_Shutdown1()(InDevice);
NVNGXProxy::SetVulkanInited(false);
spdlog::info("NVSDK_NGX_VULKAN_Shutdown1 VULKAN_Shutdown1 result: {0:X}", (UINT)result);
}
+6 -6
View File
@@ -525,9 +525,9 @@ public:
return _dx11Inited;
}
static void SetDx11Inited()
static void SetDx11Inited(bool value)
{
_dx11Inited = true;
_dx11Inited = value;
}
static bool IsDx11Inited()
@@ -661,9 +661,9 @@ public:
return _dx12Inited;
}
static void SetDx12Inited()
static void SetDx12Inited(bool value)
{
_dx12Inited = true;
_dx12Inited = value;
}
static bool IsDx12Inited()
@@ -798,9 +798,9 @@ public:
return true;
}
static void SetVulkanInited()
static void SetVulkanInited(bool value)
{
_vulkanInited = true;
_vulkanInited = value;
}
static bool IsVulkanInited()