Files
XCEngine/tests/RHI/D3D12/test_views.cpp
ssdfasd 19b33a3061 Add Phase 4 tests for DescriptorHeap, Shader, RootSignature, PipelineState, Views
- DescriptorHeap: CBV_SRV_UAV, Sampler, RTV, DSV, HandleIncrementSize
- Shader: Vertex/Pixel/Compute profiles
- RootSignature: Empty, with CBV parameter
- PipelineState: Graphics/Compute pipeline desc defaults
- Views: RTV, DSV, CBV descriptor heaps, handle increment
- All 54 tests pass
2026-03-17 04:04:57 +08:00

67 lines
2.5 KiB
C++

#include "fixtures/D3D12TestFixture.h"
TEST_F(D3D12TestFixture, Views_Placeholder) {
ASSERT_NE(GetDevice(), nullptr);
}
TEST_F(D3D12TestFixture, Views_CreateRTVDescriptorHeap) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heapDesc.NumDescriptors = 1;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
EXPECT_NE(handle.ptr, 0);
}
TEST_F(D3D12TestFixture, Views_CreateDSVDescriptorHeap) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
heapDesc.NumDescriptors = 1;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
EXPECT_NE(handle.ptr, 0);
}
TEST_F(D3D12TestFixture, Views_CreateCBVDescriptorHeap) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
heapDesc.NumDescriptors = 1;
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_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
EXPECT_NE(handle.ptr, 0);
}
TEST_F(D3D12TestFixture, Views_RTVDescriptorHandleIncrement) {
UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
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_CPU_DESCRIPTOR_HANDLE handle1 = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE handle2 = handle1;
handle2.ptr += rtvSize;
EXPECT_NE(handle1.ptr, handle2.ptr);
}