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..0335baf7e5 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,6 +240,7 @@ 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}) @@ -419,12 +420,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) @@ -496,11 +491,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/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 b2e75826b7..49b89ae671 160000 --- a/3rdparty/dxc/dxc +++ b/3rdparty/dxc/dxc @@ -1 +1 @@ -Subproject commit b2e75826b70d85d03686dd8a755ef477b4fa3807 +Subproject commit 49b89ae6712f74fba2352e099f024724bcc32673 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..571743f5b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,10 +21,10 @@ 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(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) if(NBL_SANITIZE_ADDRESS) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:ProgramDatabase>") else() @@ -35,14 +35,8 @@ endif() 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..6982e0593d 100644 --- a/cmake/adjust/flags.cmake +++ b/cmake/adjust/flags.cmake @@ -12,45 +12,130 @@ 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_}") +# Usage: NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG CONFIG OPTIONS ) +# LANG, CONFIG - optional, OPTIONS - required +function(NBL_REQUEST_COMPILE_OPTION_SUPPORT) + cmake_parse_arguments(IMPL "" "REQUEST_VAR;REQUIRED" "LANG;CONFIG;OPTIONS" ${ARGN}) - foreach(COMPILER IN ITEMS c cxx) + set(DEFAULT_COMPILERS c cxx) + set(REQUEST_ALL_OPTIONS_PRESENT True) + + if(NOT IMPL_LANG) + list(APPEND IMPL_LANG ${DEFAULT_COMPILERS}) + endif() + + if(NOT IMPL_OPTIONS) + message(FATAL_ERROR "NBL_REQUEST_COMPILE_OPTION_SUPPORT's OPTIONS empty!") + 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_UPPER STREQUAL C) + macro(VALIDATE_FLAG) + check_c_compiler_flag(${ARGV}) + endmacro() + elseif(COMPILER_UPPER STREQUAL CXX) + macro(VALIDATE_FLAG) + check_cxx_compiler_flag(${ARGV}) + endmacro() + endif() + + foreach(COMPILE_OPTION ${IMPL_OPTIONS}) + string(REGEX REPLACE "[-=:;/.]" "_" FLAG_SIGNATURE "${COMPILE_OPTION}") + set(FLAG_VAR "NBL_${COMPILER_UPPER}_COMPILER_HAS_${FLAG_SIGNATURE}_FLAG") - 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() + VALIDATE_FLAG("${COMPILE_OPTION}" "${FLAG_VAR}") - 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() + if(${FLAG_VAR}) + 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}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}") + endforeach() + else() + set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS "${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS};${COMPILE_OPTION}") + endif() + else() + if(IMPL_REQUIRED) + message(FATAL_ERROR "Terminating, NBL_REQUEST_COMPILE_OPTION_SUPPORT was invoked with REQUIRED qualifier!") + endif() + + set(REQUEST_ALL_OPTIONS_PRESENT False) + endif() + endforeach() + + if(IMPL_CONFIG) + foreach(CONFIG ${IMPL_CONFIG}) + string(TOUPPER "${CONFIG}" CONFIG_UPPER) + set(NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS ${NBL_${COMPILER_UPPER}_${CONFIG_UPPER}_COMPILE_OPTIONS} PARENT_SCOPE) + endforeach() + else() + set(NBL_${COMPILER_UPPER}_COMPILE_OPTIONS ${NBL_${COMPILER_UPPER}_COMPILE_OPTIONS} PARENT_SCOPE) + endif() endforeach() + + if(IMPL_REQUEST_VAR) + set(${IMPL_REQUEST_VAR} ${REQUEST_ALL_OPTIONS_PRESENT} PARENT_SCOPE) + endif() 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}_COMPILE_OPTIONS" (configuration dependent) + # - "NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS" (global) + + # a profile MUST NOT define + # - NBL_COMPILE_OPTIONS + + set(NBL_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS) + set(NBL_COMPILE_OPTIONS_VAR_VALUE ${${NBL_COMPILE_OPTIONS_VAR_NAME}}) + + if(NOT DEFINED ${NBL_COMPILE_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_COMPILE_OPTIONS_VAR_NAME}\"!") + endif() + + # update map with configuration dependent compile options + foreach(CONFIGURATION IN ITEMS RELEASE RELWITHDEBINFO DEBUG) + set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS) + set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE ${${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}}) + + if(NOT DEFINED ${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}) + message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}\"!") + endif() + + list(APPEND NBL_${CONFIGURATION}_COMPILE_OPTIONS + # note that "${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}" MUST NOT contain ANY + # $<$> generator expression in order to support our configuration mapping features + $<$:${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}> + ) + + set(NBL_${CONFIGURATION}_COMPILE_OPTIONS ${NBL_${CONFIGURATION}_COMPILE_OPTIONS}) + endforeach() + + # update map with global compile options + list(APPEND NBL_COMPILE_OPTIONS $<$:${NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS}>) + + set(NBL_COMPILE_OPTIONS ${NBL_COMPILE_OPTIONS}) +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) @@ -173,7 +258,7 @@ function(nbl_adjust_flags) set(MAPPED_CONFIG $>) - if(MSVC) + if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC) if(NBL_SANITIZE_ADDRESS) set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$,$>:ProgramDatabase>") else() 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..63549974c6 --- /dev/null +++ b/cmake/adjust/template/vendor/impl/Clang.cmake @@ -0,0 +1,89 @@ +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_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + -msse4.2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang1-msse4.2 + ) +endif() + +if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + -mavx2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mavx2 + ) +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + # latest Clang(CL) 19.1.1 shipped with VS seems to require explicitly features to be listed (simdjson) + # TODO: Yas, use with REQUEST_VAR, 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 + + # also instead of enabling single options maybe we could consider requesting an + # instruction implementation set instead, eg -march=haswel, though this approach + # could add a few more flags then we actually need while building - to rethink + + -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 +) + +list(APPEND NBL_${LANG}_COMPILE_OPTIONS + -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_SANITIZE_ADDRESS) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=address) +endif() + +if(NBL_SANITIZE_THREAD) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS -fsanitize=thread) +endif() + +set(NBL_${LANG}_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 + -fincremental-extensions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fincremental-extensions + -Wall # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-W-warning + -fstack-protector-strong # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstack-protector-strong + -gline-tables-only # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only + -fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer + -fno-inline-functions # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-finline-functions +) + +set(NBL_${LANG}_RELEASE_COMPILE_OPTIONS + -O2 # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-O-arg + -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 +) + +set(NBL_${LANG}_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 + -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 + -fno-omit-frame-pointer # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer +) \ 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..5b73b9073e --- /dev/null +++ b/cmake/adjust/template/vendor/impl/MSVC.cmake @@ -0,0 +1,71 @@ +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_REQUEST_SSE_4_2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + /arch:SSE4.2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 + ) +endif() + +if(NBL_REQUEST_SSE_AVX2) + NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + /arch:AVX2 # https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170 + ) +endif() + +NBL_REQUEST_COMPILE_OPTION_SUPPORT(LANG ${LANG} OPTIONS + /Zc:preprocessor # https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170 +) + +list(APPEND NBL_${LANG}_COMPILE_OPTIONS + /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) + list(APPEND NBL_${LANG}_COMPILE_OPTIONS + /fsanitize=address # https://learn.microsoft.com/en-us/cpp/build/reference/fsanitize?view=msvc-170 + ) + + list(APPEND NBL_${LANG}_DEBUG_COMPILE_OPTIONS + /RTC1 # https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-170 + ) +endif() + +list(APPEND NBL_${LANG}_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 + /INCREMENTAL # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /Oy- # https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=msvc-170 +) + +list(APPEND NBL_${LANG}_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 + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?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 +) + +list(APPEND NBL_${LANG}_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 + /INCREMENTAL:NO # https://learn.microsoft.com/en-us/cpp/build/reference/incremental-link-incrementally?view=msvc-170 + /LTCG:incremental # https://learn.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?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 +) \ 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..6eb95b6cfd --- /dev/null +++ b/cmake/adjust/template/vendor/impl/reset.cmake @@ -0,0 +1,8 @@ +# reset profile vars, for sanity + +foreach(LANG CXX C) + unset(NBL_${LANG}_COMPILE_OPTIONS) + unset(NBL_${LANG}_RELEASE_COMPILE_OPTIONS) + unset(NBL_${LANG}_RELWITHDEBINFO_COMPILE_OPTIONS) + unset(NBL_${LANG}_DEBUG_COMPILE_OPTIONS) +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..69b915bbc7 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 @@ -75,7 +71,7 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE nbl_handle_runtime_lib_properties(${EXECUTABLE_NAME}) if(WIN32 AND MSVC) - if(NBL_DYNAMIC_MSVC_RUNTIME) + if(NBL_COMPILER_DYNAMIC_RUNTIME) target_link_options(${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:$") endif() diff --git a/include/nbl/asset/IDescriptorSetLayout.h b/include/nbl/asset/IDescriptorSetLayout.h index 44e8be71ea..ec3c182fdc 100644 --- a/include/nbl/asset/IDescriptorSetLayout.h +++ b/include/nbl/asset/IDescriptorSetLayout.h @@ -330,7 +330,7 @@ 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]:asset::IShader::E_SHADER_STAGE::ESS_ALL_OR_LIBRARY; bindings[i].count = counts ? counts[i]:1u; bindings[i].samplers = nullptr; } @@ -354,7 +354,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 0cc6608b16..46f7dc1ce7 100644 --- a/include/nbl/video/ILogicalDevice.h +++ b/include/nbl/video/ILogicalDevice.h @@ -1502,7 +1502,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..99ba2e7975 100644 --- a/include/nbl/video/ISwapchain.h +++ b/include/nbl/video/ISwapchain.h @@ -21,6 +21,8 @@ class ISwapchain : public IBackendObject struct SSharedCreationParams { + SSharedCreationParams() {} + inline bool valid(const IPhysicalDevice* physDev, const ISurface* surface) const { ISurface::SCapabilities caps; @@ -465,10 +467,10 @@ class ISwapchain : public IBackendObject 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..bde7182ebd 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 @@ -351,7 +351,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>") 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/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 796f3dcaec..fdb5c61ca8 100644 --- a/src/nbl/video/utilities/CAssetConverter.cpp +++ b/src/nbl/video/utilities/CAssetConverter.cpp @@ -2142,7 +2142,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) { @@ -2461,7 +2461,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)); } } } @@ -2506,7 +2506,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())); } } } @@ -2653,7 +2653,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 @@ -2668,11 +2668,11 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult // this is super annoying, was hoping metaprogramming with `has_type` would actually work auto getConversionRequests = [&]()->auto&{return std::get>(retval.m_conversionRequests);}; if constexpr (std::is_same_v) - getConversionRequests.operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get());; + getConversionRequests.template operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get());; if constexpr (std::is_same_v) { const uint16_t recomputeMips = created.patch.recomputeMips; - getConversionRequests.operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get(),recomputeMips); + getConversionRequests.template operator()().emplace_back(core::smart_refctd_ptr(instance.asset),created.gpuObj.get(),recomputeMips); } // TODO: BLAS and TLAS requests } @@ -2939,7 +2939,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); } }