Skip to content

Commit b70d07f

Browse files
Hide platform dependent details of IAPIConnection
Also fix the Vulkan SDK issue once and for all.
1 parent cbad935 commit b70d07f

File tree

9 files changed

+84
-61
lines changed

9 files changed

+84
-61
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@
8989
[submodule "3rdparty/pstl/oneDPL/oneDPL"]
9090
path = 3rdparty/pstl/oneDPL/oneDPL
9191
url = https://github.com/Devsh-Graphics-Programming/oneDPL.git
92+
[submodule "3rdparty/Vulkan-Headers"]
93+
path = 3rdparty/Vulkan-Headers
94+
url = [email protected]:KhronosGroup/Vulkan-Headers.git
95+
branch = main

3rdparty/CMakeLists.txt

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,30 @@ set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS})
4747
set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS})
4848
set(BUILD_TESTING ${_OLD_BUILD_TESTING})
4949

50+
5051
# openssl
5152
add_subdirectory(openssl openssl EXCLUDE_FROM_ALL)
5253

54+
5355
# volk
54-
if(DEFINED ENV{VULKAN_SDK})
55-
# workaround to make sure vulkan library will not be linked in examples
56-
set(VOLK_PULL_IN_VULKAN OFF CACHE INTERNAL "" FORCE)
57-
58-
if (WIN32)
59-
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
60-
endif()
61-
add_subdirectory(volk volk EXCLUDE_FROM_ALL)
56+
set(VOLK_PULL_IN_VULKAN OFF CACHE INTERNAL "" FORCE) # Needed to make sure vulkan library will not be linked in examples
6257

63-
target_include_directories(volk PUBLIC "$ENV{VULKAN_SDK}/Include")
64-
target_include_directories(volk_headers INTERFACE "$ENV{VULKAN_SDK}/Include")
58+
if (WIN32)
59+
set(VOLK_STATIC_DEFINES VK_USE_PLATFORM_WIN32_KHR)
6560
endif()
61+
add_subdirectory(volk volk EXCLUDE_FROM_ALL)
62+
63+
target_include_directories(volk PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include")
64+
target_include_directories(volk_headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include")
6665

6766
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
6867
add_subdirectory(pstl pstl)
6968
endif()
7069

70+
71+
# TODO: redo
7172
find_package(OpenGL OPTIONAL_COMPONENTS EGL)
72-
find_package(Wayland) # TODO: remove, do it dynamically
73+
find_package(Wayland) # TODO: remove, load Wayland dynamically
7374
#[[if (OpenGL_EGL_FOUND)
7475
message(FATAL_ERROR "FOUND EGL!!")
7576
else()
@@ -85,8 +86,10 @@ if (OpenGL_EGL_FOUND AND UNIX AND NOT APPLE)
8586
message(FATAL_ERROR "Using Wayland backend!!!")
8687
endif()
8788
endif()
89+
# all of the above fuckery can be dismissed
8890
add_subdirectory(EGL/EGL)
8991

92+
9093
# zlib (target is zlibstatic)
9194
set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
9295
set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL})
@@ -139,6 +142,7 @@ set(ZLIB_LIBRARY # for PNGLIB purposes
139142
$<$<CONFIG:RelWithDebInfo>:${ZLIB_LIBRARY_RELWITHDEBINFO}>
140143
CACHE INTERNAL "" FORCE)
141144

145+
142146
set(SPIRV_HEADERS_SKIP_INSTALL ON CACHE INTERNAL "Skip SPIRV-Headers install")
143147
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE INTERNAL "Skip SPIRV-Headers examples")
144148
add_subdirectory(SPIRV-Headers SPIRV-Headers EXCLUDE_FROM_ALL)
@@ -164,6 +168,7 @@ if (UNIX)
164168
endif()
165169
add_subdirectory(shaderc shaderc EXCLUDE_FROM_ALL)
166170

171+
167172
# libjpeg-turbo
168173
option(WITH_SIMD "libjpeg-turbo" ON)
169174
option(WITH_MEM_SRCDST "libjpeg-turbo" ON)
@@ -179,13 +184,15 @@ add_subdirectory(libjpeg-turbo libjpeg-turbo EXCLUDE_FROM_ALL)
179184
unset(CMAKE_INSTALL_DOCDIR)
180185
unset(CMAKE_INSTALL_MANDIR)
181186

