|
|
@ -26,6 +26,8 @@ |
|
|
|
#pragma comment(lib, "dxguid.lib") |
|
|
|
#endif |
|
|
|
|
|
|
|
#include "imgui_internal.h" |
|
|
|
|
|
|
|
struct FrameContext |
|
|
|
{ |
|
|
|
ID3D12CommandAllocator* CommandAllocator; |
|
|
@ -47,6 +49,7 @@ static ID3D12Fence* g_fence = nullptr; |
|
|
|
static HANDLE g_fenceEvent = nullptr; |
|
|
|
static UINT64 g_fenceLastSignaledValue = 0; |
|
|
|
static IDXGISwapChain3* g_pSwapChain = nullptr; |
|
|
|
static bool g_SwapChainOccluded = false; |
|
|
|
static HANDLE g_hSwapChainWaitableObject = nullptr; |
|
|
|
static ID3D12Resource* g_mainRenderTargetResource[NUM_BACK_BUFFERS] = {}; |
|
|
|
static D3D12_CPU_DESCRIPTOR_HANDLE g_mainRenderTargetDescriptor[NUM_BACK_BUFFERS] = {}; |
|
|
@ -137,6 +140,14 @@ int main(int, char**) |
|
|
|
if (done) |
|
|
|
break; |
|
|
|
|
|
|
|
// Handle window screen locked
|
|
|
|
if (g_SwapChainOccluded && g_pSwapChain->Present(0, DXGI_PRESENT_TEST) == DXGI_STATUS_OCCLUDED) |
|
|
|
{ |
|
|
|
::Sleep(10); |
|
|
|
continue; |
|
|
|
} |
|
|
|
g_SwapChainOccluded = false; |
|
|
|
|
|
|
|
// Start the Dear ImGui frame
|
|
|
|
ImGui_ImplDX12_NewFrame(); |
|
|
|
ImGui_ImplWin32_NewFrame(); |
|
|
@ -209,8 +220,10 @@ int main(int, char**) |
|
|
|
|
|
|
|
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList); |
|
|
|
|
|
|
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
|
|
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
|
|
|
// Present
|
|
|
|
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
|
|
|
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
|
|
|
g_SwapChainOccluded = (hr == DXGI_STATUS_OCCLUDED); |
|
|
|
|
|
|
|
UINT64 fenceValue = g_fenceLastSignaledValue + 1; |
|
|
|
g_pd3dCommandQueue->Signal(g_fence, fenceValue); |
|
|
|