D3D12: Add Screenshot wrapper overload and document known limitations

- Add D3D12Screenshot::Capture(D3D12Device&, D3D12CommandQueue&, D3D12Texture&, const char*) wrapper overload
- Update minimal integration test to use encapsulated APIs
- Add DescriptorHeap wrapper unit tests
- Document minimal GetBuffer native call as known limitation in TEST_SPEC.md
This commit is contained in:
2026-03-20 17:36:51 +08:00
parent a40544344b
commit 3cd3b04c7e
5 changed files with 113 additions and 35 deletions

View File

@@ -1,4 +1,60 @@
#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(), 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(), 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(), 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(), DescriptorHeapType::RTV, 4));
EXPECT_GT(rtvHeap.GetDescriptorSize(), 0u);
D3D12DescriptorHeap cbvHeap;
ASSERT_TRUE(cbvHeap.Initialize(GetDevice(), DescriptorHeapType::CBV_SRV_UAV, 4));
EXPECT_GT(cbvHeap.GetDescriptorSize(), 0u);
}
TEST_F(D3D12TestFixture, DescriptorHeap_Wrapper_Shutdown) {
D3D12DescriptorHeap heap;
ASSERT_TRUE(heap.Initialize(GetDevice(), DescriptorHeapType::RTV, 2));
heap.Shutdown();
}
TEST_F(D3D12TestFixture, DescriptorHeap_Create_CBV_SRV_UAV) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};