187+
182188
#manipulating libpng cmake options from within cmake script
183189
set(PNG_BUILD_ZLIB ON CACHE INTERNAL "" FORCE) # get ZLIB from our /3rdparty
184190
option(PNG_SHARED "Build shared lib" OFF)
185191
option(PNG_TESTS "Build libpng tests" OFF)
186192
add_subdirectory(libpng libpng EXCLUDE_FROM_ALL)
187193
add_dependencies(png_static zlibstatic)
188194

195+
189196
#openexr
190197
option(_NBL_COMPILE_WITH_OPEN_EXR_ "Build with OpenEXR library" ON)
191198
if (_NBL_COMPILE_WITH_OPEN_EXR_)
@@ -204,6 +211,7 @@ if (_NBL_COMPILE_WITH_OPEN_EXR_)
204211
set(BUILD_TESTING ${_OLD_BUILD_TESTING})
205212
endif()
206213

214+
207215
#gli
208216
option(_NBL_COMPILE_WITH_GLI_ "Build with GLI library" ON)
209217
if(_NBL_COMPILE_WITH_GLI_)
@@ -219,8 +227,10 @@ if(_NBL_COMPILE_WITH_GLI_)
219227
set(BUILD_TESTING ${_OLD_BUILD_TESTING})
220228
endif()
221229

230+
222231
nbl_adjust_flags()
223232

233+
224234
add_library(lzma OBJECT
225235
lzma/C/Alloc.c
226236
lzma/C/LzFind.c
@@ -229,13 +239,15 @@ add_library(lzma OBJECT
229239
)
230240
target_compile_definitions(lzma PRIVATE _7ZIP_ST)
231241

242+
232243
add_library(lz4 OBJECT
233244
lz4/lib/lz4.c
234245
lz4/lib/lz4frame.c
235246
lz4/lib/lz4hc.c
236247
lz4/lib/xxhash.c
237248
)
238249

250+
239251
add_library(bzip2 OBJECT
240252
bzip2/blocksort.c
241253
bzip2/bzlib.c
@@ -256,11 +268,13 @@ add_library(spirv_cross OBJECT
256268
)
257269
target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
258270

271+
259272
# TODO: remove
260273
add_library(convert_utf OBJECT
261274
convertutf/ConvertUTF.cpp
262275
)
263276

277+
264278
add_library(aesGladman OBJECT
265279
aesGladman/aes_ni.c
266280
aesGladman/aescrypt.c
@@ -279,6 +293,7 @@ option(GLM_TEST_ENABLE "Build unit tests" OFF)
279293
set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS})
280294
set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS})
281295

296+
282297
if (NBL_BUILD_MITSUBA_LOADER)
283298
if(NBL_UPDATE_GIT_SUBMODULE)
284299
update_git_submodule(./libexpat)
@@ -304,6 +319,7 @@ if (NBL_BUILD_MITSUBA_LOADER)
304319
set(MITSUBA_LOADER_DEPENDENT_LIBS ${MITSUBA_LOADER_DEPENDENT_LIBS} PARENT_SCOPE)
305320
endif()
306321

322+
307323
if (NBL_BUILD_BULLET)
308324
if(NBL_UPDATE_GIT_SUBMODULE)
309325
update_git_submodule(./bullet3)
@@ -322,6 +338,8 @@ if (NBL_COMPILE_WITH_CUDA)
322338
endif()
323339
endif()
324340

