Files
XCEngine/tests/RHI/unit/test_pipeline_layout.cpp

154 lines
4.2 KiB
C++
Raw Normal View History

#include "fixtures/RHITestFixture.h"
#include "XCEngine/RHI/RHIPipelineLayout.h"
#include "XCEngine/RHI/RHIDescriptorSet.h"
using namespace XCEngine::RHI;
TEST_P(RHITestFixture, PipelineLayout_Create_Basic) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 1;
desc.textureCount = 0;
desc.samplerCount = 0;
desc.uavCount = 0;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
EXPECT_NE(layout->GetNativeHandle(), nullptr);
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_Create_WithTextures) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 0;
desc.textureCount = 4;
desc.samplerCount = 0;
desc.uavCount = 0;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
EXPECT_NE(layout->GetNativeHandle(), nullptr);
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_Create_WithSamplers) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 0;
desc.textureCount = 0;
desc.samplerCount = 2;
desc.uavCount = 0;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
EXPECT_NE(layout->GetNativeHandle(), nullptr);
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_Create_WithUAVs) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 0;
desc.textureCount = 0;
desc.samplerCount = 0;
desc.uavCount = 3;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
EXPECT_NE(layout->GetNativeHandle(), nullptr);
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_Create_Complex) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 2;
desc.textureCount = 4;
desc.samplerCount = 2;
desc.uavCount = 1;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
EXPECT_NE(layout->GetNativeHandle(), nullptr);
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_Create_ZeroCounts) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 0;
desc.textureCount = 0;
desc.samplerCount = 0;
desc.uavCount = 0;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
EXPECT_NE(layout->GetNativeHandle(), nullptr);
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_Shutdown) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 1;
desc.textureCount = 2;
desc.samplerCount = 1;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_DoubleShutdown) {
RHIPipelineLayoutDesc desc = {};
desc.constantBufferCount = 1;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
if (layout != nullptr) {
layout->Shutdown();
layout->Shutdown();
delete layout;
}
}
TEST_P(RHITestFixture, PipelineLayout_DescriptorSetAllocation) {
RHIPipelineLayoutDesc layoutDesc = {};
layoutDesc.constantBufferCount = 1;
layoutDesc.textureCount = 2;
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(layoutDesc);
if (layout == nullptr) {
return;
}
DescriptorPoolDesc poolDesc = {};
poolDesc.type = DescriptorHeapType::CBV_SRV_UAV;
poolDesc.descriptorCount = 10;
poolDesc.shaderVisible = true;
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(poolDesc);
if (pool != nullptr) {
DescriptorSetLayoutDesc setDesc = {};
setDesc.bindingCount = 0;
RHIDescriptorSet* set = pool->AllocateSet(setDesc);
if (set != nullptr) {
EXPECT_GE(set->GetBindingCount(), 0u);
set->Shutdown();
delete set;
}
pool->Shutdown();
delete pool;
}
layout->Shutdown();
delete layout;
}