diff --git a/.gitmodules b/.gitmodules index 8edc1cead9..caca5b69a1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,9 +27,6 @@ path = 3rdparty/libexpat url = git@github.com:Devsh-Graphics-Programming/libexpat.git branch = master -[submodule "3rdparty/glm"] - path = 3rdparty/glm - url = git@github.com:AnastaZIuk/glm.git [submodule "3rdparty/freetype2"] path = 3rdparty/freetype2 url = git@github.com:Devsh-Graphics-Programming/freetype.git @@ -117,3 +114,6 @@ [submodule "docker/compiler-explorer"] path = docker/compiler-explorer url = git@github.com:Devsh-Graphics-Programming/Compiler-Explorer-Docker.git +[submodule "3rdparty/glm"] + path = 3rdparty/glm + url = git@github.com:Devsh-Graphics-Programming/glm.git diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 56752880ae..ffbf8e4cbd 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -231,7 +231,7 @@ if(_NBL_COMPILE_WITH_OPEN_EXR_) endif() -#gli +# gli option(_NBL_COMPILE_WITH_GLI_ "Build with GLI library" ON) if(_NBL_COMPILE_WITH_GLI_) set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) @@ -240,12 +240,23 @@ if(_NBL_COMPILE_WITH_GLI_) set(BUILD_SHARED_LIBS OFF) set(BUILD_STATIC_LIBS OFF) set(BUILD_TESTING OFF) + set(GLI_GLM_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/glm") add_subdirectory(gli gli EXCLUDE_FROM_ALL) set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS}) set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS}) set(BUILD_TESTING ${_OLD_BUILD_TESTING}) endif() +set(ENABLE_STATIC_LIB ON) +set(ENABLE_SHARED_LIB OFF) +set(ENABLE_EXAMPLES OFF) +set(ENABLE_DOCS OFF) +set(ENABLE_APP OFF) +set(ENABLE_LIB_ONLY ON) +set(ENABLE_TESTS OFF) +set(ENABLE_SUMMARY OFF) +add_subdirectory(bzip2 bzip2 EXCLUDE_FROM_ALL) + add_library(lzma OBJECT lzma/C/Alloc.c lzma/C/LzFind.c @@ -262,17 +273,6 @@ add_library(lz4 OBJECT lz4/lib/xxhash.c ) - -add_library(bzip2 OBJECT - bzip2/blocksort.c - bzip2/bzlib.c - bzip2/compress.c - bzip2/crctable.c - bzip2/decompress.c - bzip2/huffman.c - bzip2/randtable.c -) - add_library(spirv_cross OBJECT nbl_spirv_cross/spirv_cfg.cpp nbl_spirv_cross/spirv_cross.cpp @@ -419,12 +419,6 @@ add_library(aesGladman OBJECT add_subdirectory(argparse argparse EXCLUDE_FROM_ALL) -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) -set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS}) -set(BUILD_STATIC_LIBS ${_OLD_BUILD_STATIC_LIBS}) - if (NBL_BUILD_MITSUBA_LOADER) option(BUILD_tools "EXPAT: build the xmlwf tool for expat library" OFF) option(BUILD_examples "EXPAT: build the examples for expat library" OFF) @@ -465,7 +459,7 @@ set(NBL_3RDPARTY_TARGETS shaderc_util shaderc jpeg-static - bzip2 + bz2_static simdjson nlohmann_json glslang @@ -496,11 +490,7 @@ if (NBL_BUILD_IMGUI) endif() foreach(trgt IN LISTS NBL_3RDPARTY_TARGETS) - if(NBL_DYNAMIC_MSVC_RUNTIME) - set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else() - set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$:DLL>") if(MSVC AND NBL_SANITIZE_ADDRESS) set_property(TARGET ${trgt} PROPERTY COMPILE_OPTIONS /fsanitize=address) diff --git a/3rdparty/bzip2 b/3rdparty/bzip2 index c4a14bb87e..f4301b0eac 160000 --- a/3rdparty/bzip2 +++ b/3rdparty/bzip2 @@ -1 +1 @@ -Subproject commit c4a14bb87ee395fb2c69ef5dbb50762fe862517e +Subproject commit f4301b0eac69eb109c5419813102be6f82d2b73a diff --git a/3rdparty/dxc/CMakeLists.txt b/3rdparty/dxc/CMakeLists.txt index 8b48c0e5a6..ed2528c922 100644 --- a/3rdparty/dxc/CMakeLists.txt +++ b/3rdparty/dxc/CMakeLists.txt @@ -63,11 +63,7 @@ if(WIN32) endif() endif() -if(NBL_DYNAMIC_MSVC_RUNTIME) - list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>DLL") -else() - list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>") -endif() +list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$:Debug>$<$:DLL>") # perform DXC compile standard requirement test set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/3rdparty/dxc/dxc b/3rdparty/dxc/dxc index 5ab4d368b6..4621c707ed 160000 --- a/3rdparty/dxc/dxc +++ b/3rdparty/dxc/dxc @@ -1 +1 @@ -Subproject commit 5ab4d368b666d365217c751f5610b496b828ff96 +Subproject commit 4621c707ed774ab8382391f6434810ebecd37111 diff --git a/3rdparty/gli b/3rdparty/gli index 559cbe1ec3..c4e6446d3b 160000 --- a/3rdparty/gli +++ b/3rdparty/gli @@ -1 +1 @@ -Subproject commit 559cbe1ec38878e182507d331e0780fbae5baf15 +Subproject commit c4e6446d3b646538026fd5a95533daed952878d4 diff --git a/3rdparty/glm b/3rdparty/glm index d162eee1e6..2d4c4b4dd3 160000 --- a/3rdparty/glm +++ b/3rdparty/glm @@ -1 +1 @@ -Subproject commit d162eee1e6f7c317a09229fe6ceab8ec6ab9a4b4 +Subproject commit 2d4c4b4dd31fde06cfffad7915c2b3006402322f diff --git a/CMakeLists.txt b/CMakeLists.txt index c819c644eb..a63d30a89d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,13 @@ # This file is part of the "Nabla Engine". # For conditions of distribution and use, see copyright notice in nabla.h.in or nabla.h -cmake_minimum_required(VERSION 3.29) -cmake_policy(SET CMP0112 NEW) +cmake_minimum_required(VERSION 3.31) +# TODO: Yas - once we deploy 4.x we will fire `cmake_policy` instead of manually picking policies +# https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html#policy-version +# also we should update deps which throw warnings about < 3.10 compatibility +cmake_policy(SET CMP0003 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0077.html#cmp0077 +cmake_policy(SET CMP0077 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0077.html#cmp0077 +cmake_policy(SET CMP0112 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0112.html#cmp0112 cmake_policy(SET CMP0141 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0141.html#policy:CMP0141 cmake_policy(SET CMP0118 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0118.html#policy:CMP0118 @@ -21,28 +26,16 @@ if(MSVC) endif() option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared -option(NBL_DYNAMIC_MSVC_RUNTIME "" ON) +option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON) option(NBL_SANITIZE_ADDRESS OFF) -if(MSVC) - if(NBL_SANITIZE_ADDRESS) - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:ProgramDatabase>") - else() - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:EditAndContinue>$<$:ProgramDatabase>") - endif() -endif() +set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT $<$:ProgramDatabase>) # ignored on non xMSVC-ABI targets if(NBL_STATIC_BUILD) message(STATUS "Static Nabla build enabled!") else() - if(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!") + if(NOT NBL_COMPILER_DYNAMIC_RUNTIME) + message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic runtime is mandatory!") endif() endif() diff --git a/CMakePresets.json b/CMakePresets.json index 8d0b62367a..da28fc1aff 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -46,7 +46,7 @@ "hidden": true, "inherits": "ci-configure-static-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "OFF" + "NBL_COMPILER_DYNAMIC_RUNTIME": "OFF" }, "condition": { "type": "allOf", @@ -69,7 +69,7 @@ "hidden": true, "inherits": "ci-configure-dynamic-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "ON" + "NBL_COMPILER_DYNAMIC_RUNTIME": "ON" }, "condition": { "type": "allOf", @@ -156,7 +156,7 @@ "hidden": true, "inherits": "user-configure-static-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "OFF" + "NBL_COMPILER_DYNAMIC_RUNTIME": "OFF" }, "condition": { "type": "equals", @@ -169,7 +169,7 @@ "hidden": true, "inherits": "user-configure-dynamic-base", "cacheVariables": { - "NBL_DYNAMIC_MSVC_RUNTIME": "ON" + "NBL_COMPILER_DYNAMIC_RUNTIME": "ON" }, "condition": { "type": "equals", @@ -193,6 +193,22 @@ "generator": "Visual Studio 17 2022", "toolset": "v143" }, + { + "name": "user-configure-static-clangcl", + "inherits": "user-configure-static-windows-base", + "displayName": "[USER]: Static library target, Visual Studio 17 2022 generator, ClangCL toolset", + "description": "Configure as static library with Visual Studio 17 2022 generator and ClangCL toolset", + "generator": "Visual Studio 17 2022", + "toolset": "ClangCL" + }, + { + "name": "user-configure-dynamic-clangcl", + "inherits": "user-configure-dynamic-windows-base", + "displayName": "[USER]: Dynamic library target, Visual Studio 17 2022 generator, ClangCL toolset", + "description": "Configure as dynamic library with Visual Studio 17 2022 generator and ClangCL toolset", + "generator": "Visual Studio 17 2022", + "toolset": "ClangCL" + }, { "name": "user-configure-static-ninja-multi", "inherits": "user-configure-static-windows-base", diff --git a/cmake/adjust/flags.cmake b/cmake/adjust/flags.cmake index 8bf2a77893..1e67914ae0 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -12,45 +12,173 @@ define_property(TARGET PROPERTY NBL_CONFIGURATION_MAP BRIEF_DOCS "Stores configuration map for a target, it will evaluate to the configuration it's mapped to" ) -function(NBL_REQUEST_COMPILE_OPTION_SUPPORT _NBL_COMPILE_OPTION_) - set(NBL_COMPILE_OPTION "${_NBL_COMPILE_OPTION_}") +# https://github.com/Kitware/CMake/blob/05e77b8a27033e6fd086456bd6cef28338ff1474/Modules/Internal/CheckCompilerFlag.cmake#L26C7-L26C42 +# must be cached because parse utility clears locals in the CheckCompilerFlag module +set(CHECK_COMPILER_FLAG_OUTPUT_VARIABLE NBL_COMPILER_FLAG_OUTPUT CACHE INTERNAL "") - foreach(COMPILER IN ITEMS c cxx) +# Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG COMPILE_OPTIONS LINK_OPTIONS ) +function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) + cmake_parse_arguments(IMPL "REQUIRED" "REQUEST_VAR" "LANG;CONFIG;COMPILE_OPTIONS;LINK_OPTIONS" ${ARGN}) + + set(DEFAULT_COMPILERS c cxx) + set(REQUEST_ALL_OPTIONS_PRESENT True) + + if(NOT IMPL_LANG) + list(APPEND IMPL_LANG ${DEFAULT_COMPILERS}) + endif() + + foreach(COMPILER IN ITEMS ${IMPL_LANG}) string(TOUPPER "${COMPILER}" COMPILER_UPPER) - string(REGEX REPLACE "[-=:;/.]" "_" flag_signature "${NBL_COMPILE_OPTION}") - set(flag_var "__${COMPILER_UPPER}_Flag_${flag_signature}") - - if(COMPILER STREQUAL "c") - check_c_compiler_flag("${NBL_COMPILE_OPTION}" ${flag_var}) - elseif(COMPILER STREQUAL "cxx") - check_cxx_compiler_flag("${NBL_COMPILE_OPTION}" ${flag_var}) - endif() - - if(${flag_var}) - message(STATUS "Enabled \"${NBL_COMPILE_OPTION}\" ${COMPILER_UPPER} compile option for Nabla projects!") - set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${NBL_COMPILE_OPTION}" PARENT_SCOPE) - else() - message(STATUS "Disabled \"${NBL_COMPILE_OPTION}\" ${COMPILER_UPPER} compile option for Nabla projects! (no support)") - endif() + foreach(WHAT_OPTIONS IN ITEMS IMPL_COMPILE_OPTIONS IMPL_LINK_OPTIONS) + if(NOT ${WHAT_OPTIONS}) + continue() + endif() + + set(IMPL_OPTIONS ${${WHAT_OPTIONS}}) + string(REPLACE IMPL_ "" WHAT_OPTIONS "${WHAT_OPTIONS}") + + foreach(COMPILE_OPTION ${IMPL_OPTIONS}) + if(IMPL_CONFIG) + foreach(CONFIG ${IMPL_CONFIG}) + # TODO: validate (${CONFIG} \in ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CONFIG}" CONFIG_UPPER) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS} "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS}};${COMPILE_OPTION}") + endforeach() + else() + set(NBL_${COMPILER_UPPER}_${WHAT_OPTIONS} "${NBL_${COMPILER_UPPER}_${WHAT_OPTIONS}};${COMPILE_OPTION}") + endif() + endforeach() + + if(IMPL_CONFIG) + foreach(CONFIG ${IMPL_CONFIG}) + string(TOUPPER "${CONFIG}" CONFIG_UPPER) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS} ${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_${WHAT_OPTIONS}} PARENT_SCOPE) + endforeach() + else() + set(NBL_${COMPILER_UPPER}_${WHAT_OPTIONS} ${NBL_${COMPILER_UPPER}_${WHAT_OPTIONS}} PARENT_SCOPE) + endif() + endforeach() endforeach() endfunction() option(NBL_REQUEST_SSE_4_2 "Request compilation with SSE 4.2 instruction set enabled for Nabla projects" ON) -option(NBL_REQUEST_SSE_AXV2 "Request compilation with SSE Intel Advanced Vector Extensions 2 for Nabla projects" ON) +option(NBL_REQUEST_SSE_AVX2 "Request compilation with SSE Intel Advanced Vector Extensions 2 for Nabla projects" ON) # profiles -if(MSVC) - include("${CMAKE_CURRENT_LIST_DIR}/template/windows/msvc.cmake") -elseif(ANDROID) - include("${CMAKE_CURRENT_LIST_DIR}/template/unix/android.cmake") -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - include("${CMAKE_CURRENT_LIST_DIR}/template/unix/gnu.cmake") -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - include("${CMAKE_CURRENT_LIST_DIR}/template/unix/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() +foreach(NBL_COMPILER_LANGUAGE IN ITEMS C CXX) + # all list of all known by CMake vendors: + # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html + set(NBL_COMPILER_VENDOR "${CMAKE_${NBL_COMPILER_LANGUAGE}_COMPILER_ID}") + set(NBL_PROFILE_NAME "${NBL_COMPILER_LANGUAGE}_${NBL_COMPILER_VENDOR}") # eg. "cxx_MSVC.cmake" + set(NBL_PROFILE_PATH "${CMAKE_CURRENT_LIST_DIR}/template/vendor/${NBL_PROFILE_NAME}.cmake") + + include("${NBL_PROFILE_PATH}" RESULT_VARIABLE _NBL_FOUND_) + + if(NOT _NBL_FOUND_) + message(WARNING "UNSUPPORTED \"${NBL_COMPILER_LANGUAGE}\" COMPILER LANGUAGE FOR \"${NBL_COMPILER_VENDOR}\" DETECTED, CMAKE CONFIGURATION OR BUILD MAY FAIL AND COMPILE OPTIONS FLAGS WILL NOT BE SET! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues") + continue() + endif() + + # a profile MUST define + + # - "NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_${WHAT}_OPTIONS" (configuration dependent) + # - "NBL_${NBL_COMPILER_LANGUAGE}_${WHAT}_OPTIONS" (global) + + # a profile MUST NOT define + # - NBL_${WHAT}_OPTIONS + + # note: + # - use NBL_REQUEST_COMPILE_OPTION_SUPPORT in profile to creates those vars + # - include reset utility in profiles to init vars with empty lists + + # TODO: DEFINITIONS for WHAT to unify the API + + foreach(WHAT COMPILE LINK) + set(NBL_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${WHAT}_OPTIONS) + set(NBL_OPTIONS_VAR_VALUE ${${NBL_OPTIONS_VAR_NAME}}) + + if(NOT DEFINED ${NBL_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_OPTIONS_VAR_NAME}\"!") + endif() + + # update map with configuration dependent compile options + foreach(CONFIGURATION IN ITEMS RELEASE RELWITHDEBINFO DEBUG) + set(NBL_CONFIGURATION_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_${WHAT}_OPTIONS) + set(NBL_CONFIGURATION_OPTIONS_VAR_VALUE ${${NBL_CONFIGURATION_OPTIONS_VAR_NAME}}) + + if(NOT DEFINED ${NBL_CONFIGURATION_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_CONFIGURATION_OPTIONS_VAR_NAME}\"!") + endif() + + set(NBL_${CONFIGURATION}_${WHAT}_OPTIONS ${NBL_${CONFIGURATION}_${WHAT}_OPTIONS} + # note that "${NBL_CONFIGURATION_OPTIONS_VAR_VALUE}" MUST NOT contain ANY + # $<$> generator expression in order to support our configuration mapping features + $<$<${WHAT}_LANGUAGE:${NBL_COMPILER_LANGUAGE}>:${NBL_CONFIGURATION_OPTIONS_VAR_VALUE}> + ) + endforeach() + + # update map with global compile options + set(NBL_${WHAT}_OPTIONS ${NBL_${WHAT}_OPTIONS} + $<$<${WHAT}_LANGUAGE:${NBL_COMPILER_LANGUAGE}>:${NBL_${NBL_COMPILER_LANGUAGE}_${WHAT}_OPTIONS}> + ) + endforeach() + + block() + # validate build with a vendor profile, any warning diagnostic = error + # if you hit error it means the profile generates diagnostics due to: + # - an option (compile or link) which doesn't exist (typo? check vendor docs) + # - a set of options which invalidates an option (eg. MSVC's /INCREMENTAL with /LTCG:incremental is invalid, however linker will emit a warning by default + do a fall-back) + # https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html#variable:CMAKE_%3CLANG%3E_FLAGS + # https://cmake.org/cmake/help/latest/module/CheckCompilerFlag.html#command:check_compiler_flag + + set(CMAKE_${NBL_COMPILER_LANGUAGE}_FLAGS) + + foreach(CONFIGURATION IN ITEMS Release RelWithDebInfo Debug) + set(CMAKE_TRY_COMPILE_CONFIGURATION ${CONFIGURATION}) + string(TOUPPER "${CONFIGURATION}" CONFIGURATION) + + set(TEST_NAME "NBL_${NBL_COMPILER_LANGUAGE}_LANG_${CONFIGURATION}_BUILD_OPTIONS_SUPPORT") + set(CMAKE_${NBL_COMPILER_LANGUAGE}_FLAGS_${CONFIGURATION}) + + set(COMPILE_OPTIONS ${NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS} ${NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS}) + set(LINK_OPTIONS ${NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_LINK_OPTIONS}) + set(COMBINED ${COMPILE_OPTIONS} ${LINK_OPTIONS}) + + set(NBL_OUTPUT_FILE "${CMAKE_BINARY_DIR}/.nbl/try-compile/${TEST_NAME}.output") # no hash in output diagnostic file, desired + + string(SHA1 OPTIONS_HASH "${COMBINED}") + string(APPEND TEST_NAME "_HASH_${OPTIONS_HASH}") + + set(FLAG_VAR ${TEST_NAME}) + set(CMAKE_REQUIRED_LINK_OPTIONS ${LINK_OPTIONS}) + string(REPLACE ";" " " CLI_COMPILE_OPTIONS "${COMPILE_OPTIONS}") + + if(NBL_COMPILER_LANGUAGE STREQUAL C) + check_c_compiler_flag("${CLI_COMPILE_OPTIONS}" "${FLAG_VAR}") + elseif(NBL_COMPILER_LANGUAGE STREQUAL CXX) + check_cxx_compiler_flag("${CLI_COMPILE_OPTIONS}" "${FLAG_VAR}") + endif() + + if(NOT ${FLAG_VAR}) + if(NOT "${NBL_COMPILER_FLAG_OUTPUT}" STREQUAL "") + file(WRITE "${NBL_OUTPUT_FILE}" "${NBL_COMPILER_FLAG_OUTPUT}") # lock into file, do not cache, must read from the file because of NBL_COMPILER_FLAG_OUTPUT availability (CMake module writes an output only once before a signature flag status is created) + endif() + + if(EXISTS "${NBL_OUTPUT_FILE}") + file(READ "${NBL_OUTPUT_FILE}" NBL_DIAGNOSTICS) + set(NBL_DIAGNOSTICS "Diagnostics:\n${NBL_DIAGNOSTICS}") + else() + set(NBL_DIAGNOSTICS) + endif() + + if(NOT DEFINED NBL_SKIP_BUILD_OPTIONS_VALIDATION) + message(FATAL_ERROR "${TEST_NAME} failed! To skip the validation define \"NBL_SKIP_BUILD_OPTIONS_VALIDATION\". ${NBL_DIAGNOSTICS}") + endif() + endif() + endforeach() + endblock() +endforeach() function(NBL_EXT_P_APPEND_COMPILE_OPTIONS NBL_LIST_NAME MAP_RELEASE MAP_RELWITHDEBINFO MAP_DEBUG) macro(NBL_MAP_CONFIGURATION NBL_CONFIG_FROM NBL_CONFIG_TO) @@ -153,37 +281,34 @@ function(nbl_adjust_flags) # global compile options list(APPEND _D_NBL_COMPILE_OPTIONS_ ${NBL_COMPILE_OPTIONS}) - - # per configuration compile options with mapping - list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$:${NBL_${NBL_MAP_DEBUG_ITEM_U}_COMPILE_OPTIONS}>) - list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$:${NBL_${NBL_MAP_RELEASE_ITEM_U}_COMPILE_OPTIONS}>) - list(APPEND _D_NBL_COMPILE_OPTIONS_ $<$:${NBL_${NBL_MAP_RELWITHDEBINFO_ITEM_U}_COMPILE_OPTIONS}>) - - # configuration mapping properties - string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_DEBUG_ITEM_U}>) - string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_RELEASE_ITEM_U}>) - string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_RELWITHDEBINFO_ITEM_U}>) + + foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CONFIG}" CONFIG_U) + + # per configuration options with mapping + foreach(WHAT COMPILE LINK) + list(APPEND _D_NBL_${WHAT}_OPTIONS_ $<$:${NBL_${NBL_MAP_${CONFIG_U}_ITEM_U}_${WHAT}_OPTIONS}>) + endforeach() + + # configuration mapping properties + string(APPEND _D_NBL_CONFIGURATION_MAP_ $<$:${NBL_MAP_${CONFIG_U}_ITEM_U}>) + endforeach() set_target_properties(${NBL_TARGET_ITEM} PROPERTIES NBL_CONFIGURATION_MAP "${_D_NBL_CONFIGURATION_MAP_}" COMPILE_OPTIONS "${_D_NBL_COMPILE_OPTIONS_}" + LINK_OPTIONS "${_D_NBL_LINK_OPTIONS_}" ) unset(_D_NBL_CONFIGURATION_MAP_) unset(_D_NBL_COMPILE_OPTIONS_) + unset(_D_NBL_LINK_OPTIONS_) set(MAPPED_CONFIG $>) - if(MSVC) - if(NBL_SANITIZE_ADDRESS) - set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$,$>:ProgramDatabase>") - else() - set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$:EditAndContinue>$<$:ProgramDatabase>") - endif() - endif() - set_target_properties(${NBL_TARGET_ITEM} PROPERTIES - MSVC_DEBUG_INFORMATION_FORMAT "${NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT}" - ) + MSVC_DEBUG_INFORMATION_FORMAT $<$,$>:ProgramDatabase> # ignored on non xMSVC-ABI targets + ) + math(EXPR _NBL_ARG_I_ "${_NBL_ARG_I_} + 1") endwhile() else() # DIRECTORY mode diff --git a/cmake/adjust/template/vendor/CXX_Clang.cmake b/cmake/adjust/template/vendor/CXX_Clang.cmake new file mode 100644 index 0000000000..2cc877c028 --- /dev/null +++ b/cmake/adjust/template/vendor/CXX_Clang.cmake @@ -0,0 +1,5 @@ +include_guard(GLOBAL) + +set(LANG CXX) +include("${CMAKE_CURRENT_LIST_DIR}/impl/Clang.cmake") +# append unique CXX options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/CXX_MSVC.cmake b/cmake/adjust/template/vendor/CXX_MSVC.cmake new file mode 100644 index 0000000000..59f4e59cdd --- /dev/null +++ b/cmake/adjust/template/vendor/CXX_MSVC.cmake @@ -0,0 +1,5 @@ +include_guard(GLOBAL) + +set(LANG CXX) +include("${CMAKE_CURRENT_LIST_DIR}/impl/MSVC.cmake") +# append unique CXX options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/C_Clang.cmake b/cmake/adjust/template/vendor/C_Clang.cmake new file mode 100644 index 0000000000..046ccaa902 --- /dev/null +++ b/cmake/adjust/template/vendor/C_Clang.cmake @@ -0,0 +1,5 @@ +include_guard(GLOBAL) + +set(LANG C) +include("${CMAKE_CURRENT_LIST_DIR}/impl/Clang.cmake") +# append unique C options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/C_MSVC.cmake b/cmake/adjust/template/vendor/C_MSVC.cmake new file mode 100644 index 0000000000..f9aca4a5b7 --- /dev/null +++ b/cmake/adjust/template/vendor/C_MSVC.cmake @@ -0,0 +1,5 @@ +include_guard(GLOBAL) + +set(LANG C) +include("${CMAKE_CURRENT_LIST_DIR}/impl/MSVC.cmake") +# append unique C options here \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/Clang.cmake b/cmake/adjust/template/vendor/impl/Clang.cmake new file mode 100644 index 0000000000..0b00294411 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -0,0 +1,109 @@ +include("${CMAKE_CURRENT_LIST_DIR}/reset.cmake") + +# vendor template with options fitting for both C and CXX LANGs + +if(NOT DEFINED LANG) + message(FATAL_ERROR "LANG must be defined!") +endif() + +if(NBL_WITH_COMPILER_CRASH_DIAGNOSTICS) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + # use it to make a repro and attach to an issue if you Clang crashes + # - it outputs preprocessed cpp files with sh script for compilation + -fcrash-diagnostics=compiler + -fcrash-diagnostics-dir=${NBL_ROOT_PATH_BINARY}/.crash-report + ) +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + -Xclang=-fconstexpr-backtrace-limit=696969 + -Xclang=-fconstexpr-depth=696969 + -Xclang=-fconstexpr-steps=696969 + -Xclang=-ftemplate-backtrace-limit=0 # no limit + -Xclang=-ftemplate-depth=696969 + -Xclang=-fmacro-backtrace-limit=0 # no limit + -Xclang=-fspell-checking-limit=0 # no limit + -Xclang=-fcaret-diagnostics-max-lines=0 # no limit + + # latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson) + # TODO: Yas, we should first do independent check if host has the flags, if the request fail then + # do not promote simdjson to build with HASWELL implementation because those flags + avx2 compose + # subset it wants in this case + + ################ + # TODO: (****) -> + -mbmi # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbmi + -mlzcnt # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mlzcnt + -mpclmul # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mpclmul + ################ <- + + -Wextra # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning + -maes # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-maes + -mfpmath=sse # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mfpmath + + # TODO: Yas, eliminate all below + -fno-strict-aliasing + -Wno-sequence-point + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-padded + -Wno-unsafe-buffer-usage + -Wno-switch-enum + -Wno-error=ignored-attributes + -Wno-unused-parameter + -Wno-unused-but-set-parameter + -Wno-error=unused-function + -Wno-error=unused-variable + -Wno-error=unused-parameter + -Wno-error=ignored-attributes + -Wno-error=non-pod-varargs +) + +if(NBL_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 +) # TODO: (****) optional but then adjust 3rdparty options on fail +endif() + +if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC) + # ClangCL with MSVC frontend (most of the options are compatible but eg /arch:SSE4.2 seems to be not) + include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake") + return() +else() + if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 + ) # TODO: (****) + endif() + + if(NBL_SANITIZE_ADDRESS) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=address) + endif() + + if(NBL_SANITIZE_THREAD) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS -fsanitize=thread) + endif() + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS + -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g + -mincremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning + -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only + -Xclang=-fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + ) + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS + -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -DNDEBUG + ) + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS + -g # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-g + -O1 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -Xclang=-finline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions + -mno-incremental-linker-compatible # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mincremental-linker-compatible + -DNDEBUG + ) +endif() \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/MSVC.cmake b/cmake/adjust/template/vendor/impl/MSVC.cmake new file mode 100644 index 0000000000..803adb1754 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/MSVC.cmake @@ -0,0 +1,10 @@ +include("${CMAKE_CURRENT_LIST_DIR}/reset.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/frontend/MSVC.cmake") + +# vendor template with options fitting for both C and CXX LANGs + +if(NBL_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 +) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail +endif() \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/frontend/MSVC.cmake b/cmake/adjust/template/vendor/impl/frontend/MSVC.cmake new file mode 100644 index 0000000000..06ab606104 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/frontend/MSVC.cmake @@ -0,0 +1,68 @@ +# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.html#variable:CMAKE_%3CLANG%3E_COMPILER_FRONTEND_VARIANT +# vendor frontend template with options fitting for both C and CXX LANGs + +if(NOT DEFINED LANG) + message(FATAL_ERROR "LANG must be defined!") +endif() + +if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 +) # TODO: (****) should be (?) optional but then adjust 3rdparty options on fail +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 + /Zc:__cplusplus # https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170 + /Zc:wchar_t # https://learn.microsoft.com/en-us/cpp/build/reference/zc-wchar-t-wchar-t-is-native-type?view=msvc-170 + /fp:fast # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170 + /MP${_NBL_JOBS_AMOUNT_} # https://learn.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-170 +) + +if(NBL_SANITIZE_ADDRESS) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} COMPILE_OPTIONS + /fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170 + ) + + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS + /RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170 + ) +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG DEBUG COMPILE_OPTIONS + /Ob0 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /Od # https://learn.microsoft.com/en-us/cpp/build/reference/od-disable-debug?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 +) + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELEASE COMPILE_OPTIONS + /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 + /Ob2 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 + /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 + /Gy- # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 + /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + /GF # https://learn.microsoft.com/en-us/cpp/build/reference/gf-eliminate-duplicate-strings?view=msvc-170 + /GS- # https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /LTCG # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 (note: /GL implies fallback with LTCG) +) + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} CONFIG RELWITHDEBINFO COMPILE_OPTIONS + /O2 # https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-size-maximize-speed?view=msvc-170 + /Ob1 # https://learn.microsoft.com/en-us/cpp/build/reference/ob-inline-function-expansion?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 + /DNDEBUG # https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/assert-macro-assert-wassert?view=msvc-170 + /GL # https://learn.microsoft.com/en-us/cpp/build/reference/gl-whole-program-optimization?view=msvc-170 + /Gy # https://learn.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking?view=msvc-170 + /sdl- # https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 + + LINK_OPTIONS + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 (note: cannot use /INCREMENTAL with /LTCG:incremental, would cause fallback) + /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=msvc-170 +) \ No newline at end of file diff --git a/cmake/adjust/template/vendor/impl/reset.cmake b/cmake/adjust/template/vendor/impl/reset.cmake new file mode 100644 index 0000000000..fc1230f326 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/reset.cmake @@ -0,0 +1,10 @@ +# init profiles vars by resetting required lists + +foreach(LANG CXX C) + foreach(WHAT COMPILE LINK DEFINITIONS) + set(NBL_${LANG}_${WHAT}_OPTIONS "") + foreach(CONFIG RELEASE RELWITHDEBINFO DEBUG) + set(NBL_${LANG}_${CONFIG}_${WHAT}_OPTIONS "") + endforeach() + endforeach() +endforeach() \ No newline at end of file diff --git a/cmake/adjust/template/windows/msvc.cmake b/cmake/adjust/template/windows/msvc.cmake deleted file mode 100644 index 0f9fe365ee..0000000000 --- a/cmake/adjust/template/windows/msvc.cmake +++ /dev/null @@ -1,75 +0,0 @@ -include_guard(GLOBAL) - -# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 - -# The default instruction set is SSE2 if no /arch option is specified. -if(NBL_REQUEST_SSE_4_2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:SSE4.2") -endif() - -# Enables Intel Advanced Vector Extensions 2. -if(NBL_REQUEST_SSE_AXV2) - NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:AVX2") -endif() - -NBL_REQUEST_COMPILE_OPTION_SUPPORT(/Zc:preprocessor) - -# Debug -set(NBL_C_DEBUG_COMPILE_OPTIONS - /Ob0 /Od /MP${_NBL_JOBS_AMOUNT_} /fp:fast /Zc:wchar_t /INCREMENTAL -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_C_DEBUG_COMPILE_OPTIONS /RTC1) -endif() - -set(NBL_CXX_DEBUG_COMPILE_OPTIONS - /Zc:__cplusplus ${NBL_C_DEBUG_COMPILE_OPTIONS} -) - -set(NBL_DEBUG_COMPILE_OPTIONS - $<$:${NBL_CXX_DEBUG_COMPILE_OPTIONS}> - $<$:${NBL_C_DEBUG_COMPILE_OPTIONS}> -) - -# Release -set(NBL_C_RELEASE_COMPILE_OPTIONS - /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast -) -set(NBL_CXX_RELEASE_COMPILE_OPTIONS - /Zc:__cplusplus ${NBL_C_RELEASE_COMPILE_OPTIONS} -) - -set(NBL_RELEASE_COMPILE_OPTIONS - $<$:${NBL_CXX_RELEASE_COMPILE_OPTIONS}> - $<$:${NBL_C_RELEASE_COMPILE_OPTIONS}> -) - -# RelWithDebInfo -set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS - /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast -) -set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS - /Zc:__cplusplus ${NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS} -) - -set(NBL_RELWITHDEBINFO_COMPILE_OPTIONS - $<$:${NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS}> - $<$:${NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS}> -) - -if(NBL_SANITIZE_ADDRESS) - list(APPEND NBL_C_COMPILE_OPTIONS /fsanitize=address) - list(APPEND NBL_CXX_COMPILE_OPTIONS ${NBL_C_COMPILE_OPTIONS}) -endif() - -set(NBL_COMPILE_OPTIONS - $<$:${NBL_CXX_COMPILE_OPTIONS}> - $<$:${NBL_C_COMPILE_OPTIONS}> -) - -# this should also be not part of profile, pasting from old flags-set function temporary -# TODO: use profile - -#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") \ No newline at end of file diff --git a/cmake/common.cmake b/cmake/common.cmake index f0d3e27f36..69a0a5b980 100755 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -25,7 +25,7 @@ function(nbl_handle_dll_definitions _TARGET_ _SCOPE_) message(FATAL_ERROR "Internal error, requsted \"${_TARGET_}\" is not defined!") endif() - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) set(_NABLA_OUTPUT_DIR_ "${NBL_ROOT_PATH_BINARY}/src/nbl/$/devshgraphicsprogramming.nabla") target_compile_definitions(${_TARGET_} ${_SCOPE_} @@ -43,11 +43,7 @@ function(nbl_handle_runtime_lib_properties _TARGET_) message(FATAL_ERROR "Internal error, requsted \"${_TARGET_}\" is not defined!") endif() - if(NBL_DYNAMIC_MSVC_RUNTIME) - set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else() - set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + set_target_properties(${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$:DLL>") endfunction() # Macro creating project for an executable @@ -73,14 +69,6 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE add_executable(${EXECUTABLE_NAME} ${NBL_EXECUTABLE_SOURCES}) nbl_handle_runtime_lib_properties(${EXECUTABLE_NAME}) - - if(WIN32 AND MSVC) - if(NBL_DYNAMIC_MSVC_RUNTIME) - target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:$") - endif() - - target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:dxcompiler.dll") - endif() endif() nbl_handle_dll_definitions(${EXECUTABLE_NAME} PUBLIC) diff --git a/include/nbl/asset/IDescriptorSetLayout.h b/include/nbl/asset/IDescriptorSetLayout.h index f65d01ddc5..c6de66995c 100644 --- a/include/nbl/asset/IDescriptorSetLayout.h +++ b/include/nbl/asset/IDescriptorSetLayout.h @@ -340,7 +340,8 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase bindings[i].binding = i; bindings[i].type = type; bindings[i].createFlags = SBinding::E_CREATE_FLAGS::ECF_NONE; - bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:asset::IShader::ESS_ALL_OR_LIBRARY; + + bindings[i].stageFlags = stageAccessFlags ? stageAccessFlags[i]:hlsl::ShaderStage::ESS_ALL_OR_LIBRARY; bindings[i].count = counts ? counts[i]:1u; bindings[i].samplers = nullptr; } @@ -364,7 +365,7 @@ class IDescriptorSetLayout : public IDescriptorSetLayoutBase for (uint32_t b = 0u; b < bindingCnt; ++b) { auto bindingNumber = m_descriptorRedirects[t].m_bindingNumbers[b]; - CBindingRedirect::template binding_number_t otherBindingNumber(CBindingRedirect::Invalid); + CBindingRedirect::binding_number_t otherBindingNumber(CBindingRedirect::Invalid); // TODO: std::find instead? for (uint32_t ob = 0u; ob < otherBindingCnt; ++ob) { diff --git a/include/nbl/asset/IFramebuffer.h b/include/nbl/asset/IFramebuffer.h index 9c78fe1e42..4f4abb89da 100644 --- a/include/nbl/asset/IFramebuffer.h +++ b/include/nbl/asset/IFramebuffer.h @@ -121,7 +121,7 @@ class IFramebuffer return true; // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFramebufferCreateInfo.html#VUID-VkFramebufferCreateInfo-pAttachments-00884 - if (viewParams.components!=ImageViewType::SComponentMapping()) + if (viewParams.components!=typename ImageViewType::SComponentMapping()) return true; // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkFramebufferCreateInfo.html#VUID-VkFramebufferCreateInfo-flags-04533 diff --git a/include/nbl/asset/IRenderpass.h b/include/nbl/asset/IRenderpass.h index 30be5c99e7..ce41e35573 100644 --- a/include/nbl/asset/IRenderpass.h +++ b/include/nbl/asset/IRenderpass.h @@ -81,11 +81,12 @@ class NBL_API2 IRenderpass { bool valid() const; }; + // The arrays pointed to by this array must be terminated by `DepthStencilAttachmentsEnd` value, which implicitly satisfies a few VUIDs - constexpr static inline SDepthStencilAttachmentDescription DepthStencilAttachmentsEnd = {}; + static const SDepthStencilAttachmentDescription DepthStencilAttachmentsEnd; // have to initialize out of line because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165 const SDepthStencilAttachmentDescription* depthStencilAttachments = &DepthStencilAttachmentsEnd; // The arrays pointed to by this array must be terminated by `ColorAttachmentsEnd` value, which implicitly satisfies a few VUIDs - constexpr static inline SColorAttachmentDescription ColorAttachmentsEnd = {}; + static const SColorAttachmentDescription ColorAttachmentsEnd; // have to initialize out of line because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165 const SColorAttachmentDescription* colorAttachments = &ColorAttachmentsEnd; struct SSubpassDescription final @@ -199,7 +200,7 @@ class NBL_API2 IRenderpass SColorAttachmentsRef colorAttachments[MaxColorAttachments] = {}; // The arrays pointed to by this array must be terminated by `InputAttachmentsEnd` value - constexpr static inline SInputAttachmentRef InputAttachmentsEnd = {}; + static const SInputAttachmentRef InputAttachmentsEnd; const SInputAttachmentRef* inputAttachments = &InputAttachmentsEnd; struct SPreserveAttachmentRef @@ -232,7 +233,7 @@ class NBL_API2 IRenderpass // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubpassDescription2.html#VUID-VkSubpassDescription2-pipelineBindPoint-04953 //E_PIPELINE_BIND_POINT pipelineBindPoint : 2 = EPBP_GRAPHICS; }; - constexpr static inline SSubpassDescription SubpassesEnd = {}; + static const SSubpassDescription SubpassesEnd; const SSubpassDescription* subpasses = &SubpassesEnd; struct SSubpassDependency final @@ -258,7 +259,7 @@ class NBL_API2 IRenderpass bool valid() const; }; // The arrays pointed to by this array must be terminated by `DependenciesEnd` value - constexpr static inline SSubpassDependency DependenciesEnd = {}; + static const SSubpassDependency DependenciesEnd; const SSubpassDependency* dependencies = &DependenciesEnd; @@ -379,6 +380,12 @@ class NBL_API2 IRenderpass uint32_t m_loadOpColorAttachmentEnd = ~0u; }; +constexpr inline IRenderpass::SCreationParams::SDepthStencilAttachmentDescription IRenderpass::SCreationParams::DepthStencilAttachmentsEnd = {}; +constexpr inline IRenderpass::SCreationParams::SColorAttachmentDescription IRenderpass::SCreationParams::ColorAttachmentsEnd = {}; +constexpr inline IRenderpass::SCreationParams::SSubpassDescription::SInputAttachmentRef IRenderpass::SCreationParams::SSubpassDescription::InputAttachmentsEnd = {}; +constexpr inline IRenderpass::SCreationParams::SSubpassDescription IRenderpass::SCreationParams::SubpassesEnd = {}; +constexpr inline IRenderpass::SCreationParams::SSubpassDependency IRenderpass::SCreationParams::DependenciesEnd = {}; + inline bool IRenderpass::compatible(const IRenderpass* other) const { // If you find yourself spending a lot of time here in your profile, go ahead and implement a precomputed hash and store it in the renderpass @@ -707,7 +714,7 @@ inline bool IRenderpass::SCreationParams::SSubpassDescription::SDepthStencilAtta template inline bool IRenderpass::SCreationParams::SSubpassDescription::SRenderAttachmentsRef::valid(const typename attachment_ref_t::description_t* descs, const uint32_t attachmentCount) const { - if (!render.valid(descs,attachmentCount) || !resolve.valid(descs,attachmentCount)) + if (!render.template valid(descs,attachmentCount) || !resolve.template valid(descs,attachmentCount)) return false; const bool renderUsed = render.used(); if (resolve.used()) diff --git a/include/nbl/asset/filters/CBlitImageFilter.h b/include/nbl/asset/filters/CBlitImageFilter.h index 1dbc7809ba..f228fea325 100644 --- a/include/nbl/asset/filters/CBlitImageFilter.h +++ b/include/nbl/asset/filters/CBlitImageFilter.h @@ -464,7 +464,7 @@ class CBlitImageFilter : auto phaseCount = IBlitUtilities::getPhaseCount(inExtentLayerCount.xyz, outExtentLayerCount.xyz, inImageType); phaseCount = hlsl::max(phaseCount,hlsl::uint32_t3(1,1,1)); - const auto axisOffsets = blit_utils_t::template getScaledKernelPhasedLUTAxisOffsets(phaseCount,real_window_size); + const auto axisOffsets = blit_utils_t::getScaledKernelPhasedLUTAxisOffsets(phaseCount,real_window_size); constexpr auto MaxAxisCount = 3; lut_value_t* scaledKernelPhasedLUTPixel[MaxAxisCount]; for (auto i = 0; i < MaxAxisCount; ++i) diff --git a/include/nbl/asset/filters/kernels/WeightFunctions.h b/include/nbl/asset/filters/kernels/WeightFunctions.h index bb0b8fb9b4..af2782dfac 100644 --- a/include/nbl/asset/filters/kernels/WeightFunctions.h +++ b/include/nbl/asset/filters/kernels/WeightFunctions.h @@ -337,12 +337,12 @@ class CWeightFunction1D final : public impl::IWeightFunction1Dscale(base_t::value_t(1)/stretchFactor); + this->scale(typename base_t::value_t(1)/stretchFactor); } inline base_t::value_t weight(const float x) const { - return static_cast(this->getTotalScale()*function_t::weight(x*this->getInvStretch())); + return static_cast(this->getTotalScale()*function_t::template weight(x*this->getInvStretch())); } // Integral of `weight(x) dx` from -INF to +INF diff --git a/include/nbl/asset/utils/CSPIRVIntrospector.h b/include/nbl/asset/utils/CSPIRVIntrospector.h index f756a58a42..45fcb0e3a7 100644 --- a/include/nbl/asset/utils/CSPIRVIntrospector.h +++ b/include/nbl/asset/utils/CSPIRVIntrospector.h @@ -208,7 +208,13 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable // `memberStrides[i]` only relevant if `memberTypes[i]->isArray()` inline ptr_t memberStrides() const {return memberOffsets()+memberCount;} using member_matrix_info_t = MatrixInfo; - inline ptr_t memberMatrixInfos() const {return reinterpret_cast&>(memberStrides()+memberCount); } + inline ptr_t memberMatrixInfos() const + { + auto t = memberStrides() + memberCount; + + return reinterpret_cast&>(t); + + } constexpr static inline size_t StoragePerMember = sizeof(member_type_t)+sizeof(member_name_t)+sizeof(member_size_t)+sizeof(member_offset_t)+sizeof(member_stride_t)+sizeof(member_matrix_info_t); @@ -326,8 +332,8 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable template inline std::enable_if_t isLastMemberRuntimeSized() const { - if (type->memberCount) - return type->memberTypes()[type->memberCount-1].count.front().isRuntimeSized(); + if (this->type->memberCount) + return this->type->memberTypes()[this->type->memberCount-1].count.front().isRuntimeSized(); return false; } template @@ -335,9 +341,9 @@ class NBL_API2 CSPIRVIntrospector : public core::Uncopyable { if (isLastMemberRuntimeSized()) { - const auto& lastMember = type->memberTypes()[type->memberCount-1]; + const auto& lastMember = this->type->memberTypes()[this->type->memberCount-1]; assert(!lastMember.count.front().isSpecConstantID); - return sizeWithoutLastMember+lastMemberElementCount*type->memberStrides()[type->memberCount-1]; + return sizeWithoutLastMember+lastMemberElementCount* this->type->memberStrides()[this->type->memberCount-1]; } return sizeWithoutLastMember; } diff --git a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl index 0309b78e0d..0d95c032b0 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl @@ -598,7 +598,7 @@ struct nClamp_helper using return_t = T; static inline return_t __call(const T x, const T _min, const T _max) { - return nMin_helper::_call(nMax_helper::_call(x, _min), _max); + return nMin_helper::_call(nMax_helper::_call(x, _min), _max); } }; diff --git a/include/nbl/macros.h b/include/nbl/macros.h index 4927f21899..fe93201a11 100644 --- a/include/nbl/macros.h +++ b/include/nbl/macros.h @@ -81,7 +81,7 @@ //! Workarounds for compiler specific bugs // MSVC 2019 is a special snowflake -#if defined(_MSC_VER) && _MSC_VER>=1920 +#if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER>=1920 #define NBL_TYPENAME_4_STTC_MBR typename #else #define NBL_TYPENAME_4_STTC_MBR diff --git a/include/nbl/video/CVulkanDeviceMemoryBacked.h b/include/nbl/video/CVulkanDeviceMemoryBacked.h index c996000e04..e6d17ddf3e 100644 --- a/include/nbl/video/CVulkanDeviceMemoryBacked.h +++ b/include/nbl/video/CVulkanDeviceMemoryBacked.h @@ -47,8 +47,8 @@ class CVulkanDeviceMemoryBacked : public Interface }; #ifndef _NBL_VIDEO_C_VULKAN_DEVICE_MEMORY_BACKED_CPP_ -extern template CVulkanDeviceMemoryBacked; -extern template CVulkanDeviceMemoryBacked; +extern template class CVulkanDeviceMemoryBacked; +extern template class CVulkanDeviceMemoryBacked; #endif } // end namespace nbl::video diff --git a/include/nbl/video/ILogicalDevice.h b/include/nbl/video/ILogicalDevice.h index 4315471e8c..6365ef936a 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -1504,7 +1504,7 @@ inline bool ILogicalDevice::validateMemoryBarrier(const uint32_t queueFamilyInde return false; }; // CANNOT CHECK: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageMemoryBarrier2-oldLayout-01197 - if (mismatchedLayout.operator()(barrier.oldLayout) || mismatchedLayout.operator()(barrier.newLayout)) + if (mismatchedLayout.template operator()(barrier.oldLayout) || mismatchedLayout.template operator()(barrier.newLayout)) return false; } diff --git a/include/nbl/video/ISwapchain.h b/include/nbl/video/ISwapchain.h index d052a819bd..882ac16648 100644 --- a/include/nbl/video/ISwapchain.h +++ b/include/nbl/video/ISwapchain.h @@ -454,21 +454,22 @@ class ISwapchain : public IBackendObject { return params.deduce(getOriginDevice()->getPhysicalDevice(),m_params.surface.get(),{&m_params.sharedParams.presentMode.value,1},{&m_params.sharedParams.compositeAlpha.value,1},{&m_params.sharedParams.preTransform.value,1}); } - inline core::smart_refctd_ptr recreate(SSharedCreationParams params={}) + inline core::smart_refctd_ptr recreate(SSharedCreationParams params) { if (!deduceRecreationParams(params)) return nullptr; return recreate_impl(std::move(params)); } + inline core::smart_refctd_ptr recreate() { return recreate({}); } // Vulkan: const VkSwapchainKHR* virtual const void* getNativeHandle() const = 0; // returns the maximum number of time acquires with infinite timeout which can be called before releasing the image index through present. - virtual uint8_t getMaxBlockingAcquiresBeforePresent() const = 0u; + virtual uint8_t getMaxBlockingAcquiresBeforePresent() const = 0; // returns the maximum number of acquires you can request without waiting for previous acquire semaphores to signal. - virtual uint8_t getMaxAcquiresInFlight() const = 0u; + virtual uint8_t getMaxAcquiresInFlight() const = 0; // only public because MultiTimelineEventHandlerST needs to know about it class DeferredFrameSemaphoreDrop final diff --git a/include/nbl/video/TimelineEventHandlers.h b/include/nbl/video/TimelineEventHandlers.h index 9405accf78..a3d6aa4c8b 100644 --- a/include/nbl/video/TimelineEventHandlers.h +++ b/include/nbl/video/TimelineEventHandlers.h @@ -410,7 +410,7 @@ class MultiTimelineEventHandlerST final : core::Unmovable, core::Uncopyable sum += handler->count(); else { - const auto local = handler->poll_impl(std::forward(args)...); + const auto local = handler->template poll_impl(std::forward(args)...); bailed = local.bailed; // if don't have any events left, remove the timeline if (local.eventsLeft) diff --git a/include/nbl/video/utilities/CSubpassKiln.h b/include/nbl/video/utilities/CSubpassKiln.h index 7df6cc0caa..c41ec3dd7e 100644 --- a/include/nbl/video/utilities/CSubpassKiln.h +++ b/include/nbl/video/utilities/CSubpassKiln.h @@ -198,7 +198,7 @@ class CSubpassKiln if (begin==end) return; - bake_impl(cmdbuf->getOriginDevice()->getPhysicalDevice()->getLimits().indirectDrawCount, drawIndirectBuffer, drawCountBuffer)(cmdbuf, begin, end); + bake_impl(cmdbuf->getOriginDevice()->getPhysicalDevice()->getLimits().drawIndirectCount, drawIndirectBuffer, drawCountBuffer)(cmdbuf, begin, end); } protected: diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index ad464bd035..ad5aa7c463 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -308,7 +308,7 @@ endif() set(COMMON_INCLUDE_DIRS ${THIRD_PARTY_SOURCE_DIR}/glm - ${THIRD_PARTY_SOURCE_DIR}/renderdoc # for renderdoc api header + ${THIRD_PARTY_SOURCE_DIR}/renderdoc # for renderdoc api header ${CMAKE_BINARY_DIR}/3rdparty/zlib #for dynamically generated zconf.h $ #for dynamically generated pnglibconf.h $ #for dynamically generated jconfig.h @@ -324,7 +324,6 @@ set(NBL_LIBRARY_CREATION_SOURCES ${NABLA_SRCS_COMMON} ${NABLA_HEADERS} $ - $ $ $ $ @@ -351,7 +350,7 @@ if(NBL_CPACK_NO_BUILD_DIRECTORY_MODULES) target_compile_definitions(Nabla PUBLIC NBL_CPACK_NO_BUILD_DIRECTORY_MODULES) endif() -if(NBL_DYNAMIC_MSVC_RUNTIME) +if(NBL_COMPILER_DYNAMIC_RUNTIME) set_property(TARGET Nabla PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") else() set_property(TARGET Nabla PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") @@ -359,6 +358,13 @@ endif() target_compile_definitions(Nabla PRIVATE __NBL_BUILDING_NABLA__) +target_link_options(Nabla INTERFACE # proxy to downstream targets + $<$: + $<$:/DELAYLOAD:$> + /DELAYLOAD:dxcompiler.dll + > +) + if (ANDROID) add_library(android_native_app_glue STATIC ${ANDROID_NDK_ROOT_PATH}/sources/android/native_app_glue/android_native_app_glue.c @@ -391,6 +397,14 @@ if(_NBL_BUILD_DPL_) target_link_libraries(Nabla INTERFACE tbb tbbmalloc tbbmalloc_proxy) endif() +# bzip2 +if(NBL_STATIC_BUILD) + target_link_libraries(Nabla INTERFACE bz2_static) +else() + target_link_libraries(Nabla PRIVATE bz2_static) +endif() +add_dependencies(Nabla bz2_static) + # boost target_include_directories(Nabla PUBLIC "${BOOST_PREPROCESSOR_INCLUDE}") diff --git a/src/nbl/builtin/utils.cmake b/src/nbl/builtin/utils.cmake index 05f9618203..0653ff97a2 100644 --- a/src/nbl/builtin/utils.cmake +++ b/src/nbl/builtin/utils.cmake @@ -39,7 +39,7 @@ endmacro() # _NAMESPACE_ is a C++ namespace builtin resources will be wrapped into # _OUTPUT_INCLUDE_SEARCH_DIRECTORY_ is an absolute path to output directory for builtin resources header files which will be a search directory for generated headers outputed to ${_OUTPUT_HEADER_DIRECTORY_}/${_NAMESPACE_PREFIX_} where namespace prefix is the namespace turned into a path # _OUTPUT_SOURCE_DIRECTORY_ is an absolute path to output directory for builtin resources source files -# _STATIC_ optional last argument is a bool, if true then add_library will use STATIC, SHARED otherwise. Pay attention that MSVC runtime is controlled by NBL_DYNAMIC_MSVC_RUNTIME which is not an argument of this function +# _STATIC_ optional last argument is a bool, if true then add_library will use STATIC, SHARED otherwise. Pay attention that MSVC runtime is controlled by NBL_COMPILER_DYNAMIC_RUNTIME which is not an argument of this function # # As an example one could list a resource as following # LIST_BUILTIN_RESOURCE(SOME_RESOURCES_TO_EMBED "glsl/blit/default_compute_normalization.comp") @@ -208,12 +208,8 @@ function(ADD_CUSTOM_BUILTIN_RESOURCES _TARGET_NAME_ _BUNDLE_NAME_ _BUNDLE_SEARCH "${_OUTPUT_HEADER_DIRECTORY_}" ) set_target_properties(${_TARGET_NAME_} PROPERTIES CXX_STANDARD 20) - - if(NBL_DYNAMIC_MSVC_RUNTIME) - set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") - else() - set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + + set_property(TARGET ${_TARGET_NAME_} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$:DLL>") set(NBL_BUILTIN_RESOURCES ${NBL_BUILTIN_RESOURCES}) # turn builtin resources paths list into variable diff --git a/src/nbl/device/DeviceGen.py b/src/nbl/device/DeviceGen.py index 288732de9b..9ad485fc84 100644 --- a/src/nbl/device/DeviceGen.py +++ b/src/nbl/device/DeviceGen.py @@ -562,7 +562,7 @@ def buildTraitsHeader(**params): res.append(emptyline) if 'enable_jit' in params and params['enable_jit']: - res.append("std::string jit_traits = R\"===(") + res.append("std::ostringstream oss;") buildTraitsHeaderHelper( res, @@ -582,7 +582,7 @@ def buildTraitsHeader(**params): ) if 'enable_jit' in params and params['enable_jit']: - res.append(")===\";") + res.append("std::string jit_traits = oss.str();") return res diff --git a/src/nbl/device/gen.py b/src/nbl/device/gen.py index b910d1aa8f..253d529b3d 100644 --- a/src/nbl/device/gen.py +++ b/src/nbl/device/gen.py @@ -120,7 +120,7 @@ args.jit_traits_output_path, buildTraitsHeader, type="JIT Members", - template="NBL_CONSTEXPR_STATIC_INLINE {} {} = )===\" + std::string(\"({})\") + CJITIncludeLoader::to_string({}.{}) + R\"===(;", + template="oss << \"NBL_CONSTEXPR_STATIC_INLINE {} {} = ({})\" + CJITIncludeLoader::to_string({}.{});", limits_json=limits, features_json=features, format_params=["type", "name", "type", "json_type", "cpp_name"], diff --git a/src/nbl/video/CJITIncludeLoader.cpp b/src/nbl/video/CJITIncludeLoader.cpp index edab1c046a..a9f27e5afd 100644 --- a/src/nbl/video/CJITIncludeLoader.cpp +++ b/src/nbl/video/CJITIncludeLoader.cpp @@ -49,4 +49,4 @@ std::string CJITIncludeLoader::collectDeviceCaps(const SPhysicalDeviceLimits& li return start + jit_traits + end; } -} \ No newline at end of file +} diff --git a/src/nbl/video/CVulkanCommandBuffer.cpp b/src/nbl/video/CVulkanCommandBuffer.cpp index b569a5fde2..9f0b0a83e1 100644 --- a/src/nbl/video/CVulkanCommandBuffer.cpp +++ b/src/nbl/video/CVulkanCommandBuffer.cpp @@ -661,7 +661,7 @@ bool CVulkanCommandBuffer::beginRenderPass_impl(const SRenderpassBeginInfo& info .renderArea = info.renderArea, // Implicitly but could be optimizedif needed // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkRenderPassBeginInfo.html#VUID-VkRenderPassBeginInfo-clearValueCount-00902 - .clearValueCount = vk_clearValues.size()/sizeof(VkClearValue), + .clearValueCount = static_cast(vk_clearValues.size()/sizeof(VkClearValue)), // Implicit // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkRenderPassBeginInfo.html#VUID-VkRenderPassBeginInfo-clearValueCount-04962 .pClearValues = vk_clearValues.data() diff --git a/src/nbl/video/CVulkanDeviceMemoryBacked.cpp b/src/nbl/video/CVulkanDeviceMemoryBacked.cpp index 2bec9e9d06..90b2993cb3 100644 --- a/src/nbl/video/CVulkanDeviceMemoryBacked.cpp +++ b/src/nbl/video/CVulkanDeviceMemoryBacked.cpp @@ -40,7 +40,7 @@ CVulkanDeviceMemoryBacked::CVulkanDeviceMemoryBacked( assert(vkHandle!=VK_NULL_HANDLE); } -template CVulkanDeviceMemoryBacked; -template CVulkanDeviceMemoryBacked; +template class CVulkanDeviceMemoryBacked; +template class CVulkanDeviceMemoryBacked; } \ No newline at end of file diff --git a/src/nbl/video/IGPUAccelerationStructure.cpp b/src/nbl/video/IGPUAccelerationStructure.cpp index eafbe08d6f..ae78754b1e 100644 --- a/src/nbl/video/IGPUAccelerationStructure.cpp +++ b/src/nbl/video/IGPUAccelerationStructure.cpp @@ -140,11 +140,11 @@ uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(cons retval += geometryCount*MaxBuffersPerGeometry; return retval; } -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const uint32_t* const) const; -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const uint32_t* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const uint32_t* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const uint32_t* const) const; using BuildRangeInfo = hlsl::acceleration_structures::bottom_level::BuildRangeInfo; -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const BuildRangeInfo* const) const; -template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::template valid(const BuildRangeInfo* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const BuildRangeInfo* const) const; +template uint32_t IGPUBottomLevelAccelerationStructure::BuildInfo::valid(const BuildRangeInfo* const) const; bool IGPUBottomLevelAccelerationStructure::validVertexFormat(const asset::E_FORMAT format) const { diff --git a/src/nbl/video/utilities/CAssetConverter.cpp b/src/nbl/video/utilities/CAssetConverter.cpp index 42e18e1631..1382efe443 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2388,7 +2388,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { for (auto& entry : conversionRequests) for (auto i=0ull; i(entry.first,entry.second.firstCopyIx,i,device->createSampler(entry.second.canonicalAsset->getParams())); + assign.template operator()(entry.first,entry.second.firstCopyIx,i,device->createSampler(entry.second.canonicalAsset->getParams())); } if constexpr (std::is_same_v) { @@ -2836,7 +2836,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { // since we don't have dependants we don't care about our group ID // we create threadsafe pipeline caches, because we have no idea how they may be used - assign.operator()(entry.first,entry.second.firstCopyIx,i,device->createPipelineCache(asset,false)); + assign.template operator()(entry.first,entry.second.firstCopyIx,i,device->createPipelineCache(asset,false)); } } } @@ -2881,7 +2881,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult { // since we don't have dependants we don't care about our group ID // we create threadsafe pipeline caches, because we have no idea how they may be used - assign.operator()(entry.first,entry.second.firstCopyIx,i,device->createRenderpass(asset->getCreationParameters())); + assign.template operator()(entry.first,entry.second.firstCopyIx,i,device->createRenderpass(asset->getCreationParameters())); } } } @@ -3030,7 +3030,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult gpuObj.get()->setObjectDebugName(debugName.str().c_str()); } // insert into staging cache - stagingCache.emplace(gpuObj.get(),CCache::key_t(contentHash,uniqueCopyGroupID)); + stagingCache.emplace(gpuObj.get(),typename CCache::key_t(contentHash,uniqueCopyGroupID)); // propagate back to dfsCache created.gpuObj = std::move(gpuObj); // record if a device memory allocation will be needed @@ -3372,7 +3372,7 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult // if something with this content hash is in the stagingCache, then it must match the `found->gpuObj` if (auto finalCacheIt=stagingCache.find(gpuObj.get()); finalCacheIt!=stagingCache.end()) { - const bool matches = finalCacheIt->second==CCache::key_t(found.contentHash,uniqueCopyGroupID); + const bool matches = finalCacheIt->second==typename CCache::key_t(found.contentHash,uniqueCopyGroupID); assert(matches); } }