diff options
Diffstat (limited to 'app/source/Cplt/ImGuiBackend/Backend_DirectX12.cpp')
-rw-r--r-- | app/source/Cplt/ImGuiBackend/Backend_DirectX12.cpp | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/app/source/Cplt/ImGuiBackend/Backend_DirectX12.cpp b/app/source/Cplt/ImGuiBackend/Backend_DirectX12.cpp index fd4a531..c0492c2 100644 --- a/app/source/Cplt/ImGuiBackend/Backend_DirectX12.cpp +++ b/app/source/Cplt/ImGuiBackend/Backend_DirectX12.cpp @@ -15,11 +15,9 @@ constexpr int kNumBackBuffers = 3; // Forward declare message handler from imgui_impl_win32.cpp extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -class DirectX12Backend : public RenderingBackend -{ +class DirectX12Backend : public RenderingBackend { private: - struct FrameContext - { + struct FrameContext { ID3D12CommandAllocator* CommandAllocator; UINT64 FenceValue; }; @@ -44,8 +42,7 @@ private: D3D12_CPU_DESCRIPTOR_HANDLE mMainRenderTargetDescriptor[kNumBackBuffers] = {}; public: - DirectX12Backend() - { + DirectX12Backend() { ImGui_ImplWin32_EnableDpiAwareness(); wc.cbSize = sizeof(WNDCLASSEX); @@ -91,8 +88,7 @@ public: ImGui_ImplDX12_Init(mD3dDevice, kNumFramesInFlight, DXGI_FORMAT_R8G8B8A8_UNORM, mD3dSrvDescHeap, mD3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), mD3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart()); } - virtual ~DirectX12Backend() - { + virtual ~DirectX12Backend() { WaitForLastSubmittedFrame(); // Cleanup @@ -105,8 +101,7 @@ public: ::UnregisterClass(wc.lpszClassName, wc.hInstance); } - virtual void RunUntilWindowClose(void (*windowContent)()) - { + virtual void RunUntilWindowClose(void (*windowContent)()) { while (true) { MSG msg; bool done = false; @@ -166,8 +161,7 @@ public: } private: - bool CreateDeviceD3D() - { + bool CreateDeviceD3D() { // Setup swap chain DXGI_SWAP_CHAIN_DESC1 sd; { @@ -266,8 +260,7 @@ private: return true; } - void CleanupDeviceD3D() - { + void CleanupDeviceD3D() { CleanupRenderTarget(); if (mSwapChain) { mSwapChain->Release(); @@ -311,8 +304,7 @@ private: } } - void CreateRenderTarget() - { + void CreateRenderTarget() { for (UINT i = 0; i < kNumBackBuffers; i++) { ID3D12Resource* pBackBuffer = nullptr; @@ -322,8 +314,7 @@ private: } } - void CleanupRenderTarget() - { + void CleanupRenderTarget() { WaitForLastSubmittedFrame(); for (UINT i = 0; i < kNumBackBuffers; i++) @@ -333,8 +324,7 @@ private: } } - void WaitForLastSubmittedFrame() - { + void WaitForLastSubmittedFrame() { FrameContext* frameCtx = &mFrameContext[mFrameIndex % kNumFramesInFlight]; UINT64 fenceValue = frameCtx->FenceValue; @@ -349,8 +339,7 @@ private: WaitForSingleObject(mFenceEvent, INFINITE); } - FrameContext* WaitForNextFrameResources() - { + FrameContext* WaitForNextFrameResources() { UINT nextFrameIndex = mFrameIndex + 1; mFrameIndex = nextFrameIndex; @@ -372,8 +361,7 @@ private: return frameCtx; } - void ResizeSwapChain(int width, int height) - { + void ResizeSwapChain(int width, int height) { DXGI_SWAP_CHAIN_DESC1 sd; mSwapChain->GetDesc1(&sd); sd.Width = width; @@ -397,8 +385,7 @@ private: assert(mSwapChainWaitableObject != nullptr); } - static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) - { + static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { DirectX12Backend* self; if (uMsg == WM_NCCREATE) { auto lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam); @@ -416,8 +403,7 @@ private: } } - LRESULT WndProc(UINT msg, WPARAM wParam, LPARAM lParam) - { + LRESULT WndProc(UINT msg, WPARAM wParam, LPARAM lParam) { if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) { return true; } @@ -451,8 +437,7 @@ private: } }; -std::unique_ptr<RenderingBackend> RenderingBackend::CreateDx12Backend() -{ +std::unique_ptr<RenderingBackend> RenderingBackend::CreateDx12Backend() { try { return std::make_unique<DirectX12Backend>(); } catch (std::exception& e) { @@ -462,8 +447,7 @@ std::unique_ptr<RenderingBackend> RenderingBackend::CreateDx12Backend() #else // ^^ BUILD_CORE_WITH_DX12_BACKEND | BUILD_CORE_WITH_DX12_BACKEND vv -std::unique_ptr<RenderingBackend> RenderingBackend::CreateDx12Backend() -{ +std::unique_ptr<RenderingBackend> RenderingBackend::CreateDx12Backend() { return nullptr; } |