2026-03-20 02:35:59 +08:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
|
|
|
|
|
|
|
|
|
project(D3D12_Integration)
|
|
|
|
|
|
2026-03-20 16:33:35 +08:00
|
|
|
set(ENGINE_ROOT_DIR ${CMAKE_SOURCE_DIR}/engine)
|
2026-03-20 02:35:59 +08:00
|
|
|
|
2026-03-20 03:08:08 +08:00
|
|
|
find_package(Python3 REQUIRED)
|
|
|
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
|
2026-03-20 02:35:59 +08:00
|
|
|
# Minimal test - just verifies initialization and render loop
|
|
|
|
|
add_executable(D3D12_Minimal
|
|
|
|
|
WIN32
|
2026-03-20 16:33:35 +08:00
|
|
|
minimal/main.cpp
|
2026-03-20 02:35:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_include_directories(D3D12_Minimal PRIVATE
|
2026-03-20 16:33:35 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/minimal
|
2026-03-20 02:35:59 +08:00
|
|
|
${ENGINE_ROOT_DIR}/include
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_compile_definitions(D3D12_Minimal PRIVATE
|
|
|
|
|
UNICODE
|
|
|
|
|
_UNICODE
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(D3D12_Minimal PRIVATE
|
|
|
|
|
d3d12
|
|
|
|
|
dxgi
|
|
|
|
|
d3dcompiler
|
|
|
|
|
winmm
|
|
|
|
|
XCEngine
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Render model test - complete rendering with model, shader, texture
|
|
|
|
|
add_executable(D3D12_RenderModel
|
|
|
|
|
WIN32
|
2026-03-20 16:33:35 +08:00
|
|
|
render_model/main.cpp
|
2026-03-20 02:35:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_include_directories(D3D12_RenderModel PRIVATE
|
2026-03-20 16:33:35 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/render_model
|
2026-03-20 02:35:59 +08:00
|
|
|
${ENGINE_ROOT_DIR}/include
|
2026-03-20 16:33:35 +08:00
|
|
|
${ENGINE_ROOT_DIR}
|
2026-03-20 02:35:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_compile_definitions(D3D12_RenderModel PRIVATE
|
|
|
|
|
UNICODE
|
|
|
|
|
_UNICODE
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(D3D12_RenderModel PRIVATE
|
|
|
|
|
d3d12
|
|
|
|
|
dxgi
|
|
|
|
|
d3dcompiler
|
|
|
|
|
winmm
|
|
|
|
|
XCEngine
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy Res folder to output directory for Minimal test
|
|
|
|
|
add_custom_command(TARGET D3D12_Minimal POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
2026-03-20 16:33:35 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/minimal/Res
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/Res
|
2026-03-20 02:35:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy Res folder to output directory for RenderModel test
|
|
|
|
|
add_custom_command(TARGET D3D12_RenderModel POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
2026-03-20 16:33:35 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/render_model/Res
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/Res
|
2026-03-20 02:35:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy test scripts to output directory for Minimal test
|
|
|
|
|
add_custom_command(TARGET D3D12_Minimal POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run.bat
|
2026-03-20 16:33:35 +08:00
|
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/
|
2026-03-20 02:35:59 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/compare_ppm.py
|
2026-03-20 16:33:35 +08:00
|
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/
|
2026-03-20 02:35:59 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
2026-03-20 16:33:35 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/
|
2026-03-20 02:35:59 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy test scripts to output directory for RenderModel test
|
|
|
|
|
add_custom_command(TARGET D3D12_RenderModel POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run.bat
|
2026-03-20 16:33:35 +08:00
|
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/
|
2026-03-20 02:35:59 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/compare_ppm.py
|
2026-03-20 16:33:35 +08:00
|
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/
|
2026-03-20 03:08:08 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
2026-03-20 16:33:35 +08:00
|
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/
|
2026-03-20 03:08:08 +08:00
|
|
|
)
|
|
|
|
|
|
2026-03-20 19:05:22 +08:00
|
|
|
# Triangle test - renders a rainbow gradient triangle
|
|
|
|
|
add_executable(D3D12_Triangle
|
|
|
|
|
WIN32
|
|
|
|
|
triangle/main.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_include_directories(D3D12_Triangle PRIVATE
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/triangle
|
|
|
|
|
${ENGINE_ROOT_DIR}/include
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_compile_definitions(D3D12_Triangle PRIVATE
|
|
|
|
|
UNICODE
|
|
|
|
|
_UNICODE
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
target_link_libraries(D3D12_Triangle PRIVATE
|
|
|
|
|
d3d12
|
|
|
|
|
dxgi
|
|
|
|
|
d3dcompiler
|
|
|
|
|
winmm
|
|
|
|
|
XCEngine
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy Res folder to output directory for Triangle test
|
|
|
|
|
add_custom_command(TARGET D3D12_Triangle POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/triangle/Res
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_Triangle>/Res
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy test scripts to output directory for Triangle test
|
|
|
|
|
add_custom_command(TARGET D3D12_Triangle POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run.bat
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_Triangle>/
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/compare_ppm.py
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_Triangle>/
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
|
|
|
|
$<TARGET_FILE_DIR:D3D12_Triangle>/
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-20 03:08:08 +08:00
|
|
|
# Register integration tests with CTest
|
|
|
|
|
add_test(NAME D3D12_Minimal_Integration
|
2026-03-20 16:33:35 +08:00
|
|
|
COMMAND ${Python3_EXECUTABLE} $<TARGET_FILE_DIR:D3D12_Minimal>/run_integration_test.py
|
2026-03-20 03:08:08 +08:00
|
|
|
$<TARGET_FILE:D3D12_Minimal>
|
|
|
|
|
minimal.ppm
|
2026-03-20 17:41:07 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/minimal/GT.ppm
|
2026-03-20 03:08:08 +08:00
|
|
|
5
|
|
|
|
|
WORKING_DIRECTORY $<TARGET_FILE_DIR:D3D12_Minimal>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
add_test(NAME D3D12_RenderModel_Integration
|
2026-03-20 16:33:35 +08:00
|
|
|
COMMAND ${Python3_EXECUTABLE} $<TARGET_FILE_DIR:D3D12_RenderModel>/run_integration_test.py
|
2026-03-20 03:08:08 +08:00
|
|
|
$<TARGET_FILE:D3D12_RenderModel>
|
|
|
|
|
screenshot.ppm
|
2026-03-20 16:33:35 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/render_model/GT.ppm
|
2026-03-20 03:08:08 +08:00
|
|
|
5
|
|
|
|
|
WORKING_DIRECTORY $<TARGET_FILE_DIR:D3D12_RenderModel>
|
|
|
|
|
)
|
2026-03-20 19:05:22 +08:00
|
|
|
|
|
|
|
|
add_test(NAME D3D12_Triangle_Integration
|
|
|
|
|
COMMAND ${Python3_EXECUTABLE} $<TARGET_FILE_DIR:D3D12_Triangle>/run_integration_test.py
|
|
|
|
|
$<TARGET_FILE:D3D12_Triangle>
|
|
|
|
|
triangle.ppm
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/triangle/GT.ppm
|
|
|
|
|
5
|
|
|
|
|
WORKING_DIRECTORY $<TARGET_FILE_DIR:D3D12_Triangle>
|
|
|
|
|
)
|