fixed a high fps crash

This commit is contained in:
cdozdil
2024-03-21 01:06:04 +03:00
parent 6cb59df57c
commit 3a5e348791
4 changed files with 30 additions and 5 deletions
+1 -1
View File
@@ -82,7 +82,7 @@
<IncludePath>$(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)CyberXess\cas\lib;$(SolutionDir)CyberXess\fsr2\lib;$(SolutionDir)CyberXess\fsr2_212\lib;$(SolutionDir)CyberXess\vulkan;$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath)</LibraryPath>
<TargetName>nvngx</TargetName>
<OutDir>E:\Games\God of War</OutDir>
<OutDir>D:\code\CyberFSR-XeSS\DLSS_Sample_App\out\build\x64-Debug\ngx_dlss_demo</OutDir>
<IntDir>.\x64\Debug</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+2
View File
@@ -23,6 +23,8 @@ private:
protected:
ImGuiContext* context;
long frameCounter = 0;
void RenderMenu();
public:
+6 -2
View File
@@ -54,6 +54,8 @@ bool Imgui_Dx11::Render(ID3D11DeviceContext* pCmdList, ID3D11Resource* outTextur
if (pCmdList == nullptr || outTexture == nullptr)
return false;
frameCounter++;
if (!IsVisible())
return true;
@@ -100,9 +102,11 @@ Imgui_Dx11::~Imgui_Dx11()
if (!_dx11Init)
return;
ImGui::SetCurrentContext(context);
std::this_thread::sleep_for(std::chrono::milliseconds(250));
if (auto currCtx = ImGui::GetCurrentContext(); currCtx && context != currCtx)
{
ImGui::SetCurrentContext(context);
ImGui_ImplDX11_Shutdown();
ImGui::SetCurrentContext(currCtx);
}
@@ -110,7 +114,7 @@ Imgui_Dx11::~Imgui_Dx11()
ImGui_ImplDX11_Shutdown();
// hackzor
std::this_thread::sleep_for(std::chrono::milliseconds(750));
std::this_thread::sleep_for(std::chrono::milliseconds(250));
if (_renderTargetTexture)
{
+21 -2
View File
@@ -9,6 +9,8 @@ bool Imgui_Dx12::Render(ID3D12GraphicsCommandList* pCmdList, ID3D12Resource* out
if (pCmdList == nullptr || outTexture == nullptr)
return false;
frameCounter++;
if (!IsVisible())
return true;
@@ -152,9 +154,26 @@ Imgui_Dx12::~Imgui_Dx12()
if (!_dx12Init)
return;
ID3D12Fence* d3d12Fence;
_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&d3d12Fence));
d3d12Fence->Signal(999);
auto fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (d3d12Fence->SetEventOnCompletion(999, fenceEvent) == S_OK)
{
WaitForSingleObject(fenceEvent, INFINITE);
CloseHandle(fenceEvent);
}
d3d12Fence->Release();
std::this_thread::sleep_for(std::chrono::milliseconds(250));
ImGui::SetCurrentContext(context);
if (auto currCtx = ImGui::GetCurrentContext(); currCtx && context != currCtx)
{
ImGui::SetCurrentContext(context);
ImGui_ImplDX12_Shutdown();
ImGui::SetCurrentContext(currCtx);
}
@@ -162,7 +181,7 @@ Imgui_Dx12::~Imgui_Dx12()
ImGui_ImplDX12_Shutdown();
// hackzor
std::this_thread::sleep_for(std::chrono::milliseconds(750));
std::this_thread::sleep_for(std::chrono::milliseconds(250));
if (_rtvDescHeap)
{