Files
XCEngine/tests/RHI/D3D12/unit/test_device.cpp
ssdfasd f427699ac6 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
2026-03-23 00:43:02 +08:00

64 lines
2.5 KiB
C++

#include "fixtures/D3D12TestFixture.h"
#include "XCEngine/RHI/RHIEnums.h"
using namespace XCEngine::RHI;
TEST_F(D3D12TestFixture, Device_Create_Success) {
ASSERT_NE(GetDevice(), nullptr);
ASSERT_NE(GetDevice()->GetDevice(), nullptr);
}
TEST_F(D3D12TestFixture, Device_Get_CommandQueue) {
ASSERT_NE(GetCommandQueue(), nullptr);
ASSERT_NE(GetCommandQueue()->GetCommandQueue(), nullptr);
}
TEST_F(D3D12TestFixture, Device_Get_FeatureLevel) {
D3D12_FEATURE_DATA_FEATURE_LEVELS featureLevels = {};
static const D3D_FEATURE_LEVEL requestedLevels[] = { D3D_FEATURE_LEVEL_12_0 };
featureLevels.NumFeatureLevels = 1;
featureLevels.pFeatureLevelsRequested = requestedLevels;
bool result = GetDevice()->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &featureLevels, sizeof(featureLevels));
ASSERT_TRUE(result);
EXPECT_EQ(featureLevels.MaxSupportedFeatureLevel, D3D_FEATURE_LEVEL_12_0);
}
TEST_F(D3D12TestFixture, Device_Get_DescriptorHandleIncrementSize) {
UINT cbvSrvUavSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::CBV_SRV_UAV);
EXPECT_GT(cbvSrvUavSize, 0);
UINT samplerSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::Sampler);
EXPECT_GT(samplerSize, 0);
UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::RTV);
EXPECT_GT(rtvSize, 0);
UINT dsvSize = GetDevice()->GetDescriptorHandleIncrementSize(DescriptorHeapType::DSV);
EXPECT_GT(dsvSize, 0);
}
TEST_F(D3D12TestFixture, Device_Get_ShaderModelSupport) {
D3D12_FEATURE_DATA_SHADER_MODEL shaderModel = {};
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_0;
bool result = GetDevice()->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModel, sizeof(shaderModel));
ASSERT_TRUE(result);
EXPECT_GE(shaderModel.HighestShaderModel, D3D_SHADER_MODEL_6_0);
}
TEST_F(D3D12TestFixture, Device_Get_ResourceBindingTier) {
D3D12_FEATURE_DATA_D3D12_OPTIONS options = {};
bool result = GetDevice()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options));
ASSERT_TRUE(result);
EXPECT_GE(options.ResourceBindingTier, D3D12_RESOURCE_BINDING_TIER_1);
}
TEST_F(D3D12TestFixture, Device_Get_TiledResourcesTier) {
D3D12_FEATURE_DATA_D3D12_OPTIONS options = {};
bool result = GetDevice()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options));
ASSERT_TRUE(result);
EXPECT_GE(options.TiledResourcesTier, D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED);
}