341+
342+
# Final gather
325343
set(NBL_3RDPARTY_TARGETS
326344
lzma
327345
lz4
@@ -376,14 +394,16 @@ endforeach()
376394

377395
set(_NBL_3RDPARTY_TARGETS_ ${NBL_3RDPARTY_TARGETS} PARENT_SCOPE)
378396

397+
398+
## REMINDER / NOTE : This is how we install 3rdparty headers we need !
379399
# parallel hashmap headers
380400
install(
381401
DIRECTORY ./parallel-hashmap/parallel_hashmap
382402
DESTINATION ./include/parallel-hashmap
383403
CONFIGURATIONS Release
384404
)
385405
install(
386-
DIRECTORY ./parallel-hashmap//parallel_hashmap
406+
DIRECTORY ./parallel-hashmap/parallel_hashmap
387407
DESTINATION ./debug/include/parallel-hashmap
388408
CONFIGURATIONS Debug
389409
)

3rdparty/Vulkan-Headers

Submodule Vulkan-Headers added at aa18f18

include/nbl/system/CSystemAndroid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef _NBL_SYSTEM_C_SYSTEM_ANDROID_H_INCLUDED_
22
#define _NBL_SYSTEM_C_SYSTEM_ANDROID_H_INCLUDED_
3+
34
#ifdef _NBL_PLATFORM_ANDROID_
45
#include "nbl/system/ISystem.h"
56
#include "nbl/system/CAPKResourcesArchive.h"
@@ -34,4 +35,5 @@ namespace nbl::system
3435
};
3536
}
3637
#endif
38+
3739
#endif

include/nbl/system/CSystemWin32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CSystemWin32 : public ISystem
2626
{
2727
public:
2828
CSystemWin32(core::smart_refctd_ptr<ISystemCaller>&& caller) : ISystem(std::move(caller)) {}
29-
//LOL the struct definition wasn't added to winapi headers do they ask to declare them yourself (probably in another header?)
29+
//LOL the struct definition wasn't added to winapi headers do they ask to declare them yourself
3030
typedef struct _PROCESSOR_POWER_INFORMATION {
3131
ULONG Number;
3232
ULONG MaxMhz;

include/nbl/video/IAPIConnection.h

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,27 @@ class IPhysicalDevice;
1414

1515
class IAPIConnection : public core::IReferenceCounted
1616
{
17-
public:
18-
// TODO: are these "instance features" ?
19-
enum E_FEATURE
20-
{
21-
EF_SURFACE = 0,
22-
EF_COUNT
23-
};
17+
public:
18+
// TODO: are these "instance features" ?
19+
enum E_FEATURE
20+
{
21+
EF_SURFACE = 0,
22+
EF_COUNT
23+
};
2424

25-
virtual E_API_TYPE getAPIType() const = 0;
25+
virtual E_API_TYPE getAPIType() const = 0;
2626

27-
virtual IDebugCallback* getDebugCallback() const = 0;
27+
virtual IDebugCallback* getDebugCallback() const = 0;
2828

29-
core::SRange<IPhysicalDevice* const> getPhysicalDevices() const;
29+
core::SRange<IPhysicalDevice* const> getPhysicalDevices() const;
3030

31-
static core::SRange<const E_FEATURE> getDependentFeatures(const E_FEATURE feature);
31+
static core::SRange<const E_FEATURE> getDependentFeatures(const E_FEATURE feature);
3232

33-
protected:
34-
// TODO: move to IAPIConnection.cpp
35-
inline IAPIConnection() : m_physicalDevices(), m_rdoc_api(nullptr)
36-
{
37-
#ifdef _NBL_PLATFORM_WINDOWS_
38-
if (HMODULE mod = GetModuleHandleA("renderdoc.dll"))
39-
#elif defined(_NBL_PLATFORM_ANDROID_)
40-
if (void* mod = dlopen("libVkLayer_GLES_RenderDoc.so", RTLD_NOW | RTLD_NOLOAD))
41-
#elif defined(_NBL_PLATFORM_LINUX_)
42-
if (void* mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD))
43-
#else
44-
if (false)
45-
#endif
46-
{
47-
#if defined(_NBL_PLATFORM_WINDOWS_)
48-
pRENDERDOC_GetAPI RENDERDOC_GetAPI =
49-
(pRENDERDOC_GetAPI)GetProcAddress(mod, "RENDERDOC_GetAPI");
50-
int ret = RENDERDOC_GetAPI(MinRenderdocVersion, (void**)&m_rdoc_api);
51-
assert(ret == 1);
52-
#elif defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_LINUX_)
53-
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI");
54-
int ret = RENDERDOC_GetAPI(MinRenderdocVersion, (void**)&m_rdoc_api);
55-
assert(ret == 1);
56-
#endif
57-
}
58-
}
33+
protected:
34+
IAPIConnection();
5935

60-
std::vector<std::unique_ptr<IPhysicalDevice>> m_physicalDevices;
61-
renderdoc_api_t* m_rdoc_api;
36+
std::vector<std::unique_ptr<IPhysicalDevice>> m_physicalDevices;
37+
renderdoc_api_t* m_rdoc_api;
6238
};
6339

6440
}

