refactor: improve test infrastructure and fix OpenGL GLAD initialization

- Rename D3D12Enum.h to D3D12Enums.h for naming consistency
- Fix OpenGL unit test GLAD initialization by using gladLoadGL()
  instead of gladLoadGLLoader(wglGetProcAddress) for fallback support
- Migrate remaining tests to use gtest_discover_tests for granular
  test discovery (math, core, containers, memory, threading, debug,
  components, scene, resources, input, opengl)
- Remove obsolete TEST_RESOURCES_DIR and copy_directory commands
  from OpenGL unit test CMakeLists (minimal/Res doesn't exist)
- Update TEST_SPEC.md with performance metrics and per-module
  build/test commands for faster development workflow
- Update CMake path references to use lowercase paths
This commit is contained in:
2026-03-23 00:43:02 +08:00
parent 0f0ab8922a
commit f427699ac6
100 changed files with 1191 additions and 1136 deletions

View File

@@ -1,62 +1,40 @@
#include "fixtures/D3D12TestFixture.h"
#include "XCEngine/RHI/D3D12/D3D12DescriptorHeap.h"
using namespace XCEngine::RHI;
TEST_F(D3D12TestFixture, Views_Create_RTVDescriptorHeap) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heapDesc.NumDescriptors = 1;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
D3D12DescriptorHeap heap;
ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 1, false));
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
CPUDescriptorHandle handle = heap.GetCPUDescriptorHandle(0);
EXPECT_NE(handle.ptr, 0);
}
TEST_F(D3D12TestFixture, Views_Create_DSVDescriptorHeap) {
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
heapDesc.NumDescriptors = 1;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
D3D12DescriptorHeap heap;
ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::DSV, 1, false));
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
CPUDescriptorHandle handle = heap.GetCPUDescriptorHandle(0);
EXPECT_NE(handle.ptr, 0);
}
TEST_F(D3D12TestFixture, Views_Create_CBVDescriptorHeap) {
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;
D3D12DescriptorHeap heap;
ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::CBV_SRV_UAV, 1, true));
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
CPUDescriptorHandle handle = heap.GetCPUDescriptorHandle(0);
EXPECT_NE(handle.ptr, 0);
}
TEST_F(D3D12TestFixture, Views_Get_RTVDescriptorHandleIncrement) {
UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::RTV);
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heapDesc.NumDescriptors = 4;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
D3D12DescriptorHeap heap;
ASSERT_TRUE(heap.Initialize(GetDevice()->GetDevice(), DescriptorHeapType::RTV, 4, false));
ComPtr<ID3D12DescriptorHeap> descriptorHeap;
HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap));
ASSERT_HRESULT_SUCCEEDED(hr);
CPUDescriptorHandle handle1 = heap.GetCPUDescriptorHandle(0);
CPUDescriptorHandle handle2 = heap.GetCPUDescriptorHandle(1);
D3D12_CPU_DESCRIPTOR_HANDLE handle1 = descriptorHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE handle2 = handle1;
handle2.ptr += rtvSize;
EXPECT_NE(handle1.ptr, handle2.ptr);
}
EXPECT_EQ(handle2.ptr - handle1.ptr, rtvSize);
}