feat: 实现 D3D12SwapChain 交换链类
- 添加 D3D12SwapChain.h 头文件 - 实现 IDXGISwapChain3 封装 - 实现 Initialize、Present、Resize 等方法 - 测试通过
This commit is contained in:
40
engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h
Normal file
40
engine/include/XCEngine/RHI/D3D12/D3D12SwapChain.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <dxgi1_4.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "../Enums.h"
|
||||
#include "D3D12Enum.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12SwapChain {
|
||||
public:
|
||||
D3D12SwapChain();
|
||||
~D3D12SwapChain();
|
||||
|
||||
bool Initialize(IDXGIFactory4* factory, ID3D12CommandQueue* commandQueue, HWND windowHandle, uint32_t width, uint32_t height, uint32_t bufferCount = 2);
|
||||
void Shutdown();
|
||||
|
||||
uint32_t GetCurrentBackBufferIndex() const;
|
||||
ID3D12Resource* GetBackBuffer(uint32_t index) const;
|
||||
void Present(uint32_t syncInterval, uint32_t flags);
|
||||
void Resize(uint32_t width, uint32_t height);
|
||||
|
||||
IDXGISwapChain3* GetSwapChain() const { return m_swapChain.Get(); }
|
||||
|
||||
private:
|
||||
ComPtr<IDXGISwapChain3> m_swapChain;
|
||||
ComPtr<ID3D12CommandQueue> m_commandQueue;
|
||||
HWND m_windowHandle;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_bufferCount;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user