Fix OpenGL device initialization and file shaders

This commit is contained in:
2026-03-26 02:07:21 +08:00
parent 10ee1fa3fa
commit c47e871c5a
5 changed files with 310 additions and 42 deletions

View File

@@ -11,21 +11,48 @@ TEST_P(RHITestFixture, Device_Initialize_Shutdown) {
RHIDevice* device = RHIFactory::CreateRHIDevice(GetBackendType());
ASSERT_NE(device, nullptr);
bool initResult = false;
if (GetBackendType() == RHIType::D3D12) {
RHIDeviceDesc desc = {};
desc.enableDebugLayer = true;
initResult = device->Initialize(desc);
} else if (GetBackendType() == RHIType::OpenGL) {
auto* oglDevice = static_cast<OpenGLDevice*>(device);
initResult = oglDevice->InitializeWithExistingWindow(GetWindowHandle());
}
RHIDeviceDesc desc = {};
desc.enableDebugLayer = true;
const bool initResult = device->Initialize(desc);
ASSERT_TRUE(initResult);
device->Shutdown();
delete device;
}
TEST_P(RHITestFixture, Device_Initialize_OpenGLUnifiedPath_CanCreateSwapChain) {
if (GetBackendType() != RHIType::OpenGL) {
GTEST_SKIP() << "OpenGL-specific unified initialization verification";
}
auto* device = new OpenGLDevice();
ASSERT_NE(device, nullptr);
RHIDeviceDesc deviceDesc = {};
ASSERT_TRUE(device->Initialize(deviceDesc));
CommandQueueDesc queueDesc = {};
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
RHICommandQueue* queue = device->CreateCommandQueue(queueDesc);
ASSERT_NE(queue, nullptr);
SwapChainDesc swapDesc = {};
swapDesc.windowHandle = GetWindowHandle();
swapDesc.width = 320;
swapDesc.height = 180;
RHISwapChain* swapChain = device->CreateSwapChain(swapDesc, queue);
ASSERT_NE(swapChain, nullptr);
swapChain->Present(0, 0);
swapChain->Shutdown();
delete swapChain;
queue->Shutdown();
delete queue;
device->Shutdown();
delete device;
}
TEST_P(RHITestFixture, Device_GetCapabilities_ReturnsValid) {
const auto& caps = GetDevice()->GetCapabilities();