#include "fixtures/D3D12TestFixture.h" #include "XCEngine/RHI/D3D12/D3D12DescriptorHeap.h" using namespace XCEngine::RHI; TEST_F(D3D12TestFixture, DescriptorHeap_Wrapper_Initialize_RTV) { D3D12DescriptorHeap heap; bool result = heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 4); ASSERT_TRUE(result); EXPECT_EQ(heap.GetDescriptorCount(), 4u); EXPECT_EQ(heap.GetType(), DescriptorHeapType::RTV); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Wrapper_GetCPUDescriptorHandle) { D3D12DescriptorHeap heap; ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 4)); uint32_t descriptorSize = heap.GetDescriptorSize(); CPUDescriptorHandle handle0 = heap.GetCPUDescriptorHandle(0); CPUDescriptorHandle handle1 = heap.GetCPUDescriptorHandle(1); CPUDescriptorHandle handle2 = heap.GetCPUDescriptorHandle(2); EXPECT_EQ(handle1.ptr - handle0.ptr, descriptorSize); EXPECT_EQ(handle2.ptr - handle1.ptr, descriptorSize); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Wrapper_GetGPUDescriptorHandle) { D3D12DescriptorHeap heap; ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::CBV_SRV_UAV, 4, true)); uint32_t descriptorSize = heap.GetDescriptorSize(); GPUDescriptorHandle handle0 = heap.GetGPUDescriptorHandle(0); GPUDescriptorHandle handle1 = heap.GetGPUDescriptorHandle(1); EXPECT_EQ(handle1.ptr - handle0.ptr, descriptorSize); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Wrapper_GetDescriptorSize) { D3D12DescriptorHeap rtvHeap; ASSERT_TRUE(rtvHeap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 4)); EXPECT_GT(rtvHeap.GetDescriptorSize(), 0u); D3D12DescriptorHeap cbvHeap; ASSERT_TRUE(cbvHeap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::CBV_SRV_UAV, 4)); EXPECT_GT(cbvHeap.GetDescriptorSize(), 0u); } TEST_F(D3D12TestFixture, DescriptorHeap_Wrapper_Shutdown) { D3D12DescriptorHeap heap; ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 2)); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Create_CBV_SRV_UAV) { D3D12DescriptorHeap heap; bool result = heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::CBV_SRV_UAV, 10, true); ASSERT_TRUE(result); EXPECT_EQ(heap.GetDescriptorCount(), 10u); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Create_Sampler) { D3D12DescriptorHeap heap; bool result = heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::Sampler, 5, true); ASSERT_TRUE(result); EXPECT_EQ(heap.GetType(), DescriptorHeapType::Sampler); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Create_RTV) { D3D12DescriptorHeap heap; bool result = heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 4, false); ASSERT_TRUE(result); EXPECT_EQ(heap.GetType(), DescriptorHeapType::RTV); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Create_DSV) { D3D12DescriptorHeap heap; bool result = heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::DSV, 2, false); ASSERT_TRUE(result); EXPECT_EQ(heap.GetType(), DescriptorHeapType::DSV); heap.Shutdown(); } TEST_F(D3D12TestFixture, DescriptorHeap_Get_HandleIncrementSize) { UINT cbvSrvUavSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::CBV_SRV_UAV); UINT samplerSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::Sampler); UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::RTV); UINT dsvSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::DSV); EXPECT_GT(cbvSrvUavSize, 0); EXPECT_GT(samplerSize, 0); EXPECT_GT(rtvSize, 0); EXPECT_GT(dsvSize, 0); }