refactor(RHI): 将窗口职责从RHI移到Platform层

- RHIDeviceDesc 删除 windowHandle/width/height/appName
- SwapChainDesc 添加 windowHandle 字段
- RHISwapChain 删除 PollEvents/ShouldClose/SetFullscreen 等窗口相关接口
- OpenGLDevice 删除 CreateRenderWindow,改用 InitializeWithExistingWindow
- 更新所有集成测试使用新API
- 273个单元测试 + 8个集成测试全部通过
This commit is contained in:
2026-03-24 23:00:49 +08:00
parent 9fae910854
commit 7a66913f2b
22 changed files with 66 additions and 379 deletions

View File

@@ -335,7 +335,7 @@ RHIFence* D3D12Device::CreateFence(const FenceDesc& desc) {
RHISwapChain* D3D12Device::CreateSwapChain(const SwapChainDesc& desc) {
auto* swapChain = new D3D12SwapChain();
HWND hwnd = static_cast<HWND>(m_deviceDesc.windowHandle);
HWND hwnd = static_cast<HWND>(desc.windowHandle);
if (swapChain->Initialize(m_factory.Get(), m_commandQueue.Get(), hwnd,
desc.width, desc.height, desc.bufferCount)) {
return swapChain;

View File

@@ -5,8 +5,7 @@ namespace XCEngine {
namespace RHI {
D3D12SwapChain::D3D12SwapChain()
: m_windowHandle(nullptr)
, m_width(0)
: m_width(0)
, m_height(0)
, m_bufferCount(2) {
}
@@ -40,7 +39,6 @@ bool D3D12SwapChain::Initialize(IDXGIFactory4* factory, ID3D12CommandQueue* comm
}
m_commandQueue = commandQueue;
m_windowHandle = windowHandle;
m_width = width;
m_height = height;
m_bufferCount = bufferCount;
@@ -102,15 +100,6 @@ void D3D12SwapChain::Resize(uint32_t width, uint32_t height) {
m_height = height;
}
void D3D12SwapChain::SetFullscreen(bool fullscreen) {
m_fullscreen = fullscreen;
m_swapChain->SetFullscreenState(fullscreen, nullptr);
}
bool D3D12SwapChain::IsFullscreen() const {
return m_fullscreen;
}
void* D3D12SwapChain::GetNativeHandle() {
return reinterpret_cast<void*>(m_swapChain.Get());
}
@@ -119,16 +108,5 @@ RHITexture* D3D12SwapChain::GetCurrentBackBuffer() {
return &GetBackBuffer(GetCurrentBackBufferIndex());
}
bool D3D12SwapChain::ShouldClose() const {
return m_shouldClose;
}
void D3D12SwapChain::SetShouldClose(bool shouldClose) {
m_shouldClose = shouldClose;
}
void D3D12SwapChain::PollEvents() {
}
} // namespace RHI
} // namespace XCEngine