-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
192 lines (173 loc) · 8.31 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#
# Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.10)
project(StreamlineSample)
# Variables
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/_bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(DONUT_SHADERS_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/shaders/framework")
if (MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_ITERATOR_DEBUG_LEVEL=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /MP")
endif()
set(PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/_package")
# Do not install additional libraries
option(NVRHI_INSTALL "Generate install rules for NVRHI" OFF)
option(JSONCPP_WITH_CMAKE_PACKAGE "" OFF)
option(JSONCPP_WITH_PKGCONFIG_SUPPORT "" OFF)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/_extra_install")
# Overide donut options
option(STREAMLINE_FEATURE_DLSS_SR "Include DLSS-SR dll" ON)
option(STREAMLINE_FEATURE_IMGUI "Include Imgui dll" ON)
option(STREAMLINE_FEATURE_NVPERF "Include NSight Perf SDK dll" ON)
option(STREAMLINE_FEATURE_REFLEX "Include Reflex dll" ON)
option(STREAMLINE_FEATURE_NIS "Include NIS dll" ON)
option(STREAMLINE_FEATURE_DEEPDVC "Include DEEPDVC dll" ON)
# DLSS-FG will take precedence over Latewarp if both are enabled at the same time
# Be sure to clean the output dir when toggling flags, as sl.dlss_g.dll will override sl.latewarp.dll
option(STREAMLINE_FEATURE_DLSS_FG "Include DLSS-FG dll" ON)
option(STREAMLINE_FEATURE_LATEWARP "Include Latewarp dll" OFF)
if(STREAMLINE_FEATURE_DLSS_SR)
add_compile_definitions(STREAMLINE_FEATURE_DLSS_SR)
endif()
if(STREAMLINE_FEATURE_IMGUI)
add_compile_definitions(STREAMLINE_FEATURE_IMGUI)
endif()
if(STREAMLINE_FEATURE_NVPERF)
add_compile_definitions(STREAMLINE_FEATURE_NVPERF)
endif()
if(STREAMLINE_FEATURE_REFLEX)
add_compile_definitions(STREAMLINE_FEATURE_REFLEX)
endif()
if(STREAMLINE_FEATURE_NIS)
add_compile_definitions(STREAMLINE_FEATURE_NIS)
endif()
if (STREAMLINE_FEATURE_DLSS_FG)
add_compile_definitions(STREAMLINE_FEATURE_DLSS_FG)
endif()
if(STREAMLINE_FEATURE_DEEPDVC)
add_compile_definitions(STREAMLINE_FEATURE_DEEPDVC)
endif()
if(STREAMLINE_FEATURE_LATEWARP)
add_compile_definitions(STREAMLINE_FEATURE_LATEWARP)
endif()
set(STREAMLINE_INSTALL_DIR "${PACKAGE_DIRECTORY}/_bin" CACHE STRING "Streamline Install Dir")
# Override vulkan dll used by glfw
add_compile_definitions(_GLFW_VULKAN_LIBRARY="sl.interposer.dll")
# Add libraries
add_subdirectory(donut)
add_subdirectory(streamline)
# Apply Patch for VK support
set(success OFF)
find_package(Git)
message(STATUS "Found Git for patching: ${GIT_EXECUTABLE}")
if(Git_FOUND)
set(status 1)
execute_process(
COMMAND ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_SOURCE_DIR}/VKpatch.patch
RESULT_VARIABLE status
ERROR_QUIET
)
if(${status} EQUAL "0")
set(success ON)
message(STATUS "Successfully applied VKPatch.patch")
endif()
endif()
if(NOT success)
message("WARNING: Failed to apply VKPatch.patch. It is possible patch has already been applied, otherwise Streamline may fail with Vulkan.")
endif()
# Remove d3d linking from donut and relink with streamline
get_target_property(TARGET_LIBRARIES donut_app LINK_LIBRARIES)
LIST(REMOVE_ITEM TARGET_LIBRARIES d3d11)
LIST(REMOVE_ITEM TARGET_LIBRARIES d3d12)
LIST(REMOVE_ITEM TARGET_LIBRARIES dxgi)
set_property(TARGET donut_app PROPERTY LINK_LIBRARIES ${TARGET_LIBRARIES} )
# Collect Code
file(GLOB src_header
"src/StreamlineSample.h"
"src/SLWrapper.h"
"src/UIRenderer.h"
"src/RenderTargets.h"
"src/UIData.h"
)
file(GLOB src_source
"src/main.cpp"
"src/StreamlineSample.cpp"
"src/SLWrapper.cpp"
)
file(GLOB src_overrides
"src/DeviceManagerOverride/DeviceManagerOverride.h"
"src/DeviceManagerOverride/DeviceManagerOverride_DX11.cpp"
"src/DeviceManagerOverride/DeviceManagerOverride_DX12.cpp"
"src/DeviceManagerOverride/DeviceManagerOverride_VK.cpp"
)
# Create exe and link
add_executable(StreamlineSample WIN32 ${src_header} ${src_source} ${src_overrides})
source_group("Headers" FILES ${src_header})
source_group("Sources" FILES ${src_source})
source_group("DeviceManagerOverride" FILES ${src_overrides})
# Add AGS
option(AMD_AGS "Add AMD AGS support" OFF)
if(AMD_AGS)
set(AGS_DIR "${CMAKE_SOURCE_DIR}/amd_ags/ags_lib")
find_library(AGS_LIB amd_ags_x64 HINTS "${AGS_DIR}/lib" NO_CACHE)
if(AGS_LIB)
find_path(AGS_INCLUDE_DIR "amd_ags.h" HINTS "${AGS_DIR}/inc" NO_CACHE)
find_file(AGS_DLL "amd_ags_x64.dll" HINTS "${AGS_DIR}/lib" NO_CACHE)
add_library(amd_ags STATIC IMPORTED GLOBAL)
set_target_properties(amd_ags
PROPERTIES
IMPORTED_LOCATION "${AGS_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${AGS_INCLUDE_DIR}")
add_compile_definitions(AGS_ENABLE)
install(FILES ${AGS_DLL} DESTINATION "${STREAMLINE_INSTALL_DIR}")
else()
comment("Warning: Failed to find AMD AGS")
endif()
target_link_libraries(StreamlineSample amd_ags)
if (WIN32)
add_custom_target(CopyAGSdll ALL DEPENDS ${AGS_DLL})
add_custom_command(TARGET CopyAGSdll
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${AGS_DLL} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMENT "Copied DLL: ${AGS_DLL}")
add_dependencies(StreamlineSample CopyAGSdll)
endif ()
endif()
target_link_libraries(StreamlineSample donut_render donut_app donut_engine streamline)
set_target_properties(StreamlineSample PROPERTIES FOLDER "Streamline Sample")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT StreamlineSample)
# Install
install(TARGETS StreamlineSample DESTINATION "${PACKAGE_DIRECTORY}/_bin")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/_bin/shaders" DESTINATION "${PACKAGE_DIRECTORY}/_bin")
install(FILES "${CMAKE_SOURCE_DIR}/media/sponza-plus.scene.json" DESTINATION "${PACKAGE_DIRECTORY}/media")
install(FILES "${CMAKE_SOURCE_DIR}/media/fonts/DroidSans/DroidSans-Mono.ttf" DESTINATION "${PACKAGE_DIRECTORY}/media/fonts/DroidSans")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/media/glTF-Sample-Models/2.0/Sponza" DESTINATION "${PACKAGE_DIRECTORY}/media/glTF-Sample-Models/2.0")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/media/glTF-Sample-Models/2.0/BrainStem" DESTINATION "${PACKAGE_DIRECTORY}/media/glTF-Sample-Models/2.0")
install(FILES "${CMAKE_SOURCE_DIR}/run.bat" DESTINATION "${PACKAGE_DIRECTORY}")
install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION "${PACKAGE_DIRECTORY}")
install(FILES "${CMAKE_SOURCE_DIR}/NVIDIA RTX SDKs License (12Apr2021).txt" DESTINATION "${PACKAGE_DIRECTORY}")
install(FILES "${CMAKE_SOURCE_DIR}/release.txt" DESTINATION "${PACKAGE_DIRECTORY}")