@@ -36,10 +36,6 @@ if (RGL_ENABLE_WEBGPU)
36
36
set (RGL_WEBGPU_AVAILABLE ON CACHE INTERNAL "RGL WebGPU" )
37
37
endif ()
38
38
39
- if (RGL_RUNTIME_COMPILATION )
40
- set (RGL_RUNTIME_COMPILER_LIB "librglc" )
41
- endif ()
42
-
43
39
if (CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" )
44
40
set (RGL_DISABLE_VK ON CACHE INTERNAL "" )
45
41
endif ()
@@ -66,6 +62,13 @@ else()
66
62
set (ST_ENABLE_WGSL OFF CACHE INTERNAL "" )
67
63
endif ()
68
64
set (ST_ENABLE_TEST OFF CACHE INTERNAL "" )
65
+ if ((WIN32 AND NOT WINDOWS_STORE ) AND EXISTS "${CMAKE_CURRENT_LIST_DIR} /deps/ShaderTranspiler/deps/DirectXShaderCompiler/CMakeLists.txt" )
66
+ message ("Building DXC from source" )
67
+ set (ST_BUNDLED_DXC ON )
68
+ else ()
69
+ message ("Not building DXC from source" )
70
+ set (ST_BUNDLED_DXC OFF )
71
+ endif ()
69
72
add_subdirectory (deps/ShaderTranspiler EXCLUDE_FROM_ALL )
70
73
file (GLOB_RECURSE LIBRGLC_SOURCES "tools/librglc/*.cpp" "tools/librglc/*.hpp" )
71
74
add_library (librglc ${LIBRGLC_SOURCES} )
@@ -95,57 +98,80 @@ if (RGL_ENABLE_RGLC)
95
98
)
96
99
endif ()
97
100
98
- find_package (Vulkan )
99
-
100
- if (CMAKE_SYSTEM_NAME MATCHES "WindowsStore" OR RGL_DISABLE_VK OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "Emscripten" )
101
+ if (WINDOWS_STORE OR RGL_DISABLE_VK OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "Emscripten" )
101
102
set (VK_FORCE_DISABLED ON )
102
103
else ()
103
104
set (VK_FORCE_DISABLED OFF )
104
105
endif ()
105
106
106
- if (NOT VK_FORCE_DISABLED AND Vulkan_FOUND )
107
-
108
-
109
- set (VK_LIBS ${Vulkan_LIBRARIES} VulkanMemoryAllocator )
107
+ if (NOT VK_FORCE_DISABLED )
108
+ add_subdirectory (deps/volk EXCLUDE_FROM_ALL )
109
+ target_compile_definitions (volk PUBLIC NOMINMAX=1 )
110
110
111
111
# Get our vendored headers
112
- set (VK_INCLUDE deps/VulkanMemoryAllocator/include deps/Vulkan-Headers/include deps/Vulkan-Utility-Libraries/include )
112
+ set (VK_INCLUDE deps/Vulkan-Headers/include deps/Vulkan-Utility-Libraries/include )
113
+ target_include_directories (volk PUBLIC ${VK_INCLUDE} )
114
+ if (LINUX )
115
+ target_compile_definitions (volk PRIVATE VK_USE_PLATFORM_XLIB_KHR VK_USE_PLATFORM_WAYLAND_KHR )
116
+ elseif (ANDROID )
117
+ target_compile_definitions (volk PRIVATE VK_USE_PLATFORM_ANDROID_KHR )
118
+ elseif (WIN32 OR WINDOWS_STORE )
119
+ target_compile_definitions (volk PRIVATE VK_USE_PLATFORM_WIN32_KHR )
120
+ endif ()
113
121
114
- target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_VK_AVAILABLE=1 )
122
+ target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_VK_AVAILABLE=1 )
115
123
set (RGL_VK_AVAILABLE ON CACHE INTERNAL "RGL Vulkan" )
116
- set (VMA_STATIC_VULKAN_FUNCTIONS ON )
117
124
add_subdirectory (deps/VulkanMemoryAllocator EXCLUDE_FROM_ALL )
118
- target_include_directories (VulkanMemoryAllocator PUBLIC ${Vulkan_INCLUDE_DIRS} )
119
- target_include_directories (${PROJECT_NAME} PUBLIC ${Vulkan_INCLUDE_DIRS} ) # so that library users get the vk paths if applicable
120
- target_compile_features (VulkanMemoryAllocator PUBLIC cxx_std_20 )
125
+ target_compile_definitions (VulkanMemoryAllocator INTERFACE VMA_STATIC_VULKAN_FUNCTIONS=0 VMA_DYNAMIC_VULKAN_FUNCTIONS=0 )
126
+
127
+ target_link_libraries (${PROJECT_NAME}
128
+ PUBLIC
129
+ volk
130
+ PRIVATE
131
+ GPUOpen::VulkanMemoryAllocator
132
+ )
133
+
134
+ set_target_properties (VulkanMemoryAllocator volk PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
135
+ if (TARGET loader-opt )
136
+ set_target_properties (loader-opt loader-unknown-chain PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
137
+ endif ()
138
+ if (RGL_USE_MINIVKSDK )
139
+ set_target_properties (vulkan vvl VkLayer_utils loader_asm_gen_files PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
140
+ endif ()
121
141
else ()
122
142
target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_VK_AVAILABLE=0 )
123
143
set (RGL_VK_AVAILABLE OFF CACHE INTERNAL "RGL Vulkan" )
124
144
endif ()
125
145
126
146
if (MSVC AND NOT RGL_DISABLE_DX )
127
147
add_subdirectory (deps/DirectX-Headers EXCLUDE_FROM_ALL )
128
- set (DX12_LIBRARIES "d3d12.lib" "DirectX-Headers" "DirectX-Guids" "dxgi.lib" "d3dcompiler.lib" "D3D12MemoryAllocator" "DirectXTK12" )
129
148
target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_DX12_AVAILABLE=1 )
130
149
131
150
set (RGL_DX12_AVAILABLE ON CACHE INTERNAL "RGL DX12" )
132
151
add_subdirectory ("deps/D3D12MemoryAllocator" EXCLUDE_FROM_ALL )
133
152
set (BUILD_XAUDIO_WIN10 OFF CACHE INTERNAL "" )
134
153
add_subdirectory ("deps/DirectXTK12" EXCLUDE_FROM_ALL )
135
154
136
- set_target_properties ("DirectX-Guids" "DirectXTK12" PROPERTIES
137
- FOLDER "${RGL_IDE_ROOT} /Libraries"
138
- )
139
155
target_include_directories (${PROJECT_NAME} PUBLIC "deps/DirectXTK12/Inc" )
140
156
141
157
# PIX stuff
142
-
143
158
add_subdirectory (deps/PixEvents-cmake )
144
- set (PIXLIB $< $< NOT:$< CONFIG:release> > :WinPixEventRuntime> )
145
159
146
- set_target_properties ("WinPixEventRuntime" "WinPixEventRuntime_ETW" "PixDecoder" PROPERTIES
147
- FOLDER "${RGL_IDE_ROOT} /Libraries/"
148
- )
160
+ set_target_properties ("WinPixEventRuntime" "WinPixEventRuntime_ETW" "PixDecoder" "DirectX-Guids" "DirectXTK12" DirectX-Headers PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries/" )
161
+
162
+ target_link_libraries (${PROJECT_NAME}
163
+ PRIVATE
164
+ d3d12.lib
165
+ DirectX-Headers
166
+ DirectX-Guids
167
+ dxgi.lib
168
+ d3dcompiler.lib
169
+ D3D12MemoryAllocator
170
+ DirectXTK12
171
+ $< $< NOT:$< CONFIG:release> > :WinPixEventRuntime>
172
+ )
173
+
174
+ set_target_properties (D3D12MemoryAllocator PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
149
175
else ()
150
176
target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_DX12_AVAILABLE=0 )
151
177
set (RGL_DX12_AVAILABLE OFF CACHE INTERNAL "RGL DX12" )
@@ -158,6 +184,13 @@ if(APPLE)
158
184
find_library (METAL_LIB Metal REQUIRED )
159
185
find_library (QZC_LIB QuartzCore REQUIRED )
160
186
set (RGL_MTL_AVAILABLE ON CACHE INTERNAL "RGL Metal" )
187
+
188
+ target_link_libraries (${PROJECT_NAME}
189
+ PRIVATE
190
+ ${FOUNDATION_LIB}
191
+ ${METAL_LIB}
192
+ ${QZC_LIB}
193
+ )
161
194
else ()
162
195
target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_MTL_AVAILABLE=0 )
163
196
set (RGL_MTL_AVAILABLE OFF CACHE INTERNAL "RGL Metal" )
@@ -169,23 +202,17 @@ else()
169
202
target_compile_definitions (${PROJECT_NAME} PUBLIC RGL_WEBGPU_AVAILABLE=0 )
170
203
endif ()
171
204
172
- target_link_libraries (${PROJECT_NAME} PRIVATE
173
- ${VK_LIBS}
174
- ${DX12_LIBRARIES}
175
- ${FOUNDATION_LIB}
176
- ${METAL_LIB}
177
- ${QZC_LIB}
178
- ${X11_LIBRARIES}
179
- ${RGL_RUNTIME_COMPILER_LIB}
180
- ${PIXLIB}
181
- SPIRV-Reflect
182
- )
183
-
184
- if (APPLE )
185
- target_include_directories (${PROJECT_NAME} PRIVATE "tools/librglc/include/" )
186
205
if (RGL_RUNTIME_COMPILATION )
187
- target_compile_definitions (${PROJECT_NAME} PRIVATE "RGL_CAN_RUNTIME_COMPILE" )
206
+ target_link_libraries (${PROJECT_NAME} PRIVATE librglc )
188
207
endif ()
208
+
209
+ target_link_libraries (${PROJECT_NAME} PRIVATE SPIRV-Reflect ${X11_LIBRARIES} )
210
+
211
+ if (APPLE )
212
+ target_include_directories (${PROJECT_NAME} PRIVATE "tools/librglc/include/" )
213
+ if (RGL_RUNTIME_COMPILATION )
214
+ target_compile_definitions (${PROJECT_NAME} PRIVATE "RGL_CAN_RUNTIME_COMPILE" )
215
+ endif ()
189
216
endif ()
190
217
191
218
set (AFTERMATH_DIR "AftermathSDK" )
@@ -211,6 +238,8 @@ target_include_directories(${PROJECT_NAME}
211
238
"include"
212
239
)
213
240
241
+ target_compile_definitions (${PROJECT_NAME} PUBLIC NOMINMAX=1 )
242
+
214
243
set_target_properties ("RGL" ${rglc_exe} "librglc" PROPERTIES
215
244
FOLDER "${RGL_IDE_ROOT} "
216
245
XCODE_GENERATE_SCHEME ON
@@ -224,7 +253,7 @@ set_target_properties("libtint" "tint_diagnostic_utils" PROPERTIES
224
253
)
225
254
endif ()
226
255
227
- set_target_properties ("GenericCodeGen" "glslang" "MachineIndependent " "OGLCompiler " "OSDependent" "SPIRV" "SPVRemapper" "glslang-default-resource-limits" PROPERTIES
256
+ set_target_properties ("GenericCodeGen" "glslang" "OGLCompiler " "MachineIndependent " "OSDependent" "SPIRV" "SPVRemapper" "glslang-default-resource-limits" PROPERTIES
228
257
FOLDER "${RGL_IDE_ROOT} /Libraries/glslang"
229
258
)
230
259
@@ -237,12 +266,12 @@ set_target_properties(
237
266
238
267
set_target_properties (
239
268
"spirv-cross-core"
240
- "spirv-cross-glsl" "spirv-cross-hlsl" "spirv-cross-msl" "spirv-cross-reflect" "spirv-cross-cpp" "spirv-cross-util" "HLSL"
269
+ "spirv-cross-glsl" "spirv-cross-hlsl" "spirv-cross-msl" "spirv-cross-reflect" "spirv-cross-cpp" "spirv-cross-util"
241
270
PROPERTIES
242
271
FOLDER "${RGL_IDE_ROOT} /Libraries/SPIRV-Cross"
243
272
)
244
273
245
- if (ST_BUNDLED_DXC )
274
+ if (ST_BUNDLED_DXC AND NOT WINDOWS_STORE )
246
275
function (dxc_set_for_dir DIR )
247
276
get_property (TGTS DIRECTORY "${DIR} " PROPERTY BUILDSYSTEM_TARGETS )
248
277
set_target_properties (
@@ -259,20 +288,6 @@ if(ST_BUNDLED_DXC)
259
288
dxc_set_for_dir ("${CMAKE_CURRENT_LIST_DIR} /deps/ShaderTranspiler/deps/DirectXShaderCompiler" )
260
289
endif ()
261
290
262
- if (RGL_VK_AVAILABLE )
263
- set_target_properties (VulkanMemoryAllocator PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
264
- if (TARGET loader-opt )
265
- set_target_properties (loader-opt loader-unknown-chain PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
266
- endif ()
267
- if (RGL_USE_MINIVKSDK )
268
- set_target_properties (vulkan vvl VkLayer_utils loader_asm_gen_files PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
269
- endif ()
270
- endif ()
271
- if (RGL_DX12_AVAILABLE )
272
- set_target_properties (D3D12MemoryAllocator PROPERTIES FOLDER "${RGL_IDE_ROOT} /Libraries" )
273
- endif ()
274
-
275
-
276
291
if (NOT RGL_SKIP_BACKEND_CHECK )
277
292
if (RGL_VK_AVAILABLE OR RGL_DX12_AVAILABLE OR RGL_MTL_AVAILABLE OR RGL_WEBGPU_AVAILABLE )
278
293
else ()
0 commit comments