forked from vs-shirokii/RTGL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
311 lines (273 loc) · 10.3 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
cmake_minimum_required(VERSION 3.20)
project(RayTracedGL1 CXX C)
set(CMAKE_CXX_STANDARD 23)
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE )
include(CheckIPOSupported)
check_ipo_supported()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)
set(PublicHeaders
Include/RTGL1/RTGL1.h
)
set(Sources
"Source/RTGL1.cpp"
"Source/RTGL1A.cpp"
"Source/VulkanDevice.cpp"
"Source/VulkanDevice_Init.cpp"
"Source/Buffer.cpp"
"Source/Scene.cpp"
"Source/PhysicalDevice.cpp"
"Source/Queues.cpp"
"Source/Swapchain.cpp"
"Source/GlobalUniform.cpp"
"Source/CommandBufferManager.cpp"
"Source/ShaderManager.cpp"
"Source/RayTracingPipeline.cpp"
"Source/VertexCollector.cpp"
"Source/ASManager.cpp"
"Source/VertexCollectorFilter.cpp"
"Source/ASBuilder.cpp"
"Source/ScratchBuffer.cpp"
"Source/Utils.cpp"
"Source/PathTracer.cpp"
"Source/Common.cpp"
"Source/Matrix.cpp"
"Source/Rasterizer.cpp"
"Source/RasterizedDataCollector.cpp"
"Source/Vma/vk_mem_alloc_imp.cpp"
"Source/ImageLoader.cpp"
"Source/TextureManager.cpp"
"Source/MemoryAllocator.cpp"
"Source/SamplerManager.cpp"
"Source/TextureOverrides.cpp"
"Source/TextureDescriptors.cpp"
"Source/TextureUploader.cpp"
"Source/VertexCollectorFilterType.cpp"
"Source/Generated/ShaderCommonCFramebuf.cpp"
"Source/Framebuffers.cpp"
"Source/BlueNoise.cpp"
"Source/ImageComposition.cpp"
"Source/Tonemapping.cpp"
"Source/LightManager.cpp"
"Source/AutoBuffer.cpp"
"Source/ASComponent.cpp"
"Source/CubemapManager.cpp"
"Source/CubemapUploader.cpp"
"Source/GeomInfoManager.cpp"
"Source/VertexPreprocessing.cpp"
"Source/Denoiser.cpp"
"Source/RasterizerPipelines.cpp"
"Source/RenderCubemap.cpp"
"Source/DepthCopying.cpp"
"Source/RasterPass.cpp"
"Source/SwapchainPass.cpp"
"Source/RgException.cpp"
"Source/Bloom.cpp"
"Source/Sharpening.cpp"
"Source/DLSS2.cpp"
"Source/DLSS3_DX12.cpp"
"Source/HaltonSequence.cpp"
"Source/LensFlares.cpp"
"Source/DecalManager.cpp"
"Source/EffectBase.cpp"
"Source/LightGrid.cpp"
"Source/FSR2.cpp"
"Source/FSR3_DX12.cpp"
"Source/Stb/stb_image.cpp"
"Source/Stb/stb_image_write.cpp"
"Source/ImageLoaderDev.cpp"
"Source/PortalList.cpp"
"Source/RestirBuffers.cpp"
"Source/Volumetric.cpp"
"Source/DebugWindows.cpp"
"Source/ScratchImmediate.cpp"
"Source/GltfExporter.cpp"
"Source/GltfImporter.cpp"
"Source/FolderObserver.cpp"
"Source/TextureExporter.cpp"
"Source/TextureMeta.cpp"
"Source/VulkanDevice_Dev.cpp"
"Source/SceneMeta.cpp"
"Source/Fluid.cpp"
"Source/DX12_Swapchain.cpp"
"Source/DX12_Vulkan.cpp"
)
set(KTXSourceFolder Source/KTX/lib)
set(KTXSources
"${KTXSourceFolder}/texture.c"
"${KTXSourceFolder}/texture1.c"
"${KTXSourceFolder}/texture2.c"
"${KTXSourceFolder}/hashlist.c"
"${KTXSourceFolder}/checkheader.c"
"${KTXSourceFolder}/swap.c"
"${KTXSourceFolder}/memstream.c"
"${KTXSourceFolder}/filestream.c"
"${KTXSourceFolder}/vkloader.c"
"${KTXSourceFolder}/vk_funcs.c"
"${KTXSourceFolder}/basisu/zstd/zstd.c"
"${KTXSourceFolder}/dfdutils/createdfd.c"
"${KTXSourceFolder}/dfdutils/interpretdfd.c"
"${KTXSourceFolder}/dfdutils/queries.c"
"${KTXSourceFolder}/dfdutils/vk2dfd.c"
)
option(RG_WITH_EXPORTS "Compile library for export" ON)
option(RG_WITH_SURFACE_WIN32 "Build with Win32 VkSurfaceKHR support" OFF)
option(RG_WITH_SURFACE_METAL "Build with Metal VkSurfaceKHR support" OFF)
option(RG_WITH_SURFACE_WAYLAND "Build with Wayland VkSurfaceKHR support" OFF)
option(RG_WITH_SURFACE_XCB "Build with Xcb VkSurfaceKHR support" OFF)
option(RG_WITH_SURFACE_XLIB "Build with Xlib VkSurfaceKHR support" OFF)
option(RG_WITH_IMGUI "Build RTGL1 with ImGui debug windows" ON)
option(RG_WITH_DX12 "Build RTGL1 with DX12 features" ON)
option(RG_WITH_NATIVE_DLSS "Build RTGL1 with native DLSS2" ON)
option(RG_WITH_EXAMPLES "Build with examples executable" ON)
# for KTX-Software
add_definitions(-DKHRONOS_STATIC -DLIBKTX)
# options to definitions
if (RG_WITH_EXPORTS)
message(STATUS "RG_WITH_EXPORTS enabled. RTGL1 functions are exported.")
add_definitions(-DRG_LIBRARY_EXPORTS)
endif()
if (RG_WITH_SURFACE_WIN32)
message(STATUS "RG_WITH_SURFACE_WIN32 enabled")
add_definitions(-DNOMINMAX)
add_definitions(-DRG_USE_SURFACE_WIN32)
add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
endif()
if (RG_WITH_SURFACE_METAL)
message(STATUS "RG_WITH_SURFACE_METAL enabled")
add_definitions(-DRG_USE_SURFACE_METAL)
add_definitions(-DVK_USE_PLATFORM_METAL_EXT)
endif()
if (RG_WITH_SURFACE_WAYLAND)
message(STATUS "RG_WITH_SURFACE_WAYLAND enabled")
add_definitions(-DRG_USE_SURFACE_WAYLAND)
add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR)
endif()
if (RG_WITH_SURFACE_XCB)
message(STATUS "RG_WITH_SURFACE_XCB enabled")
add_definitions(-DRG_USE_SURFACE_XCB)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
if (RG_WITH_SURFACE_XLIB)
message(STATUS "RG_WITH_SURFACE_XLIB enabled")
add_definitions(-DRG_USE_SURFACE_XLIB)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
endif()
# Vulkan
message(STATUS "Adding Vulkan. VulkanSDK: $ENV{VULKAN_SDK}")
find_package(Vulkan REQUIRED)
add_library(Vulkan INTERFACE)
target_include_directories(Vulkan INTERFACE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(Vulkan INTERFACE ${Vulkan_LIBRARIES})
# DirectX 12
if (RG_WITH_DX12)
message(STATUS "RG_WITH_DX12 enabled")
add_definitions(-DRG_USE_DX12)
set(D3D12_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
find_package(D3D12 REQUIRED)
add_library(D3D12 INTERFACE)
target_include_directories(D3D12 INTERFACE "Source/DX12/include/directx")
target_link_libraries(D3D12 INTERFACE ${D3D12_LIBRARIES})
endif()
# Imgui
if (RG_WITH_IMGUI)
message(STATUS "RG_WITH_IMGUI enabled")
add_definitions(-DRG_USE_IMGUI)
set(ImGuiSourceFolder Source/imgui)
add_library(ImGui STATIC)
target_sources(ImGui PRIVATE
${ImGuiSourceFolder}/imgui_demo.cpp
${ImGuiSourceFolder}/imgui_draw.cpp
${ImGuiSourceFolder}/imgui_tables.cpp
${ImGuiSourceFolder}/imgui_widgets.cpp
${ImGuiSourceFolder}/imgui.cpp
${ImGuiSourceFolder}/backends/imgui_impl_vulkan.cpp
${ImGuiSourceFolder}/backends/imgui_impl_glfw.cpp
)
target_include_directories(ImGui PUBLIC ${ImGuiSourceFolder} ${ImGuiSourceFolder}/backends)
# Use Vulkan and GLFW as ImGui backend
target_link_libraries(ImGui PUBLIC Vulkan)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
add_subdirectory(Source/glfw)
target_link_libraries(ImGui PRIVATE glfw)
target_include_directories(ImGui PRIVATE glfw)
endif()
add_library(RayTracedGL1 SHARED
${Sources}
${KTXSources}
${PublicHeaders}
)
set(LibraryName "RTGL1")
add_definitions(-DRG_LIBRARY_NAME="${LibraryName}")
set_target_properties(RayTracedGL1 PROPERTIES
OUTPUT_NAME ${LibraryName}
)
set_target_properties(RayTracedGL1 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY $<IF:$<CONFIG:Debug>,${CMAKE_SOURCE_DIR}/Build/bin/debug,${CMAKE_SOURCE_DIR}/Build/bin>
)
target_include_directories(RayTracedGL1 PUBLIC "Include")
# Vulkan
target_link_libraries(RayTracedGL1 PUBLIC Vulkan)
# DirectX
if (RG_WITH_DX12)
target_link_libraries(RayTracedGL1 PRIVATE D3D12)
endif()
# GLM
target_include_directories(RayTracedGL1 PRIVATE Source/glm)
# KTX
target_include_directories(RayTracedGL1 PRIVATE "Source/KTX/include")
target_include_directories(RayTracedGL1 PRIVATE "Source/KTX/include" "Source/KTX/other_include" "Source/KTX/lib/basisu/zstd")
# DLSS
target_include_directories(RayTracedGL1 PRIVATE "Source/Streamline/include")
if (RG_WITH_NATIVE_DLSS AND DEFINED ENV{DLSS_SDK_PATH})
message(STATUS "Found Native DLSS SDK: $ENV{DLSS_SDK_PATH}")
target_include_directories(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/include")
add_definitions(-DRG_USE_NATIVE_DLSS2)
if (WIN32)
if (BUILD_TYPE STREQUAL "DEBUG")
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d_dbg.lib")
else()
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Windows_x86_64/x86_64/nvsdk_ngx_d.lib")
endif()
else()
target_link_libraries(RayTracedGL1 PRIVATE "$ENV{DLSS_SDK_PATH}/lib/Linux_x86_64/libnvsdk_ngx.a")
target_link_libraries(RayTracedGL1 PRIVATE ${CMAKE_DL_LIBS})
endif()
endif()
# FSR2
target_include_directories(RayTracedGL1 PRIVATE "Source/FSR2/include" )
# Debug windows - ImGui
if (RG_WITH_IMGUI)
target_link_libraries(RayTracedGL1 PRIVATE ImGui)
target_include_directories(RayTracedGL1 PRIVATE ImGui)
target_link_libraries(RayTracedGL1 PRIVATE glfw)
target_include_directories(RayTracedGL1 PRIVATE glfw)
endif()
# Json parser - glaze
add_library(GlazeWrapper STATIC "Source/JsonParser.cpp")
add_subdirectory(Source/glaze)
target_include_directories(GlazeWrapper PRIVATE "Include")
target_link_libraries(GlazeWrapper PRIVATE glaze::glaze)
target_link_libraries(RayTracedGL1 PRIVATE GlazeWrapper)
if (RG_WITH_EXAMPLES)
message(STATUS "RG_WITH_EXAMPLES enabled")
add_definitions(-DASSET_DIRECTORY="../")
add_executable(RtglExample Tests/RtglTest.cpp)
set_property(TARGET RtglExample PROPERTY CXX_STANDARD 20)
target_link_libraries(RtglExample glfw)
target_include_directories(ImGui PRIVATE glfw)
target_include_directories(RtglExample PRIVATE "Include" )
target_include_directories(RtglExample PUBLIC Source/glm)
# not needed, but let RtglExample be built after RayTracedGL1
add_dependencies(RtglExample RayTracedGL1)
endif()
# VS hot-reload - disabled because of glaze
if (MSVC AND WIN32 AND NOT MSVC_VERSION VERSION_LESS 142)
target_link_options(RayTracedGL1 PRIVATE $<$<CONFIG:Debug>:/INCREMENTAL>)
target_compile_options(RayTracedGL1 PRIVATE $<$<CONFIG:Debug>:/ZI>)
target_link_options(RtglExample PRIVATE $<$<CONFIG:Debug>:/INCREMENTAL>)
target_compile_options(RtglExample PRIVATE $<$<CONFIG:Debug>:/ZI>)
endif()