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

@@ -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;
}
}