- 将RHITestFixture改为TestWithParam<RHIType>,支持D3D12和OpenGL双后端 - 重构RHIFactory.cpp的include结构,修复OpenGL设备创建 - 在CMakeLists.txt中添加XCENGINE_SUPPORT_OPENGL宏定义 - 更新engine/CMakeLists.txt和tests/RHI/unit/CMakeLists.txt - 将所有TEST_F改为TEST_P以支持参数化测试 测试结果: 138 tests (D3D12: 58 passed / OpenGL: 48 passed)
110 lines
3.0 KiB
C++
110 lines
3.0 KiB
C++
#include "fixtures/RHITestFixture.h"
|
|
#include "XCEngine/RHI/RHICommandQueue.h"
|
|
#include "XCEngine/RHI/RHICommandList.h"
|
|
#include "XCEngine/RHI/RHIFence.h"
|
|
|
|
using namespace XCEngine::RHI;
|
|
|
|
TEST_P(RHITestFixture, CommandQueue_ExecuteCommandLists) {
|
|
CommandQueueDesc queueDesc = {};
|
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandQueue* queue = GetDevice()->CreateCommandQueue(queueDesc);
|
|
ASSERT_NE(queue, nullptr);
|
|
|
|
CommandListDesc cmdDesc = {};
|
|
cmdDesc.commandListType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandList* cmdList = GetDevice()->CreateCommandList(cmdDesc);
|
|
ASSERT_NE(cmdList, nullptr);
|
|
|
|
cmdList->Reset();
|
|
cmdList->Close();
|
|
|
|
void* cmdLists[] = { cmdList };
|
|
queue->ExecuteCommandLists(1, cmdLists);
|
|
|
|
cmdList->Shutdown();
|
|
delete cmdList;
|
|
queue->Shutdown();
|
|
delete queue;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, CommandQueue_SignalWaitFence) {
|
|
CommandQueueDesc queueDesc = {};
|
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandQueue* queue = GetDevice()->CreateCommandQueue(queueDesc);
|
|
ASSERT_NE(queue, nullptr);
|
|
|
|
FenceDesc fenceDesc = {};
|
|
fenceDesc.initialValue = 0;
|
|
|
|
RHIFence* fence = GetDevice()->CreateFence(fenceDesc);
|
|
ASSERT_NE(fence, nullptr);
|
|
|
|
queue->Signal(fence, 1);
|
|
fence->Wait(1);
|
|
|
|
EXPECT_EQ(fence->GetCompletedValue(), 1u);
|
|
|
|
fence->Shutdown();
|
|
delete fence;
|
|
queue->Shutdown();
|
|
delete queue;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, CommandQueue_GetCompletedValue) {
|
|
CommandQueueDesc queueDesc = {};
|
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandQueue* queue = GetDevice()->CreateCommandQueue(queueDesc);
|
|
ASSERT_NE(queue, nullptr);
|
|
|
|
uint64_t completedValue = queue->GetCompletedValue();
|
|
EXPECT_GE(completedValue, 0u);
|
|
|
|
queue->Shutdown();
|
|
delete queue;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, CommandQueue_WaitForIdle) {
|
|
CommandQueueDesc queueDesc = {};
|
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandQueue* queue = GetDevice()->CreateCommandQueue(queueDesc);
|
|
ASSERT_NE(queue, nullptr);
|
|
|
|
queue->WaitForIdle();
|
|
|
|
queue->Shutdown();
|
|
delete queue;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, CommandQueue_GetType) {
|
|
CommandQueueDesc queueDesc = {};
|
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandQueue* queue = GetDevice()->CreateCommandQueue(queueDesc);
|
|
ASSERT_NE(queue, nullptr);
|
|
|
|
EXPECT_EQ(queue->GetType(), CommandQueueType::Direct);
|
|
|
|
queue->Shutdown();
|
|
delete queue;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, CommandQueue_GetTimestampFrequency) {
|
|
CommandQueueDesc queueDesc = {};
|
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
|
|
RHICommandQueue* queue = GetDevice()->CreateCommandQueue(queueDesc);
|
|
ASSERT_NE(queue, nullptr);
|
|
|
|
uint64_t frequency = queue->GetTimestampFrequency();
|
|
EXPECT_GT(frequency, 0u);
|
|
|
|
queue->Shutdown();
|
|
delete queue;
|
|
}
|