include/nbl/video/utilities/renderdoc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __NBL_VIDEO_UTILITIES_RENDERDOC_H_INCLUDED_
2-
#define __NBL_VIDEO_UTILITIES_RENDERDOC_H_INCLUDED_
1+
#ifndef _NBL_VIDEO_UTILITIES_RENDERDOC_H_INCLUDED_
2+
#define _NBL_VIDEO_UTILITIES_RENDERDOC_H_INCLUDED_
33

44
#include "renderdoc/renderdoc_app.h" // renderdoc_app from /3rdparty
55

src/nbl/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,6 @@ set(COMMON_INCLUDE_DIRS
384384
$<TARGET_PROPERTY:jpeg-static,BINARY_DIR> #for dynamically generated jconfig.h
385385
)
386386

387-
macro(nbl_target_link_vulkan _trgt) # we don't want to link against library directly
388-
target_include_directories(${_trgt} PUBLIC "$ENV{VULKAN_SDK}/include")
389-
endmacro()
390-
391387
macro(nbl_target_link_utfcpp _trgt) # TODO: remove
392388
target_include_directories(${_trgt} PUBLIC ${THIRD_PARTY_SOURCE_DIR}/utfcpp/source)
393389
endmacro()
@@ -536,9 +532,7 @@ set_property(TARGET Nabla PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG
536532
if(ANDROID AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") # OpenSSL can't be built for Android platform using windows OS host
537533
add_dependencies(Nabla openssl_build)
538534
endif()
539-
if(DEFINED ENV{VULKAN_SDK})
540-
nbl_target_link_vulkan(Nabla)
541-
endif()
535+
target_include_directories(Nabla PUBLIC "${THIRD_PARTY_SOURCE_DIR}/Vulkan-Headers/include")
542536
nbl_target_link_openssl(Nabla)
543537
nbl_target_link_zlib(Nabla)
544538
nbl_target_link_shaderc(Nabla)

src/nbl/video/IAPIConnection.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "nbl/video/IAPIConnection.h"
22

33
#include "nbl/video/IPhysicalDevice.h"
4+
#include "nbl/video/utilities/renderdoc.h"
45

56
namespace nbl::video
67
{
@@ -28,4 +29,29 @@ core::SRange<const IAPIConnection::E_FEATURE> IAPIConnection::getDependentFeatur
2829
}
2930
}
3031

32+
IAPIConnection::IAPIConnection() : m_physicalDevices(), m_rdoc_api(nullptr)
33+
{
34+
#ifdef _NBL_PLATFORM_WINDOWS_
35+
if (HMODULE mod = GetModuleHandleA("renderdoc.dll"))
36+
#elif defined(_NBL_PLATFORM_ANDROID_)
37+
if (void* mod = dlopen("libVkLayer_GLES_RenderDoc.so", RTLD_NOW | RTLD_NOLOAD))
38+
#elif defined(_NBL_PLATFORM_LINUX_)
39+
if (void* mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD))
40+
#else
41+
#error "Nabla Unsupported Platform!"
42+
#endif
43+
{
44+
#if defined(_NBL_PLATFORM_WINDOWS_)
45+
pRENDERDOC_GetAPI RENDERDOC_GetAPI =
46+
(pRENDERDOC_GetAPI)GetProcAddress(mod, "RENDERDOC_GetAPI");
47+
int ret = RENDERDOC_GetAPI(MinRenderdocVersion, (void**)&m_rdoc_api);
48+
assert(ret == 1);
49+
#elif defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_LINUX_)
50+
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI");
51+
int ret = RENDERDOC_GetAPI(MinRenderdocVersion, (void**)&m_rdoc_api);
52+
assert(ret == 1);
53+
#endif
54+
}
55+
}
56+
3157
}

0 commit comments

Comments
 (0)