- RHIDeviceDesc 删除 windowHandle/width/height/appName - SwapChainDesc 添加 windowHandle 字段 - RHISwapChain 删除 PollEvents/ShouldClose/SetFullscreen 等窗口相关接口 - OpenGLDevice 删除 CreateRenderWindow,改用 InitializeWithExistingWindow - 更新所有集成测试使用新API - 273个单元测试 + 8个集成测试全部通过
61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
#include "RHITestFixture.h"
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <windows.h>
|
|
|
|
#include "XCEngine/RHI/D3D12/D3D12Device.h"
|
|
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
INSTANTIATE_TEST_SUITE_P(D3D12, RHITestFixture, ::testing::Values(RHIType::D3D12));
|
|
INSTANTIATE_TEST_SUITE_P(OpenGL, RHITestFixture, ::testing::Values(RHIType::OpenGL));
|
|
|
|
void RHITestFixture::SetUpTestSuite() {
|
|
}
|
|
|
|
void RHITestFixture::TearDownTestSuite() {
|
|
}
|
|
|
|
void RHITestFixture::SetUp() {
|
|
mDevice = RHIFactory::CreateRHIDevice(GetParam());
|
|
ASSERT_NE(mDevice, nullptr);
|
|
|
|
WNDCLASSEXW wc = {};
|
|
wc.cbSize = sizeof(WNDCLASSEXW);
|
|
wc.lpfnWndProc = DefWindowProcW;
|
|
wc.hInstance = GetModuleHandle(nullptr);
|
|
wc.lpszClassName = L"RHIUnitTestClass";
|
|
RegisterClassExW(&wc);
|
|
|
|
mWindow = CreateWindowExW(0, L"RHIUnitTestClass", L"RHIUnitTest", WS_OVERLAPPEDWINDOW,
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
|
|
|
|
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);
|
|
}
|
|
|
|
void RHITestFixture::TearDown() {
|
|
if (mDevice != nullptr) {
|
|
mDevice->Shutdown();
|
|
delete mDevice;
|
|
mDevice = nullptr;
|
|
}
|
|
if (mWindow) {
|
|
DestroyWindow(mWindow);
|
|
mWindow = nullptr;
|
|
}
|
|
}
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|