120 lines
3.5 KiB
C++
120 lines
3.5 KiB
C++
#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;
|
|
}
|
|
}
|