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

@@ -3,6 +3,9 @@
#include <iostream>
#include <windows.h>
#include "XCEngine/RHI/D3D12/D3D12Device.h"
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
namespace XCEngine {
namespace RHI {
@@ -26,15 +29,18 @@ void RHITestFixture::SetUp() {
wc.lpszClassName = L"RHIUnitTestClass";
RegisterClassExW(&wc);
HWND hwnd = CreateWindowExW(0, L"RHIUnitTestClass", L"RHIUnitTest", WS_OVERLAPPEDWINDOW,
mWindow = CreateWindowExW(0, L"RHIUnitTestClass", L"RHIUnitTest", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
RHIDeviceDesc desc = {};
desc.enableDebugLayer = true;
desc.appName = L"RHIUnitTest";
desc.windowHandle = hwnd;
bool initResult = mDevice->Initialize(desc);
bool initResult = false;
if (GetParam() == RHIType::D3D12) {
RHIDeviceDesc desc = {};
desc.enableDebugLayer = true;
initResult = mDevice->Initialize(desc);
} else if (GetParam() == RHIType::OpenGL) {
auto* oglDevice = static_cast<OpenGLDevice*>(mDevice);
initResult = oglDevice->InitializeWithExistingWindow(mWindow);
}
ASSERT_TRUE(initResult);
}
@@ -44,6 +50,10 @@ void RHITestFixture::TearDown() {
delete mDevice;
mDevice = nullptr;
}
if (mWindow) {
DestroyWindow(mWindow);
mWindow = nullptr;
}
}
} // namespace RHI