3232# Include developer's "private.cmake" (if any) for ad hoc customization.
3333include ( "private.cmake" OPTIONAL )
3434
35- # Minimum version of cmake to support OptiXIR compilation
36- cmake_minimum_required (VERSION 3.27.7 FATAL_ERROR)
35+
36+ if (WIN32 )
37+ # newer cmake has better optixir support with MSVC
38+ cmake_minimum_required (VERSION 3.27.7 FATAL_ERROR)
39+ else ()
40+ cmake_minimum_required (VERSION 3.25.3 FATAL_ERROR)
41+ endif ()
3742
3843# Temporarily quiet some warnings related to FetchContent usage
3944if (POLICY CMP0169)
@@ -56,10 +61,20 @@ endif()
5661# default CUDA arch. This needs to be declared before any project(... CUDA) lines
5762set (CMAKE_CUDA_ARCHITECTURES "86" CACHE STRING "" )
5863
64+
5965project (OptixSubd LANGUAGES C CXX CUDA VERSION 1.13.0)
6066
67+ find_package (CUDAToolkit 12.0 REQUIRED)
68+
6169message (STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES} " )
6270
71+ # Dynamically link against the CUDA runtime
72+ if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "13.0" )
73+ set (CMAKE_CUDA_RUNTIME_LIBRARY "Hybrid" )
74+ else ()
75+ set (CMAKE_CUDA_RUNTIME_LIBRARY "Shared" )
76+ endif ()
77+
6378# C++ standards
6479
6580set (CMAKE_CXX_STANDARD 20)
@@ -93,9 +108,6 @@ if(MSVC)
93108else ()
94109 # Ignore warnings from some third party headers by including them with -isystem
95110 include_directories (SYSTEM
96- ${CMAKE_CURRENT_LIST_DIR} /extern/osd_lite
97- ${CMAKE_CURRENT_LIST_DIR} /extern/osd_lite/opensubdiv
98- ${CMAKE_CURRENT_LIST_DIR} /extern/osd_lite/opensubdiv/tmr
99111 ${CMAKE_CURRENT_LIST_DIR} /texture
100112 ${CMAKE_BINARY_DIR} /_deps/implot-src
101113 ${CMAKE_BINARY_DIR} /_deps/imgui-src
@@ -129,7 +141,6 @@ add_compile_options($<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CUDA>>:-lineinfo>
129141add_compile_options ($<$<AND :$<CONFIG:Release>,$<COMPILE_LANGUAGE:CUDA>>:-lineinfo>)
130142
131143
132- find_package ( CUDAToolkit 12.0 REQUIRED )
133144
134145
135146# TBB (optional) needed for C++17 parallel algorithms on gcc
@@ -157,11 +168,19 @@ add_library(glad::glad ALIAS glad)
157168
158169add_subdirectory (${CMAKE_CURRENT_LIST_DIR} /optix-toolkit EXCLUDE_FROM_ALL )
159170
171+ # Make OptiX Toolkit use dynamic CUDA runtime
172+ set (OTK_LINK_CUDA_STATIC OFF CACHE BOOL "Enable static linking against the cuda run-time" FORCE)
160173
161174# OSD
162175add_definitions (-D_USE_MATH_DEFINES)
163- set (OSD_LITE_FOLDER_NAME "external/osd_lite" )
164- add_subdirectory (${CMAKE_CURRENT_LIST_DIR} /extern/osd_lite EXCLUDE_FROM_ALL )
176+ include (CMake/FetchOsdLite.cmake)
177+
178+ # optional DLSS
179+
180+ option (ENABLE_DLSS "Enable DLSS support if found" ON )
181+ if (ENABLE_DLSS)
182+ include (CMake/FetchDLSS.cmake)
183+ endif ()
165184
166185
167186# Build configuration
@@ -207,6 +226,7 @@ if (MSVC)
207226endif ()
208227
209228add_subdirectory (cluster_builder)
229+ add_subdirectory (depth)
210230add_subdirectory (material)
211231add_subdirectory (motionvec)
212232add_subdirectory (profiler)
@@ -219,8 +239,8 @@ set( optixSubd_SOURCES )
219239list ( APPEND optixSubd_SOURCES
220240 args.cpp
221241 args.h
222- denoiserstub .h
223- denoiserstub .cu
242+ denoiser .h
243+ denoiserAccum .cu
224244 GBuffer.cu
225245 GBuffer.h
226246 GBuffer.cuh
@@ -241,10 +261,14 @@ list( APPEND optixSubd_SOURCES
241261 version .cpp
242262)
243263
264+ if (DLSS_FOUND AND ENABLE_DLSS)
265+ list (APPEND optixSubd_SOURCES denoiserDlss.cu)
266+ endif ()
244267
245268add_executable ( optixSubd
246269 ${optixSubd_SOURCES}
247270 $<TARGET_OBJECTS:cluster_builder>
271+ $<TARGET_OBJECTS:depth>
248272 $<TARGET_OBJECTS:material>
249273 $<TARGET_OBJECTS:motionvec>
250274 $<TARGET_OBJECTS:profiler>
@@ -256,11 +280,13 @@ add_executable( optixSubd
256280target_include_directories ( optixSubd PRIVATE
257281 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} /EmbeddedDeviceCode
258282 ${CMAKE_CURRENT_SOURCE_DIR}
283+ ${CUDAToolkit_INCLUDE_DIRS} # Add CUDA include paths to help find system headers
259284)
260285
261286target_link_libraries ( optixSubd
262287 PRIVATE
263288 EmbeddedDeviceCode
289+ DepthPassDeviceCode
264290 OptiXToolkit::Gui
265291 OptiXToolkit::Util
266292 OptiXToolkit::ShaderUtil
@@ -274,6 +300,11 @@ target_link_libraries( optixSubd
274300 ${CMAKE_DL_LIBS}
275301)
276302
303+ if (DLSS_FOUND AND ENABLE_DLSS)
304+ target_compile_definitions (optixSubd PRIVATE DLSS_ENABLED)
305+ target_link_libraries (optixSubd PRIVATE DLSS::DLSS)
306+ dlss_setup_runtime_dependencies(optixSubd)
307+ endif ()
277308
278309# Optionally link tbb for parallel C++17 algorithms on gcc
279310if ( TBB_FOUND )
@@ -301,6 +332,7 @@ endif()
301332# dependencies are not compatible with more strict warnings.
302333foreach (TARGET
303334 #cluster_builder
335+ depth
304336 material
305337 motionvec
306338 profiler
0 commit comments