From 453bb2d255d56a2cfc8e39f64a231b201fdfa69e Mon Sep 17 00:00:00 2001 From: Arkadiusz Lachowicz Date: Fri, 14 Apr 2023 18:57:05 +0200 Subject: [PATCH 01/20] add macos-clang PLATFORM given apple clang compiler vendor to CMake --- src/nbl/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 36b742aa5d..b5eb129d19 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -63,12 +63,16 @@ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(PLATFORM android-gcc) endif() - elseif (UNIX AND NOT APPLE) + elseif (UNIX) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(PLATFORM linux-clang) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(PLATFORM linux-gcc) endif() + elseif(APPLE) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(PLATFORM macos-clang) + endif() endif() if ("${PLATFORM}" STREQUAL "NOTFOUND") From c4a41b4ea66dc1ef53a0d14bbd546bf008b80eed Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 15 Apr 2023 16:32:30 +0200 Subject: [PATCH 02/20] Correct dxc's CMakeLists file in order to cover non multi generators, set CMP0042 policy to NEW (MACOSX_RPATH) and correct top CMakeLists file to not throw warning of unknown compiler - make CMake generate with Sublime Text 2 Ninja generator --- 3rdparty/dxc/CMakeLists.txt | 38 ++++++++++++++++++++++++++----------- CMakeLists.txt | 3 ++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/3rdparty/dxc/CMakeLists.txt b/3rdparty/dxc/CMakeLists.txt index 77a7dddeb2..13397304fa 100644 --- a/3rdparty/dxc/CMakeLists.txt +++ b/3rdparty/dxc/CMakeLists.txt @@ -122,24 +122,40 @@ if(_NBL_ENABLE_DXC_COMPILE_TESTS_) add_subdirectory(CT CT) endif() -include("${DXC_BUILD_DIR}/nbl/generate/dxc/config/debug.cmake") -include("${DXC_BUILD_DIR}/nbl/generate/dxc/config/release.cmake") +if(GENERATOR_IS_MULTI_CONFIG) + include("${DXC_BUILD_DIR}/nbl/generate/dxc/config/debug.cmake") + include("${DXC_BUILD_DIR}/nbl/generate/dxc/config/release.cmake") +else() + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + include("${DXC_BUILD_DIR}/nbl/generate/dxc/config/debug.cmake") + else() + include("${DXC_BUILD_DIR}/nbl/generate/dxc/config/release.cmake") + endif() +endif() set(DXC_INCLUDE_DIRECTORIES - $,${NBL_DXC_DEBUG_INCLUDE_DIRECTORIES},${NBL_DXC_RELEASE_INCLUDE_DIRECTORIES}> + $,${NBL_DXC_DEBUG_INCLUDE_DIRECTORIES},${NBL_DXC_RELEASE_INCLUDE_DIRECTORIES}> CACHE INTERNAL "") set(DXC_LIB - $,${NBL_DXC_DEBUG_LIB},${NBL_DXC_RELEASE_LIB}> + $,${NBL_DXC_DEBUG_LIB},${NBL_DXC_RELEASE_LIB}> CACHE INTERNAL "") -set(DXC_DLL - $,${NBL_DXC_DEBUG_DLL},${NBL_DXC_RELEASE_DLL}> +set(DXC_DLL + $,${NBL_DXC_DEBUG_DLL},${NBL_DXC_RELEASE_DLL}> CACHE INTERNAL "") -cmake_path(GET NBL_DXC_DEBUG_DLL FILENAME _NBL_DXC_DEBUG_DLL_NAME_) -cmake_path(GET NBL_DXC_RELEASE_DLL FILENAME _NBL_DXC_RELEASE_DLL_NAME_) +if(GENERATOR_IS_MULTI_CONFIG) + cmake_path(GET NBL_DXC_DEBUG_DLL FILENAME _NBL_DXC_DEBUG_DLL_NAME_) + cmake_path(GET NBL_DXC_RELEASE_DLL FILENAME _NBL_DXC_RELEASE_DLL_NAME_) +else() + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + cmake_path(GET NBL_DXC_DEBUG_DLL FILENAME _NBL_DXC_DEBUG_DLL_NAME_) + else() + cmake_path(GET NBL_DXC_RELEASE_DLL FILENAME _NBL_DXC_RELEASE_DLL_NAME_) + endif() +endif() -set(DXC_DLL_NAME - $,${_NBL_DXC_DEBUG_DLL_NAME_},${_NBL_DXC_RELEASE_DLL_NAME_}> -CACHE INTERNAL "") \ No newline at end of file +set(DXC_DLL_NAME + $,${_NBL_DXC_DEBUG_DLL_NAME_},${_NBL_DXC_RELEASE_DLL_NAME_}> +CACHE INTERNAL "") diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f2953aa7f..c5bf01c710 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.26) #policies cmake_policy(SET CMP0112 NEW) +cmake_policy(SET CMP0042 NEW) set(NBL_BUILD_ANDROID OFF) @@ -110,7 +111,7 @@ macro(nbl_adjust_flags) option(NBL_SANITIZE_THREAD OFF) endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") add_compile_options( -Wextra -Wno-unused-parameter From df32b15caa0cfb563e0d66a72b5b46592937b9ef Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 15 Apr 2023 17:06:46 +0200 Subject: [PATCH 03/20] remove x86 processor specific compile flags added without respect to CMAKE_HOST_SYSTEM_PROCESSOR --- CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5bf01c710..874b8275f3 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,12 +112,18 @@ macro(nbl_adjust_flags) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - add_compile_options( + if(NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") + add_compile_options( + -msse4.2 + -mfpmath=sse + $<$,C>:-maes> + ) + endif() + + add_compile_options( -Wextra -Wno-unused-parameter -fno-strict-aliasing - -msse4.2 - -mfpmath=sse -Wextra -Wno-sequence-point @@ -125,8 +131,6 @@ macro(nbl_adjust_flags) -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-parameter - - $<$,C>:-maes> $<$:-Wall> $<$:-fno-omit-frame-pointer> From dece03ab9bafd608a03b12729c9f6b9400c51426 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 17 Apr 2023 19:19:20 +0200 Subject: [PATCH 04/20] generate endian.h and byteswap.h patch headers on fly for AppleClang on MacOS ARM builds - fix building of zlibstatic and aesGladman targets --- 3rdparty/CMakeLists.txt | 32 +++++++++++++++++++++++++++++++- 3rdparty/zlib | 2 +- CMakeLists.txt | 8 +++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 686e70aaef..7387b088c7 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -50,7 +50,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_subdirectory(pstl pstl EXCLUDE_FROM_ALL) endif() - # zlib (target is zlibstatic) set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL}) @@ -62,11 +61,16 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E rename zconf.h.included zconf.h set(SKIP_INSTALL_ALL ${_OLD_SKIP_INSTALL_ALL}) set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS}) +if(APPLE) + target_compile_options(zlibstatic PUBLIC "-includeunistd.h") +endif() + get_target_property(ZLIB_SOURCE_DIR zlibstatic "SOURCE_DIR") get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR") get_filename_component(_ORIGINAL_SOURCE_ "${ZLIB_SOURCE_DIR}" ABSOLUTE) get_filename_component(_COPY_BIN_SOURCE_ "${ZLIB_BINARY_DIR}/copy_source" ABSOLUTE) +# TODO: add coresponding custom command and mark proper dependencies [zlib_copy] add_custom_target(zlib_copy COMMAND ${CMAKE_COMMAND} -E rm -Rf "${_COPY_BIN_SOURCE_}" COMMAND ${CMAKE_COMMAND} -E copy_directory "${_ORIGINAL_SOURCE_}" "${_COPY_BIN_SOURCE_}" @@ -241,6 +245,32 @@ add_library(aesGladman OBJECT aesGladman/sha1.c ) +# MacOS patches +if(APPLE) + set(_NBL_MACOS_PATCH_INCLUDE_ "${CMAKE_CURRENT_BINARY_DIR}/macos/include" CACHE INTERNAL "") + + set(_NBL_MACOS_BYTESWAP_H_ +"#if defined(__APPLE__)\n\ +// Mac OS X / Darwin features\n\ +#include \n\n\ +#define bswap_16(x) OSSwapInt16(x)\n\ +#define bswap_32(x) OSSwapInt32(x)\n\ +#define bswap_64(x) OSSwapInt64(x)\n\ +#endif // __APPLE__" + ) + + set(_NBL_MACOS_ENDIAN_H_ +"#if defined(__APPLE__)\n\ +#include \n\ +#endif // __APPLE__" + ) + + file(WRITE "${_NBL_MACOS_PATCH_INCLUDE_}/byteswap.h" "${_NBL_MACOS_BYTESWAP_H_}") + file(WRITE "${_NBL_MACOS_PATCH_INCLUDE_}/endian.h" "${_NBL_MACOS_ENDIAN_H_}") + + include_directories(BEFORE SYSTEM "${_NBL_MACOS_PATCH_INCLUDE_}") +endif() + option(GLM_TEST_ENABLE_SIMD_SSE4_2 "Enable SSE 4.2 optimizations" ON) option(GLM_TEST_ENABLE "Build unit tests" OFF) #add_subdirectory(glm EXCLUDE_FROM_ALL) diff --git a/3rdparty/zlib b/3rdparty/zlib index cacf7f1d4e..04f42ceca4 160000 --- a/3rdparty/zlib +++ b/3rdparty/zlib @@ -1 +1 @@ -Subproject commit cacf7f1d4e3d44d871b605da3b647f07d718623f +Subproject commit 04f42ceca40f73e2978b50e93806c2a18c1281fc diff --git a/CMakeLists.txt b/CMakeLists.txt index 874b8275f3..e973915b6b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,8 +136,10 @@ macro(nbl_adjust_flags) $<$:-fno-omit-frame-pointer> $<$:-fstack-protector-strong> ) - - if(ANDROID) + + if(APPLE) + include_directories(BEFORE SYSTEM "${_NBL_MACOS_PATCH_INCLUDE_}") + elseif(ANDROID) add_compile_options( $<$:-glldb> ) @@ -219,7 +221,7 @@ macro(nbl_adjust_flags) #reason for INCREMENTAL:NO: https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=vs-2019 /LTCG is not valid for use with /INCREMENTAL. set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO /LTCG:incremental") - else() + else() message(WARNING "UNTESTED COMPILER DETECTED, EXPECT WRONG OPTIMIZATION FLAGS! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues") endif() endmacro() From 00399601be88f1802a001e4ff1407e0ad6aa1e99 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Wed, 19 Apr 2023 16:54:59 +0200 Subject: [PATCH 05/20] force x86_64 arch builds for all APPLE devices --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e973915b6b..b0a29dc417 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,10 @@ cmake_minimum_required(VERSION 3.26) cmake_policy(SET CMP0112 NEW) cmake_policy(SET CMP0042 NEW) +if(APPLE) + set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "" FORCE) +endif() + set(NBL_BUILD_ANDROID OFF) include(ExternalProject) @@ -112,18 +116,14 @@ macro(nbl_adjust_flags) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - if(NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") - add_compile_options( - -msse4.2 - -mfpmath=sse - $<$,C>:-maes> - ) - endif() - add_compile_options( -Wextra -Wno-unused-parameter -fno-strict-aliasing + + -msse4.2 + -mfpmath=sse + $<$,C>:-maes> -Wextra -Wno-sequence-point From afe16f67acf81343a06168975b9b734ee1760158 Mon Sep 17 00:00:00 2001 From: devshgraphicsprogrammingjenkins <97687838+devshgraphicsprogrammingjenkins@users.noreply.github.com> Date: Sat, 22 Apr 2023 13:05:42 +0200 Subject: [PATCH 06/20] turn explicit instantiation definition in builtin resources auto-generated header into declaration of an explicit template specialization, get rid of AppleClang compile errors on builtin resource targets --- src/nbl/builtin/builtinHeaderGen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nbl/builtin/builtinHeaderGen.py b/src/nbl/builtin/builtinHeaderGen.py index 11632e54ff..490ea9e9d0 100644 --- a/src/nbl/builtin/builtinHeaderGen.py +++ b/src/nbl/builtin/builtinHeaderGen.py @@ -38,7 +38,7 @@ #Iterating through input list for x in resourcePaths: - outp.write('\n\t\textern template const std::pair get_resource();' % x) + outp.write('\n\t\ttemplate<> const std::pair get_resource();' % x) outp.write("\n\t}") outp.write("\n#endif // _" + guardSuffix + "_BUILTINRESOURCEDATA_H_") From b4b7d9eab880040cac1cb8c8b688480e6091aa76 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 22 Apr 2023 14:39:28 +0200 Subject: [PATCH 07/20] add standalone boost math library in order to patch Nabla for MacOS builds (missing bessel special functions implementation in shipped libc++ by Xcode), update CMakeLists with clang build corrections, add missing typename keywords and fix some compile errors) --- .gitmodules | 3 +++ 3rdparty/boost/standalone/math | 1 + include/nbl/core/execution.h | 6 ++++-- include/nbl/core/math/glslFunctions.tcc | 16 ++++++++++++++-- include/nbl/system/IAsyncQueueDispatcher.h | 2 +- src/nbl/CMakeLists.txt | 5 +++++ 6 files changed, 28 insertions(+), 5 deletions(-) create mode 160000 3rdparty/boost/standalone/math diff --git a/.gitmodules b/.gitmodules index 398cf603f9..a36fb517aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -84,3 +84,6 @@ [submodule "3rdparty/tcpp"] path = 3rdparty/tcpp url = git@github.com:Erfan-Ahmadi/tcpp.git +[submodule "3rdparty/boost/standalone/math"] + path = 3rdparty/boost/standalone/math + url = git@github.com:boostorg/math.git diff --git a/3rdparty/boost/standalone/math b/3rdparty/boost/standalone/math new file mode 160000 index 0000000000..c56f334348 --- /dev/null +++ b/3rdparty/boost/standalone/math @@ -0,0 +1 @@ +Subproject commit c56f334348d5476783fba996d604fc5c6ae980c3 diff --git a/include/nbl/core/execution.h b/include/nbl/core/execution.h index 9c67dc3a5e..0b93257073 100644 --- a/include/nbl/core/execution.h +++ b/include/nbl/core/execution.h @@ -26,9 +26,11 @@ inline auto highLevelF(Args&&... args) -> decltype(lowLevelF(std::forward( namespace nbl::core { -#if __has_include() +#if __has_include() and not defined(__clang__) namespace execution = std::execution; +#include + ALIAS_TEMPLATE_FUNCTION(for_each_n, std::for_each_n) ALIAS_TEMPLATE_FUNCTION(for_each, std::for_each) ALIAS_TEMPLATE_FUNCTION(swap_ranges, std::swap_ranges) @@ -42,7 +44,7 @@ ALIAS_TEMPLATE_FUNCTION(nth_element, std::nth_element) //template //const auto swap_ranges = std::swap_ranges<_ExPo, _FwdIt1, _FwdIt2>; #else -namespace execution = oneapi::dpl::execution; +namespace execution = oneapi::dpl::execution; // TODO: fix those targets it in order to make Nabla compile again with any clang ALIAS_TEMPLATE_FUNCTION(for_each_n, oneapi::dpl::for_each_n) ALIAS_TEMPLATE_FUNCTION(for_each, oneapi::dpl::for_each) diff --git a/include/nbl/core/math/glslFunctions.tcc b/include/nbl/core/math/glslFunctions.tcc index c2ed1868de..0474b2f4cc 100644 --- a/include/nbl/core/math/glslFunctions.tcc +++ b/include/nbl/core/math/glslFunctions.tcc @@ -10,6 +10,10 @@ #include "nbl/core/math/floatutil.tcc" #include "matrix4SIMD.h" +#if defined(__clang__) +#include +#endif //__clang__ + #include #include @@ -482,7 +486,11 @@ NBL_FORCE_INLINE vectorSIMDf cyl_bessel_i(const vectorSIMDf& v, con template NBL_FORCE_INLINE T cyl_bessel_i(const T& v, const T& x) { - return std::cyl_bessel_i(double(v),double(x)); + #if defined(__clang__) + return boost::math::cyl_bessel_i(double(v),double(x)); + #else + return std::cyl_bessel_i(double(v),double(x)); + #endif } template<> @@ -493,7 +501,11 @@ NBL_FORCE_INLINE vectorSIMDf d_cyl_bessel_i(const vectorSIMDf& v, c template NBL_FORCE_INLINE T d_cyl_bessel_i(const T& v, const T& x) { - return 0.5*(std::cyl_bessel_i(double(v)-1.0,double(x))+std::cyl_bessel_i(double(v)+1.0,double(x))); + #if defined(__clang__) + return 0.5*(boost::math::cyl_bessel_i(double(v)-1.0,double(x))+boost::math::cyl_bessel_i(double(v)+1.0,double(x))); + #else + return 0.5*(std::cyl_bessel_i(double(v)-1.0,double(x))+std::cyl_bessel_i(double(v)+1.0,double(x))); + #endif } #endif diff --git a/include/nbl/system/IAsyncQueueDispatcher.h b/include/nbl/system/IAsyncQueueDispatcher.h index ee5b5087da..3135b610e1 100644 --- a/include/nbl/system/IAsyncQueueDispatcher.h +++ b/include/nbl/system/IAsyncQueueDispatcher.h @@ -438,7 +438,7 @@ class IAsyncQueueDispatcher : public IThreadHandler, pro public: inline IAsyncQueueDispatcher() {} - inline IAsyncQueueDispatcher(base_t::start_on_construction_t) : base_t(base_t::start_on_construction) {} + inline IAsyncQueueDispatcher(typename base_t::start_on_construction_t) : base_t(base_t::start_on_construction) {} using mutex_t = typename base_t::mutex_t; using lock_t = typename base_t::lock_t; diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index b5eb129d19..be1730b7e7 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -554,6 +554,11 @@ if(_NBL_COMPILE_WITH_GLI_) target_include_directories(Nabla PUBLIC ${THIRD_PARTY_SOURCE_DIR}/gli) endif() +# Clang special math functions (libc++ shipped on MacOSes doesnt implement some of the special functions) +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + target_include_directories(Nabla PUBLIC "${THIRD_PARTY_SOURCE_DIR}/boost/standalone/math/include") +endif() + # DXC if(_NBL_ENABLE_DXC_COMPILE_TESTS_) add_dependencies(Nabla HLSL_NABLA_COMPILE_TEST) From 76e466268c72b9d5bde8050e13ea252813712fc4 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 22 Apr 2023 14:46:42 +0200 Subject: [PATCH 08/20] Force Xcode legacy build system in order to work with Nabla, add validation of CMake generator toolset --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0a29dc417..da51763810 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,12 @@ cmake_policy(SET CMP0042 NEW) if(APPLE) set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "" FORCE) + + if("${CMAKE_GENERATOR}" STREQUAL "Xcode") + if(NOT "${CMAKE_GENERATOR_TOOLSET}" STREQUAL "buildsystem=1") + message("Nabla build isn't supported with new Xcode buildsystem, you must specify CMake generator toolset as '-T buildsystem=1' in order to use legacy Xcode build system") + endif() + endif() endif() set(NBL_BUILD_ANDROID OFF) From 50e657de8999292538343732fe31f31e620b37ab Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 22 Apr 2023 23:03:03 +0200 Subject: [PATCH 09/20] fix oneDPL & oneTBB Nabla build system and make it work on MacOS with AppleClang. Temporary disable installation of tbb targets - TODO. Fix Nabla execution header related errors. Update CMake files. Make a SBuildInfo struct MoveInsertable and eliminate emplate_back errors --- .gitmodules | 2 +- 3rdparty/CMakeLists.txt | 2 +- 3rdparty/pstl/.DS_Store | Bin 0 -> 6148 bytes 3rdparty/pstl/CMakeLists.txt | 118 ++++++++++++----------- 3rdparty/pstl/oneDPL/CMakeLists.txt | 49 +++++++--- 3rdparty/pstl/oneDPL/oneDPL | 2 +- CMakeLists.txt | 2 - cmake/common.cmake | 20 ++-- include/nbl/asset/IDescriptorSetLayout.h | 8 +- include/nbl/core/execution.h | 2 +- src/nbl/CMakeLists.txt | 8 +- 11 files changed, 119 insertions(+), 94 deletions(-) create mode 100644 3rdparty/pstl/.DS_Store diff --git a/.gitmodules b/.gitmodules index a36fb517aa..fa05c77b37 100644 --- a/.gitmodules +++ b/.gitmodules @@ -69,7 +69,7 @@ url = https://github.com/Devsh-Graphics-Programming/oneTBB.git [submodule "3rdparty/pstl/oneDPL/oneDPL"] path = 3rdparty/pstl/oneDPL/oneDPL - url = https://github.com/Devsh-Graphics-Programming/oneDPL.git + url = git@github.com:Devsh-Graphics-Programming/oneDPL.git [submodule "3rdparty/Vulkan-Headers"] path = 3rdparty/Vulkan-Headers url = git@github.com:KhronosGroup/Vulkan-Headers.git diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 7387b088c7..185bd47526 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -46,7 +46,7 @@ add_subdirectory(volk volk EXCLUDE_FROM_ALL) target_include_directories(volk PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include") target_include_directories(volk_headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include") -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") add_subdirectory(pstl pstl EXCLUDE_FROM_ALL) endif() diff --git a/3rdparty/pstl/.DS_Store b/3rdparty/pstl/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..82ad257caf8664b939f0096cb89ab021aaf6c751 GIT binary patch literal 6148 zcmeHKQEL-H5S~qAdZ8$JQ0R-W(AQAYRw|`0=QVv0S`e@3gG#(JL64rdC3i7G2;8&% zF~0gs{5$&1?lzd#`cwqV49tGByEAjQ-yS=+M5Ln0aEquzL;;ks(MIzJ;d$08((ofK zpt3nebVM1IR6#}l2L^cW?$H4qQ$nZo`~GcW7r#*TEI04d+@$d1kK`$I^QRS9L@hE@ zAg)i(>FAR0x4-#*j>koAiVyI?x3kD|LJ>vFdDO#e@>t(=TAum$`<|ZVSy}aZKU8C- zd8f4+tOjer+xVlI##K^H$|xDX=H7`hd3s?d>C0?19dzy=n4(IuVl=h^*>D7xH?Oi{ zXr_^w6vNWS#%>~L2kk*;eKy --prefix ${ONETBB_INSTALL_DIR} - COMMAND ${CMAKE_COMMAND} --install ${ONETBB_BUILD} --component runtime -v --config $ --prefix ${ONETBB_INSTALL_DIR} - DEPENDS tbb tbbmalloc tbbmalloc_proxy - COMMENT "Building oneTBB..." - ) - - set(ONEDPL_BUILD ${CCBD_ABSOLUTE}/oneDPL/build) - set(ONEDPL_INSTALL_DIR ${ONEDPL_BUILD}/install CACHE STRING "oneDPL install directory" FORCE) - - set(CMAKE_ARGS_ONEDPL - -DCMAKE_BUILD_TYPE:STRING=$ - -DONETBB_INSTALL_DIR:PATH=${ONETBB_INSTALL_DIR} +get_filename_component(CCBD_ABSOLUTE "${CMAKE_CURRENT_BINARY_DIR}" ABSOLUTE) + +set(_NBL_BUILD_DPL_ ON CACHE BOOL "") + +set(TBB_INSTALL_VARS ON CACHE BOOL "" FORCE) +set(TBB_TEST OFF CACHE BOOL "" FORCE) +set(TBB_STRICT ON CACHE BOOL "" FORCE) +set(PREVIOUS_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) +set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE) +set(TBB_SANITIZE "" CACHE STRING "" FORCE) + +add_subdirectory(oneTBB oneTBB EXCLUDE_FROM_ALL) +target_compile_options(tbb PUBLIC + -Wno-conversion +) + +if(PREVIOUS_BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ${PREVIOUS_BUILD_SHARED_LIBS} CACHE BOOL "" FORCE) +else() + unset(BUILD_SHARED_LIBS CACHE) +endif() + +set(ONETBB_BUILD ${CCBD_ABSOLUTE}/oneTBB) +set(ONETBB_INSTALL_DIR ${ONETBB_BUILD}/install CACHE STRING "oneTBB install directory" FORCE) + +add_custom_target(onetbb_build + COMMAND ${CMAKE_COMMAND} --install ${ONETBB_BUILD} --component devel -v --config $ --prefix ${ONETBB_INSTALL_DIR} + COMMAND ${CMAKE_COMMAND} --install ${ONETBB_BUILD} --component runtime -v --config $ --prefix ${ONETBB_INSTALL_DIR} + DEPENDS tbb tbbmalloc #tbbmalloc_proxy + COMMENT "Building oneTBB..." +) + +set(ONEDPL_BUILD ${CCBD_ABSOLUTE}/oneDPL/build) +set(ONEDPL_INSTALL_DIR ${ONEDPL_BUILD}/install CACHE STRING "oneDPL install directory" FORCE) + +set(CMAKE_ARGS_ONEDPL + -DCMAKE_BUILD_TYPE:STRING=$ + -DONETBB_INSTALL_DIR:PATH=${ONETBB_INSTALL_DIR} +) + +if(ANDROID) + list(APPEND CMAKE_ARGS_ONEDPL + -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} + -DANDROID_ABI:STRING=${ANDROID_ABI} + -DANDROID_PLATFORM:STRING=${ANDROID_PLATFORM} ) - - if(ANDROID) - list(APPEND CMAKE_ARGS_ONEDPL - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE} - -DANDROID_ABI:STRING=${ANDROID_ABI} - -DANDROID_PLATFORM:STRING=${ANDROID_PLATFORM} - ) - endif() - - ExternalProject_Add(oneDPL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/oneDPL - BINARY_DIR ${ONEDPL_BUILD} - CMAKE_ARGS ${CMAKE_ARGS_ONEDPL} - BUILD_COMMAND cmake --build ${ONEDPL_BUILD} - INSTALL_COMMAND cmake --install ${ONEDPL_BUILD} --prefix ${ONEDPL_INSTALL_DIR} - USES_TERMINAL_BUILD 1 - COMMENT "Building oneDPL..." +elseif(APPLE) + list(APPEND CMAKE_ARGS_ONEDPL + "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}" ) - - add_dependencies(oneDPL onetbb_build) -endif() \ No newline at end of file +endif() + +ExternalProject_Add(oneDPL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/oneDPL + BINARY_DIR ${ONEDPL_BUILD} + CMAKE_ARGS ${CMAKE_ARGS_ONEDPL} + BUILD_COMMAND cmake --build ${ONEDPL_BUILD} --config $ + INSTALL_COMMAND cmake --install ${ONEDPL_BUILD} --config $ -v --prefix ${ONEDPL_INSTALL_DIR} + USES_TERMINAL_BUILD 1 + COMMENT "Building oneDPL..." +) + +add_dependencies(oneDPL onetbb_build) \ No newline at end of file diff --git a/3rdparty/pstl/oneDPL/CMakeLists.txt b/3rdparty/pstl/oneDPL/CMakeLists.txt index 27c4f7850f..614c885c53 100644 --- a/3rdparty/pstl/oneDPL/CMakeLists.txt +++ b/3rdparty/pstl/oneDPL/CMakeLists.txt @@ -1,18 +1,35 @@ -cmake_minimum_required(VERSION 3.20) -include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/toolchains/android/build.cmake) +cmake_minimum_required(VERSION 3.26) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - if(NOT DEFINED ONETBB_INSTALL_DIR) - message(FATAL_ERROR "oneDPL submodule requires valid ONETBB_INSTALL_DIR!") - endif() - - set(TBB_DIR ${ONETBB_INSTALL_DIR}/lib/cmake/TBB CACHE INTERNAL "" FORCE) - set(ONEDPL_BACKEND tbb CACHE STRING "" FORCE) - add_subdirectory(oneDPL oneDPL) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) - if(ANDROID) - add_compile_options( - $<$:-glldb> - ) - endif() -endif() \ No newline at end of file +# assume built-in pthreads on MacOS +if(APPLE) + set(CMAKE_THREAD_LIBS_INIT "-lpthread") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(CMAKE_USE_WIN32_THREADS_INIT 0) + set(CMAKE_USE_PTHREADS_INIT 1) + set(THREADS_PREFER_PTHREAD_FLAG ON CACHE BOOL "") +endif() + +if(ANDROID) + include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/toolchains/android/build.cmake) +endif() + +if(NOT DEFINED ONETBB_INSTALL_DIR) + message(FATAL_ERROR "oneDPL submodule requires valid ONETBB_INSTALL_DIR!") +endif() + +set(TBB_DIR ${ONETBB_INSTALL_DIR}/lib/cmake/TBB CACHE INTERNAL "" FORCE) +set(ONEDPL_BACKEND tbb CACHE STRING "" FORCE) +set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH ON CACHE BOOL "") +set(ONE_DPL_INSTALL_OVERRIDE "${CMAKE_CURRENT_BINARY_DIR}/output" CACHE STRING "" FORCE) +find_package(Threads REQUIRED) + +add_subdirectory(oneDPL oneDPL) + +if(ANDROID) + add_compile_options( + $<$:-glldb> + ) +endif() diff --git a/3rdparty/pstl/oneDPL/oneDPL b/3rdparty/pstl/oneDPL/oneDPL index 0bd676a2e4..db48d5ed68 160000 --- a/3rdparty/pstl/oneDPL/oneDPL +++ b/3rdparty/pstl/oneDPL/oneDPL @@ -1 +1 @@ -Subproject commit 0bd676a2e45074c7d5c59242eb6c36bc76a52aa8 +Subproject commit db48d5ed68ced6ada4d0b3d34a387e678d71a1e3 diff --git a/CMakeLists.txt b/CMakeLists.txt index da51763810..d95bf6da84 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,8 +275,6 @@ endif() #uncomment in the future #option(NBL_TARGET_ARCH_ARM "Build for ARM?" OFF) -option(NBL_BUILD_DPL "Enable DPL (Dynamic Parallelism Library)" OFF) - option(NBL_PCH "Enable pre-compiled header" ON) option(NBL_FAST_MATH "Enable fast low-precision math" ON) diff --git a/cmake/common.cmake b/cmake/common.cmake index 6b5548c907..b8ec3dfd3f 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -431,7 +431,7 @@ macro(nbl_android_create_apk _TARGET) set(NBL_APK_OBJ_DIR obj) set(NBL_APK_BIN_DIR bin) set(NBL_APK_ASSETS_DIR assets) - + if(EXISTS ${ASSET_SOURCE_DIR}) add_custom_command( OUTPUT ${APK_FILE} @@ -444,10 +444,10 @@ macro(nbl_android_create_apk _TARGET) COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_OBJ_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_BIN_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_ASSETS_DIR} - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ COMMAND ${CMAKE_COMMAND} -E copy_directory ${ASSET_SOURCE_DIR} ${NBL_APK_ASSETS_DIR} COMMAND ${ANDROID_BUILD_TOOLS}/aapt package -f -m -J src -M AndroidManifest.xml -I ${ANDROID_JAR} COMMAND ${ANDROID_JAVA_BIN}/javac -d ./obj -source 1.7 -target 1.7 -bootclasspath ${ANDROID_JAVA_RT_JAR} -classpath "${ANDROID_JAR}" -sourcepath src ${NBL_ANDROID_LOADER_JAVA} @@ -472,10 +472,10 @@ macro(nbl_android_create_apk _TARGET) COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_LIBRARY_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_OBJ_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_BIN_DIR} - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ COMMAND ${ANDROID_BUILD_TOOLS}/aapt package -f -m -J src -M AndroidManifest.xml -I ${ANDROID_JAR} COMMAND ${ANDROID_JAVA_BIN}/javac -d ./obj -source 1.7 -target 1.7 -bootclasspath ${ANDROID_JAVA_RT_JAR} -classpath "${ANDROID_JAR}" -sourcepath src ${NBL_ANDROID_LOADER_JAVA} COMMAND ${DEX_COMMAND} @@ -714,4 +714,4 @@ sleep 5 else() execute_process(COMMAND ${CMAKE_COMMAND} -E echo "NBL_UPDATE_GIT_SUBMODULE is turned OFF therefore submodules won't get updated.") endif() -endfunction() \ No newline at end of file +endfunction() diff --git a/include/nbl/asset/IDescriptorSetLayout.h b/include/nbl/asset/IDescriptorSetLayout.h index d5d37f2152..2371464926 100644 --- a/include/nbl/asset/IDescriptorSetLayout.h +++ b/include/nbl/asset/IDescriptorSetLayout.h @@ -173,7 +173,13 @@ class IDescriptorSetLayout : public virtual core::IReferenceCounted core::bitflag createFlags; core::bitflag stageFlags; uint32_t count; - + + SBuildInfo(uint32_t _binding, core::bitflag _createFlags, core::bitflag _stageFlags, uint32_t _count) + : binding(_binding), createFlags(_createFlags), stageFlags(_stageFlags), count(_count) {} + SBuildInfo(SBuildInfo&& other) + : binding(other.binding), createFlags(other.createFlags), stageFlags(other.stageFlags), count(other.count) {} + + SBuildInfo& operator=(const SBuildInfo& other) = default; inline bool operator< (const SBuildInfo& other) const { return binding < other.binding; } }; diff --git a/include/nbl/core/execution.h b/include/nbl/core/execution.h index 0b93257073..54e01e4856 100644 --- a/include/nbl/core/execution.h +++ b/include/nbl/core/execution.h @@ -5,7 +5,7 @@ #ifndef _NBL_CORE_EXECUTION_H_INCLUDED_ #define _NBL_CORE_EXECUTION_H_INCLUDED_ -#if __has_include () +#if __has_include () and not defined(__clang__) #include #include #else diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index be1730b7e7..2cf95739a5 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -360,7 +360,7 @@ set(COMMON_INCLUDE_DIRS $ #for dynamically generated jconfig.h ) -# just gather all the header files and later put them into project so it's easy to search for things using IDE +# just gather all the header files and later put them into project so its easy to search for things using IDE file(GLOB_RECURSE NABLA_HEADERS_PRIV1 "*.h") file(GLOB_RECURSE NABLA_HEADERS_PRIV2 "${NBL_ROOT_PATH}/src/nbl/*.h") @@ -722,9 +722,9 @@ if(NBL_STATIC_BUILD) nbl_install_lib(simdjson) nbl_install_lib(volk) if(_NBL_BUILD_DPL_) - nbl_install_program(tbb) - nbl_install_program(tbbmalloc) - nbl_install_program(tbbmalloc_proxy) + #nbl_install_program(tbb) + #nbl_install_program(tbbmalloc) + #nbl_install_program(tbbmalloc_proxy) endif() else() nbl_install_program(Nabla) From 7a6de707b850345150d86292f50c171c23412fd4 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 23 Apr 2023 12:31:56 +0200 Subject: [PATCH 10/20] bring back installation of tbb targets and coditionally handle tbbmalloc_proxy target --- 3rdparty/pstl/CMakeLists.txt | 8 ++++++-- cmake/common.cmake | 16 ++++++++-------- src/nbl/CMakeLists.txt | 9 ++++++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/3rdparty/pstl/CMakeLists.txt b/3rdparty/pstl/CMakeLists.txt index 6367fda09d..dfd363a22f 100644 --- a/3rdparty/pstl/CMakeLists.txt +++ b/3rdparty/pstl/CMakeLists.txt @@ -26,9 +26,13 @@ set(ONETBB_INSTALL_DIR ${ONETBB_BUILD}/install CACHE STRING "oneTBB install dire add_custom_target(onetbb_build COMMAND ${CMAKE_COMMAND} --install ${ONETBB_BUILD} --component devel -v --config $ --prefix ${ONETBB_INSTALL_DIR} COMMAND ${CMAKE_COMMAND} --install ${ONETBB_BUILD} --component runtime -v --config $ --prefix ${ONETBB_INSTALL_DIR} - DEPENDS tbb tbbmalloc #tbbmalloc_proxy COMMENT "Building oneTBB..." ) +add_dependencies(onetbb_build tbb tbbmalloc) + +if(NOT (APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")) + add_dependencies(onetbb_build tbbmalloc_proxy) +endif() set(ONEDPL_BUILD ${CCBD_ABSOLUTE}/oneDPL/build) set(ONEDPL_INSTALL_DIR ${ONEDPL_BUILD}/install CACHE STRING "oneDPL install directory" FORCE) @@ -60,4 +64,4 @@ ExternalProject_Add(oneDPL COMMENT "Building oneDPL..." ) -add_dependencies(oneDPL onetbb_build) \ No newline at end of file +add_dependencies(oneDPL onetbb_build) diff --git a/cmake/common.cmake b/cmake/common.cmake index b8ec3dfd3f..4f8c44b4dd 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -444,10 +444,10 @@ macro(nbl_android_create_apk _TARGET) COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_OBJ_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_BIN_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_ASSETS_DIR} - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ COMMAND ${CMAKE_COMMAND} -E copy_directory ${ASSET_SOURCE_DIR} ${NBL_APK_ASSETS_DIR} COMMAND ${ANDROID_BUILD_TOOLS}/aapt package -f -m -J src -M AndroidManifest.xml -I ${ANDROID_JAR} COMMAND ${ANDROID_JAVA_BIN}/javac -d ./obj -source 1.7 -target 1.7 -bootclasspath ${ANDROID_JAVA_RT_JAR} -classpath "${ANDROID_JAR}" -sourcepath src ${NBL_ANDROID_LOADER_JAVA} @@ -472,10 +472,10 @@ macro(nbl_android_create_apk _TARGET) COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_LIBRARY_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_OBJ_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${NBL_APK_BIN_DIR} - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ - #COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ + COMMAND ${CMAKE_COMMAND} -E copy $ libs/lib/x86_64/$ COMMAND ${ANDROID_BUILD_TOOLS}/aapt package -f -m -J src -M AndroidManifest.xml -I ${ANDROID_JAR} COMMAND ${ANDROID_JAVA_BIN}/javac -d ./obj -source 1.7 -target 1.7 -bootclasspath ${ANDROID_JAVA_RT_JAR} -classpath "${ANDROID_JAR}" -sourcepath src ${NBL_ANDROID_LOADER_JAVA} COMMAND ${DEX_COMMAND} diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 2cf95739a5..5b9d78a306 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -722,9 +722,12 @@ if(NBL_STATIC_BUILD) nbl_install_lib(simdjson) nbl_install_lib(volk) if(_NBL_BUILD_DPL_) - #nbl_install_program(tbb) - #nbl_install_program(tbbmalloc) - #nbl_install_program(tbbmalloc_proxy) + nbl_install_program(tbb) + nbl_install_program(tbbmalloc) + + if(NOT (APPLE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")) + nbl_install_program(tbbmalloc_proxy) + endif() endif() else() nbl_install_program(Nabla) From 3d4c2c32e5876cdf1692dcb0148e42c5c8885781 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 23 Apr 2023 14:19:44 +0200 Subject: [PATCH 11/20] fix dependent type errors, add some copy constructor with assignment operators to nbl::system::ISystem::SRequestType because of std::variant type-safe union defined as a member and elimiante some of compile errors --- include/nbl/system/ISystem.h | 104 ++++++++++++++++++++++++++++++++ src/nbl/system/ISystem.cpp | 4 +- src/nbl/system/ISystemPOSIX.cpp | 9 ++- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/include/nbl/system/ISystem.h b/include/nbl/system/ISystem.h index 8e855ce820..2f0fe38b2e 100644 --- a/include/nbl/system/ISystem.h +++ b/include/nbl/system/ISystem.h @@ -267,6 +267,110 @@ class NBL_API2 ISystem : public core::IReferenceCounted }; struct SRequestType { + + SRequestType() + { + std::memset(this, 0, sizeof(SRequestType)); + } + + ~SRequestType() {} + + //! SRequestParams_READ to SRequestType because of std::variant type-safe union + + SRequestType(SRequestParams_READ& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_READ)); + } + + SRequestType(const SRequestParams_READ& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_READ)); + } + + SRequestType& operator=(SRequestParams_READ& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_READ)); + return *this; + } + + SRequestType& operator=(const SRequestParams_READ& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_READ)); + return *this; + } + + //! SRequestParams_WRITE to SRequestType because of std::variant type-safe union + + SRequestType(SRequestParams_WRITE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_WRITE)); + } + + SRequestType(const SRequestParams_WRITE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_WRITE)); + } + + SRequestType& operator=(SRequestParams_WRITE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_WRITE)); + return *this; + } + + SRequestType& operator=(const SRequestParams_WRITE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_WRITE)); + return *this; + } + + //! SRequestParams_CREATE_FILE to SRequestType because of std::variant type-safe union + + SRequestType(SRequestParams_CREATE_FILE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_CREATE_FILE)); + } + + SRequestType(const SRequestParams_CREATE_FILE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_CREATE_FILE)); + } + + SRequestType& operator=(SRequestParams_CREATE_FILE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_CREATE_FILE)); + return *this; + } + + SRequestType& operator=(const SRequestParams_CREATE_FILE& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_CREATE_FILE)); + return *this; + } + + //! SRequestParams_NOOP to SRequestType because of std::variant type-safe union + + SRequestType(SRequestParams_NOOP& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_NOOP)); + } + + SRequestType(const SRequestParams_NOOP& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_NOOP)); + } + + SRequestType& operator=(SRequestParams_NOOP& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_NOOP)); + return *this; + } + + SRequestType& operator=(const SRequestParams_NOOP& copy) + { + std::memmove(this, ©, sizeof(SRequestParams_NOOP)); + return *this; + } + std::variant< SRequestParams_NOOP, SRequestParams_CREATE_FILE, diff --git a/src/nbl/system/ISystem.cpp b/src/nbl/system/ISystem.cpp index b1d8a4685e..b6d58089ef 100644 --- a/src/nbl/system/ISystem.cpp +++ b/src/nbl/system/ISystem.cpp @@ -314,7 +314,7 @@ ISystem::FoundArchiveFile ISystem::findFileInArchive(const system::path& absolut void ISystem::CAsyncQueue::process_request(base_t::future_base_t* _future_base, SRequestType& req) { std::visit([=](auto& visitor) { - using retval_t = std::remove_reference_t::retval_t; + using retval_t = typename std::remove_reference_t::retval_t; visitor(base_t::future_storage_cast(_future_base),m_caller.get()); }, req.params); } @@ -348,4 +348,4 @@ bool ISystem::ICaller::flushMapping(IFile* file, size_t offset, size_t size) else if (flags&IFile::ECF_COHERENT) return true; return flushMapping_impl(file,offset,size); -} \ No newline at end of file +} diff --git a/src/nbl/system/ISystemPOSIX.cpp b/src/nbl/system/ISystemPOSIX.cpp index 6692a1e8b9..ae4b3cb4e9 100644 --- a/src/nbl/system/ISystemPOSIX.cpp +++ b/src/nbl/system/ISystemPOSIX.cpp @@ -9,13 +9,20 @@ using namespace nbl::system; #if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) #include +#include #include #include core::smart_refctd_ptr ISystemPOSIX::CCaller::createFile(const std::filesystem::path& filename, const core::bitflag flags) { const bool writeAccess = flags.value&IFile::ECF_WRITE; - int createFlags = O_LARGEFILE|(writeAccess ? O_CREAT:0); + +#if defined(__APPLE__) + int createFlags = (writeAccess ? O_CREAT:0); +#else + int createFlags = O_LARGEFILE|(writeAccess ? O_CREAT:0); +#endif + switch (flags.value&IFile::ECF_READ_WRITE) { case IFile::ECF_READ: From 1f024e5c813346a5e4780954e18bc199207cfe3e Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 24 Apr 2023 16:55:14 +0200 Subject: [PATCH 12/20] Add CSystemMacOS source and header file, update Nabla codebase with MacOS defines, update CMake files --- CMakeLists.txt | 2 + include/nbl/config/BuildConfigOptions.h.in | 3 +- include/nbl/core/decl/compile_config.h | 2 +- .../system/CFileViewVirtualAllocatorPOSIX.h | 4 +- include/nbl/system/CSystemMacOS.h | 21 +++++++++++ include/nbl/system/IFileViewAllocator.h | 4 +- include/nbl/system/ISystemPOSIX.h | 2 +- include/nbl/system/declarations.h | 4 +- include/nbl/ui/declarations.h | 3 +- include/nbl/video/surface/CSurfaceVulkan.h | 4 +- src/nbl/CMakeLists.txt | 1 + src/nbl/system/CFilePOSIX.h | 4 +- .../system/CFileViewVirtualAllocatorPOSIX.cpp | 4 +- src/nbl/system/CSystemLinux.cpp | 4 +- src/nbl/system/CSystemMacOS.cpp | 37 +++++++++++++++++++ src/nbl/system/ISystemPOSIX.cpp | 2 +- src/nbl/video/IAPIConnection.cpp | 10 ++--- 17 files changed, 89 insertions(+), 22 deletions(-) create mode 100644 include/nbl/system/CSystemMacOS.h create mode 100644 src/nbl/system/CSystemMacOS.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d95bf6da84..9811ecd222 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -261,6 +261,8 @@ if(WIN32) set(_NBL_PLATFORM_WINDOWS_ 1) elseif(ANDROID) set(_NBL_PLATFORM_ANDROID_ 1) +elseif(APPLE) + set(_NBL_PLATFORM_MACOS_ 1) elseif(UNIX) set(_NBL_PLATFORM_LINUX_ 1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1") diff --git a/include/nbl/config/BuildConfigOptions.h.in b/include/nbl/config/BuildConfigOptions.h.in index 031d324552..a42058bb87 100644 --- a/include/nbl/config/BuildConfigOptions.h.in +++ b/include/nbl/config/BuildConfigOptions.h.in @@ -18,6 +18,7 @@ #cmakedefine _NBL_PLATFORM_LINUX_ #cmakedefine _NBL_PLATFORM_OSX_ #cmakedefine _NBL_PLATFORM_ANDROID_ +#cmakedefine _NBL_PLATFORM_MACOS_ // graphics API backend #cmakedefine _NBL_COMPILE_WITH_VULKAN_ @@ -106,4 +107,4 @@ #include "define.h" #endif // __NBL_BUILDING_NABLA__ -#endif // __NBL_BUILD_CONFIG_OPTIONS_H_INCLUDED__ \ No newline at end of file +#endif // __NBL_BUILD_CONFIG_OPTIONS_H_INCLUDED__ diff --git a/include/nbl/core/decl/compile_config.h b/include/nbl/core/decl/compile_config.h index 5f6a3cb5a8..95c4cdf1d7 100644 --- a/include/nbl/core/decl/compile_config.h +++ b/include/nbl/core/decl/compile_config.h @@ -19,7 +19,7 @@ // this actually includes file depending on build type (Debug/Release) #include "BuildConfigOptions.h" -#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) +#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_MACOS_) # define _NBL_POSIX_API_ // Android is not 100% POSIX, but it's close enough #elif defined(_NBL_PLATFORM_WINDOWS_) # define _NBL_WINDOWS_API_ diff --git a/include/nbl/system/CFileViewVirtualAllocatorPOSIX.h b/include/nbl/system/CFileViewVirtualAllocatorPOSIX.h index 8b0bf51e2e..f18b599a21 100644 --- a/include/nbl/system/CFileViewVirtualAllocatorPOSIX.h +++ b/include/nbl/system/CFileViewVirtualAllocatorPOSIX.h @@ -3,7 +3,7 @@ namespace nbl::system { -#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) +#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_MACOS_) class CFileViewVirtualAllocatorPOSIX : public IFileViewAllocator { public: @@ -15,4 +15,4 @@ class CFileViewVirtualAllocatorPOSIX : public IFileViewAllocator #endif } -#endif \ No newline at end of file +#endif diff --git a/include/nbl/system/CSystemMacOS.h b/include/nbl/system/CSystemMacOS.h new file mode 100644 index 0000000000..d3be9f5fac --- /dev/null +++ b/include/nbl/system/CSystemMacOS.h @@ -0,0 +1,21 @@ +#ifndef _NBL_SYSTEM_C_SYSTEM_MACOS_H_INCLUDED_ +#define _NBL_SYSTEM_C_SYSTEM_MACOS_H_INCLUDED_ + +#include "nbl/system/ISystem.h" +#include "nbl/system/ISystemPOSIX.h" + +namespace nbl::system +{ +#ifdef _NBL_PLATFORM_MACOS_ + +class CSystemMacOS final : public ISystemPOSIX +{ + public: + inline CSystemMacOS() : ISystemPOSIX() {} + + NBL_API2 SystemInfo getSystemInfo() const override; +}; +#endif // _NBL_PLATFORM_MACOS_ +} + +#endif // _NBL_SYSTEM_C_SYSTEM_MACOS_H_INCLUDED_ diff --git a/include/nbl/system/IFileViewAllocator.h b/include/nbl/system/IFileViewAllocator.h index aedeb6320b..2731b42aa2 100644 --- a/include/nbl/system/IFileViewAllocator.h +++ b/include/nbl/system/IFileViewAllocator.h @@ -61,11 +61,11 @@ class CNullAllocator : public IFileViewAllocator #ifdef _NBL_PLATFORM_WINDOWS_ #include "nbl/system/CFileViewVirtualAllocatorWin32.h" using VirtualMemoryAllocator = nbl::system::CFileViewVirtualAllocatorWin32; -#elif defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) +#elif defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_MACOS_) #include "nbl/system/CFileViewVirtualAllocatorPOSIX.h" using VirtualMemoryAllocator = nbl::system::CFileViewVirtualAllocatorPOSIX; #else #error "Unsupported platform!" #endif -#endif \ No newline at end of file +#endif diff --git a/include/nbl/system/ISystemPOSIX.h b/include/nbl/system/ISystemPOSIX.h index c021aefaa9..9d813c9bc9 100644 --- a/include/nbl/system/ISystemPOSIX.h +++ b/include/nbl/system/ISystemPOSIX.h @@ -9,7 +9,7 @@ namespace nbl::system { -#if defined(_NBL_PLATFORM_LINUX_) || defined (_NBL_PLATFORM_ANDROID_) +#if defined(_NBL_PLATFORM_LINUX_) || defined (_NBL_PLATFORM_ANDROID_) || defined (_NBL_PLATFORM_MACOS_) class ISystemPOSIX : public ISystem { protected: diff --git a/include/nbl/system/declarations.h b/include/nbl/system/declarations.h index 718314d2f4..d92d41a0f4 100644 --- a/include/nbl/system/declarations.h +++ b/include/nbl/system/declarations.h @@ -27,8 +27,10 @@ #elif defined(_NBL_PLATFORM_LINUX_) # include "nbl/system/CColoredStdoutLoggerANSI.h" # include "nbl/system/CSystemLinux.h" +#elif defined(_NBL_PLATFORM_MACOS_) +# include "nbl/system/CSystemMacOS.h" #else #error "Unsupported Platform" #endif // TODO more platforms (android) -#endif \ No newline at end of file +#endif diff --git a/include/nbl/ui/declarations.h b/include/nbl/ui/declarations.h index 4a2bce9552..4d67241623 100644 --- a/include/nbl/ui/declarations.h +++ b/include/nbl/ui/declarations.h @@ -13,6 +13,7 @@ #elif defined(_NBL_BUILD_WITH_WAYLAND) && defined(_NBL_TEST_WAYLAND) # include "nbl/ui/CWindowManagerWayland.h" #elif defined(_NBL_PLATFORM_LINUX_) +#elif defined(_NBL_PLATFORM_MACOS_) #endif // TODO more platforms (android) // clipboards @@ -22,4 +23,4 @@ #include "nbl/ui/IInputEventChannel.h" -#endif \ No newline at end of file +#endif diff --git a/include/nbl/video/surface/CSurfaceVulkan.h b/include/nbl/video/surface/CSurfaceVulkan.h index 203f580f67..3d53fdd448 100644 --- a/include/nbl/video/surface/CSurfaceVulkan.h +++ b/include/nbl/video/surface/CSurfaceVulkan.h @@ -49,7 +49,9 @@ class NBL_API2 CSurfaceVulkanWin32 final : public CSurface void* CFileViewVirtualAllocatorPOSIX::alloc(size_t size) @@ -14,4 +14,4 @@ bool CFileViewVirtualAllocatorPOSIX::dealloc(void* data, size_t size) const auto ret = munmap(data,size); return ret != -1; } -#endif \ No newline at end of file +#endif diff --git a/src/nbl/system/CSystemLinux.cpp b/src/nbl/system/CSystemLinux.cpp index 5a62518b0a..f73e4a5ba7 100644 --- a/src/nbl/system/CSystemLinux.cpp +++ b/src/nbl/system/CSystemLinux.cpp @@ -9,7 +9,7 @@ using namespace nbl::system; ISystem::SystemInfo CSystemLinux::getSystemInfo() const { SystemInfo info; - + // TODO // info.cpuFrequencyHz = 3000000000u; @@ -26,4 +26,4 @@ ISystem::SystemInfo CSystemLinux::getSystemInfo() const return info; } -#endif \ No newline at end of file +#endif diff --git a/src/nbl/system/CSystemMacOS.cpp b/src/nbl/system/CSystemMacOS.cpp new file mode 100644 index 0000000000..2b39945011 --- /dev/null +++ b/src/nbl/system/CSystemMacOS.cpp @@ -0,0 +1,37 @@ +#include "nbl/system/CSystemMacOS.h" + +using namespace nbl; +using namespace nbl::system; + +#ifdef _NBL_PLATFORM_MACOS_ + +#include +#include +#include +#include + +ISystem::SystemInfo CSystemMacOS::getSystemInfo() const +{ + #define BUFFERLEN 128 + + auto getProperty = [](const std::string_view property) -> int32_t + { + std::string buffer; + buffer.resize(BUFFERLEN); + size_t bufferCopyLen = buffer.size(); + sysctlbyname(property.data(), buffer.data(), &bufferCopyLen, nullptr, 0); + return std::stoi(buffer.substr(0, bufferCopyLen)); + }; + + SystemInfo info; + + // info.OSFullName = ; + info.cpuFrequencyHz = 3000000000u; // TODO + info.desktopResX = 0xdeadbeefu; // TODO + info.desktopResY = 0xdeadbeefu; // TODO + info.totalMemory = getProperty("hw.memsize"); //hw.memsize + // info.availableMemory = ; // TODO + + return info; +} +#endif // _NBL_PLATFORM_MACOS_ diff --git a/src/nbl/system/ISystemPOSIX.cpp b/src/nbl/system/ISystemPOSIX.cpp index ae4b3cb4e9..d803917de2 100644 --- a/src/nbl/system/ISystemPOSIX.cpp +++ b/src/nbl/system/ISystemPOSIX.cpp @@ -6,7 +6,7 @@ using namespace nbl; using namespace nbl::system; -#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) +#if defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_MACOS_) #include #include diff --git a/src/nbl/video/IAPIConnection.cpp b/src/nbl/video/IAPIConnection.cpp index 244dfabc0a..c2b4289552 100644 --- a/src/nbl/video/IAPIConnection.cpp +++ b/src/nbl/video/IAPIConnection.cpp @@ -28,8 +28,8 @@ IAPIConnection::IAPIConnection(const SFeatures& enabledFeatures) if (HMODULE mod = GetModuleHandleA("renderdoc.dll")) #elif defined(_NBL_PLATFORM_ANDROID_) if (void* mod = dlopen("libVkLayer_GLES_RenderDoc.so", RTLD_NOW | RTLD_NOLOAD)) -#elif defined(_NBL_PLATFORM_LINUX_) - if (void* mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD)) +#elif defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_MACOS_) + if (void* mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD)) // TODO: check it on MacOS #else #error "Nabla Unsupported Platform!" #endif @@ -39,12 +39,12 @@ IAPIConnection::IAPIConnection(const SFeatures& enabledFeatures) (pRENDERDOC_GetAPI)GetProcAddress(mod, "RENDERDOC_GetAPI"); int ret = RENDERDOC_GetAPI(MinRenderdocVersion, (void**)&m_rdoc_api); assert(ret == 1); - #elif defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_LINUX_) - pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI"); + #elif defined(_NBL_PLATFORM_ANDROID_) || defined(_NBL_PLATFORM_LINUX_) || defined(_NBL_PLATFORM_MACOS_) + pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI"); // TODO: check it on MacOS int ret = RENDERDOC_GetAPI(MinRenderdocVersion, (void**)&m_rdoc_api); assert(ret == 1); #endif } } -} \ No newline at end of file +} From b9c830ea834bdadd9615a671ac50b899e1abda57 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 25 Apr 2023 15:17:09 +0200 Subject: [PATCH 13/20] eliminate last errors and compile Nabla on MacOS with AppleClang and Xcode generator --- src/nbl/asset/interchange/CImageLoaderJPG.cpp | 4 ++-- src/nbl/asset/interchange/CImageLoaderPNG.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nbl/asset/interchange/CImageLoaderJPG.cpp b/src/nbl/asset/interchange/CImageLoaderJPG.cpp index d7ddd1e4e2..5eb198d03e 100644 --- a/src/nbl/asset/interchange/CImageLoaderJPG.cpp +++ b/src/nbl/asset/interchange/CImageLoaderJPG.cpp @@ -274,7 +274,7 @@ asset::SAssetBundle CImageLoaderJPG::loadAsset(system::IFile* _file, const asset // https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion break; case JCS_CMYK: - _params.logger.log("CMYK color space is unsupported:", system::ILogger::ELL_ERROR, _file->getFileName().string()); + _params.logger.log("CMYK color space is unsupported:", system::ILogger::ELL_ERROR, _file->getFileName().string().c_str()); return {}; break; case JCS_YCCK: // this I have no resources on @@ -336,4 +336,4 @@ asset::SAssetBundle CImageLoaderJPG::loadAsset(system::IFile* _file, const asset } // end namespace video } // end namespace nbl -#endif \ No newline at end of file +#endif diff --git a/src/nbl/asset/interchange/CImageLoaderPNG.cpp b/src/nbl/asset/interchange/CImageLoaderPNG.cpp index 8b9ade44f6..adb0659707 100644 --- a/src/nbl/asset/interchange/CImageLoaderPNG.cpp +++ b/src/nbl/asset/interchange/CImageLoaderPNG.cpp @@ -117,7 +117,7 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset _file->read(success, buffer, 0, sizeof(buffer)); if (!success) { - _params.logger.log("LOAD PNG: can't read _file\n", system::ILogger::ELL_ERROR, _file->getFileName().string()); + _params.logger.log("LOAD PNG: can't read _file\n", system::ILogger::ELL_ERROR, _file->getFileName().string().c_str()); return {}; } @@ -347,4 +347,4 @@ asset::SAssetBundle CImageLoaderPng::loadAsset(system::IFile* _file, const asset }// end namespace nbl }//end namespace video -#endif \ No newline at end of file +#endif From e43df25d249a7693113fc6932ce80fc1690e3622 Mon Sep 17 00:00:00 2001 From: "Hazard (Cyprian Skrzypczak)" Date: Thu, 21 Sep 2023 20:08:16 +0200 Subject: [PATCH 14/20] updated .gitmodules to use DevshGraphicsProgramming forks and SSH --- .gitmodules | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.gitmodules b/.gitmodules index fa05c77b37..b0727280ab 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,78 +1,78 @@ [submodule "3rdparty/glslang"] path = 3rdparty/glslang - url = https://github.com/devshgraphicsprogramming/glslang.git + url = git@github.com:devshgraphicsprogramming/glslang.git branch = nabla [submodule "3rdparty/shaderc"] path = 3rdparty/shaderc - url = https://github.com/google/shaderc.git + url = git@github.com:Devsh-Graphics-Programming/shaderc.git [submodule "3rdparty/bzip2"] path = 3rdparty/bzip2 - url = https://github.com/sergiud/bzip2.git + url = git@github.com:Devsh-Graphics-Programming/bzip2.git [submodule "3rdparty/lz4"] path = 3rdparty/lz4 - url = https://github.com/lz4/lz4.git + url = git@github.com:Devsh-Graphics-Programming/lz4.git [submodule "3rdparty/zlib"] path = 3rdparty/zlib - url = https://github.com/madler/zlib.git + url = git@github.com:Devsh-Graphics-Programming/zlib.git [submodule "3rdparty/libpng"] path = 3rdparty/libpng - url = https://github.com/glennrp/libpng.git + url = git@github.com:Devsh-Graphics-Programming/libpng.git [submodule "3rdparty/openssl/openssl"] path = 3rdparty/openssl/openssl - url = https://github.com/openssl/openssl.git + url = git@github.com:Devsh-Graphics-Programming/openssl.git branch = OpenSSL_1_0_2-stable [submodule "3rdparty/libjpeg-turbo"] path = 3rdparty/libjpeg-turbo - url = https://github.com/libjpeg-turbo/libjpeg-turbo.git + url = git@github.com:Devsh-Graphics-Programming/libjpeg-turbo.git [submodule "3rdparty/bullet3"] path = 3rdparty/bullet3 - url = https://github.com/bulletphysics/bullet3.git + url = git@github.com:Devsh-Graphics-Programming/bullet3.git [submodule "3rdparty/portable-file-dialogs"] path = 3rdparty/portable-file-dialogs - url = https://github.com/samhocevar/portable-file-dialogs.git + url = git@github.com:Devsh-Graphics-Programming/portable-file-dialogs.git [submodule "3rdparty/libexpat"] path = 3rdparty/libexpat - url = https://github.com/libexpat/libexpat.git + url = git@github.com:Devsh-Graphics-Programming/libexpat.git branch = master [submodule "3rdparty/glm"] path = 3rdparty/glm - url = https://github.com/AnastaZIuk/glm.git + url = git@github.com:AnastaZIuk/glm.git [submodule "3rdparty/freetype2"] path = 3rdparty/freetype2 - url = https://git.sv.nongnu.org/r/freetype/freetype2.git + url = git@github.com:Devsh-Graphics-Programming/freetype.git [submodule "3rdparty/openexr"] path = 3rdparty/openexr - url = https://github.com/AcademySoftwareFoundation/openexr.git + url = git@github.com:Devsh-Graphics-Programming/openexr.git [submodule "3rdparty/gli"] path = 3rdparty/gli - url = https://github.com/g-truc/gli.git + url = git@github.com:Devsh-Graphics-Programming/gli.git [submodule "3rdparty/parallel-hashmap"] path = 3rdparty/parallel-hashmap - url = https://github.com/greg7mdp/parallel-hashmap + url = git@github.com:Devsh-Graphics-Programming/parallel-hashmap.git [submodule "3rdparty/jitify"] path = 3rdparty/jitify - url = https://github.com/NVIDIA/jitify + url = git@github.com:Devsh-Graphics-Programming/jitify.git [submodule "3rdparty/volk"] path = 3rdparty/volk - url = https://github.com/zeux/volk.git + url = git@github.com:Devsh-Graphics-Programming/volk.git [submodule "3rdparty/simdjson"] path = 3rdparty/simdjson - url = https://github.com/simdjson/simdjson.git + url = git@github.com:Devsh-Graphics-Programming/simdjson.git [submodule "3rdparty/glTFSampleModels"] path = 3rdparty/glTFSampleModels - url = https://github.com/KhronosGroup/glTF-Sample-Models.git + url = git@github.com:Devsh-Graphics-Programming/glTF-Sample-Models.git [submodule "3rdparty/nbl_spirv_cross"] path = 3rdparty/nbl_spirv_cross - url = https://github.com/devshgraphicsprogramming/SPIRV-Cross.git + url = git@github.com:devshgraphicsprogramming/SPIRV-Cross.git [submodule "3rdparty/pstl/oneTBB"] path = 3rdparty/pstl/oneTBB - url = https://github.com/Devsh-Graphics-Programming/oneTBB.git + url = git@github.com:Devsh-Graphics-Programming/oneTBB.git [submodule "3rdparty/pstl/oneDPL/oneDPL"] path = 3rdparty/pstl/oneDPL/oneDPL url = git@github.com:Devsh-Graphics-Programming/oneDPL.git [submodule "3rdparty/Vulkan-Headers"] path = 3rdparty/Vulkan-Headers - url = git@github.com:KhronosGroup/Vulkan-Headers.git + url = git@github.com:Devsh-Graphics-Programming/Vulkan-Headers.git branch = main [submodule "examples_tests"] path = examples_tests @@ -86,4 +86,4 @@ url = git@github.com:Erfan-Ahmadi/tcpp.git [submodule "3rdparty/boost/standalone/math"] path = 3rdparty/boost/standalone/math - url = git@github.com:boostorg/math.git + url = git@github.com:Devsh-Graphics-Programming/boostmath.git From 5752d7e0a62249ada0e92963af32c1517c42e5dd Mon Sep 17 00:00:00 2001 From: Arkadiusz Lachowicz <34793522+AnastaZIuk@users.noreply.github.com> Date: Thu, 25 Jul 2024 10:46:24 +0200 Subject: [PATCH 15/20] Delete 3rdparty/boost/standalone directory --- 3rdparty/boost/standalone/math | 1 - 1 file changed, 1 deletion(-) delete mode 160000 3rdparty/boost/standalone/math diff --git a/3rdparty/boost/standalone/math b/3rdparty/boost/standalone/math deleted file mode 160000 index c56f334348..0000000000 --- a/3rdparty/boost/standalone/math +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c56f334348d5476783fba996d604fc5c6ae980c3 From e7bef08232cbce156ed8a3ad1d95e3e0e2955aaf Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 25 Jul 2024 10:51:40 +0200 Subject: [PATCH 16/20] Refactor submodule.update.cmake & do not use proxy scripts anymore, submit all commands within the file to prevent OS wide issues with chmod (which turns out doesn't work even if FILE(CHMOD <..>) is used properly, it may be a CMake bug), temporary disable NBL_UPDATE_GIT_SUBMODULE_NO_SEPARATE_SHELL usage, will bring it back in following commit --- CMakeLists.txt | 3 +- CMakePresets.json | 24 ++--- cmake/submodules/update.cmake | 194 ++++++++++++---------------------- 3 files changed, 78 insertions(+), 143 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdf61276c7..9e589d3a5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,14 +41,13 @@ endif() if(NBL_STATIC_BUILD) message(STATUS "Static Nabla build enabled!") else() + # TODO: needs correcting those checks if(WIN32 AND MSVC) if(NBL_DYNAMIC_MSVC_RUNTIME) message(STATUS "Shared Nabla build enabled!") else() message(FATAL_ERROR "Turn NBL_DYNAMIC_MSVC_RUNTIME on! For dynamic Nabla builds dynamic MSVC runtime is mandatory!") endif() - else() - message(FATAL_ERROR "Nabla can't be built with shared libraries! Please make sure you are targetting Windows OS and MSVC compiler!") endif() endif() diff --git a/CMakePresets.json b/CMakePresets.json index 04a6177b14..03e323ae2a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -152,11 +152,6 @@ "inherits": "user-configure-static-base", "cacheVariables": { "NBL_DYNAMIC_MSVC_RUNTIME": "OFF" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" } }, { @@ -165,11 +160,6 @@ "inherits": "user-configure-dynamic-base", "cacheVariables": { "NBL_DYNAMIC_MSVC_RUNTIME": "ON" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" } }, { @@ -178,7 +168,12 @@ "displayName": "[USER]: Static library target, Visual Studio 17 2022 generator, MSVC v143 toolset", "description": "Configure as static library with Visual Studio 17 2022 generator and MSVC v143 toolset", "generator": "Visual Studio 17 2022", - "toolset": "v143" + "toolset": "v143", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } }, { "name": "user-configure-dynamic-msvc", @@ -186,7 +181,12 @@ "displayName": "[USER]: Dynamic library target, Visual Studio 17 2022 generator, MSVC v143 toolset", "description": "Configure as dynamic library with Visual Studio 17 2022 generator and MSVC v143 toolset", "generator": "Visual Studio 17 2022", - "toolset": "v143" + "toolset": "v143", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } }, { "name": "user-configure-static-ninja-multi", diff --git a/cmake/submodules/update.cmake b/cmake/submodules/update.cmake index bafcc359ff..400b905d6e 100644 --- a/cmake/submodules/update.cmake +++ b/cmake/submodules/update.cmake @@ -39,166 +39,102 @@ function(NBL_UPDATE_SUBMODULES) set(NBL_FORCE "") endif() - macro(NBL_WRAPPER_COMMAND_EXCLUSIVE GIT_RELATIVE_ENTRY GIT_SUBMODULE_PATH SHOULD_RECURSIVE EXCLUDE_SUBMODULE_PATHS) - set(EXCLUDE_SUBMODULE_PATHS ${EXCLUDE_SUBMODULE_PATHS}) - set(SHOULD_RECURSIVE ${SHOULD_RECURSIVE}) - - if("${EXCLUDE_SUBMODULE_PATHS}" STREQUAL "") + function(NBL_EXCLUSIVE_UPDATE_EXECUTE GIT_RELATIVE_ENTRY GIT_SUBMODULE_PATH SHOULD_RECURSIVE EXCLUDE_SUBMODULE_PATHS) + if(EXCLUDE_SUBMODULE_PATHS STREQUAL "") set(NBL_EXCLUDE "") else() foreach(EXCLUDE_SUBMODULE_PATH ${EXCLUDE_SUBMODULE_PATHS}) - string(APPEND NBL_EXCLUDE "-c submodule.\"${EXCLUDE_SUBMODULE_PATH}\".update=none ") + string(APPEND NBL_EXCLUDE "-c;submodule.\"${EXCLUDE_SUBMODULE_PATH}\".update=none;") endforeach() string(STRIP "${NBL_EXCLUDE}" NBL_EXCLUDE) endif() + list(APPEND NBL_COMMAND "${GIT_EXECUTABLE}" -C "${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}" ${NBL_EXCLUDE} submodule update --init -j ${_GIT_SUBMODULES_JOBS_AMOUNT_} ${NBL_FORCE}) + if(SHOULD_RECURSIVE) - set(_NBL_EXECUTE_COMMAND_ "\"${GIT_EXECUTABLE}\" -C \"${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}\" ${NBL_EXCLUDE} submodule update --init -j ${_GIT_SUBMODULES_JOBS_AMOUNT_} ${NBL_FORCE} --recursive ${NBL_SHALLOW} ${GIT_SUBMODULE_PATH}") - else() - set(_NBL_EXECUTE_COMMAND_ "\"${GIT_EXECUTABLE}\" -C \"${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}\" ${NBL_EXCLUDE} submodule update --init -j ${_GIT_SUBMODULES_JOBS_AMOUNT_} ${NBL_FORCE} ${NBL_SHALLOW} ${GIT_SUBMODULE_PATH}") + list(APPEND NBL_COMMAND --recursive) endif() - - string(APPEND _NBL_UPDATE_SUBMODULES_COMMANDS_ "${_NBL_EXECUTE_COMMAND_}\n") - - unset(NBL_EXCLUDE) - endmacro() - - set(_NBL_UPDATE_SUBMODULES_CMD_NAME_ "nbl-update-submodules") - set(_NBL_UPDATE_SUBMODULES_CMD_FILE_ "${NBL_ROOT_PATH_BINARY}/${_NBL_UPDATE_SUBMODULES_CMD_NAME_}.cmd") - get_filename_component(_NBL_UPDATE_IMPL_CMAKE_FILE_ "${NBL_ROOT_PATH_BINARY}/${_NBL_UPDATE_SUBMODULES_CMD_NAME_}.cmake" ABSOLUTE) - - # Proxy script for inclusive submodule updating - string(APPEND NBL_IMPL_SCRIPT "set(NBL_ROOT_PATH \"${NBL_ROOT_PATH}\")\nset(_GIT_SUBMODULES_JOBS_AMOUNT_ ${_GIT_SUBMODULES_JOBS_AMOUNT_})\nset(GIT_EXECUTABLE \"${GIT_EXECUTABLE}\")\nset(NBL_SHALLOW \"${NBL_SHALLOW}\")\nset(NBL_FORCE \"${NBL_FORCE}\")\n\n") - string(APPEND NBL_IMPL_SCRIPT -[=[ -if(NOT DEFINED GIT_RELATIVE_ENTRY) - message(FATAL_ERROR "GIT_RELATIVE_ENTRY must be defined to use this script!") -endif() -if(NOT DEFINED INCLUDE_SUBMODULE_PATHS) - message(FATAL_ERROR "INCLUDE_SUBMODULE_PATHS must be defined to use this script!") -endif() + list(APPEND NBL_COMMAND ${NBL_SHALLOW} ${GIT_SUBMODULE_PATH}) -# update an inclusive submodule first -execute_process(COMMAND "${GIT_EXECUTABLE}" -C "${NBL_ROOT_PATH}" submodule update --init "${GIT_RELATIVE_ENTRY}") + execute_process(COMMAND ${NBL_COMMAND}) + endfunction() + + function(NBL_INCLUSIVE_UPDATE_EXECUTE GIT_RELATIVE_ENTRY INCLUDE_SUBMODULE_PATHS) + execute_process(COMMAND "${GIT_EXECUTABLE}" -C "${NBL_ROOT_PATH}" submodule update --init "${GIT_RELATIVE_ENTRY}") -if("${INCLUDE_SUBMODULE_PATHS}" STREQUAL "") - set(NBL_SUBMODULE_UPDATE_CONFIG_ENTRY "") -else() - execute_process(COMMAND "${GIT_EXECUTABLE}" -C "${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}" config --file .gitmodules --get-regexp path - OUTPUT_VARIABLE NBL_OUTPUT_VARIABLE - ) + if("${INCLUDE_SUBMODULE_PATHS}" STREQUAL "") + set(NBL_SUBMODULE_UPDATE_CONFIG_ENTRY "") + else() + execute_process(COMMAND "${GIT_EXECUTABLE}" -C "${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}" config --file .gitmodules --get-regexp path + OUTPUT_VARIABLE NBL_OUTPUT_VARIABLE + ) - string(REGEX REPLACE "\n" ";" NBL_SUBMODULE_CONFIG_LIST "${NBL_OUTPUT_VARIABLE}") - - foreach(NBL_SUBMODULE_NAME ${NBL_SUBMODULE_CONFIG_LIST}) - string(REGEX MATCH "submodule\\.(.*)\\.path" NBL_SUBMODULE_NAME "${NBL_SUBMODULE_NAME}") - list(APPEND NBL_ALL_SUBMODULES "${CMAKE_MATCH_1}") - endforeach() - - foreach(NBL_SUBMODULE_NAME ${NBL_ALL_SUBMODULES}) - list(FIND INCLUDE_SUBMODULE_PATHS "${NBL_SUBMODULE_NAME}" NBL_FOUND) - - if("${NBL_FOUND}" STREQUAL "-1") - list(APPEND NBL_CONFIG_SETUP_CMD "-c;submodule.${NBL_SUBMODULE_NAME}.update=none") # filter submodules - only those on the INCLUDE_SUBMODULE_PATHS list will be updated when recursive update is requested, all left will be skipped + string(REGEX REPLACE "\n" ";" NBL_SUBMODULE_CONFIG_LIST "${NBL_OUTPUT_VARIABLE}") + + foreach(NBL_SUBMODULE_NAME ${NBL_SUBMODULE_CONFIG_LIST}) + string(REGEX MATCH "submodule\\.(.*)\\.path" NBL_SUBMODULE_NAME "${NBL_SUBMODULE_NAME}") + list(APPEND NBL_ALL_SUBMODULES "${CMAKE_MATCH_1}") + endforeach() + + foreach(NBL_SUBMODULE_NAME ${NBL_ALL_SUBMODULES}) + list(FIND INCLUDE_SUBMODULE_PATHS "${NBL_SUBMODULE_NAME}" NBL_FOUND) + + if("${NBL_FOUND}" STREQUAL "-1") + list(APPEND NBL_CONFIG_SETUP_CMD "-c;submodule.${NBL_SUBMODULE_NAME}.update=none") # filter submodules - only those on the INCLUDE_SUBMODULE_PATHS list will be updated when recursive update is requested, all left will be skipped + endif() + endforeach() endif() - endforeach() -endif() -execute_process(COMMAND "${GIT_EXECUTABLE}" ${NBL_CONFIG_SETUP_CMD} submodule update --init -j ${_GIT_SUBMODULES_JOBS_AMOUNT_} --recursive ${NBL_SHALLOW} ${NBL_FORCE} - WORKING_DIRECTORY "${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}" -) -]=] -) - file(WRITE "${_NBL_UPDATE_IMPL_CMAKE_FILE_}" "${NBL_IMPL_SCRIPT}") - - macro(NBL_WRAPPER_COMMAND_INCLUSIVE GIT_RELATIVE_ENTRY INCLUDE_SUBMODULE_PATHS) - string(APPEND _NBL_UPDATE_SUBMODULES_COMMANDS_ "\"${CMAKE_COMMAND}\" \"-DGIT_RELATIVE_ENTRY=${GIT_RELATIVE_ENTRY}\" \"-DINCLUDE_SUBMODULE_PATHS=${INCLUDE_SUBMODULE_PATHS}\" -P \"${_NBL_UPDATE_IMPL_CMAKE_FILE_}\"\n") - endmacro() + execute_process(COMMAND "${GIT_EXECUTABLE}" ${NBL_CONFIG_SETUP_CMD} submodule update --init -j ${_GIT_SUBMODULES_JOBS_AMOUNT_} --recursive ${NBL_SHALLOW} ${NBL_FORCE} + WORKING_DIRECTORY "${NBL_ROOT_PATH}/${GIT_RELATIVE_ENTRY}" + ) + endfunction() if(NBL_UPDATE_GIT_SUBMODULE) - execute_process(COMMAND ${CMAKE_COMMAND} -E echo "All submodules are about to get updated and initialized in repository because NBL_UPDATE_GIT_SUBMODULE is turned ON!") + execute_process(COMMAND ${CMAKE_COMMAND} -E echo "NBL_UPDATE_GIT_SUBMODULE is turned ON, updating submodules.") + if(NBL_SYNC_ON_UPDATE_GIT_SUBMODULE) + execute_process(COMMAND "${GIT_EXECUTABLE}" submodule sync --recursive + WORKING_DIRECTORY "${NBL_ROOT_PATH}" + ) + endif() + include("${THIRD_PARTY_SOURCE_DIR}/boost/dep/wave.cmake") - macro(NBL_IMPL_INIT_COMMON_SUBMODULES) - # 3rdparty except boost & gltf - set(NBL_3RDPARTY_MODULES_TO_SKIP - 3rdparty/boost/superproject # a lot of submodules we don't use - 3rdparty/glTFSampleModels # more then 2GB waste of space (disk + .gitmodules data) - ) - NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./3rdparty TRUE "${NBL_3RDPARTY_MODULES_TO_SKIP}") - - # boost's 3rdparties, special case - set(NBL_BOOST_LIBS_TO_INIT ${NBL_BOOST_LIBS} wave numeric_conversion) # wave and all of its deps, numeric_conversion is nested in conversion submodule (for some reason boostdep tool doesn't output it properly) - foreach(NBL_TARGET ${NBL_BOOST_LIBS_TO_INIT}) - list(APPEND NBL_BOOST_SUBMODULES_TO_INIT ${NBL_TARGET}) - endforeach() - NBL_WRAPPER_COMMAND_INCLUSIVE(3rdparty/boost/superproject "${NBL_BOOST_SUBMODULES_TO_INIT}") - - # tests - NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./tests FALSE "") - endmacro() + # 3rdparty except boost & gltf + set(NBL_3RDPARTY_MODULES_TO_SKIP + 3rdparty/boost/superproject # a lot of submodules we don't use + 3rdparty/glTFSampleModels # more then 2GB waste of space (disk + .gitmodules data) + ) + + NBL_EXCLUSIVE_UPDATE_EXECUTE("" ./3rdparty TRUE "${NBL_3RDPARTY_MODULES_TO_SKIP}") + + # boost's 3rdparties, special case + set(NBL_BOOST_LIBS_TO_INIT ${NBL_BOOST_LIBS} wave numeric_conversion) # wave and all of its deps, numeric_conversion is nested in conversion submodule (for some reason boostdep tool doesn't output it properly) + foreach(NBL_TARGET ${NBL_BOOST_LIBS_TO_INIT}) + list(APPEND NBL_BOOST_SUBMODULES_TO_INIT ${NBL_TARGET}) + endforeach() + + NBL_INCLUSIVE_UPDATE_EXECUTE(3rdparty/boost/superproject "${NBL_BOOST_SUBMODULES_TO_INIT}") - NBL_IMPL_INIT_COMMON_SUBMODULES() + # tests + NBL_EXCLUSIVE_UPDATE_EXECUTE("" ./tests FALSE "") if(NBL_UPDATE_GIT_SUBMODULE_INCLUDE_PRIVATE) - NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./examples_tests TRUE "") + NBL_EXCLUSIVE_UPDATE_EXECUTE("" ./examples_tests TRUE "") else() - # NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./ci TRUE "") TODO: enable it once we merge Ditt, etc + # NBL_EXCLUSIVE_UPDATE_EXECUTE("" ./ci TRUE "") TODO: enable it once we merge Ditt, etc # examples and their media if(NBL_BUILD_EXAMPLES) - NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./examples_tests FALSE "") - NBL_WRAPPER_COMMAND_EXCLUSIVE(examples_tests ./media FALSE "") + NBL_EXCLUSIVE_UPDATE_EXECUTE("" ./examples_tests FALSE "") + NBL_EXCLUSIVE_UPDATE_EXECUTE(examples_tests ./media FALSE "") endif() endif() - - file(WRITE "${_NBL_UPDATE_SUBMODULES_CMD_FILE_}" "${_NBL_UPDATE_SUBMODULES_COMMANDS_}") - - if(WIN32) - if(NBL_UPDATE_GIT_SUBMODULE_NO_SEPARATE_SHELL) - set(UPDATE_COMMAND - nbl-update-submodules.cmd - ) - - execute_process(COMMAND ${UPDATE_COMMAND} - WORKING_DIRECTORY "${NBL_ROOT_PATH_BINARY}" - RESULT_VARIABLE _NBL_TMP_RET_CODE_ - ) - else() - find_package(GitBash REQUIRED) - - execute_process(COMMAND "${GIT_BASH_EXECUTABLE}" "-c" -[=[ ->&2 echo "" -clear -./nbl-update-submodules.cmd 2>&1 | tee nbl-update-submodules.log -sleep 1 -clear -tput setaf 2; echo -e "Submodules have been updated! -Created nbl-update-submodules.log in your build directory." -]=] - WORKING_DIRECTORY ${NBL_ROOT_PATH_BINARY} - OUTPUT_VARIABLE _NBL_TMP_OUTPUT_ - RESULT_VARIABLE _NBL_TMP_RET_CODE_ - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_STRIP_TRAILING_WHITESPACE - ) - - unset(_NBL_TMP_OUTPUT_) - unset(_NBL_TMP_RET_CODE_) - - message(STATUS "Generated \"${NBL_ROOT_PATH_BINARY}/nbl-update-submodules.log\"") - endif() - - message(STATUS "Submodules have been updated!") - else() - execute_process(COMMAND "${_NBL_UPDATE_SUBMODULES_CMD_FILE_}") - endif() else() - execute_process(COMMAND ${CMAKE_COMMAND} -E echo "NBL_UPDATE_GIT_SUBMODULE is turned OFF therefore submodules won't get updated.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "NBL_UPDATE_GIT_SUBMODULE is turned OFF, submodules won't get updated.") endif() endfunction() From e2067c2a4aeb4ba02f2d075f26a283cd2a9a84b3 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 25 Jul 2024 11:09:48 +0200 Subject: [PATCH 17/20] make NBL_FORCE_ON_UPDATE_GIT_SUBMODULE truely wipe-all thing --- cmake/submodules/update.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmake/submodules/update.cmake b/cmake/submodules/update.cmake index 400b905d6e..0377ab427d 100644 --- a/cmake/submodules/update.cmake +++ b/cmake/submodules/update.cmake @@ -2,7 +2,7 @@ include(ProcessorCount) find_package(Git REQUIRED) option(NBL_UPDATE_GIT_SUBMODULE "Turn this ON to let CMake update all public submodules for you" ON) -option(NBL_FORCE_ON_UPDATE_GIT_SUBMODULE "Submodules will be updated with --force flag if NBL_FORCE_UPDATE_GIT_SUBMODULE is turned ON, use with caution - if there are any uncommited files in submodules' working tree they will be removed!" OFF) +option(NBL_FORCE_ON_UPDATE_GIT_SUBMODULE "Submodules will be updated with --force flag if NBL_FORCE_UPDATE_GIT_SUBMODULE is turned ON + ALL SUBMODULES' CONTENT will be WIPED, use with caution - if there are any uncommited files in submodules' working tree they will be removed!" OFF) option(NBL_SYNC_ON_UPDATE_GIT_SUBMODULE "Sync initialized submodule paths if NBL_FORCE_UPDATE_GIT_SUBMODULE is turned ON, this is useful when any submodule remote path got modified and you want to apply this modification to your local repository. Turning NBL_FORCE_ON_UPDATE_GIT_SUBMODULE implies this option" OFF) option(NBL_UPDATE_GIT_SUBMODULE_INCLUDE_PRIVATE "Turn this ON to attempt to update private Nabla submodules" OFF) option(NBL_UPDATE_GIT_SUBMODULE_NO_SEPARATE_SHELL "Turn this ON to prevent CMake from executing git submodules update or sync in a separate shell - be aware that the interaction with shell will be impossible in case of paraphrase prompt request of your key!" ON) @@ -101,6 +101,16 @@ function(NBL_UPDATE_SUBMODULES) ) endif() + if(NBL_FORCE_ON_UPDATE_GIT_SUBMODULE) + execute_process(COMMAND "${GIT_EXECUTABLE}" submodule foreach --recursive "${GIT_EXECUTABLE}" clean -fdx + WORKING_DIRECTORY "${NBL_ROOT_PATH}" + ) + + execute_process(COMMAND "${GIT_EXECUTABLE}" submodule foreach --recursive "${GIT_EXECUTABLE}" reset --hard + WORKING_DIRECTORY "${NBL_ROOT_PATH}" + ) + endif() + include("${THIRD_PARTY_SOURCE_DIR}/boost/dep/wave.cmake") # 3rdparty except boost & gltf From e08ee2c798cc36006249dc8e80fa4025317bf58d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 25 Jul 2024 12:01:24 +0200 Subject: [PATCH 18/20] make this configure again --- 3rdparty/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index a0602b592d..1e7f7e318c 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -29,8 +29,10 @@ add_subdirectory(freetype2 freetype2 EXCLUDE_FROM_ALL) add_library(Freetype::Freetype ALIAS freetype) # alias target for MSDFGEN not trying to find freetype system-wide but rather to use the logical target available in our build tree # msdfgen + +set(MSDFGEN_USE_SKIA OFF) set(MSDFGEN_USE_VCPKG OFF) -set(MSDFGEN_CORE_ONLY OFF) # if turned on then MSDFGEN will be built without dependencies like freetype or skia +set(MSDFGEN_CORE_ONLY OFF) set(MSDFGEN_INSTALL OFF) set(MSDFGEN_BUILD_STANDALONE OFF) set(MSDFGEN_USE_CPP11 ON) @@ -80,6 +82,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "App add_subdirectory(pstl pstl EXCLUDE_FROM_ALL) endif() +# boost +add_subdirectory(boost boost EXCLUDE_FROM_ALL) + # zlib (target is zlibstatic) set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL}) From e7bfe9e367b8044030a26e50be4150d79aeea69c Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 25 Jul 2024 12:29:27 +0200 Subject: [PATCH 19/20] make it generate on my MacOS Air M2 (cross-compile to x86_64) --- 3rdparty/dxc/CMakeLists.txt | 11 +++-------- cmake/common.cmake | 6 ++++-- src/nbl/CMakeLists.txt | 6 +----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/3rdparty/dxc/CMakeLists.txt b/3rdparty/dxc/CMakeLists.txt index d17b2d8908..e215a7e9ba 100644 --- a/3rdparty/dxc/CMakeLists.txt +++ b/3rdparty/dxc/CMakeLists.txt @@ -115,6 +115,9 @@ else() endif() endif() +# this whole shit needs to be changed, +# leaving it till we get to relocatable packages + set(DXC_INCLUDE_DIRECTORIES $,${NBL_DXC_DEBUG_INCLUDE_DIRECTORIES},${NBL_DXC_RELEASE_INCLUDE_DIRECTORIES}> CACHE INTERNAL "" FORCE) @@ -142,14 +145,6 @@ set(DXC_DLL_NAME $,${_NBL_DXC_DEBUG_DLL_NAME_},${_NBL_DXC_RELEASE_DLL_NAME_}> CACHE INTERNAL "" FORCE) -set(DXC_COMPILE_FLAGS_RELEASE "") -set(DXC_COMPILE_FLAGS_RWDI "") -set(DXC_COMPILE_FLAGS_DEBUG "") - -set(DXC_COMPILE_FLAGS - $<$:${DXC_COMPILE_FLAGS_RELEASE}>$<$:${DXC_COMPILE_FLAGS_DEBUG}>$<$:${DXC_COMPILE_FLAGS_RWDI}> -CACHE INTERNAL "" FORCE) - get_filename_component(_SPIRV_BR_BUNDLE_SEARCH_DIRECTORY_ "${DXC_SPIRV_HEADERS_DIR}/include" ABSOLUTE) get_filename_component(_SPIRV_BR_OUTPUT_DIRECTORY_SOURCE_ "${CMAKE_CURRENT_BINARY_DIR}/src" ABSOLUTE) get_filename_component(_SPIRV_BR_OUTPUT_DIRECTORY_HEADER_ "${CMAKE_CURRENT_BINARY_DIR}/include" ABSOLUTE) diff --git a/cmake/common.cmake b/cmake/common.cmake index 56eb390b61..46defe6832 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -435,8 +435,10 @@ function(nbl_install_program_spec _TRGT _RELATIVE_DESTINATION) install(PROGRAMS $ DESTINATION ${_DEST_GE_} CONFIGURATIONS ${_CONFIGURATION_} COMPONENT Runtimes) endforeach() - install(PROGRAMS $ DESTINATION debug/runtime/${_RELATIVE_DESTINATION} CONFIGURATIONS Debug COMPONENT Runtimes) # TODO: write cmake script with GE to detect if target in configuration has PDB files generated then add install rule - + if(MSVC) + install(PROGRAMS $ DESTINATION debug/runtime/${_RELATIVE_DESTINATION} CONFIGURATIONS Debug COMPONENT Runtimes) # TODO: write cmake script with GE to detect if target in configuration has PDB files generated then add install rule + endif() + get_property(_DEFINED_PROPERTY_ TARGET ${_TRGT} PROPERTY NBL_PACKAGE_RUNTIME_DLL_DIR_PATH diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 58fda0620a..a77851e52d 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -544,16 +544,12 @@ if(_NBL_ENABLE_DXC_COMPILE_TESTS_) add_dependencies(Nabla HLSL_NABLA_COMPILE_TEST) endif() -add_custom_target(dxcompiler +add_custom_command(OUTPUT "${DXC_LIB}" "${DXC_DLL}" COMMAND "${CMAKE_COMMAND}" --build "${DXC_BUILD_DIR}" --target dxcompiler --config $,Debug,Release> -j${_NBL_JOBS_AMOUNT_} - BYPRODUCTS "${DXC_LIB}" "${DXC_DLL}" VERBATIM COMMAND_EXPAND_LISTS ) -add_dependencies(Nabla dxcompiler) -add_dependencies(3rdparty dxcompiler) - if(NBL_STATIC_BUILD) target_link_libraries(Nabla INTERFACE "${DXC_LIB}") else() From edb3c8dceadfd714aa6d255ecd7f22c4bd0a32d4 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 25 Jul 2024 12:43:24 +0200 Subject: [PATCH 20/20] silent all warnings regarding flags & definitions, add apple-clang.cmake and update flags.cmake --- cmake/adjust/flags.cmake | 2 ++ cmake/adjust/template/unix/apple-clang.cmake | 1 + 2 files changed, 3 insertions(+) create mode 100644 cmake/adjust/template/unix/apple-clang.cmake diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index 731ecb21f0..df35f9a078 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -13,6 +13,8 @@ macro(_NBL_IMPL_GET_FLAGS_PROFILE_) include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/unix/gnu.cmake") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/unix/clang.cmake") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/unix/apple-clang.cmake") else() message(WARNING "UNTESTED COMPILER DETECTED, EXPECT WRONG OPTIMIZATION FLAGS! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues") endif() diff --git a/cmake/adjust/template/unix/apple-clang.cmake b/cmake/adjust/template/unix/apple-clang.cmake new file mode 100644 index 0000000000..41ec16125b --- /dev/null +++ b/cmake/adjust/template/unix/apple-clang.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/clang.cmake") \ No newline at end of file