diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h b/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h index 67c93525..bd91e43b 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h @@ -18,6 +18,7 @@ public: ~D3D12SwapChain(); bool Initialize(IDXGIFactory4* factory, ID3D12CommandQueue* commandQueue, HWND windowHandle, uint32_t width, uint32_t height, uint32_t bufferCount = 2); + bool Initialize(IDXGISwapChain* swapChain, uint32_t width, uint32_t height); void Shutdown(); uint32_t GetCurrentBackBufferIndex() const; diff --git a/engine/src/RHI/D3D12SwapChain.cpp b/engine/src/RHI/D3D12SwapChain.cpp index 424334fc..e812daaf 100644 --- a/engine/src/RHI/D3D12SwapChain.cpp +++ b/engine/src/RHI/D3D12SwapChain.cpp @@ -47,6 +47,18 @@ bool D3D12SwapChain::Initialize(IDXGIFactory4* factory, ID3D12CommandQueue* comm return true; } +bool D3D12SwapChain::Initialize(IDXGISwapChain* swapChain, uint32_t width, uint32_t height) { + HRESULT hResult = swapChain->QueryInterface(IID_PPV_ARGS(&m_swapChain)); + if (FAILED(hResult)) { + return false; + } + + m_width = width; + m_height = height; + + return true; +} + void D3D12SwapChain::Shutdown() { m_swapChain.Reset(); } diff --git a/tests/D3D12/main.cpp b/tests/D3D12/main.cpp index a643d87b..a2725d95 100644 --- a/tests/D3D12/main.cpp +++ b/tests/D3D12/main.cpp @@ -606,7 +606,7 @@ bool InitD3D12(HWND inHWND, int inWidth, int inHeight) { IDXGISwapChain* swapChain = nullptr; dxgiFactory->CreateSwapChain(gCommandQueue.GetCommandQueue(), &swapChainDesc, &swapChain); - gSwapChain.Initialize(dxgiFactory, gCommandQueue.GetCommandQueue(), inHWND, inWidth, inHeight, 2); + gSwapChain.Initialize(swapChain, inWidth, inHeight); D3D12_HEAP_PROPERTIES d3dHeapProperties = {}; d3dHeapProperties.Type = D3D12_HEAP_TYPE_DEFAULT;