Fix OpenGL device initialization and file shaders
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -140,4 +140,40 @@ TEST_P(RHITestFixture, Shader_Shutdown_Invalidates) {
|
||||
EXPECT_FALSE(shader->IsValid());
|
||||
delete shader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Shader_Compile_FromFile_ReturnsValidShader) {
|
||||
ShaderCompileDesc desc = {};
|
||||
if (GetBackendType() == RHIType::D3D12) {
|
||||
desc.fileName = L"tests/RHI/D3D12/integration/quad/Res/Shader/quad.hlsl";
|
||||
desc.entryPoint = L"MainVS";
|
||||
desc.profile = L"vs_5_0";
|
||||
} else {
|
||||
desc.fileName = L"tests/RHI/OpenGL/integration/triangle/Res/Shader/triangle.vert";
|
||||
desc.entryPoint = L"main";
|
||||
desc.profile = L"vs_4_30";
|
||||
}
|
||||
|
||||
RHIShader* shader = GetDevice()->CreateShader(desc);
|
||||
ASSERT_NE(shader, nullptr);
|
||||
EXPECT_TRUE(shader->IsValid());
|
||||
EXPECT_EQ(shader->GetType(), ShaderType::Vertex);
|
||||
shader->Shutdown();
|
||||
delete shader;
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Shader_Compile_MissingFile_ReturnsNullptr) {
|
||||
ShaderCompileDesc desc = {};
|
||||
if (GetBackendType() == RHIType::D3D12) {
|
||||
desc.fileName = L"tests/RHI/D3D12/integration/quad/Res/Shader/does_not_exist.hlsl";
|
||||
desc.entryPoint = L"MainVS";
|
||||
desc.profile = L"vs_5_0";
|
||||
} else {
|
||||
desc.fileName = L"tests/RHI/OpenGL/integration/triangle/Res/Shader/does_not_exist.vert";
|
||||
desc.entryPoint = L"main";
|
||||
desc.profile = L"vs_4_30";
|
||||
}
|
||||
|
||||
RHIShader* shader = GetDevice()->CreateShader(desc);
|
||||
EXPECT_EQ(shader, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user