bvle-voxels/CMakeLists.txt
Samuel Bouchet 7f36bdae38 Phase 6.1: RT infrastructure — MRT normals + BLAS/TLAS build
- Normal render target (R16G16B16A16_SNORM) as MRT SV_TARGET1 in all 3 pixel
  shaders (voxelPS, voxelTopingPS, voxelSmoothPS) for future RT shadow/AO
- BLAS extraction compute shader (voxelBLASExtractCS.hlsl): converts PackedQuad
  StructuredBuffer to float3 position buffer for DXR BLAS input
- Blocky BLAS: single BLAS from all GPU-meshed quads (~1.5M triangles)
- Smooth BLAS: single BLAS from smooth vertex buffer directly
- TLAS: 2 instances (blocky + smooth), identity transforms, CreateBuffer2 with
  callback to avoid UpdateBuffer on RAY_TRACING flagged buffers
- Fix: Wicked always accesses index_buffer in CreateRaytracingAccelerationStructure
  via to_internal() even for non-indexed geometry — provide dummy valid buffer
2026-03-28 14:48:11 +01:00

71 lines
3.5 KiB
CMake

cmake_minimum_required(VERSION 3.19)
project(BVLEVoxels LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Wicked Engine options - disable what we don't need
set(WICKED_EDITOR OFF CACHE BOOL "" FORCE)
set(WICKED_TESTS OFF CACHE BOOL "" FORCE)
set(WICKED_IMGUI_EXAMPLE OFF CACHE BOOL "" FORCE)
set(WICKED_WINDOWS_TEMPLATE OFF CACHE BOOL "" FORCE)
set(WICKED_LINUX_TEMPLATE OFF CACHE BOOL "" FORCE)
set(WICKED_ENABLE_SYMLINKS OFF CACHE BOOL "" FORCE)
add_subdirectory(engine)
# ── Voxel Engine Library ──────────────────────────────────────────
file(GLOB_RECURSE VOXEL_SOURCES src/voxel/*.cpp src/voxel/*.h)
add_library(VoxelEngine STATIC ${VOXEL_SOURCES})
target_include_directories(VoxelEngine PUBLIC src)
target_link_libraries(VoxelEngine PUBLIC WickedEngine)
# ── Main Application ─────────────────────────────────────────────
file(GLOB APP_SOURCES src/app/*.cpp src/app/*.h)
add_executable(BVLEVoxels WIN32 ${APP_SOURCES})
target_link_libraries(BVLEVoxels PRIVATE VoxelEngine WickedEngine)
# Copy Content directory (shaders, etc.) to build output
add_custom_command(TARGET BVLEVoxels POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/engine/Content
$<TARGET_FILE_DIR:BVLEVoxels>/Content
)
# Copy DXC shader compiler DLL next to the exe (required for runtime shader compilation)
add_custom_command(TARGET BVLEVoxels POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/engine/WickedEngine/dxcompiler.dll
$<TARGET_FILE_DIR:BVLEVoxels>/dxcompiler.dll
COMMENT "Copying DXC shader compiler DLL"
)
# Copy our custom shader sources into Wicked's shader source tree
# so LoadShader can find and compile them as "voxel/voxelVS.cso"
add_custom_command(TARGET BVLEVoxels POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/shaders
${CMAKE_SOURCE_DIR}/engine/WickedEngine/shaders/voxel
COMMENT "Copying voxel shaders to Wicked Engine shader source directory"
)
# Delete stale compiled voxel shaders to force runtime recompilation.
# Wicked Engine only compiles .hlsl → .cso when .cso is ABSENT (no timestamp check).
# Without this step, .hlsl changes are silently ignored if old .cso files exist.
add_custom_command(TARGET BVLEVoxels POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm -f
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelVS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelPS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelCullCS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelMeshCS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelTopingVS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelTopingPS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelSmoothVS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelSmoothPS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelSmoothCentroidCS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelSmoothCS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelBLASExtractCS.cso
$<TARGET_FILE_DIR:BVLEVoxels>/shaders/hlsl6/voxel/voxelCommon.hlsli.cso
COMMENT "Clearing stale voxel shader cache (forces recompilation from current .hlsl sources)"
)