feat: add RHI abstraction layer unit tests

- Add RHITestFixture with RHI_BACKEND env var support for backend selection
- Add unit tests for: Device, Buffer, Texture, SwapChain, CommandList, CommandQueue, Shader, Fence, Sampler
- Tests can run against D3D12 or OpenGL backends via RHI_BACKEND env var
- Add integration folder placeholder for future integration tests
This commit is contained in:
2026-03-22 16:18:51 +08:00
parent a980f2bd66
commit 8d4447915d
15 changed files with 1260 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.15)
get_filename_component(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../.. ABSOLUTE)
find_package(GTest REQUIRED)
set(TEST_SOURCES
fixtures/RHITestFixture.cpp
test_device.cpp
test_buffer.cpp
test_texture.cpp
test_swap_chain.cpp
test_command_list.cpp
test_command_queue.cpp
test_shader.cpp
test_fence.cpp
test_sampler.cpp
)
add_executable(rhi_unit_tests ${TEST_SOURCES})
target_link_libraries(rhi_unit_tests PRIVATE
d3d12
dxgi
d3dcompiler
opengl32
glfw3
XCEngine
GTest::gtest
GTest::gtest_main
)
target_include_directories(rhi_unit_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/fixtures
${PROJECT_ROOT_DIR}/engine/include
${PROJECT_ROOT_DIR}/engine/src
${CMAKE_SOURCE_DIR}/tests/OpenGL/package/include/
)
enable_testing()
add_test(NAME RHIUnitTests COMMAND rhi_unit_tests)