Files
XCEngine/tests/RHI/D3D12/unit/test_descriptor_heap.cpp
ssdfasd fae520854e refactor: reorganize unit tests into separate folder
- Move test_*.cpp and fixtures/ to tests/RHI/D3D12/unit/
- Create unit/CMakeLists.txt with proper test configuration
- Simplify parent CMakeLists.txt to use add_subdirectory
- Integration tests remain in integration/ folder
2026-03-20 02:58:33 +08:00

76 lines
3.0 KiB
C++

#include "fixtures/D3D12TestFixture.h"
TEST_F(D3D12TestFixture, DescriptorHeap_Placeholder) {
ASSERT_NE(GetDevice(), nullptr);
}
TEST_F(D3D12TestFixture, DescriptorHeap_CreateCBV_SRV_UAV) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
heapDesc.NumDescriptors = 10;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
ASSERT_NE(descriptorHeap.Get(), nullptr);
D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc();
EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
EXPECT_EQ(desc.NumDescriptors, 10);
}
TEST_F(D3D12TestFixture, DescriptorHeap_CreateSampler) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;
heapDesc.NumDescriptors = 5;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc();
EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
}
TEST_F(D3D12TestFixture, DescriptorHeap_CreateRTV) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heapDesc.NumDescriptors = 4;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc();
EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
}
TEST_F(D3D12TestFixture, DescriptorHeap_CreateDSV) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
heapDesc.NumDescriptors = 2;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc();
EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
}
TEST_F(D3D12TestFixture, DescriptorHeap_GetHandleIncrementSize) {
UINT cbvSrvUavSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
UINT samplerSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
UINT dsvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
EXPECT_GT(cbvSrvUavSize, 0);
EXPECT_GT(samplerSize, 0);
EXPECT_GT(rtvSize, 0);
EXPECT_GT(dsvSize, 0);
}