refactor: RHI抽象层测试支持参数化
- 将RHITestFixture改为TestWithParam<RHIType>,支持D3D12和OpenGL双后端 - 重构RHIFactory.cpp的include结构,修复OpenGL设备创建 - 在CMakeLists.txt中添加XCENGINE_SUPPORT_OPENGL宏定义 - 更新engine/CMakeLists.txt和tests/RHI/unit/CMakeLists.txt - 将所有TEST_F改为TEST_P以支持参数化测试 测试结果: 138 tests (D3D12: 58 passed / OpenGL: 48 passed)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "XCEngine/RHI/RHIFactory.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12Device.h"
|
||||
#ifdef XCENGINE_SUPPORT_OPENGL
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
#endif
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
@@ -8,14 +11,9 @@ RHIDevice* RHIFactory::CreateRHIDevice(RHIType type) {
|
||||
switch (type) {
|
||||
case RHIType::D3D12:
|
||||
return new D3D12Device();
|
||||
case RHIType::OpenGL:
|
||||
#ifdef XCENGINE_SUPPORT_OPENGL
|
||||
{
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
return new OpenGLDevice();
|
||||
}
|
||||
#else
|
||||
return nullptr;
|
||||
case RHIType::OpenGL:
|
||||
return new OpenGLDevice();
|
||||
#endif
|
||||
case RHIType::Vulkan:
|
||||
case RHIType::Metal:
|
||||
@@ -27,12 +25,9 @@ RHIDevice* RHIFactory::CreateRHIDevice(RHIType type) {
|
||||
RHIDevice* RHIFactory::CreateRHIDevice(const std::string& typeName) {
|
||||
if (typeName == "D3D12" || typeName == "d3d12") {
|
||||
return new D3D12Device();
|
||||
} else if (typeName == "OpenGL" || typeName == "opengl" || typeName == "GL") {
|
||||
#ifdef XCENGINE_SUPPORT_OPENGL
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
} else if (typeName == "OpenGL" || typeName == "opengl" || typeName == "GL") {
|
||||
return new OpenGLDevice();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user