RHI: Add DescriptorPool unit tests (8 tests, P1-5)

This commit is contained in:
2026-03-25 13:21:13 +08:00
parent fbbf5dca55
commit 920d3be78b
3 changed files with 131 additions and 2 deletions

View File

@@ -593,7 +593,8 @@ TEST_F(OpenGLTestFixture, CommandList_Dispatch) {
| 优先级 | 问题 | 工作量 | 影响 | 状态 |
|--------|------|--------|------|------|
| 5 | 添加 DescriptorPool/Set 测试 | 中 | 已实现未测试 | ⏳ 待完成 |
| 5 | 添加 DescriptorPool 测试 | 中 | 已实现未测试 | ✅ 已完成 (DescriptorPool) |
| 5b | DescriptorSet 测试 | 中 | OpenGL 需要 GL context暂跳过 | ⚠️ 待完成 |
| 6 | CommandList 测试增强 | 大 | 大部分传递 nullptr | ⏳ 待完成 |
| 7 | 添加 Compute/Dispatch 测试 | 中 | 重要功能缺失 | ⏳ 待完成 |
| 8 | D3D12 PSO/shader 测试增强 | 小 | 当前测试 trivial | ⏳ 待完成 |
@@ -720,12 +721,20 @@ ctest -R "D3D12|OpenGL|RHITestFixture" -C Debug --output-on-failure
---
**文档版本**: 1.2
**文档版本**: 1.3
**最后更新**: 2026-03-25
**作者**: XCEngine Team
## 更新日志
### v1.3 (2026-03-25)
- P1-5: DescriptorPool 测试 ✅ 已完成
- 新增 `test_descriptor.cpp`8个 DescriptorPool 测试
- 测试通过D3D12 8 + OpenGL 8 = 16 tests
- DescriptorSet 测试暂跳过OpenGL 需要 GL context
- 测试结果D3D12 108测试 + OpenGL 108测试 = 216测试全部通过
- 集成测试8/8 全部通过
### v1.2 (2026-03-25)
- P0-3: RenderPass 测试 ✅ 已完成
- 新增 `test_render_pass.cpp`10个测试

View File

@@ -18,6 +18,7 @@ set(TEST_SOURCES
test_framebuffer.cpp
test_fence.cpp
test_sampler.cpp
test_descriptor.cpp
${CMAKE_SOURCE_DIR}/tests/opengl/package/src/glad.c
)

View File

@@ -0,0 +1,119 @@
#include "fixtures/RHITestFixture.h"
#include "XCEngine/RHI/RHIDescriptorPool.h"
#include "XCEngine/RHI/RHIDescriptorSet.h"
#include "XCEngine/RHI/RHISampler.h"
using namespace XCEngine::RHI;
TEST_P(RHITestFixture, DescriptorPool_Create_CBV_SRV_UAV) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::CBV_SRV_UAV;
desc.descriptorCount = 10;
desc.shaderVisible = true;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
EXPECT_EQ(pool->GetType(), DescriptorHeapType::CBV_SRV_UAV);
EXPECT_EQ(pool->GetDescriptorCount(), 10u);
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_Create_Sampler) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::Sampler;
desc.descriptorCount = 5;
desc.shaderVisible = true;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
EXPECT_EQ(pool->GetType(), DescriptorHeapType::Sampler);
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_Create_RTV) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::RTV;
desc.descriptorCount = 4;
desc.shaderVisible = false;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
EXPECT_EQ(pool->GetType(), DescriptorHeapType::RTV);
EXPECT_EQ(pool->GetDescriptorCount(), 4u);
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_Create_DSV) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::DSV;
desc.descriptorCount = 2;
desc.shaderVisible = false;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
EXPECT_EQ(pool->GetType(), DescriptorHeapType::DSV);
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_GetDescriptorCount) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::CBV_SRV_UAV;
desc.descriptorCount = 100;
desc.shaderVisible = false;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
EXPECT_EQ(pool->GetDescriptorCount(), 100u);
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_GetType) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::Sampler;
desc.descriptorCount = 8;
desc.shaderVisible = true;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
EXPECT_EQ(pool->GetType(), DescriptorHeapType::Sampler);
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_Shutdown) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::CBV_SRV_UAV;
desc.descriptorCount = 10;
desc.shaderVisible = false;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
pool->Shutdown();
delete pool;
}
}
TEST_P(RHITestFixture, DescriptorPool_DoubleShutdown) {
DescriptorPoolDesc desc = {};
desc.type = DescriptorHeapType::CBV_SRV_UAV;
desc.descriptorCount = 10;
desc.shaderVisible = false;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(desc);
if (pool != nullptr) {
pool->Shutdown();
pool->Shutdown();
delete pool;
}
}