diff --git a/CyberXeSS/CyberXeSS.vcxproj b/CyberXeSS/CyberXeSS.vcxproj index 56232a9d..b5727a1f 100644 --- a/CyberXeSS/CyberXeSS.vcxproj +++ b/CyberXeSS/CyberXeSS.vcxproj @@ -82,7 +82,7 @@ $(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) $(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) nvngx - E:\Games\God of War + D:\code\CyberFSR-XeSS\DLSS_Sample_App\out\build\x64-Debug\ngx_dlss_demo .\x64\Debug diff --git a/CyberXeSS/imgui/Imgui_Base.h b/CyberXeSS/imgui/Imgui_Base.h index beea7c59..016a372b 100644 --- a/CyberXeSS/imgui/Imgui_Base.h +++ b/CyberXeSS/imgui/Imgui_Base.h @@ -23,6 +23,8 @@ private: protected: ImGuiContext* context; + long frameCounter = 0; + void RenderMenu(); public: diff --git a/CyberXeSS/imgui/Imgui_Dx11.cpp b/CyberXeSS/imgui/Imgui_Dx11.cpp index 31dcbf8e..96bcc020 100644 --- a/CyberXeSS/imgui/Imgui_Dx11.cpp +++ b/CyberXeSS/imgui/Imgui_Dx11.cpp @@ -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) { diff --git a/CyberXeSS/imgui/imgui_dx12.cpp b/CyberXeSS/imgui/imgui_dx12.cpp index 75129d91..7a0dbcae 100644 --- a/CyberXeSS/imgui/imgui_dx12.cpp +++ b/CyberXeSS/imgui/imgui_dx12.cpp @@ -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) {