Files
XCEngine/tests/RHI/unit/test_command_queue.cpp
ssdfasd 0a3fe842b9 Refactor RHI ResourceView abstraction layer for unified cross-platform interface
- Create unified RHIResourceView base interface with type-specific Initialize methods
- Implement D3D12ResourceView with RTV/DSV/SRV/UAV/CBV support
- Implement OpenGL ResourceView simulation layer using FBO, texture units, and UBO
- Add OpenGLTextureUnitAllocator for managing texture unit bindings
- Add OpenGLUniformBufferManager for UBO binding points
- Add OpenGLFramebuffer for FBO management
- Remove deprecated D3D12 view classes (RenderTargetView, DepthStencilView, etc.)
- Fix ExecuteCommandLists type confusion bug by adding GetNativeHandle to RHICommandList
- Fix test bug where Close() was called before ExecuteCommandLists
- Update all integration tests to use new D3D12ResourceView class
- All tests pass: 144 unit tests + 8 integration tests
2026-03-24 03:49:13 +08:00

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();
void* cmdLists[] = { cmdList };
queue->ExecuteCommandLists(1, cmdLists);
cmdList->Close();
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;
}