diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml index c4a3a9b9f..6d2ab72ca 100644 --- a/.github/codeql/codeql-config.yml +++ b/.github/codeql/codeql-config.yml @@ -6,7 +6,9 @@ queries: paths: - Apps - Modules + paths-ignore: + - Build/Output - Externals - Tests - CMake diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 48de87cb4..11cc24f44 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,14 +9,18 @@ on: - '.github/**/codeql-*.yml' - 'Apps/**' - 'Modules/**' + - 'Externals/**' - 'Tests/**' + - 'CMakeLists.txt' pull_request: branches: [ master ] paths: - '.github/**/codeql-*.yml' - 'Apps/**' - 'Modules/**' + - 'Externals/**' - 'Tests/**' + - 'CMakeLists.txt' schedule: - cron: '20 23 * * 3' @@ -51,10 +55,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - with: - submodules: 'recursive' - # Windows CodeQL analysis is DISABLED (see reason description next to Analysis step below) + # NOTE: CodeQL is temporary DISABLED on Windows (see reason description next to Analysis step below) - name: Initialize CodeQL if: ${{ matrix.os != 'windows-2019' }} uses: github/codeql-action/init@v2 @@ -62,6 +64,15 @@ jobs: languages: cpp config-file: ./.github/codeql/codeql-config.yml + - name: Initialize Externals Cache + id: cache-externals + uses: actions/cache@v3 + env: + cache-name: cache-externals + with: + path: Build/Output/ExternalsCache + key: ExternalsCache-${{ matrix.config_preset }}-${{ hashFiles('Externals/*.cmake') }} + - name: CMake Configure Preset ${{ matrix.config_preset }} run: cmake --preset ${{ matrix.config_preset }} -DMETHANE_CODE_COVERAGE_ENABLED:BOOL=OFF -DMETHANE_TESTS_BUILD_ENABLED:BOOL=OFF -DMETHANE_SHADERS_VALIDATION_ENABLED:BOOL=OFF @@ -72,3 +83,23 @@ jobs: - name: Perform CodeQL Analysis if: ${{ matrix.os != 'windows-2019' }} uses: github/codeql-action/analyze@v2 + with: + upload: false + output: results + + - name: Filter CodeQL Results + if: ${{ matrix.os != 'windows-2019' }} + uses: MethanePowered/FilterSarif@master + with: + patterns: | + -Build/Output/** + -Externals/** + -Tests/** + input: results/cpp.sarif + output: results/cpp-filtered.sarif + + - name: Upload Filtered CodeQL Results + if: ${{ matrix.os != 'windows-2019' }} + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: results/cpp-filtered.sarif diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 43a83da63..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Externals"] - path = Externals - url = https://github.com/egorodet/MethaneExternals.git diff --git a/.idea/cmake.xml b/.idea/cmake.xml index 140325c90..2ce3ce8f1 100644 --- a/.idea/cmake.xml +++ b/.idea/cmake.xml @@ -25,14 +25,15 @@ - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 57ba3f43c..94a25f7f4 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,23 +2,5 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Build/README.md b/Build/README.md index 23bd29b08..ee011a58b 100644 --- a/Build/README.md +++ b/Build/README.md @@ -5,9 +5,9 @@ - [First time initialization](#first-time-initialization) - [Update sources to latest revision](#update-sources-to-latest-revision) - [Building from Sources](#building-from-sources) - - [Windows Build with Visual Studio](#-windows-build-with-visual-studio) - - [MacOS Build with XCode](#-macos-build-with-xcode) - - [Linux Build with Unix Makefiles](#-linux-build-with-unix-makefiles) + - [Windows Build with Visual Studio](#windows-build-with-visual-studio) + - [Linux Build with Unix Makefiles](#linux-build-with-unix-makefiles) + - [MacOS Build with XCode](#macos-build-with-xcode) - [CMake Generator](#cmake-generator) - [CMake Options](#cmake-options) - [CMake Presets](#cMake-presets) @@ -15,12 +15,11 @@ ## Prerequisites - **Common** - - Git (required to pull sub-modules) - CMake 3.18 or later - **Windows** - Windows 10 RS5 (build 1809) or later - Visual Studio 2019/22 with MSVC v142 or later - - Windows 10 SDK latest + - Windows 10 SDK (latest) - **MacOS** - MacOS 10.15 "Catalina" or later - XCode 11 or later with command-line tools @@ -34,33 +33,36 @@ ## Fetch Sources -**IMPORTANT!** -- Do not download source code via Zip archive, since it does not include content of -[Externals](https://github.com/egorodet/MethaneExternals/tree/master) submodules. -Use `git clone` command as described below. -- Consider using short path for repository location on Windows (for example `c:\Git`), -which may be required to resolve problem with support of paths longer than 260 symbols in some Microsoft build tools. +### Notes +- Since v0.6 Methane Kit does not use Git submodules anymore and switches to [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) +to fetch dependent repositories during CMake configuration stage, so it should be both possible to acquire sources +with `git clone` command or to download as ZIP-archive using `Code > Download ZIP` button. +- All [External](/Externals) dependencies are fetched to the `Build/Output/ExternalsCache/...` directory, +which can be changed by adding `-DCPM_SOURCE_CACHE=` to the CMake configuration command. +- Consider using short path for repository location on Windows (for example `c:\Git\`), +which may be required to resolve problem with support of paths longer than 260 symbols for some of Microsoft build tools. -#### First time initialization +### First time initialization ```console -git clone --recurse-submodules https://github.com/egorodet/MethaneKit.git +git clone https://github.com/egorodet/MethaneKit.git cd MethaneKit ``` -#### Update sources to latest revision +### Update sources to latest revision ```console cd MethaneKit -git pull && git submodule update --init --recursive +git pull ``` ## Building from Sources -### Windows Build with Visual Studio +### Windows Build with Visual Studio -Start Command Prompt, go to `MethaneKit` root directory (don't forget to pull dependent submodules as [described above](#fetch-sources)) -and either start auxiliary build script [Build/Windows/Build.bat](/Build/Windows/Build.bat) or build with CMake command line + +Start Command Prompt, go to `MethaneKit` root directory and either start auxiliary build script +[Build/Windows/Build.bat](/Build/Windows/Build.bat) or build with CMake command line to generate Visual Studio 2019/22 solution: ```console @@ -70,7 +72,7 @@ cmake --build %OUTPUT_DIR%\Build --config Release --target install ``` Alternatively root [CMakeLists.txt](/CMakeLists.txt) can be opened directly in Visual Studio or -[any other IDE with native CMake support](#development-environments) and [built using CMake presets](#cmake-presets). +[any other IDE with native CMake support](/README.md#development-environments) and [built using CMake presets](#cmake-presets). [Methane Graphics Core](/Modules/Graphics/Core) is built using **DirectX 12** graphics API by default on Windows. Vulkan graphics API can be used instead by adding cmake generator option `-DMETHANE_GFX_VULKAN_ENABLED:BOOL=ON` or @@ -78,10 +80,32 @@ by running `Build/Windows/Build.bat --vulkan`. Run built applications from the installation directory `Build\Output\VisualStudio\Win64-DX\Install\Apps` -### MacOS Build with XCode +### Linux Build with Unix Makefiles -Start Terminal, go to `MethaneKit` root directory (don't forget to pull dependent submodules as [described above](#fetch-sources)) -and either start auxiliary build script [Build/Unix/Build.sh](/Build/Unix/Build.sh) or build with CMake command line: + +Start Terminal, go to `MethaneKit` root directory and either start auxiliary build script +[Build/Unix/Build.sh](/Build/Unix/Build.sh) or build with CMake command line to generate Unix Makefiles: + +```console +OUTPUT_DIR=Build/Output/Linux +cmake -S . -B $OUTPUT_DIR/Build -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install" +cmake --build $OUTPUT_DIR/Build --config Release --target install --parallel 8 +``` + +[Methane Graphics Core](/Modules/Graphics/Core) is built using **Vulkan** graphics API on Linux. + +Alternatively root [CMakeLists.txt](/CMakeLists.txt) can be opened directly in +[any IDE with native CMake support](/README.md#development-environments) and [built using CMake presets](#cmake-presets). + +Run built applications from the installation directory `Build/Output/Linux/Install/Apps`. +Note that in Ubuntu Linux even GUI applications should be started from "Terminal" app, +because of `noexec` permission set on user's home directory by security reasons. + +### MacOS Build with XCode + + +Start Terminal, go to `MethaneKit` root directory and either start auxiliary build script +[Build/Unix/Build.sh](/Build/Unix/Build.sh) or build with CMake command line to generate XCode workspace: ```console OUTPUT_DIR=Build/Output/XCode @@ -94,7 +118,7 @@ using CMake generator command line option `-DCMAKE_OSX_ARCHITECTURES="arm64;x86_ This option should be omitted with earlier versions of Clang on macOS. Alternatively root [CMakeLists.txt](/CMakeLists.txt) can be opened directly in Visual Studio or -[any other IDE with native CMake support](#development-environments) and [built using CMake presets](#cmake-presets). +[any other IDE with native CMake support](/README.md#development-environments) and [built using CMake presets](#cmake-presets). [Methane Graphics Core](/Modules/Graphics/Core) is built using **Metal** graphics API on MacOS by default. Vulkan graphics API can be used instead by adding cmake generator option `-DMETHANE_GFX_VULKAN_ENABLED:BOOL=ON` or @@ -103,26 +127,6 @@ on top of Metal, which is not currently supporting all extensions required by Me Run built applications from the installation directory `Build/Output/XCode/Install/Apps`. -### Linux Build with Unix Makefiles - -Start Terminal, go to `MethaneKit` root directory (don't forget to pull dependent submodules as [described above](#fetch-sources)) -and either start auxiliary build script [Build/Unix/Build.sh](/Build/Unix/Build.sh) or build with CMake command line: - -```console -OUTPUT_DIR=Build/Output/Linux -cmake -S . -B $OUTPUT_DIR/Build -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$(pwd)/$OUTPUT_DIR/Install" -cmake --build $OUTPUT_DIR/Build --config Release --target install --parallel 8 -``` - -[Methane Graphics Core](/Modules/Graphics/Core) is built using **Vulkan** graphics API on Linux. - -Alternatively root [CMakeLists.txt](/CMakeLists.txt) can be opened directly in -[any IDE with native CMake support](#development-environments) and [built using CMake presets](#cmake-presets). - -Run built applications from the installation directory `Build/Output/Linux/Install/Apps`. -Note that in Ubuntu Linux even GUI applications should be started from "Terminal" app, -because of `noexec` permission set on user's home directory by security reasons. - ## CMake Generator ### CMake Options diff --git a/Build/Unix/AzureBuild.yml b/Build/Unix/AzureBuild.yml index 7a467ea41..5a405f984 100644 --- a/Build/Unix/AzureBuild.yml +++ b/Build/Unix/AzureBuild.yml @@ -19,6 +19,12 @@ steps: inputs: cmakeArgs: '--version' + - task: Cache@2 + displayName: 'Initialize Externals Cache' + inputs: + key: 'ExternalsCache | $(cmake.ConfigurePreset) | Externals/*.cmake' + path: '$(cmake.ExternalsCacheDir)' + - task: CMake@1 displayName: 'Generate with configuration preset $(cmake.ConfigurePreset)' inputs: diff --git a/Build/Unix/AzureSonarScan.yml b/Build/Unix/AzureSonarScan.yml index 533c833a5..8ca5b5e04 100644 --- a/Build/Unix/AzureSonarScan.yml +++ b/Build/Unix/AzureSonarScan.yml @@ -26,11 +26,17 @@ steps: displayName: 'Download and unpack Sonar Build-Wrapper' - task: Cache@2 - displayName: 'Sonar Scanner Cache' + displayName: 'Initialize Sonar Scanner Cache' inputs: key: 'SonarCache | $(sonar.ProjectKey) | $(Build.SourceBranchName) | $(cmake.ConfigurePreset) | "$(sonar.ScannerVersion)"' path: $(sonar.CacheDir) + - task: Cache@2 + displayName: 'Initialize Externals Cache' + inputs: + key: 'ExternalsCache | $(cmake.ConfigurePreset) | Externals/*.cmake' + path: '$(cmake.ExternalsCacheDir)' + - task: SonarCloudPrepare@1 displayName: 'Prepare Sonar Cloud Scanner' inputs: diff --git a/Build/Windows/AzureBuild.yml b/Build/Windows/AzureBuild.yml index 3072c09c0..c1b680bab 100644 --- a/Build/Windows/AzureBuild.yml +++ b/Build/Windows/AzureBuild.yml @@ -13,6 +13,12 @@ steps: inputs: cmakeArgs: '--version' + - task: Cache@2 + displayName: 'Initialize Externals Cache' + inputs: + key: 'ExternalsCache | $(cmake.ConfigurePreset) | Externals/*.cmake' + path: '$(cmake.ExternalsCacheDir)' + - task: CMake@1 displayName: 'Generate with configuration preset $(cmake.ConfigurePreset)' inputs: diff --git a/Build/Windows/AzureSonarScan.yml b/Build/Windows/AzureSonarScan.yml index a08179a97..4c80bc240 100644 --- a/Build/Windows/AzureSonarScan.yml +++ b/Build/Windows/AzureSonarScan.yml @@ -15,17 +15,18 @@ steps: workingDirectory: $(buildDir) displayName: 'Download and unpack Sonar Build-Wrapper' - - powershell: | - Expand-Archive -Path 'OpenCppCoverage.zip' -DestinationPath '.' - workingDirectory: Externals\Tools - displayName: 'Unpack OpenCppCoverage tool' - - task: Cache@2 - displayName: 'Sonar Scanner Cache' + displayName: 'Initialize Sonar Scanner Cache' inputs: key: 'SonarCache | $(sonar.ProjectKey) | $(Build.SourceBranchName) | $(cmake.ConfigurePreset) | "$(sonar.ScannerVersion)"' path: $(sonar.CacheDir) + - task: Cache@2 + displayName: 'Initialize Externals Cache' + inputs: + key: 'ExternalsCache | $(cmake.ConfigurePreset) | Externals/*.cmake' + path: '$(cmake.ExternalsCacheDir)' + - task: SonarCloudPrepare@1 displayName: 'Prepare Sonar Cloud Scanner' inputs: @@ -52,16 +53,36 @@ steps: workingDirectory: $(Build.SourcesDirectory) displayName: 'Build under Sonar Build-Wrapper with $(cmake.BuildPreset)' + - powershell: | + Invoke-WebRequest -Uri '$(coverage.OpenCppCoverageUrl)' -OutFile 'OpenCppCoverage.zip' + Expand-Archive -Path 'OpenCppCoverage.zip' -DestinationPath 'OpenCppCoverage' + if (-not(Test-Path -Path 'OpenCppCoverage\OpenCppCoverage.exe' -PathType Leaf)) { + Get-ChildItem 'OpenCppCoverage' + throw 'OpenCppCoverage\OpenCppCoverage.exe executable was not found in unpacked content!' + } + workingDirectory: '$(installDir)\Tests' + displayName: 'Download and unpack OpenCppCoverage tool' + - script: | setlocal enabledelayedexpansion + set open_cpp_coverage_exe="OpenCppCoverage\OpenCppCoverage.exe" + if not exist "%open_cpp_coverage_exe%" ( + echo File path "%open_cpp_coverage_exe%" does not exist! + exit 101 + ) echo Running unit-tests in directory "%cd%" mkdir Results mkdir Coverage + set /A result_error_level=0 for /r "." %%a in (*Test.exe) do ( - "$(Build.SourcesDirectory)\Externals\Tools\OpenCppCoverage\OpenCppCoverage.exe" --sources "$(Build.SourcesDirectory)\Modules" --export_type=cobertura:Coverage\%%~na.xml -- "%%~fa" -r sonarqube -o "Results\%%~na.xml" + echo "%open_cpp_coverage_exe%" --sources "$(Build.SourcesDirectory)\Modules" --export_type=cobertura:Coverage\%%~na.xml -- "%%~fa" -r sonarqube -o "Results\%%~na.xml" + "%open_cpp_coverage_exe%" --sources "$(Build.SourcesDirectory)\Modules" --export_type=cobertura:Coverage\%%~na.xml -- "%%~fa" -r sonarqube -o "Results\%%~na.xml" echo - %%~na - completed with !errorlevel! exit status + if not !errorlevel!==0 ( + set /A result_error_level=!errorlevel! + ) ) - exit 0 + exit !result_error_level! workingDirectory: '$(installDir)\Tests' failOnStderr: false displayName: 'Collect code coverage from all unit-tests in install directory' diff --git a/CMake/MethaneBuildOptions.cmake b/CMake/MethaneBuildOptions.cmake new file mode 100644 index 000000000..f4d6187b8 --- /dev/null +++ b/CMake/MethaneBuildOptions.cmake @@ -0,0 +1,146 @@ +#[[**************************************************************************** + +Copyright 2022 Evgeny Gorodetskiy + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +******************************************************************************* + +FILE: MethaneBuildOptions.cmake +Methane compilation and build options interface target. + +*****************************************************************************]] + +include(MethaneUtils) + +split_by_first_delimiter("${METHANE_VERSION_BUILD}" "." METHANE_VERSION_BUILD_MAJOR METHANE_VERSION_BUILD_MINOR) + +add_library(MethaneBuildOptions INTERFACE) + +target_compile_definitions(MethaneBuildOptions INTERFACE + $<$:_DEBUG> + $<$:NDEBUG> + $<$:NDEBUG> + $<$:NDEBUG> + $<$:METHANE_CHECKS_ENABLED> + $<$:ITT_INSTRUMENTATION_ENABLED> + $<$,$>:ITT_ARGUMENTS_METADATA_ENABLED> + METHANE_VERSION_MAJOR=${METHANE_VERSION_MAJOR} + METHANE_VERSION_MINOR=${METHANE_VERSION_MINOR} + METHANE_VERSION_BUILD=${METHANE_VERSION_BUILD_MAJOR} +) + +if(WIN32) + + include(FindWindowsSDK) + + if(WINDOWSSDK_FOUND) + message(STATUS "${WINDOWSSDK_LATEST_NAME} was selected for build") + else() + message(FATAL_ERROR "Windows SDK was not found!") + endif() + + get_windowssdk_include_dirs(${WINDOWSSDK_LATEST_DIR} WINDOWSSDK_INCLUDE_DIRS) + if(NOT WINDOWSSDK_INCLUDE_DIRS) + message(FATAL_ERROR "Failed to get Windows SDK include directories from ${WINDOWSSDK_LATEST_DIR}") + endif() + + get_windowssdk_library_dirs(${WINDOWSSDK_LATEST_DIR} WINDOWSSDK_LIBRARY_DIRS) + if(NOT WINDOWSSDK_LIBRARY_DIRS) + message(FATAL_ERROR "Failed to get Windows SDK library directories from ${WINDOWSSDK_LATEST_DIR}") + endif() + + target_include_directories(MethaneBuildOptions INTERFACE ${WINDOWSSDK_INCLUDE_DIRS}) + target_link_directories(MethaneBuildOptions INTERFACE ${WINDOWSSDK_LIBRARY_DIRS}) + target_compile_definitions(MethaneBuildOptions INTERFACE + UNICODE _UNICODE NOMINMAX WIN32_LEAN_AND_MEAN USE_PIX + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING # silence warning C4996 about std::wstring_convert deprecation + ) + +endif() + +if (MSVC) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + target_compile_options(MethaneBuildOptions INTERFACE + # Exception handling mode + /EHsc + # Set maximum warnings level and treat warnings as errors + /W4 /WX + # Disable useless warnings + /wd4250 # - C4250: inheritance via dominance (used only with abstract interfaces) + /wd4324 # - C4324: structure was padded due to alignment specifier + ) + + else() # Clang compiler on Windows + + target_compile_options(MethaneBuildOptions INTERFACE + # Set maximum warnings level & treat warnings as errors + -Werror + # Disable useless warnings produced by Windows headers + -Wno-unknown-pragmas + -Wno-unused-local-typedef + -Wno-ignored-pragma-intrinsic + -Wno-expansion-to-defined + -Wno-nonportable-include-path + -Wno-pragma-pack + -Wno-unused-value + -Wno-microsoft-template + -Wno-microsoft-template-shadow + -Wno-microsoft-sealed + -Wno-microsoft-exception-spec + -Wno-ignored-attributes + -Wno-macro-redefined + -Wno-extern-c-compat + -Wno-invalid-noreturn + ) + + endif() + +else() # Clang or GCC on Linux/MacOS + + target_compile_options(MethaneBuildOptions INTERFACE + # Set maximum warnings level & treat warnings as errors + -Wall -Wextra -Werror + # Disable useless Clang and GCC warnings + -Wno-missing-field-initializers + ) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # GCC + + target_compile_options(MethaneBuildOptions INTERFACE + # Disable useless GCC warnings + -Wno-ignored-qualifiers + ) + + endif() + +endif() + +if (METHANE_CODE_COVERAGE_ENABLED) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR + CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + message(STATUS "Methane code coverage is enabled with Clang compiler") + target_compile_options(MethaneBuildOptions INTERFACE -fprofile-instr-generate -fcoverage-mapping) + target_link_options(MethaneBuildOptions INTERFACE -fprofile-instr-generate) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message(STATUS "Methane code coverage is enabled with GCC compiler") + target_compile_options(MethaneBuildOptions INTERFACE -coverage) + target_link_options(MethaneBuildOptions INTERFACE -coverage) + else() + message(AUTHOR_WARNING "Methane code coverage is unavailable with ${CMAKE_CXX_COMPILER_ID} compiler") + endif() + +endif() \ No newline at end of file diff --git a/CMake/MethaneModules.cmake b/CMake/MethaneModules.cmake index 886106e2b..bfecccc24 100644 --- a/CMake/MethaneModules.cmake +++ b/CMake/MethaneModules.cmake @@ -39,14 +39,14 @@ endfunction() function(get_platform_dir PLATFORM_DIR CPP_EXT) if (WIN32) - set(PLATFORM_DIR Windows PARENT_SCOPE) - set(CPP_EXT cpp PARENT_SCOPE) + set(${PLATFORM_DIR} Windows PARENT_SCOPE) + set(${CPP_EXT} cpp PARENT_SCOPE) elseif(APPLE) - set(PLATFORM_DIR MacOS PARENT_SCOPE) - set(CPP_EXT mm PARENT_SCOPE) + set(${PLATFORM_DIR} MacOS PARENT_SCOPE) + set(${CPP_EXT} mm PARENT_SCOPE) else() - set(PLATFORM_DIR Linux PARENT_SCOPE) - set(CPP_EXT cpp PARENT_SCOPE) + set(${PLATFORM_DIR} Linux PARENT_SCOPE) + set(${CPP_EXT} cpp PARENT_SCOPE) endif() endfunction() @@ -54,19 +54,19 @@ function(get_platform_arch_dir PLATFORM_ARCH_DIR CPP_EXT) get_platform_dir(PLATFORM_DIR CPP_EXT) if (WIN32) get_target_arch(WIN_ARCH) - set(PLATFORM_ARCH_DIR "${PLATFORM_DIR}-${WIN_ARCH}" PARENT_SCOPE) + set(${PLATFORM_ARCH_DIR} "${PLATFORM_DIR}-${WIN_ARCH}" PARENT_SCOPE) else() - set(PLATFORM_ARCH_DIR "${PLATFORM_DIR}" PARENT_SCOPE) + set(${PLATFORM_ARCH_DIR} "${PLATFORM_DIR}" PARENT_SCOPE) endif() endfunction() function(get_graphics_dir GRAPHICS_DIR) if (METHANE_GFX_API EQUAL METHANE_GFX_DIRECTX) - set(GRAPHICS_DIR DirectX12 PARENT_SCOPE) + set(${GRAPHICS_DIR} DirectX12 PARENT_SCOPE) elseif(METHANE_GFX_API EQUAL METHANE_GFX_METAL) - set(GRAPHICS_DIR Metal PARENT_SCOPE) + set(${GRAPHICS_DIR} Metal PARENT_SCOPE) elseif(METHANE_GFX_API EQUAL METHANE_GFX_VULKAN) - set(GRAPHICS_DIR Vulkan PARENT_SCOPE) + set(${GRAPHICS_DIR} Vulkan PARENT_SCOPE) endif() endfunction() diff --git a/CMake/MethaneShaders.cmake b/CMake/MethaneShaders.cmake index ea99c4f7c..5304047c2 100644 --- a/CMake/MethaneShaders.cmake +++ b/CMake/MethaneShaders.cmake @@ -58,16 +58,12 @@ function(get_generated_shader_extension OUT_SHADER_EXT) endfunction() function(generate_metal_shaders_from_hlsl FOR_TARGET SHADERS_HLSL PROFILE_VER SHADER_TYPES OUT_SHADERS_METAL OUT_GENERATE_METAL_TARGETS) - get_platform_dir(PLATFORM_DIR CPP_EXT) get_target_shaders_dir(${FOR_TARGET} TARGET_SHADERS_DIR) get_file_name(${SHADERS_HLSL} SHADERS_NAME) - set(DXC_BIN_DIR "${CMAKE_SOURCE_DIR}/Externals/DirectXCompiler/binaries/${PLATFORM_DIR}/bin") - set(DXC_EXE "${DXC_BIN_DIR}/dxc") - - set(SPIRV_BIN_DIR "${CMAKE_SOURCE_DIR}/Externals/SPIRV/binaries/${PLATFORM_DIR}") - set(SPIRV_GEN_EXE "${SPIRV_BIN_DIR}/glslangValidator") - set(SPIRV_CROSS_EXE "${SPIRV_BIN_DIR}/spirv-cross") + set(DXC_EXE "${DXC_BINARY_DIR}/dxc") + set(SPIRV_GEN_EXE "${SPIRV_BINARY_DIR}/glslangValidator") + set(SPIRV_CROSS_EXE "${SPIRV_BINARY_DIR}/spirv-cross") foreach(KEY_VALUE_STRING ${SHADER_TYPES}) trim_spaces(${KEY_VALUE_STRING} KEY_VALUE_STRING) @@ -172,14 +168,11 @@ function(compile_metal_shaders_to_library FOR_TARGET SDK METAL_SHADERS METAL_LIB endfunction() function(compile_hlsl_shaders FOR_TARGET SHADERS_HLSL PROFILE_VER SHADER_TYPES OUT_COMPILED_SHADER_BINARIES OUT_COMPILE_SHADER_TARGETS) - - get_platform_arch_dir(PLATFORM_ARCH_DIR CPP_EXT) get_target_shaders_dir(${FOR_TARGET} TARGET_SHADERS_DIR) get_file_name(${SHADERS_HLSL} SHADERS_NAME) get_generated_shader_extension(OUTPUT_FILE_EXT) - set(DXC_DIR "${CMAKE_SOURCE_DIR}/Externals/DirectXCompiler/binaries/${PLATFORM_ARCH_DIR}/bin") - set(DXC_EXE "${DXC_DIR}/dxc") + set(DXC_EXE "${DXC_BINARY_DIR}/dxc") if (NOT WIN32) set(DXC_EXE "LD_LIBRARY_PATH=.;${DXC_EXE}") @@ -236,7 +229,7 @@ function(compile_hlsl_shaders FOR_TARGET SHADERS_HLSL PROFILE_VER SHADER_TYPES O COMMENT "Compiling HLSL shader from file ${SHADERS_HLSL} with profile ${SHADER_PROFILE} and macro-definitions \"${SHADER_DEFINITIONS}\" to ${OUTPUT_FILE_EXT} file ${SHADER_OBJ_FILE}" BYPRODUCTS "${SHADER_OBJ_PATH}" DEPENDS "${SHADERS_HLSL}" "${SHADERS_CONFIG}" - WORKING_DIRECTORY "${DXC_DIR}" + WORKING_DIRECTORY "${DXC_BINARY_DIR}" COMMAND ${CMAKE_COMMAND} -E make_directory "${TARGET_SHADERS_DIR}" COMMAND ${DXC_EXE} ${OUTPUT_TYPE_ARG} ${EXTRA_OPTIONS} /T ${SHADER_PROFILE} /E ${ORIG_ENTRY_POINT} /Fo ${SHADER_OBJ_PATH} ${EXTRA_COMPILE_FLAGS} ${SHADER_DEFINITION_ARGUMENTS} ${SHADERS_HLSL} ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 772cf3f5d..546f945ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ set(METHANE_VERSION_SHORT "${METHANE_VERSION_MAJOR}.${METHANE_VERSION_MINOR}") set(METHANE_VERSION_FULL "${METHANE_VERSION_SHORT}.${METHANE_VERSION_BUILD}") set(METHANE_PRODUCT_NAME "Methane Kit (https://github.com/egorodet/MethaneKit)") set(METHANE_COPYRIGHT "Copyright 2019-2021 Evgeny Gorodetskiy") +set(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Resources") # Methane graphics native APIs set(METHANE_GFX_METAL 1) # MacOS default API @@ -73,16 +74,9 @@ else() endif() endif() -list(APPEND CMAKE_MODULE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/CMake" - "${CMAKE_CURRENT_SOURCE_DIR}/Externals/CMakeModules" - "${CMAKE_CURRENT_SOURCE_DIR}/Externals/CMakeExtraModules" - "${CMAKE_CURRENT_SOURCE_DIR}/Externals/Catch2/contrib" - "${CMAKE_CURRENT_SOURCE_DIR}/Externals/CMRC" -) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") include(MethaneModules) -include(MethaneUtils) set(CMAKE_CXX_STANDARD 17) set(CTEST_OUTPUT_ON_FAILURE ON) @@ -92,44 +86,32 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") set_property(GLOBAL PROPERTY USE_FOLDERS ON) -add_library(MethaneBuildOptions INTERFACE) - -if(NOT WIN32 AND NOT APPLE AND UNIX) - set(LINUX 1) +# Use build-independent location for CPM package source cache to speedup CMake configuration +# NOTE: Do not use single cache location under CLion IDE to workaround CPM cache initialization collision +# when multiple CMake configurations are initialized simultaneously +if (NOT CPM_SOURCE_CACHE AND NOT DEFINED ENV{CLION_IDE}) + set(CPM_SOURCE_CACHE "${CMAKE_SOURCE_DIR}/Build/Output/ExternalsCache" CACHE STRING "Set default CPM source cache path for External repositories") endif() if(WIN32) - include(FindWindowsSDK) - if(WINDOWSSDK_FOUND) - message(STATUS "${WINDOWSSDK_LATEST_NAME} was selected for build") - else() - message(FATAL_ERROR "Windows SDK was not found!") - endif() - - get_windowssdk_include_dirs(${WINDOWSSDK_LATEST_DIR} WINDOWSSDK_INCLUDE_DIRS) - if(NOT WINDOWSSDK_INCLUDE_DIRS) - message(FATAL_ERROR "Failed to get Windows SDK include directories from ${WINDOWSSDK_LATEST_DIR}") - endif() + set(VS_STARTUP_PROJECT MethaneAsteroids) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") # use /MT static runtime linking + string(REPLACE "/W3 " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - get_windowssdk_library_dirs(${WINDOWSSDK_LATEST_DIR} WINDOWSSDK_LIBRARY_DIRS) - if(NOT WINDOWSSDK_LIBRARY_DIRS) - message(FATAL_ERROR "Failed to get Windows SDK library directories from ${WINDOWSSDK_LATEST_DIR}") + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Enable multi-threaded build with MSVC + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() - target_include_directories(MethaneBuildOptions INTERFACE ${WINDOWSSDK_INCLUDE_DIRS}) - target_link_directories(MethaneBuildOptions INTERFACE ${WINDOWSSDK_LIBRARY_DIRS}) - target_compile_definitions(MethaneBuildOptions INTERFACE - UNICODE _UNICODE NOMINMAX WIN32_LEAN_AND_MEAN USE_PIX - _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING # silence warning C4996 about std::wstring_convert deprecation - ) - -elseif(APPLE) +elseif(APPLE) # MacOS set(CMAKE_BUILD_WITH_INSTALL_RPATH true) set(CMAKE_INSTALL_RPATH "@executable_path") -else(UNIX) +else(UNIX) # Linux + + set(LINUX 1) find_package(X11 REQUIRED) if (NOT X11_xcb_FOUND OR @@ -140,105 +122,23 @@ else(UNIX) endif() -if (MSVC) - - set(VS_STARTUP_PROJECT MethaneAsteroids) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") # use /MT static runtime linking - string(REPLACE "/W3 " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - - # Enable multi-threaded build with MSVC - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - target_compile_options(MethaneBuildOptions INTERFACE - # Exception handling mode - /EHsc - # Set maximum warnings level and treat warnings as errors - /W4 /WX - # Disable useless warnings - /wd4250 # - C4250: inheritance via dominance (used only with abstract interfaces) - /wd4324 # - C4324: structure was padded due to alignment specifier - ) - - else() # Clang compiler on Windows - - target_compile_options(MethaneBuildOptions INTERFACE - # Set maximum warnings level & treat warnings as errors - -Werror - # Disable useless warnings produced by Windows headers - -Wno-unknown-pragmas - -Wno-unused-local-typedef - -Wno-ignored-pragma-intrinsic - -Wno-expansion-to-defined - -Wno-nonportable-include-path - -Wno-pragma-pack - -Wno-unused-value - -Wno-microsoft-template - -Wno-microsoft-template-shadow - -Wno-microsoft-sealed - -Wno-microsoft-exception-spec - -Wno-ignored-attributes - -Wno-macro-redefined - -Wno-extern-c-compat - -Wno-invalid-noreturn - ) - - endif() - -else() # Clang or GCC on Linux/MacOS - - target_compile_options(MethaneBuildOptions INTERFACE - # Set maximum warnings level & treat warnings as errors - -Wall -Wextra -Werror - # Disable useless Clang and GCC warnings - -Wno-missing-field-initializers - ) - - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # GCC - - target_compile_options(MethaneBuildOptions INTERFACE - # Disable useless GCC warnings - -Wno-ignored-qualifiers - ) - - endif() - -endif() - -target_compile_definitions(MethaneBuildOptions INTERFACE - "$<$:_DEBUG>" - "$<$:NDEBUG>" - "$<$:NDEBUG>" - "$<$:NDEBUG>" -) - message(STATUS "Methane Kit version ${METHANE_VERSION_FULL}") -split_by_first_delimiter("${METHANE_VERSION_BUILD}" "." METHANE_VERSION_BUILD_MAJOR METHANE_VERSION_BUILD_MINOR) -target_compile_definitions(MethaneBuildOptions INTERFACE - METHANE_VERSION_MAJOR=${METHANE_VERSION_MAJOR} - METHANE_VERSION_MINOR=${METHANE_VERSION_MINOR} - METHANE_VERSION_BUILD=${METHANE_VERSION_BUILD_MAJOR} -) # METHANE_GFX_API is platform dependent and is selected in CMake/MethaneModules.cmake -if(METHANE_GFX_API EQUAL METHANE_GFX_DIRECTX) - message(STATUS "Methane is using DirectX 12 graphics API") -elseif(METHANE_GFX_API EQUAL METHANE_GFX_METAL) - message(STATUS "Methane is using Metal graphics API") -elseif (METHANE_GFX_API EQUAL METHANE_GFX_VULKAN) - message(STATUS "Methane is using Vulkan graphics API") +get_graphics_dir(GRAPHICS_API_NAME) +message(STATUS "Methane is built with ${GRAPHICS_API_NAME} graphics API") + +if (APPLE AND METHANE_GFX_API EQUAL METHANE_GFX_VULKAN) # On Windows and Linux, only Vulkan-Headers are required to build Methane Kit, # because it is dynamically loading Vulkan library in runtime. Vulkan SDK is not required for build. - if (APPLE) - message(WARNING "Vulkan API is not supported on MacOS, because MoltenVK does not support extension 'VK_EXT_extended_dynamic_state'") - # To enable Vulkan API on MacOS we link statically with MoltenVK framework (translation layer to Metal). - # in order to enable finding Vulkan SDK with MoltenVK framework, set environment variable - # - VULKAN_SDK to full installation path before running CMake generator ($USER_HOME$/VulkanSDK/1.2.182.0/macOS) - find_package(Vulkan REQUIRED) - # To run Vulkan application on MacOS, additional environment variables need to be set for application: - # - VK_ICD_FILENAMES=$USER_HOME$/VulkanSDK/1.2.182.0/macOS/share/vulkan/icd.d/MoltenVK_icd.json - # - VK_LAYER_PATH=$USER_HOME$/VulkanSDK/1.2.182.0/macOS/share/vulkan/explicit_layer.d - endif() + message(AUTHOR_WARNING "Vulkan API is not supported on MacOS, because MoltenVK does not support extension 'VK_EXT_extended_dynamic_state'") + # To enable Vulkan API on MacOS we link statically with MoltenVK framework (translation layer to Metal). + # in order to enable finding Vulkan SDK with MoltenVK framework, set environment variable + # - VULKAN_SDK to full installation path before running CMake generator ($USER_HOME$/VulkanSDK/1.2.182.0/macOS) + find_package(Vulkan REQUIRED) + # To run Vulkan application on MacOS, additional environment variables need to be set for application: + # - VK_ICD_FILENAMES=$USER_HOME$/VulkanSDK/1.2.182.0/macOS/share/vulkan/icd.d/MoltenVK_icd.json + # - VK_LAYER_PATH=$USER_HOME$/VulkanSDK/1.2.182.0/macOS/share/vulkan/explicit_layer.d endif() if (METHANE_APPS_BUILD_ENABLED) @@ -252,30 +152,12 @@ endif() if (METHANE_CHECKS_ENABLED) message(STATUS "Methane runtime checks of input arguments are enabled") - target_compile_definitions(MethaneBuildOptions INTERFACE METHANE_CHECKS_ENABLED) endif() if(METHANE_RUN_TESTS_DURING_BUILD) message(STATUS "Methane tests running during build is enabled") endif() -if (METHANE_CODE_COVERAGE_ENABLED) - - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR - CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - message(STATUS "Methane code coverage is enabled with Clang compiler") - target_compile_options(MethaneBuildOptions INTERFACE -fprofile-instr-generate -fcoverage-mapping) - target_link_options(MethaneBuildOptions INTERFACE -fprofile-instr-generate) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - message(STATUS "Methane code coverage is enabled with GCC compiler") - target_compile_options(MethaneBuildOptions INTERFACE -coverage) - target_link_options(MethaneBuildOptions INTERFACE -coverage) - else() - message(STATUS "Methane code coverage is unavailable with ${CMAKE_CXX_COMPILER_ID} compiler") - endif() - -endif() - if(METHANE_SHADERS_CODEVIEW_ENABLED) message(STATUS "Methane shaders code symbols are enabled") endif() @@ -298,11 +180,8 @@ endif() if(METHANE_ITT_INSTRUMENTATION_ENABLED) message(STATUS "Methane ITT instrumentation is enabled") - target_compile_definitions(MethaneBuildOptions INTERFACE ITT_INSTRUMENTATION_ENABLED) - if(METHANE_ITT_METADATA_ENABLED) message(STATUS "Methane ITT metadata is enabled") - target_compile_definitions(MethaneBuildOptions INTERFACE ITT_ARGUMENTS_METADATA_ENABLED) endif() endif() @@ -328,22 +207,10 @@ else() set(CTEST_EXE "ctest") endif() -set(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Resources") - -# Disable finding packages by External libraries -set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_PkgConfig TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_PNG TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_BZip2 TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_HHC TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_LATEX TRUE) -set(CMAKE_DISABLE_FIND_PACKAGE_Perl TRUE) +add_subdirectory(Externals) -set(MAGIC_ENUM_OPT_INSTALL ON CACHE BOOL "Generate and install magic_enum target") +include(MethaneBuildOptions) -add_subdirectory(Externals) add_subdirectory(Modules) if (METHANE_APPS_BUILD_ENABLED) diff --git a/Externals b/Externals deleted file mode 160000 index bc8296dcc..000000000 --- a/Externals +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bc8296dcc315f664616baee416c5982c2e06de92 diff --git a/Externals/BoostNowide.cmake b/Externals/BoostNowide.cmake new file mode 100644 index 000000000..58219889c --- /dev/null +++ b/Externals/BoostNowide.cmake @@ -0,0 +1,15 @@ +CPMAddPackage( + NAME BoostNowide + GITHUB_REPOSITORY MethanePowered/BoostNowide + GIT_TAG 40666d41d287b9cbb2092f564e8832d3b8c0e1d9 # last commit from 'standalone' branch + VERSION 11.1.4 + OPTIONS + "BUILD_SHARED_LIBS OFF" + "BUILD_TESTING OFF" + "NOWIDE_INSTALL OFF" +) + +set_target_properties(nowide + PROPERTIES + FOLDER Externals +) diff --git a/Externals/CLI11.cmake b/Externals/CLI11.cmake new file mode 100644 index 000000000..3f8ee4dbb --- /dev/null +++ b/Externals/CLI11.cmake @@ -0,0 +1,5 @@ +CPMAddPackage( + NAME CLI11 + GITHUB_REPOSITORY MethanePowered/CLI11 + VERSION 2.2.0 +) diff --git a/Externals/CMRC.cmake b/Externals/CMRC.cmake new file mode 100644 index 000000000..90d3809d4 --- /dev/null +++ b/Externals/CMRC.cmake @@ -0,0 +1,7 @@ +CPMAddPackage( + NAME CMRC + GITHUB_REPOSITORY MethanePowered/CMRC + GIT_TAG a64bea50c05594c8e7cf1f08e441bb9507742e2e # last commit from 'master' branch +) + +list(APPEND CMAKE_MODULE_PATH "${CMRC_SOURCE_DIR}") \ No newline at end of file diff --git a/Externals/CMakeLists.txt b/Externals/CMakeLists.txt new file mode 100644 index 000000000..0f4b9c8f1 --- /dev/null +++ b/Externals/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.14.0) + +set(CMAKE_DISABLE_FIND_PACKAGE_Doxygen TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_PkgConfig TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_PNG TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_BZip2 TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_HHC TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_LATEX TRUE) +set(CMAKE_DISABLE_FIND_PACKAGE_Perl TRUE) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +# CMake libraries +include(CPM) # keep 1-st +include(CMakeModules) +include(CMRC) +include(FindPkgConfig) + +# Set Windows SDK for external libraries build +if(WIN32) + include(FindWindowsSDK) + if(WINDOWSSDK_FOUND) + message(STATUS "${WINDOWSSDK_LATEST_NAME} from directory '${WINDOWSSDK_LATEST_DIR}' is used for External libraries build") + get_windowssdk_include_dirs(${WINDOWSSDK_LATEST_DIR} WINSDK_INCLUDE_DIRS) + get_windowssdk_library_dirs(${WINDOWSSDK_LATEST_DIR} WINSDK_LINK_DIRS) + include_directories(${WINSDK_INCLUDE_DIRS}) + link_directories(${WINSDK_LINK_DIRS}) + else() + message(FATAL_ERROR "Windows SDK was not found!") + endif() +endif() + +# Cross-platform C++ libraries +include(BoostNowide) +include(FMT) +include(Catch2) +include(CLI11) +include(FreeType2) +include(HLSLpp) +include(MagicEnum) +include(TaskFlow) +include(Tracy) +include(PerlinNoise) + +if(METHANE_ITT_INSTRUMENTATION_ENABLED) + include(IttApi) +endif() + +if (NOT METHANE_OPEN_IMAGE_IO_ENABLED) + include(STB) +endif() + +# DirectX API C++ libraries +if(METHANE_GFX_API EQUAL METHANE_GFX_DIRECTX) + include(DirectXHeaders) + include(DirectXTex) +endif() + +# Vulkan API C++ libraries +if (METHANE_GFX_API EQUAL METHANE_GFX_VULKAN) + include(VulkanHeaders) + include(SPIRVCross) +endif() + +# Pre-built binary tools +include(DirectXShaderCompilerBinary) +include(SPIRVCrossBinary) + +if (METHANE_OPEN_IMAGE_IO_ENABLED) + include(OpenImageIOBinary) +endif() + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} PARENT_SCOPE) \ No newline at end of file diff --git a/Externals/CMakeModules.cmake b/Externals/CMakeModules.cmake new file mode 100644 index 000000000..a2fb0449a --- /dev/null +++ b/Externals/CMakeModules.cmake @@ -0,0 +1,7 @@ +CPMAddPackage( + NAME CMakeModules + GITHUB_REPOSITORY MethanePowered/CMakeModules + GIT_TAG 9de6ddab101ee6778bda388ae6a807d18cec91ac # last commit from 'methane' branch +) + +list(APPEND CMAKE_MODULE_PATH "${CMakeModules_SOURCE_DIR}") \ No newline at end of file diff --git a/Externals/CPM.cmake b/Externals/CPM.cmake new file mode 100644 index 000000000..6073550c1 --- /dev/null +++ b/Externals/CPM.cmake @@ -0,0 +1,21 @@ +set(CPM_DOWNLOAD_VERSION 0.35.1) + +if(CPM_SOURCE_CACHE) + # Expand relative path. This is important if the provided path contains a tilde (~) + get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endif() + +include(${CPM_DOWNLOAD_LOCATION}) diff --git a/Externals/Catch2.cmake b/Externals/Catch2.cmake new file mode 100644 index 000000000..2e110b375 --- /dev/null +++ b/Externals/Catch2.cmake @@ -0,0 +1,15 @@ +CPMAddPackage( + NAME Catch2 + GITHUB_REPOSITORY MethanePowered/Catch2 + VERSION 3.0.1 +) + +list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras") + +# Catch2 headers produce build errors with GCC <= 9, which are muted here +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # GCC + target_compile_options(Catch2 + PUBLIC + -Wno-parentheses + ) +endif() diff --git a/Externals/DirectXHeaders.cmake b/Externals/DirectXHeaders.cmake new file mode 100644 index 000000000..fdb86c866 --- /dev/null +++ b/Externals/DirectXHeaders.cmake @@ -0,0 +1,6 @@ +CPMAddPackage( + NAME DirectXHeaders + GITHUB_REPOSITORY MethanePowered/DirectXHeaders + VERSION 1.602.0 +) + diff --git a/Externals/DirectXShaderCompilerBinary.cmake b/Externals/DirectXShaderCompilerBinary.cmake new file mode 100644 index 000000000..8ad6965b6 --- /dev/null +++ b/Externals/DirectXShaderCompilerBinary.cmake @@ -0,0 +1,10 @@ +include(MethaneModules) + +CPMAddPackage( + NAME DirectXShaderCompilerBinary + GITHUB_REPOSITORY MethanePowered/DirectXShaderCompilerBinary + VERSION 1.6.2104 +) + +get_platform_arch_dir(PLATFORM_ARCH_DIR CPP_EXT) +set(DXC_BINARY_DIR "${DirectXShaderCompilerBinary_SOURCE_DIR}/binaries/${PLATFORM_ARCH_DIR}/bin" PARENT_SCOPE) \ No newline at end of file diff --git a/Externals/DirectXTex.cmake b/Externals/DirectXTex.cmake new file mode 100644 index 000000000..99fe8af96 --- /dev/null +++ b/Externals/DirectXTex.cmake @@ -0,0 +1,16 @@ +CPMAddPackage( + NAME DirectXTex + GITHUB_REPOSITORY MethanePowered/DirectXTex + GIT_TAG may2022 + VERSION 1.9.6 + OPTIONS + "BUILD_DX12 ON" + "BUILD_DX11 OFF" + "BUILD_TOOLS OFF" + "BUILD_SAMPLE OFF" +) + +set_target_properties(DirectXTex + PROPERTIES + FOLDER Externals +) diff --git a/Externals/FMT.cmake b/Externals/FMT.cmake new file mode 100644 index 000000000..45092b953 --- /dev/null +++ b/Externals/FMT.cmake @@ -0,0 +1,11 @@ +CPMAddPackage( + NAME FMT + GITHUB_REPOSITORY MethanePowered/FMT + GIT_TAG 8.1.1 + VERSION 8.1.1 +) + +set_target_properties(fmt + PROPERTIES + FOLDER Externals +) diff --git a/Externals/FreeType2.cmake b/Externals/FreeType2.cmake new file mode 100644 index 000000000..ee0675c6f --- /dev/null +++ b/Externals/FreeType2.cmake @@ -0,0 +1,23 @@ +CPMAddPackage( + NAME FreeType2 + GITHUB_REPOSITORY MethanePowered/FreeType2 + GIT_TAG VER-2-12-1 + VERSION 2.12.1 + OPTIONS + "FT_DISABLE_ZLIB ON" + "FT_DISABLE_BZIP2 ON" + "FT_DISABLE_PNG ON" + "FT_DISABLE_HARFBUZZ ON" + "FT_DISABLE_BROTLI ON" +) + +if(MSVC) + target_compile_options(freetype PRIVATE /wd4267 /wd4244 /wd4018 /wd4312) +else() + target_compile_options(freetype PRIVATE -Wno-everything) +endif() + +set_target_properties(freetype + PROPERTIES + FOLDER Externals +) diff --git a/Externals/HLSLpp.cmake b/Externals/HLSLpp.cmake new file mode 100644 index 000000000..19d6a1755 --- /dev/null +++ b/Externals/HLSLpp.cmake @@ -0,0 +1,20 @@ +CPMAddPackage( + NAME HLSLpp + GITHUB_REPOSITORY MethanePowered/HLSLpp + GIT_TAG 3.2 + VERSION 3.2 +) + +add_library(HLSLpp INTERFACE) +target_include_directories(HLSLpp INTERFACE ${HLSLpp_SOURCE_DIR}/include) +target_compile_definitions(HLSLpp INTERFACE + HLSLPP_FEATURE_TRANSFORM # Enable transformation matrices + HLSLPP_LOGICAL_LAYOUT=0 # Set row-major logical layout + HLSLPP_COORDINATES=0 # Set left-handed coordinate system +) + +if(MSVC) + target_sources(HLSLpp INTERFACE ${HLSLpp_SOURCE_DIR}/include/hlsl++.natvis) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # GCC + target_compile_options(HLSLpp INTERFACE -Wno-deprecated-copy) +endif() diff --git a/Externals/IttApi.cmake b/Externals/IttApi.cmake new file mode 100644 index 000000000..733f3b971 --- /dev/null +++ b/Externals/IttApi.cmake @@ -0,0 +1,10 @@ +CPMAddPackage( + NAME IttApi + GITHUB_REPOSITORY MethanePowered/IttApi + VERSION 3.23.0 +) + +set_target_properties(ittnotify + PROPERTIES + FOLDER Externals +) diff --git a/Externals/MagicEnum.cmake b/Externals/MagicEnum.cmake new file mode 100644 index 000000000..75e28b7d1 --- /dev/null +++ b/Externals/MagicEnum.cmake @@ -0,0 +1,7 @@ +CPMAddPackage( + NAME MagicEnum + GITHUB_REPOSITORY MethanePowered/MagicEnum + VERSION 0.8.0 + OPTIONS + "MAGIC_ENUM_OPT_INSTALL ON" +) diff --git a/Externals/OpenImageIOBinary.cmake b/Externals/OpenImageIOBinary.cmake new file mode 100644 index 000000000..9c290c504 --- /dev/null +++ b/Externals/OpenImageIOBinary.cmake @@ -0,0 +1,5 @@ +CPMAddPackage( + NAME OpenImageIOBinary + GITHUB_REPOSITORY MethanePowered/OpenImageIOBinary + VERSION 2.0.5 +) diff --git a/Externals/PerlinNoise.cmake b/Externals/PerlinNoise.cmake new file mode 100644 index 000000000..5252a0d78 --- /dev/null +++ b/Externals/PerlinNoise.cmake @@ -0,0 +1,5 @@ +CPMAddPackage( + NAME PerlinNoise + GITHUB_REPOSITORY MethanePowered/PerlinNoise + VERSION 1.0 +) diff --git a/Externals/README.md b/Externals/README.md new file mode 100644 index 000000000..a3643083c --- /dev/null +++ b/Externals/README.md @@ -0,0 +1,55 @@ +# Methane Kit External Dependencies + +All external [libraries](#libraries) and [build tools](#build-tools) +are integrated using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) package manager script. +Specific versions of the dependent repositories are cloned and configured +during `MethaneKit` CMake configuration step either to the `Build/Output/ExternalsCache` directory (by default) +or to the custom location provided via CMake option `CPM_SOURCE_CACHE`. +Under CLion IDE dependent repositories are cloned inside cmake build directory of each configuration +to support parallel cmake configurations processing. + +## Libraries + +| Libraries | Version | Linkage | License | Description | +|-------------------------------------------------------------------|------------|-------------------|---------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------| +| [Boost Nowide](https://github.com/boostorg/nowide) | 11.1.4 | Static | [BSL 1.0](https://github.com/boostorg/nowide/blob/develop/LICENSE) | Standard library functions with UTF-8 API on Windows. | +| [Catch2](https://github.com/catchorg/Catch2) | 3.0.1 | Static (tests) | [BSL 1.0](https://github.com/catchorg/Catch2/blob/devel/LICENSE.txt) | A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later. | +| [CLI11](https://github.com/CLIUtils/CLI11) | 2.2.0 | Header-only | [CLI11 2.2](https://github.com/CLIUtils/CLI11/blob/main/LICENSE) | CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface. | +| [DirectX Headers](https://github.com/microsoft/DirectX-Headers) | n/a | Header-only | [MIT](https://github.com/microsoft/DirectX-Headers/blob/main/LICENSE) | Official DirectX headers available under an open source license | +| [DirectX Tex](https://github.com/microsoft/DirectXTex) | 1.9.6 | Static | [MIT](https://github.com/microsoft/DirectXTex/blob/main/LICENSE) | Texture processing library. | +| [FMT](https://github.com/fmtlib/fmt) | 8.1.1 | Header-only | [Victor Zverovich](https://github.com/fmtlib/fmt/blob/master/LICENSE.rst) | A modern formatting library. | +| [FreeType](https://gitlab.freedesktop.org/freetype/freetype/) | 2.12.1 | Static | [FreeType (GPL 3.0)](https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/docs/FTL.TXT) | FreeType is a freely available software library to render fonts. | +| [HLSL++](https://github.com/redorav/hlslpp) | 3.2 | Header-only | [MIT](https://github.com/MethanePowered/HLSLpp/blob/master/LICENSE) | Math library using hlsl syntax with SSE/NEON support. | +| [ITT API](https://github.com/intel/ittapi) | 3.23.0 | Static | [BSD 3.0](https://github.com/MethanePowered/IttApi/blob/master/LICENSES/BSD-3-Clause.txt) | Intel® Instrumentation and Tracing Technology (ITT) and Just-In-Time (JIT) API. | +| [Magic Enum](https://github.com/Neargye/magic_enum) | 0.8.0 | Header-only | [MIT](https://github.com/Neargye/magic_enum/blob/master/LICENSE) | Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code. | +| [OpenImageIO](https://github.com/OpenImageIO/oiio) | 2.0.5 | Static (optional) | [GPL 3.0](https://github.com/OpenCppCoverage/OpenCppCoverage/blob/master/LICENSE.txt) | Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications. | +| [Perlin Noise](https://github.com/stegu/perlin-noise/) | 1.0 | Static | [Public Domain](https://github.com/stegu/perlin-noise/blob/master/LICENSE.md) | Simplex and Perlin noise implementation by Stefan Gustavson. | +| [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) | 1.3.216.0 | Static | [Apache 2.0](https://github.com/KhronosGroup/SPIRV-Cross/blob/master/LICENSE) | A library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages. | +| [STB](https://github.com/nothings/stb) | 2020-01-16 | Header-only | [MIT, Public Domain](https://github.com/nothings/stb/blob/master/LICENSE) | Single-file public domain libraries for C/C++. | +| [TaskFlow](https://github.com/taskflow/taskflow) | 3.4.0 | Header-only | [MIT](https://github.com/taskflow/taskflow/blob/master/LICENSE) | A General-purpose Parallel and Heterogeneous Task Programming System. | +| [Tracy](https://github.com/wolfpld/tracy) | 0.8.2.1 | Static | [BSD 3.0](https://github.com/wolfpld/tracy/blob/master/LICENSE) | A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications. | +| [Vulkan Headers](https://github.com/MethanePowered/VulkanHeaders) | 1.3.219 | Header-only | [Apache 2.0](https://github.com/KhronosGroup/Vulkan-Headers/blob/main/LICENSE.txt) | Vulkan Header files and API registry. | + +## Build Tools + +| Libraries | Version | Usage | License | Description | +|-------------------------------------------------------------------------------|-----------|--------------------------|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------| +| [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) | 0.35.1 | CMake | [MIT](https://github.com/cpm-cmake/CPM.cmake/blob/master/LICENSE) | CMake's missing package manager. | +| [CMRC](https://github.com/vector-of-bool/cmrc) | n/a | CMake | [MIT](https://github.com/vector-of-bool/cmrc/blob/master/LICENSE.txt) | A Resource Compiler in a Single CMake script. | +| [CMake Modules](https://github.com/rpavlik/cmake-modules) | n/a | CMake | [BSL 1.0](https://github.com/microsoft/CMakeModules/blob/main/LICENSE_1_0.txt) | R.Pavlik collection of CMake modules. | +| [DirectX Shader Compiler](https://github.com/microsoft/DirectXShaderCompiler) | 1.6.2104 | HLSL Compiler to SPIRV | [LLVM Release](https://github.com/microsoft/DirectXShaderCompiler/blob/main/LICENSE.TXT) | Open-source HLSL Shader Compiler which is based on LLVM/Clang. | +| [Filter Sarif](https://github.com/zbazztian/filter-sarif) | n/a | CodeQL Workflow | [Apache 2.0](https://github.com/zbazztian/filter-sarif/blob/master/LICENSE) | GitHub action to filter .sarif files produced by CodeQL. | +| [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) | 1.3.216.0 | SPIRV Converter to Metal | [Apache 2.0](https://github.com/KhronosGroup/SPIRV-Cross/blob/master/LICENSE) | Practical tool for disassembling SPIR-V back to high level languages. | +| [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage) | 0.9.9.0 | Code Coverage in Azure | [GPL 3.0](https://github.com/OpenCppCoverage/OpenCppCoverage/blob/master/LICENSE.txt) | Open source code coverage tool for C++ under Windows. | + +## Assets + +| Type | Asset Name | Copyright | License | Description | +|----------|----------------------------------------------------------------------|--------------------------------------------------------|-----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Font | [Amiri](https://fonts.google.com/specimen/Amiri) | [Khaled Hosny](khaledhosny@eglug.org) | [OFL 1.1](http://scripts.sil.org/OFL) | Amiri is a classical Arabic typeface in Naskh style for typesetting books and other running text. Its design is a revival of the beautiful typeface pioneered in early 20th century by Bulaq Press in Cairo, also known as Amiria Press, after which the font is named. | +| Font | [Playball](https://fonts.google.com/specimen/Playball) | [Robert Leuschke, TypeSETit LLC](typesetit.com) | [OFL 1.1](http://scripts.sil.org/OFL) | An athletic look was the inspiration for Playball. Take advantage of the sweeping swashes to give a true sports look. Perfect for baseball banners and the like. Playball comes with Latin Character sets including Western, Central, and Vietnamese language support. | +| Font | [Roboto](https://fonts.google.com/specimen/Roboto) | [Christian Robertson](http://christianrobertson.com/) | [Apache 2.0](http://www.apache.org/licenses/) | Roboto has a mechanical skeleton and the forms are largely geometric. At the same time, the font features friendly and open curves. This makes for a more natural reading rhythm more commonly found in humanist and serif types. | +| Font | [Roboto Mono](https://fonts.google.com/specimen/Roboto+Mono) | [Christian Robertson](http://christianrobertson.com/) | [Apache 2.0](http://www.apache.org/licenses/) | Monospaced addition to the Roboto type family. Like the other members of the Roboto family, the fonts are optimized for readability on screens across a wide variety of devices and reading environments. | +| Font | [Sawarabi Mincho](https://fonts.google.com/specimen/Sawarabi+Mincho) | [Mshio](http://mshio.b.osdn.me/) | [OFL 1.1](http://scripts.sil.org/OFL) | Japanese font with a delicate and beautiful design, it is suitable for text and headline usage. It already has many hiragana, katakana, ruled lines, and so on, but it does not yet have enough kanji glyphs. | +| Font | [Squada One](https://fonts.google.com/specimen/Squada+One) | [Admix Designs](http://www.admixdesigns.com/) | [OFL 1.1](http://scripts.sil.org/OFL) | Perfect font to make a lasting impression on any webpage. Its bold presence and geometric, condensed form allow for setting in any context. Squada One can be used at any size while still maintaining clarity and smoothness. | +| Textures | [Solar System Planets](https://www.solarsystemscope.com/textures/) | [Solar System Scope](https://www.solarsystemscope.com) | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) | Textures in this pack are based on NASA elevation and imagery data. Colors and shades of the textures are tuned accordng to true-color photos made by Messenger, Viking and Cassini spacecrafts, and, of course, the Hubble Space Telescope. | diff --git a/Externals/SPIRVCross.cmake b/Externals/SPIRVCross.cmake new file mode 100644 index 000000000..e67bf24e3 --- /dev/null +++ b/Externals/SPIRVCross.cmake @@ -0,0 +1,23 @@ +CPMAddPackage( + NAME SPIRVCross + GITHUB_REPOSITORY MethanePowered/SPIRVCross + GIT_TAG sdk-1.3.216.0 + VERSION 1.3.216.0 + OPTIONS + "SPIRV_CROSS_STATIC ON" + "SPIRV_CROSS_SHARED OFF" + "SPIRV_CROSS_CLI OFF" + "SPIRV_CROSS_ENABLE_TESTS OFF" + "SPIRV_CROSS_ENABLE_HLSL ON" + "SPIRV_CROSS_ENABLE_GLSL ON" + "SPIRV_CROSS_ENABLE_MSL OFF" + "SPIRV_CROSS_ENABLE_CPP OFF" + "SPIRV_CROSS_ENABLE_REFLECT OFF" + "SPIRV_CROSS_ENABLE_C_API OFF" + "SPIRV_CROSS_ENABLE_UTIL OFF" +) + +set_target_properties(spirv-cross-core spirv-cross-hlsl spirv-cross-glsl uninstall + PROPERTIES + FOLDER Externals +) \ No newline at end of file diff --git a/Externals/SPIRVCrossBinary.cmake b/Externals/SPIRVCrossBinary.cmake new file mode 100644 index 000000000..93ce8e8d5 --- /dev/null +++ b/Externals/SPIRVCrossBinary.cmake @@ -0,0 +1,8 @@ +CPMAddPackage( + NAME SPIRVCrossBinary + GITHUB_REPOSITORY MethanePowered/SPIRVCrossBinary + GIT_TAG b440a00005bf0225b4a815fd3dd2d98bba84d4df # 2020-01-16 +) + +get_platform_dir(PLATFORM_DIR CPP_EXT) +set(SPIRV_BINARY_DIR "${SPIRVCrossBinary_SOURCE_DIR}/binaries/${PLATFORM_DIR}" PARENT_SCOPE) diff --git a/Externals/STB.cmake b/Externals/STB.cmake new file mode 100644 index 000000000..804dbbaac --- /dev/null +++ b/Externals/STB.cmake @@ -0,0 +1,8 @@ +CPMAddPackage( + NAME STB + GITHUB_REPOSITORY MethanePowered/STB + GIT_TAG af1a5bc352164740c1cc1354942b1c6b72eacb8a +) + +add_library(STB INTERFACE) +target_include_directories(STB INTERFACE "${STB_SOURCE_DIR}") diff --git a/Externals/TaskFlow.cmake b/Externals/TaskFlow.cmake new file mode 100644 index 000000000..75276b418 --- /dev/null +++ b/Externals/TaskFlow.cmake @@ -0,0 +1,18 @@ +CPMAddPackage( + NAME TaskFlow + GITHUB_REPOSITORY MethanePowered/TaskFlow + VERSION 3.4.0 + OPTIONS + "TF_BUILD_BENCHMARKS OFF" + "TF_BUILD_CUDA OFF" + "TF_BUILD_TESTS OFF" + "TF_BUILD_EXAMPLES OFF" +) + +add_library(TaskFlow ALIAS Taskflow) + +if(MSVC) + target_compile_options(Taskflow INTERFACE + /wd4456 # declaration of 'lock' hides previous local declaration (taskflow/core/executor.hpp:1842) + ) +endif() \ No newline at end of file diff --git a/Externals/Tracy.cmake b/Externals/Tracy.cmake new file mode 100644 index 000000000..61b0482db --- /dev/null +++ b/Externals/Tracy.cmake @@ -0,0 +1,12 @@ +CPMAddPackage( + NAME Tracy + GITHUB_REPOSITORY MethanePowered/Tracy + VERSION 0.8.2.1 + OPTIONS + "TRACY_ENABLE ${METHANE_TRACY_PROFILING_ENABLED}" + "TRACY_ON_DEMAND ${METHANE_TRACY_PROFILING_ON_DEMAND}" +) + +# Tracy instrumentation interface library +add_library(TracyInstrumentation INTERFACE) +target_include_directories(TracyInstrumentation INTERFACE "${Tracy_SOURCE_DIR}") diff --git a/Externals/VulkanHeaders.cmake b/Externals/VulkanHeaders.cmake new file mode 100644 index 000000000..1a02380fa --- /dev/null +++ b/Externals/VulkanHeaders.cmake @@ -0,0 +1,5 @@ +CPMAddPackage( + NAME VulkanHeaders + GITHUB_REPOSITORY MethanePowered/VulkanHeaders + VERSION 1.3.219 +) diff --git a/Modules/Common/Instrumentation/CMakeLists.txt b/Modules/Common/Instrumentation/CMakeLists.txt index 10c53803a..b511059ab 100644 --- a/Modules/Common/Instrumentation/CMakeLists.txt +++ b/Modules/Common/Instrumentation/CMakeLists.txt @@ -37,10 +37,10 @@ target_include_directories(${TARGET} target_link_libraries(${TARGET} PUBLIC - $<$:MethanePlatformUtils> # Logging functions MethanePrimitives + $<$:MethanePlatformUtils> # Logging functions + $<$:ittnotify> TracyInstrumentation - ittnotify nowide PRIVATE MethaneBuildOptions @@ -74,15 +74,6 @@ if (WIN32 AND METHANE_TRACY_PROFILING_ENABLED) ) endif() -# TracyClient interface target is defined separately in Externals, -# but it also has to be configured with TRACY_* macro definitions -# and is required for linking in target application for Tracy profiling -target_compile_definitions(TracyClient - INTERFACE - $<$:TRACY_ENABLE> - $<$:TRACY_ON_DEMAND> -) - source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${HEADERS} ${SOURCES}) if (APPLE) diff --git a/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp b/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp index b136da9fa..e07f0cd85 100644 --- a/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp +++ b/Modules/Common/Instrumentation/Include/Methane/TracyGpu.hpp @@ -343,7 +343,7 @@ class GpuScope tracy_force_inline void Complete(Timestamp gpu_begin_timestamp, Timestamp gpu_end_timestamp) { - if (!m_context_ptr) + if (!m_context_ptr || gpu_begin_timestamp == gpu_end_timestamp) return; #ifdef TRACY_ON_DEMAND diff --git a/Modules/Common/PrecompiledHeaders/CMakeLists.txt b/Modules/Common/PrecompiledHeaders/CMakeLists.txt index 23592fb98..9892c415d 100644 --- a/Modules/Common/PrecompiledHeaders/CMakeLists.txt +++ b/Modules/Common/PrecompiledHeaders/CMakeLists.txt @@ -91,12 +91,12 @@ set(PRECOMPILED_EXTRA_HEADERS ${PRECOMPILED_HEADERS} if (METHANE_GFX_API EQUAL METHANE_GFX_DIRECTX) set(PRECOMPILED_EXTRA_HEADERS ${PRECOMPILED_EXTRA_HEADERS} - - + + ) set(PLATFORM_LIBRARIES - D3DX12 + DirectX-Headers ) endif() diff --git a/Modules/Common/Primitives/Include/Methane/Exceptions.hpp b/Modules/Common/Primitives/Include/Methane/Exceptions.hpp index b9ff6dc47..2e17f89eb 100644 --- a/Modules/Common/Primitives/Include/Methane/Exceptions.hpp +++ b/Modules/Common/Primitives/Include/Methane/Exceptions.hpp @@ -99,7 +99,7 @@ class InvalidArgumentException : public ArgumentExceptionBase) - return fmt::format("{}::{}({}) is not valid", magic_enum::enum_type_name(), magic_enum::enum_name(value), value); + return fmt::format("{}::{}({}) is not valid", magic_enum::enum_type_name(), magic_enum::enum_name(value), magic_enum::enum_integer(value)); else if constexpr (std::is_pointer_v) return fmt::format("{}*({}) is not valid", typeid(V).name(), fmt::ptr(value)); else if constexpr (IsStaticCastable::value) @@ -158,29 +158,30 @@ class ZeroArgumentException : public ArgumentExceptionBase> +template class UnexpectedArgumentException : public ArgumentExceptionBase { public: - template - UnexpectedArgumentException(const std::string& function_name, const std::string& variable_name, ValueType&& value, const std::string& description = "") + using DecayType = typename std::decay_t; + + UnexpectedArgumentException(const std::string& function_name, const std::string& variable_name, DecayType value, const std::string& description = "") : ArgumentExceptionBaseType(function_name, variable_name, GetMessage(value), description) - , m_value(std::forward(value)) + , m_value(std::move(value)) { } - [[nodiscard]] RawType GetValue() const noexcept { m_value; } + [[nodiscard]] const DecayType& GetValue() const noexcept { m_value; } private: - template - static std::string GetMessage(ValueType&& value) + template + static std::string GetMessage(const V& value) { - if constexpr (std::is_enum_v) - return fmt::format("{}::{}({}) is unexpected", magic_enum::enum_type_name(), magic_enum::enum_name(std::forward(value)), std::forward(value)); + if constexpr (std::is_enum_v) + return fmt::format("{}::{}({}) is unexpected", magic_enum::enum_type_name(), magic_enum::enum_name(value), magic_enum::enum_integer(value)); else - return fmt::format("{}({}) is unexpected", typeid(ValueType).name(), std::forward(value)); + return fmt::format("{}({}) is unexpected", typeid(V).name(), value); } - RawType m_value; + DecayType m_value; }; class NotImplementedException : public std::logic_error diff --git a/Modules/Data/Types/Include/Methane/Data/Point.hpp b/Modules/Data/Types/Include/Methane/Data/Point.hpp index a453a1cd0..46560d482 100644 --- a/Modules/Data/Types/Include/Methane/Data/Point.hpp +++ b/Modules/Data/Types/Include/Methane/Data/Point.hpp @@ -72,6 +72,16 @@ class Point VectorType& AsVector() noexcept { return m_vector; } const VectorType& AsVector() const noexcept { return m_vector; } + std::array AsArray() const noexcept + { + if constexpr (size == 2) + return std::array{{ GetX(), GetY() }}; + else if constexpr (size == 3) + return std::array{{ GetX(), GetY(), GetZ() }}; + else if constexpr (size == 4) + return std::array{{ GetX(), GetY(), GetZ(), GetW() }}; + } + T GetX() const noexcept { return m_vector.x; } T GetY() const noexcept { return m_vector.y; } @@ -111,11 +121,59 @@ class Point return *this; } - bool operator==(const PointType& other) const noexcept { return hlslpp::all(m_vector == other.AsVector()); } + [[nodiscard]] T operator[](size_t index) const + { + switch(index) + { + case 0: return m_vector.x; + case 1: return m_vector.y; + case 2: if constexpr(size > 2) return m_vector.z; + case 3: if constexpr(size > 3) return m_vector.w; + default: META_UNEXPECTED_ARG_RETURN(index, T{}); + } + } + + [[nodiscard]] bool operator==(const PointType& other) const noexcept + { +#if defined(__APPLE__) && defined(__x86_64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/61): + // Integer vector comparison is working incorrectly on Intel based Macs with MacOS >= 11 + return AsArray() == other.AsArray(); +#else + return hlslpp::all(m_vector == other.AsVector()); +#endif + } + + [[nodiscard]] bool operator<(const PointType& other) const noexcept + { +#if defined(__APPLE__) && defined(__x86_64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/61): + // Integer vector comparison is working incorrectly on Intel based Macs with MacOS >= 11 + for(size_t i = 0; i < size; ++i) + if ((*this)[i] >= other[i]) + return false; + return true; +#else + return hlslpp::all(m_vector < other.AsVector()); +#endif + } + + [[nodiscard]] bool operator>(const PointType& other) const noexcept + { +#if defined(__APPLE__) && defined(__x86_64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/61): + // Integer vector comparison is working incorrectly on Intel based Macs with MacOS >= 11 + for(size_t i = 0; i < size; ++i) + if ((*this)[i] <= other[i]) + return false; + return true; +#else + return hlslpp::all(m_vector > other.AsVector()); +#endif + } + bool operator!=(const PointType& other) const noexcept { return !operator==(other); } - bool operator<(const PointType& other) const noexcept { return hlslpp::all(m_vector < other.AsVector()); } bool operator<=(const PointType& other) const noexcept { return hlslpp::all(m_vector <= other.AsVector()); } - bool operator>(const PointType& other) const noexcept { return hlslpp::all(m_vector > other.AsVector()); } bool operator>=(const PointType& other) const noexcept { return hlslpp::all(m_vector >= other.AsVector()); } PointType operator+(const PointType& other) const noexcept { return PointType(m_vector + other.AsVector()); } @@ -140,6 +198,13 @@ class Point template std::enable_if_t, PointType> operator/(M divisor) const noexcept { +#if defined(__APPLE__) && defined(__aarch64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/60) + // Integer vector division is working incorrectly on Macs with Apple M1 (ARM) + std::array components = AsArray(); + Divide(components, divisor); + return PointType(std::move(components)); +#else if constexpr (std::is_same_v) return PointType(m_vector / divisor); else @@ -149,6 +214,7 @@ class Point else return PointType(m_vector / static_cast(divisor)); } +#endif } template @@ -170,6 +236,13 @@ class Point template std::enable_if_t, PointType> operator/(const Point& divisor) const noexcept { +#if defined(__APPLE__) && defined(__aarch64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/60) + // Integer vector division is working incorrectly on Macs with Apple M1 (ARM) + std::array components = AsArray(); + Divide(components, divisor.AsArray()); + return PointType(std::move(components)); +#else if constexpr (std::is_same_v) return PointType(m_vector / divisor.AsVector()); else @@ -179,6 +252,7 @@ class Point else return PointType(m_vector / static_cast(divisor).AsVector()); } +#endif } template @@ -199,6 +273,13 @@ class Point template std::enable_if_t, PointType&> operator/=(M divisor) noexcept { +#if defined(__APPLE__) && defined(__aarch64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/60) + // Integer vector division is working incorrectly on Macs with Apple M1 (ARM) + std::array components = AsArray(); + Divide(components, divisor); + m_vector = RawVector(std::move(components)).AsHlsl(); +#else if constexpr (std::is_same_v) m_vector /= divisor; else @@ -208,6 +289,7 @@ class Point else m_vector /= static_cast(divisor); } +#endif return *this; } @@ -229,6 +311,13 @@ class Point template std::enable_if_t, PointType&> operator/=(const Point& divisor) noexcept { +#if defined(__APPLE__) && defined(__aarch64__) + // FIXME: workaround for HLSL++ issue (https://github.com/redorav/hlslpp/issues/60) + // Integer vector division is working incorrectly on Macs with Apple M1 (ARM) + std::array components = AsArray(); + Divide(components, divisor.AsArray()); + m_vector = RawVector(std::move(components)).AsHlsl(); +#else if constexpr (std::is_same_v) m_vector /= divisor.AsVector(); else @@ -238,6 +327,7 @@ class Point else m_vector /= static_cast(divisor).AsVector(); } +#endif return *this; } @@ -264,11 +354,37 @@ class Point explicit operator VectorType() const noexcept { return m_vector; } - const VectorType& AsHlsl() const noexcept { return m_vector; } - private: static inline T Square(T s) noexcept { return s * s; } + template + static void Divide(T& component, M divisor) + { + if constexpr (std::is_same_v) + component /= divisor; + else + { + if constexpr (std::is_floating_point_v) + component = RoundCast(static_cast(component) / divisor); + else + component = RoundCast(component / static_cast(divisor)); + } + } + + template + static void Divide(std::array& components, M divisor) + { + for (T& component: components) + Divide(component, divisor); + } + + template + static void Divide(std::array& components, const std::array& divisors) + { + for (size_t i = 0; i < size; ++i) + Divide(components[i], divisors[i]); + } + VectorType m_vector; }; diff --git a/Modules/Data/Types/Include/Methane/Data/TimeRange.hpp b/Modules/Data/Types/Include/Methane/Data/TimeRange.hpp index 2fd5add81..67a2081b2 100644 --- a/Modules/Data/Types/Include/Methane/Data/TimeRange.hpp +++ b/Modules/Data/Types/Include/Methane/Data/TimeRange.hpp @@ -26,6 +26,10 @@ Methane time range type definition #include #include +#ifdef _WIN32 +#include +#endif + namespace Methane::Data { @@ -34,21 +38,45 @@ using TimeRange = Range; constexpr Timestamp g_one_sec_in_nanoseconds = 1000000000; [[nodiscard]] -inline Timestamp ConvertTimeSecondsToNanoseconds(double seconds) +inline Timestamp ConvertTimeSecondsToNanoseconds(double seconds) noexcept { return static_cast(seconds * g_one_sec_in_nanoseconds); } [[nodiscard]] -inline Timestamp ConvertTicksToNanoseconds(Timestamp ticks, Frequency frequency) +inline Timestamp ConvertTicksToNanoseconds(Timestamp ticks, Frequency frequency) noexcept { return ticks * g_one_sec_in_nanoseconds / frequency; } [[nodiscard]] -inline float ConvertFrequencyToTickPeriod(Frequency frequency) +inline float ConvertFrequencyToTickPeriod(Frequency frequency) noexcept { return static_cast(g_one_sec_in_nanoseconds) / static_cast(frequency); } +#ifdef _WIN32 + +inline uint64_t GetQpcFrequency() noexcept +{ + LARGE_INTEGER t; + QueryPerformanceFrequency( &t ); + return static_cast(t.QuadPart); +} + +inline uint64_t GetQpcToNSecMultiplier() noexcept +{ + static const auto s_qpc_to_nsec = static_cast(static_cast(g_one_sec_in_nanoseconds) / static_cast(GetQpcFrequency())); + return s_qpc_to_nsec; +} + +#else // !defined(_WIN32) + +inline uint64_t GetQpcToNSecMultiplier() noexcept +{ + return 1U; +} + +#endif // defined(_WIN32) + } // namespace Methane::Data diff --git a/Modules/Data/Types/Include/Methane/Data/Vector.hpp b/Modules/Data/Types/Include/Methane/Data/Vector.hpp index fa8ac0bcc..41a5d1aa9 100644 --- a/Modules/Data/Types/Include/Methane/Data/Vector.hpp +++ b/Modules/Data/Types/Include/Methane/Data/Vector.hpp @@ -254,10 +254,10 @@ class RawVector return RoundCast(std::sqrt(square_sum)); } - [[nodiscard]] T operator[](size_t index) const noexcept { return m_components[index]; } - [[nodiscard]] T& operator[](size_t index) noexcept { return m_components[index]; } + [[nodiscard]] T operator[](size_t index) const { META_CHECK_ARG_LESS(index, size); return m_components[index]; } + [[nodiscard]] T& operator[](size_t index) { META_CHECK_ARG_LESS(index, size); return m_components[index]; } - [[nodiscard]] T Get(size_t index) const { META_CHECK_ARG_LESS(index, size); return m_components[index]; } + [[nodiscard]] T Get(size_t index) const { META_CHECK_ARG_LESS(index, size); return m_components[index]; } [[nodiscard]] T GetX() const noexcept { return m_components[0]; } [[nodiscard]] T GetY() const noexcept { return m_components[1]; } diff --git a/Modules/Graphics/Core/CMakeLists.txt b/Modules/Graphics/Core/CMakeLists.txt index 1d56f528f..a3845c85e 100644 --- a/Modules/Graphics/Core/CMakeLists.txt +++ b/Modules/Graphics/Core/CMakeLists.txt @@ -82,9 +82,9 @@ if (METHANE_GFX_API EQUAL METHANE_GFX_DIRECTX) ) set(PLATFORM_LIBRARIES - D3DX12 + DirectX-Headers DirectXTex - D3DCompilerToDXC + DirectXCompiler d3d12 dxgi dxguid @@ -217,7 +217,8 @@ elseif(METHANE_GFX_API EQUAL METHANE_GFX_VULKAN) endif() set(PLATFORM_LIBRARIES - $<$>:Vulkan-Headers> # Lin/Win: Dynamic linking with Vulkan, so only Vulkan headers are needed + $<$>:Vulkan-Headers> # Lin/Win: Dynamic linking with Vulkan, only Vulkan headers are needed + $<$:dl> # Linux: Link with dynamic linker for vk::DynamicLoader on Linux $<$:Vulkan::Vulkan> # MacOS: Link statically with MoltenVK framework on MacOS spirv-cross-core spirv-cross-hlsl diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.cpp index 852994363..52faa59e5 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.cpp @@ -262,6 +262,7 @@ void CommandListBase::CompleteInternal() "{} command list '{}' in {} state can not be completed; only command lists in 'Executing' state can be completed", magic_enum::enum_name(m_type), GetName(), magic_enum::enum_name(m_state)); + ReleaseRetainedResources(); SetCommandListStateNoLock(State::Pending); TRACY_GPU_SCOPE_COMPLETE(m_tracy_gpu_scope, GetGpuTimeRange(false)); @@ -380,7 +381,6 @@ void CommandListBase::ResetCommandState() { META_FUNCTION_TASK(); m_command_state.program_bindings_ptr = nullptr; - m_command_state.retained_resources.clear(); } void CommandListBase::ApplyProgramBindings(ProgramBindingsBase& program_bindings, ProgramBindings::ApplyBehavior apply_behavior) diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.h b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.h index bf57fb17a..d2304e7d6 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandListBase.h @@ -110,8 +110,9 @@ class CommandListBase const ProgramBindingsBase* GetProgramBindingsPtr() const noexcept { return GetCommandState().program_bindings_ptr; } Ptr GetCommandListPtr() { return GetPtr(); } - inline void RetainResource(const Ptr& resource_ptr) { if (resource_ptr) m_command_state.retained_resources.emplace_back(resource_ptr); } - inline void RetainResource(ObjectBase& resource) { m_command_state.retained_resources.emplace_back(resource.GetBasePtr()); } + inline void RetainResource(const Ptr& resource_ptr) { if (resource_ptr) m_command_state.retained_resources.emplace_back(resource_ptr); } + inline void RetainResource(ObjectBase& resource) { m_command_state.retained_resources.emplace_back(resource.GetBasePtr()); } + inline void ReleaseRetainedResources() { m_command_state.retained_resources.clear(); } template>> inline void RetainResources(const Ptrs& resource_ptrs) @@ -127,11 +128,12 @@ class CommandListBase CommandState& GetCommandState() { return m_command_state; } const CommandState& GetCommandState() const { return m_command_state; } - void SetCommandListState(State state); - void SetCommandListStateNoLock(State state); - bool IsExecutingOnAnyFrame() const { return m_state == State::Executing; } - bool IsCommitted() const { return m_state == State::Committed; } - bool IsExecuting() const { return m_state == State::Executing; } + void SetCommandListState(State state); + void SetCommandListStateNoLock(State state); + bool IsExecutingOnAnyFrame() const { return m_state == State::Executing; } + bool IsCommitted() const { return m_state == State::Committed; } + bool IsExecuting() const { return m_state == State::Executing; } + auto LockStateMutex() const { return std::scoped_lock(m_state_mutex); } void InitializeTimestampQueries(); void BeginGpuZone(); @@ -155,7 +157,7 @@ class CommandListBase DebugGroupStack m_open_debug_groups; CompletedCallback m_completed_callback; State m_state = State::Pending; - mutable TracyLockable(std::mutex, m_state_mutex) + mutable TracyLockable(std::recursive_mutex, m_state_mutex) TracyLockable(std::mutex, m_state_change_mutex) std::condition_variable_any m_state_change_condition_var; TRACY_GPU_SCOPE_TYPE m_tracy_gpu_scope; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.cpp index 084aba23a..1569b6e95 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.cpp @@ -61,20 +61,7 @@ CommandQueueTrackingBase::CommandQueueTrackingBase(const ContextBase& context, C CommandQueueTrackingBase::~CommandQueueTrackingBase() { META_FUNCTION_TASK(); - try - { - // Do not use virtual call in destructor - CommandQueueTrackingBase::CompleteExecution(); - } - catch(const std::exception& ex) - { - META_UNUSED(ex); - META_LOG("WARNING: Command queue '{}' has failed to complete command list execution, exception occurred: {}", GetName(), ex.what()); - assert(false); - } - m_execution_waiting = false; - m_execution_waiting_condition_var.notify_one(); - m_execution_waiting_thread.join(); + ShutdownQueueExecution(); } void CommandQueueTrackingBase::InitializeTimestampQueryBuffer() @@ -132,7 +119,6 @@ void CommandQueueTrackingBase::CompleteExecution(const Opt& frame_i while (!m_executing_command_lists.empty() && m_executing_command_lists.front()->GetFrameIndex() == frame_index) { - META_CHECK_ARG_NOT_NULL(m_executing_command_lists.front()); m_executing_command_lists.front()->Complete(); m_executing_command_lists.pop(); } @@ -146,7 +132,7 @@ void CommandQueueTrackingBase::WaitForExecution() noexcept do { std::unique_lock lock(m_execution_waiting_mutex); - m_execution_waiting_condition_var.wait(lock, + m_execution_waiting_condition_var.wait_for(lock, std::chrono::milliseconds(32), [this] { return !m_execution_waiting || !m_executing_command_lists.empty(); } ); @@ -167,14 +153,11 @@ void CommandQueueTrackingBase::WaitForExecution() noexcept CompleteCommandListSetExecution(*command_list_set_ptr); } - // FIXME: GPU timestamps re-calibration does not work correctly for DirectX, so it's used for Vulkan only -#ifdef METHANE_GFX_VULKAN if (m_timestamp_query_buffer_ptr) { const TimestampQueryBuffer::CalibratedTimestamps calibrated_timestamps = m_timestamp_query_buffer_ptr->Calibrate(); GetTracyContext().Calibrate(calibrated_timestamps.cpu_ts, calibrated_timestamps.gpu_ts); } -#endif } while (m_execution_waiting); } @@ -216,4 +199,32 @@ void CommandQueueTrackingBase::CompleteCommandListSetExecution(CommandListSetBas } } +void CommandQueueTrackingBase::ShutdownQueueExecution() +{ + META_FUNCTION_TASK(); + if (!m_execution_waiting) + return; + + { + std::unique_lock lock(m_execution_waiting_mutex); + m_timestamp_query_buffer_ptr.reset(); + + try + { + // Do not use virtual call in destructor + CommandQueueTrackingBase::CompleteExecution(); + } + catch (const std::exception& ex) // NOSONAR + { + META_UNUSED(ex); + META_LOG("WARNING: Command queue '{}' has failed to complete command list execution, exception occurred: {}", GetName(), ex.what()); + assert(false); + } + + m_execution_waiting = false; + } + m_execution_waiting_condition_var.notify_one(); + m_execution_waiting_thread.join(); +} + } // namespace Methane::Graphics diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.h b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.h index bcfd8b10e..2d358c7eb 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/CommandQueueTrackingBase.h @@ -86,6 +86,8 @@ class CommandQueueTrackingBase // NOSONAR - destructor is required virtual void CompleteCommandListSetExecution(CommandListSetBase& executing_command_list_set); + void ShutdownQueueExecution(); + private: void WaitForExecution() noexcept; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.cpp index 410b5f34c..75d4a4a75 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.cpp @@ -104,7 +104,7 @@ void ContextBase::Reset(Device& device) WaitForGpu(WaitFor::RenderComplete); Release(); - Initialize(static_cast(device), false); + Initialize(static_cast(device), true); } void ContextBase::Reset() @@ -147,7 +147,7 @@ void ContextBase::Release() Data::Emitter::Emit(&IContextCallback::OnContextReleased, std::ref(*this)); } -void ContextBase::Initialize(DeviceBase& device, bool /* deferred_heap_allocation */, bool is_callback_emitted) +void ContextBase::Initialize(DeviceBase& device, bool is_callback_emitted) { META_FUNCTION_TASK(); META_LOG("Context '{}' INITIALIZE", GetName()); diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.h b/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.h index 4b8a7d0c4..14ca8d941 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/ContextBase.h @@ -79,7 +79,7 @@ class ContextBase const Device& GetDevice() const final; // ContextBase interface - virtual void Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted = true); + virtual void Initialize(DeviceBase& device, bool is_callback_emitted = true); virtual void Release(); // Object interface diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DescriptorManagerBase.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DescriptorManagerBase.cpp index 6aee21dea..4b8351c59 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DescriptorManagerBase.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DescriptorManagerBase.cpp @@ -54,8 +54,11 @@ void DescriptorManagerBase::CompleteInitialization() static const auto binding_initialization_completer = [](const WeakPtr& program_bindings_wptr) { META_FUNCTION_TASK(); + // Some binding pointers may become expired here due to command list retained resources cleanup on execution completion Ptr program_bindings_ptr = program_bindings_wptr.lock(); - META_CHECK_ARG_NOT_NULL(program_bindings_ptr); + if (!program_bindings_ptr) + return; + static_cast(*program_bindings_ptr).CompleteInitialization(); }; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/BufferDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/BufferDX.h index 8fca0a7a7..a197e3cca 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/BufferDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/BufferDX.h @@ -28,13 +28,13 @@ DirectX 12 implementation of the buffer interface. #include "DescriptorHeapDX.h" #include -#include +#include #include #include #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.h index 93aa9873a..ef95db7fa 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.h @@ -28,7 +28,7 @@ DirectX 12 command list accessor interface for template class CommandListDX #include -#include +#include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp index f29ea2eff..e030b9c08 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandListDX.hpp @@ -31,13 +31,13 @@ DirectX 12 base template implementation of the command list interface. #include "ProgramBindingsDX.h" #include -#include +#include #include #include #include #include -#include +#include #include #include #include @@ -92,6 +92,7 @@ class CommandListDX void Commit() override { META_FUNCTION_TASK(); + const auto state_lock = CommandListBase::LockStateMutex(); CommandListBaseT::Commit(); EndGpuZoneDX(); @@ -122,6 +123,7 @@ class CommandListDX void Reset(CommandList::DebugGroup* p_debug_group) override { META_FUNCTION_TASK(); + const auto state_lock = CommandListBase::LockStateMutex(); if (!m_is_native_committed) return; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.cpp index 4d11cc1fa..8f3bc0e8c 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.cpp @@ -29,7 +29,7 @@ DirectX 12 implementation of the command queue interface. #include "ParallelRenderCommandListDX.h" #include -#include +#include #include #include @@ -100,6 +100,8 @@ CommandQueueDX::CommandQueueDX(const ContextBase& context, CommandList::Type com CommandQueueDX::~CommandQueueDX() // NOSONAR - destructor is not default under define { + META_FUNCTION_TASK(); + ShutdownQueueExecution(); #if defined(METHANE_GPU_INSTRUMENTATION_ENABLED) && METHANE_GPU_INSTRUMENTATION_ENABLED == 2 TracyD3D12Destroy(m_tracy_context); #endif diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.h index 282626eba..dcee1cf67 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/CommandQueueDX.h @@ -31,7 +31,7 @@ DirectX 12 implementation of the command queue interface. #pragma warning(pop) #include -#include +#include namespace Methane::Graphics { @@ -41,7 +41,8 @@ namespace wrl = Microsoft::WRL; struct IContextDX; class CommandListSetDX; -class CommandQueueDX final : public CommandQueueTrackingBase +class CommandQueueDX final // NOSONAR - destructor is needed + : public CommandQueueTrackingBase { public: CommandQueueDX(const ContextBase& context, CommandList::Type command_lists_type); diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.h index 14187cb41..06c4e7619 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.h @@ -25,7 +25,7 @@ DirectX 12 context accessor interface for template class ContextDX #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.hpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.hpp index de837df83..9377dcb4e 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.hpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ContextDX.hpp @@ -31,12 +31,12 @@ DirectX 12 base template implementation of the context interface. #include #include -#include +#include #include #include #include -#include +#include #include @@ -57,20 +57,11 @@ class ContextDX : public ContextBaseT // ContextBase interface - void Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted) override + void Initialize(DeviceBase& device, bool is_callback_emitted) override { META_FUNCTION_TASK(); - ContextBaseT::Initialize(device, deferred_heap_allocation, false); - - m_descriptor_manager_init_settings.deferred_heap_allocation = deferred_heap_allocation; - if (deferred_heap_allocation) - { - m_descriptor_manager_init_settings.default_heap_sizes = {}; - m_descriptor_manager_init_settings.shader_visible_heap_sizes = {}; - } - + ContextBaseT::Initialize(device, false); GetDescriptorManagerDX().Initialize(m_descriptor_manager_init_settings); - if (is_callback_emitted) { Data::Emitter::Emit(&IContextCallback::OnContextInitialized, *this); @@ -130,7 +121,7 @@ class ContextDX : public ContextBaseT using NativeQueryHeaps = std::array, D3D12_QUERY_HEAP_TYPE_COPY_QUEUE_TIMESTAMP + 1>; DescriptorManagerDX::Settings m_descriptor_manager_init_settings{ true, {}, {} }; - mutable NativeQueryHeaps m_query_heaps; + mutable NativeQueryHeaps m_query_heaps; }; } // namespace Methane::Graphics diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.cpp index 6b4a2b1ae..2f5b0b165 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.cpp @@ -26,7 +26,7 @@ Descriptor Heap is a platform abstraction of DirectX 12 descriptor heaps. #include #include -#include +#include #include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.h index f2f4d4c3b..2a5975401 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DescriptorHeapDX.h @@ -36,7 +36,7 @@ Descriptor Heap is a platform abstraction of DirectX 12 descriptor heaps. #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.cpp index ec03739cc..fd13a108f 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.cpp @@ -23,7 +23,7 @@ DirectX 12 implementation of the device interface. #include "DeviceDX.h" -#include +#include #include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.h index c057c0483..c3a739572 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/DeviceDX.h @@ -27,8 +27,8 @@ DirectX 12 implementation of the device interface. #include #include -#include -#include +#include +#include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.cpp index c3a534cf3..acb794d3f 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.cpp @@ -27,7 +27,7 @@ DirectX 12 fence implementation. #include #include -#include +#include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.h index 0d9d50933..ba519ddb5 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/FenceDX.h @@ -26,7 +26,7 @@ DirectX 12 fence implementation. #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ParallelRenderCommandListDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ParallelRenderCommandListDX.cpp index 1e12f240c..005d2084e 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ParallelRenderCommandListDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ParallelRenderCommandListDX.cpp @@ -30,7 +30,7 @@ DirectX 12 implementation of the parallel render command list interface. #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.cpp index 63b30c472..ecb26649d 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.cpp @@ -35,7 +35,7 @@ DirectX 12 implementation of the program bindings interface. #include #include -#include +#include #include namespace Methane::Graphics diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.h index 10e94fd5d..61da0baa0 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramBindingsDX.h @@ -28,7 +28,7 @@ DirectX 12 implementation of the program bindings interface. #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.cpp index d29e6c213..b4bed8ee1 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.cpp @@ -29,9 +29,9 @@ DirectX 12 implementation of the program interface. #include #include -#include +#include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.h index f63c52181..1b9135410 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ProgramDX.h @@ -29,7 +29,7 @@ DirectX 12 implementation of the program interface. #include "ProgramBindingsDX.h" #include -#include +#include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.cpp index 34eff0047..166058bbd 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.cpp @@ -31,12 +31,12 @@ DirectX 12 GPU query results buffer. #include #include #include -#include +#include #include #include #include -#include +#include namespace wrl = Microsoft::WRL; @@ -201,6 +201,7 @@ TimestampQueryBuffer::CalibratedTimestamps TimestampQueryBufferDX::Calibrate() CalibratedTimestamps calibrated_timestamps{ 0U, 0U }; ThrowIfFailed(GetCommandQueueDX().GetNativeCommandQueue().GetClockCalibration(&calibrated_timestamps.gpu_ts, &calibrated_timestamps.cpu_ts), GetContextDX().GetDeviceDX().GetNativeDevice().Get()); + calibrated_timestamps.cpu_ts *= Data::GetQpcToNSecMultiplier(); SetCalibratedTimestamps(calibrated_timestamps); return calibrated_timestamps; } diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.h index bdd2c6a7e..ac34bd84d 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/QueryBufferDX.h @@ -26,7 +26,7 @@ DirectX 12 GPU query results buffer. #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderCommandListDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderCommandListDX.cpp index 128330998..8fbd555f8 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderCommandListDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderCommandListDX.cpp @@ -32,10 +32,10 @@ DirectX 12 implementation of the render command list interface. #include #include -#include +#include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.cpp index b03ad5692..4d8867c23 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.cpp @@ -26,7 +26,7 @@ DirectX 12 implementation of the render context interface. #include "CommandQueueDX.h" #include "TypesDX.h" -#include +#include #include #include @@ -135,7 +135,7 @@ void RenderContextDX::Release() ContextDX::Release(); } -void RenderContextDX::Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted) +void RenderContextDX::Initialize(DeviceBase& device, bool is_callback_emitted) { META_FUNCTION_TASK(); @@ -204,7 +204,7 @@ void RenderContextDX::Initialize(DeviceBase& device, bool deferred_heap_allocati UpdateFrameBufferIndex(); - ContextDX::Initialize(device, deferred_heap_allocation, is_callback_emitted); + ContextDX::Initialize(device, is_callback_emitted); } void RenderContextDX::Resize(const FrameSize& frame_size) diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.h index 8fa3f71ed..cbe645444 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderContextDX.h @@ -51,7 +51,7 @@ class RenderContextDX final : public ContextDX uint32_t GetFontResolutionDpi() const override; // ContextBase interface - void Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted = true) override; + void Initialize(DeviceBase& device, bool is_callback_emitted = true) override; void Release() override; const wrl::ComPtr& GetNativeSwapChain() const { return m_cp_swap_chain; } diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.cpp index b489824b5..f628fba17 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.cpp @@ -30,12 +30,12 @@ DirectX 12 implementation of the render pass interface. #include #include -#include +#include #include #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.h index 1b8c67adf..789152d56 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderPassDX.h @@ -29,7 +29,7 @@ DirectX 12 implementation of the render pass interface. #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.cpp index f8824c612..a45a65563 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.cpp @@ -30,14 +30,14 @@ DirectX 12 implementation of the render state interface. #include "TextureDX.h" #include "RenderCommandListDX.h" -#include +#include #include #include #include #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.h index 7f0563bfd..def5c56b0 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/RenderStateDX.h @@ -26,8 +26,8 @@ DirectX 12 implementation of the render state interface. #include #include -#include -#include +#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceBarriersDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceBarriersDX.h index ea9080c2f..e5ff4b881 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceBarriersDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceBarriersDX.h @@ -27,7 +27,7 @@ DirectX 12 specialization of the resource barriers. #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.h index a1c32ff7c..a3c915f35 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.h @@ -30,7 +30,7 @@ DirectX 12 specialization of the resource interface. #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.hpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.hpp index b84f20967..255b6af2b 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.hpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ResourceDX.hpp @@ -31,12 +31,12 @@ DirectX 12 implementation of the resource interface. #include #include -#include +#include #include #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/SamplerDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/SamplerDX.h index 2c02643bb..4b3b8f7ba 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/SamplerDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/SamplerDX.h @@ -28,7 +28,7 @@ DirectX 12 implementation of the sampler interface. #include #include -#include +#include namespace Methane::Graphics { diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.cpp index 22eba869c..90ccb0298 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.cpp @@ -28,12 +28,12 @@ DirectX 12 implementation of the shader interface. #include "TypesDX.h" #include -#include +#include #include #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.h index 693569309..8c8a2d618 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/ShaderDX.h @@ -26,8 +26,8 @@ DirectX 12 implementation of the shader interface. #include #include -#include -#include +#include +#include #include namespace Methane::Data diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.cpp index aa2da1685..c0adc3bd1 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.cpp @@ -29,7 +29,7 @@ DirectX 12 implementation of the texture interface. #include "BlitCommandListDX.h" #include "TypesDX.h" -#include +#include #include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.h index 2431ed118..a6aa0b589 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TextureDX.h @@ -28,11 +28,11 @@ DirectX 12 implementation of the texture interface. #include #include #include -#include +#include #include #include -#include +#include #include namespace DirectX diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TypesDX.h b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TypesDX.h index 30afc9089..ac20a5749 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TypesDX.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/DirectX12/TypesDX.h @@ -26,7 +26,7 @@ Methane graphics types converters to DirectX 12 native types. #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.hh b/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.hh index 57a523801..36f6feed3 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.hh +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.hh @@ -54,7 +54,7 @@ public: Platform::AppView GetAppView() const override { return { m_app_view }; } // ContextBase overrides - void Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted = true) override; + void Initialize(DeviceBase& device, bool is_callback_emitted = true) override; void Release() override; id GetNativeDrawable() const { return m_app_view.currentDrawable; } diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.mm b/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.mm index 85fd014fb..9eb036aea 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.mm +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Metal/RenderContextMT.mm @@ -99,11 +99,11 @@ ContextMT::Release(); } -void RenderContextMT::Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted) +void RenderContextMT::Initialize(DeviceBase& device, bool is_callback_emitted) { META_FUNCTION_TASK(); - ContextMT::Initialize(device, deferred_heap_allocation, is_callback_emitted); + ContextMT::Initialize(device, is_callback_emitted); #ifdef USE_DISPATCH_QUEUE_SEMAPHORE m_dispatch_semaphore = dispatch_semaphore_create(GetSettings().frame_buffers_count); diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.cpp index dd1678e10..f7eb34b9c 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.cpp @@ -205,10 +205,10 @@ void RenderContextBase::ResetWithSettings(const Settings& settings) Initialize(*device_ptr, true); } -void RenderContextBase::Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted) +void RenderContextBase::Initialize(DeviceBase& device, bool is_callback_emitted) { META_FUNCTION_TASK(); - ContextBase::Initialize(device, deferred_heap_allocation, false); + ContextBase::Initialize(device, false); m_frame_index = 0U; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.h b/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.h index 7f96ca7a1..90589aecd 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/RenderContextBase.h @@ -56,7 +56,7 @@ class RenderContextBase bool SetFullScreen(bool is_full_screen) override; // ContextBase interface - void Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted = true) override; + void Initialize(DeviceBase& device, bool is_callback_emitted = true) override; // Frame buffer is in use while there are executing rendering commands contributing to this frame buffer bool IsFrameBufferInUse() const noexcept { return m_is_frame_buffer_in_use; } diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandListVK.hpp b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandListVK.hpp index 8f11467ef..a0f32a81d 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandListVK.hpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandListVK.hpp @@ -149,6 +149,8 @@ class CommandListVK void Commit() override { META_FUNCTION_TASK(); + const auto state_lock = CommandListBase::LockStateMutex(); + CommandListBaseT::Commit(); CommandListBaseT::EndGpuZone(); @@ -197,6 +199,7 @@ class CommandListVK void Reset(CommandList::DebugGroup* p_debug_group) override { META_FUNCTION_TASK(); + const auto state_lock = CommandListBase::LockStateMutex(); if (!m_is_native_committed) return; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandQueueVK.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandQueueVK.cpp index 8eb2f4eec..f92930e8c 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandQueueVK.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/CommandQueueVK.cpp @@ -141,6 +141,7 @@ CommandQueueVK::CommandQueueVK(const ContextBase& context, CommandList::Type com CommandQueueVK::~CommandQueueVK() { META_FUNCTION_TASK(); + ShutdownQueueExecution(); GetDeviceVK().GetQueueFamilyReservation(CommandQueueBase::GetCommandListType()).ReleaseQueueIndex(m_queue_index); } diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/DeviceVK.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/DeviceVK.cpp index ef24fcfe8..6dd554dcf 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/DeviceVK.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/DeviceVK.cpp @@ -60,8 +60,12 @@ static const std::string g_vk_validation_extension = VK_EXT_VALIDATION_FEATUR static const std::vector g_common_device_extensions{ VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME, - VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, +#ifdef METHANE_GPU_INSTRUMENTATION_ENABLED VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME, +#endif +#ifndef __APPLE__ + VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, +#endif #ifdef VK_GOOGLE_SPIRV_EXTENSIONS_ENABLED VK_GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME, VK_GOOGLE_USER_TYPE_EXTENSION_NAME, @@ -242,16 +246,17 @@ using InstanceCreateInfoChain = vk::StructureChain& layers, const std::vector& extensions) { META_FUNCTION_TASK(); #ifdef NDEBUG - return InstanceCreateInfoChain({ {}, &vk_app_info, layers, extensions }); + return InstanceCreateInfoChain({ vk_instance_create_flags, &vk_app_info, layers, extensions }); #else return InstanceCreateInfoChain( - { {}, &vk_app_info, layers, extensions }, + { vk_instance_create_flags, &vk_app_info, layers, extensions }, MakeDebugUtilsMessengerCreateInfoEXT() #ifdef VULKAN_VALIDATION_BEST_PRACTICES_ENABLED , { vk::ValidationFeatureEnableEXT::eBestPractices } @@ -269,11 +274,18 @@ static vk::UniqueInstance CreateVulkanInstance(const vk::DynamicLoader& vk_loade VULKAN_HPP_DEFAULT_DISPATCHER.init(vk_loader.getProcAddress("vkGetInstanceProcAddr")); + vk::InstanceCreateFlags vk_instance_create_flags{}; + if (std::find_if(extensions.begin(), extensions.end(), + [](const std::string_view& ext) { return ext == VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME; }) + != extensions.end()) + vk_instance_create_flags = vk::InstanceCreateFlagBits::eEnumeratePortabilityKHR; + constexpr uint32_t engine_version = METHANE_VERSION_MAJOR * 10 + METHANE_VERSION_MINOR; const std::vector enabled_layers = GetEnabledLayers(layers); const std::vector enabled_extensions = GetEnabledExtensions(extensions); const vk::ApplicationInfo vk_app_info(g_vk_app_name.c_str(), 1, g_vk_engine_name.c_str(), engine_version, vk_api_version); - const vk::InstanceCreateInfo vk_instance_create_info = MakeInstanceCreateInfoChain(vk_app_info, enabled_layers, enabled_extensions).get(); + const vk::InstanceCreateInfo vk_instance_create_info = MakeInstanceCreateInfoChain(vk_app_info, vk_instance_create_flags, + enabled_layers, enabled_extensions).get(); vk::UniqueInstance vk_unique_instance = vk::createInstanceUnique(vk_instance_create_info); VULKAN_HPP_DEFAULT_DISPATCHER.init(vk_unique_instance.get()); @@ -483,13 +495,16 @@ DeviceVK::DeviceVK(const vk::PhysicalDevice& vk_physical_device, const vk::Surfa // Add descriptions of enabled device features: vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT vk_device_dynamic_state_feature(true); vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR vk_device_timeline_semaphores_feature(true); - vk::PhysicalDeviceSynchronization2FeaturesKHR vk_device_synchronization_2_feature(true); vk::PhysicalDeviceHostQueryResetFeatures vk_device_host_query_reset_feature(true); vk::DeviceCreateInfo vk_device_info(vk::DeviceCreateFlags{}, vk_queue_create_infos, { }, raw_enabled_extension_names, &vk_device_features); vk_device_info.setPNext(&vk_device_dynamic_state_feature); vk_device_dynamic_state_feature.setPNext(&vk_device_timeline_semaphores_feature); - vk_device_timeline_semaphores_feature.setPNext(&vk_device_synchronization_2_feature); - vk_device_synchronization_2_feature.setPNext(&vk_device_host_query_reset_feature); + vk_device_timeline_semaphores_feature.setPNext(&vk_device_host_query_reset_feature); + +#ifndef __APPLE__ + vk::PhysicalDeviceSynchronization2FeaturesKHR vk_device_synchronization_2_feature(true); + vk_device_host_query_reset_feature.setPNext(&vk_device_synchronization_2_feature); +#endif m_vk_unique_device = vk_physical_device.createDeviceUnique(vk_device_info); VULKAN_HPP_DEFAULT_DISPATCHER.init(m_vk_unique_device.get()); @@ -530,7 +545,9 @@ const QueueFamilyReservationVK& DeviceVK::GetQueueFamilyReservation(CommandList: { META_FUNCTION_TASK(); const QueueFamilyReservationVK* queue_family_reservation_ptr = GetQueueFamilyReservationPtr(cmd_list_type); - META_CHECK_ARG_NOT_NULL_DESCR(queue_family_reservation_ptr, fmt::format("queue family was not reserved for {} command list type", cmd_list_type)); + META_CHECK_ARG_NOT_NULL_DESCR(queue_family_reservation_ptr, + fmt::format("queue family was not reserved for {} command list type", + magic_enum::enum_name(cmd_list_type))); return *queue_family_reservation_ptr; } diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/MacOS/PlatformExtVK.mm b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/MacOS/PlatformExtVK.mm index 67ded5b9c..12538e201 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/MacOS/PlatformExtVK.mm +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/MacOS/PlatformExtVK.mm @@ -35,6 +35,7 @@ { META_FUNCTION_TASK(); static const std::vector s_instance_extensions = GetPlatformInstanceExtensions({ + VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME }); return s_instance_extensions; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.cpp index f5e68c16c..0dc0e99f2 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.cpp @@ -36,20 +36,16 @@ Vulkan GPU query results buffer. #include #include -#ifdef _WIN32 - -#include - -static uint64_t GetQpcFrequency() -{ - - LARGE_INTEGER t; - QueryPerformanceFrequency( &t ); - return static_cast(t.QuadPart); -} - +static const vk::TimeDomainEXT g_vk_cpu_time_domain = +#if defined(_WIN32) + vk::TimeDomainEXT::eQueryPerformanceCounter; +#elif defined(__linux__) && defined CLOCK_MONOTONIC_RAW + vk::TimeDomainEXT::eClockMonotonicRaw; +#else + static_cast(-1); #endif + namespace Methane::Graphics { @@ -148,9 +144,6 @@ TimestampQueryBufferVK::TimestampQueryBufferVK(CommandQueueVK& command_queue, ui : QueryBufferVK(command_queue, Type::Timestamp, 1U << 15U, 1U, GetMaxTimestampsCount(command_queue.GetContext(), max_timestamps_per_frame) * sizeof(Timestamp), sizeof(Timestamp)) -#ifdef _WIN32 - , m_qpc_to_nsec(static_cast(1000000000.0 / GetQpcFrequency())) -#endif { META_FUNCTION_TASK(); @@ -163,11 +156,11 @@ TimestampQueryBufferVK::TimestampQueryBufferVK(CommandQueueVK& command_queue, ui // Check if Vulkan supports CPU time domains calibration const auto calibrateable_time_domains = vk_physical_device.getCalibrateableTimeDomainsEXT(); - bool is_cpu_time_domain_calibrateable = std::find(calibrateable_time_domains.begin(), calibrateable_time_domains.end(), m_vk_cpu_time_domain) != calibrateable_time_domains.end(); - META_CHECK_ARG_TRUE_DESCR(is_cpu_time_domain_calibrateable, "Vulkan does not support calibration of the CPU time domain {}", magic_enum::enum_name(m_vk_cpu_time_domain)); + bool is_cpu_time_domain_calibrateable = std::find(calibrateable_time_domains.begin(), calibrateable_time_domains.end(), g_vk_cpu_time_domain) != calibrateable_time_domains.end(); + META_CHECK_ARG_TRUE_DESCR(is_cpu_time_domain_calibrateable, "Vulkan does not support calibration of the CPU time domain {}", magic_enum::enum_name(g_vk_cpu_time_domain)); // Calculate the desired CPU-GPU timestamps deviation - const std::array timestamp_infos = {{ { vk::TimeDomainEXT::eDevice }, { m_vk_cpu_time_domain }, }}; + const std::array timestamp_infos = {{ { vk::TimeDomainEXT::eDevice }, { g_vk_cpu_time_domain }, }}; std::array timestamps{{}}; std::array probe_deviations{{}}; for(uint64_t& deviation : probe_deviations) @@ -194,10 +187,8 @@ Ptr TimestampQueryBufferVK::CreateTimestam TimestampQueryBuffer::CalibratedTimestamps TimestampQueryBufferVK::Calibrate() { META_FUNCTION_TASK(); - META_CHECK_ARG_NOT_EQUAL(m_vk_cpu_time_domain, vk::TimeDomainEXT::eDevice); - const vk::Device& vk_device = GetCommandQueueVK().GetDeviceVK().GetNativeDevice(); - const std::array timestamp_infos = {{ { vk::TimeDomainEXT::eDevice }, { m_vk_cpu_time_domain }, }}; + const std::array timestamp_infos = {{ { vk::TimeDomainEXT::eDevice }, { g_vk_cpu_time_domain }, }}; std::array timestamps{{}}; uint64_t deviation = 0U; @@ -210,7 +201,7 @@ TimestampQueryBuffer::CalibratedTimestamps TimestampQueryBufferVK::Calibrate() CalibratedTimestamps calibrated_timestamps{}; calibrated_timestamps.gpu_ts = timestamps[0]; - calibrated_timestamps.cpu_ts = timestamps[1] * m_qpc_to_nsec; + calibrated_timestamps.cpu_ts = timestamps[1] * Data::GetQpcToNSecMultiplier(); SetCalibratedTimestamps(calibrated_timestamps); return calibrated_timestamps; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.h b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.h index 6c611a4e3..447aa61ee 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/QueryBufferVK.h @@ -105,14 +105,6 @@ class TimestampQueryBufferVK final CalibratedTimestamps Calibrate() override; private: -#if defined(_WIN32) - const vk::TimeDomainEXT m_vk_cpu_time_domain = vk::TimeDomainEXT::eQueryPerformanceCounter; -#elif defined(__linux__) && defined CLOCK_MONOTONIC_RAW - const vk::TimeDomainEXT m_vk_cpu_time_domain = vk::TimeDomainEXT::eClockMonotonicRaw; -#else - const vk::TimeDomainEXT m_vk_cpu_time_domain = m_vk_cpu_time_domain(static_cast(-1)); -#endif - const uint64_t m_qpc_to_nsec = 1U; uint64_t m_deviation = 0U; }; diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.cpp index b46682af0..519b4bdfc 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.cpp @@ -83,13 +83,13 @@ bool RenderContextVK::SetName(const std::string& name) return true; } -void RenderContextVK::Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted) +void RenderContextVK::Initialize(DeviceBase& device, bool is_callback_emitted) { META_FUNCTION_TASK(); SetDevice(device); InitializeNativeSwapchain(); UpdateFrameBufferIndex(); - ContextVK::Initialize(device, deferred_heap_allocation, is_callback_emitted); + ContextVK::Initialize(device, is_callback_emitted); } void RenderContextVK::WaitForGpu(WaitFor wait_for) diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.h b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.h index be22185e9..93707e0c1 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.h +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/RenderContextVK.h @@ -73,7 +73,7 @@ class RenderContextVK final // NOSONAR - this class requires destructor Platform::AppView GetAppView() const override { return { }; } // ContextBase overrides - void Initialize(DeviceBase& device, bool deferred_heap_allocation, bool is_callback_emitted = true) override; + void Initialize(DeviceBase& device, bool is_callback_emitted = true) override; void Release() override; // ObjectBase overrides diff --git a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/ShaderVK.cpp b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/ShaderVK.cpp index 48112cf21..2a5e926e6 100644 --- a/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/ShaderVK.cpp +++ b/Modules/Graphics/Core/Sources/Methane/Graphics/Vulkan/ShaderVK.cpp @@ -191,12 +191,10 @@ static void AddSpirvResourcesToArgumentBindings(const spirv_cross::Compiler& spi } )); -#ifdef METHANE_LOGGING_ENABLED - log_ss << " - '" << shader_argument.GetName() - << "' with descriptor type " << vk::to_string(vk_descriptor_type) - << ", array size " << array_size - << ";" << std::endl; -#endif + META_LOG(" - '{}' with descriptor type {}, array size {};", + shader_argument.GetName(), + vk::to_string(vk_descriptor_type), + array_size); } } @@ -216,20 +214,16 @@ ShaderVK::ShaderVK(Shader::Type shader_type, const ContextBase& context, const S ShaderBase::ArgumentBindings ShaderVK::GetArgumentBindings(const Program::ArgumentAccessors& argument_accessors) const { META_FUNCTION_TASK(); - const spirv_cross::Compiler& spirv_compiler = GetNativeCompiler(); const Shader::Settings& shader_settings = GetSettings(); - ArgumentBindings argument_bindings; - -#ifdef METHANE_LOGGING_ENABLED - std::stringstream log_ss; - log_ss << magic_enum::enum_name(GetType()) - << " shader '" << shader_settings.entry_function.function_name - << "' (" << Shader::ConvertMacroDefinitionsToString(shader_settings.compile_definitions) - << ") with argument bindings:" << std::endl; -#else META_UNUSED(shader_settings); -#endif + META_LOG("{} shader '{}' ({}) with argument bindings:", + magic_enum::enum_name(GetType()), + shader_settings.entry_function.function_name, + Shader::ConvertMacroDefinitionsToString(shader_settings.compile_definitions)); + + ArgumentBindings argument_bindings; + const spirv_cross::Compiler& spirv_compiler = GetNativeCompiler(); const auto add_spirv_resources_to_argument_bindings = [this, &spirv_compiler, &argument_accessors, &argument_bindings] (const spirv_cross::SmallVector& spirv_resources, const vk::DescriptorType vk_descriptor_type) @@ -248,12 +242,10 @@ ShaderBase::ArgumentBindings ShaderVK::GetArgumentBindings(const Program::Argume add_spirv_resources_to_argument_bindings(spirv_resources.separate_samplers, vk::DescriptorType::eSampler); // TODO: add support for spirv_resources.atomic_counters, vk::DescriptorType::eMutableVALVE -#ifdef METHANE_LOGGING_ENABLED if (argument_bindings.empty()) - log_ss << " - No argument bindings." << std::endl; -#endif - - META_LOG("{}", log_ss.str()); + { + META_LOG(" - No argument bindings."); + } return argument_bindings; } diff --git a/Modules/Graphics/Primitives/CMakeLists.txt b/Modules/Graphics/Primitives/CMakeLists.txt index 2f814bdd2..ae66d39f9 100644 --- a/Modules/Graphics/Primitives/CMakeLists.txt +++ b/Modules/Graphics/Primitives/CMakeLists.txt @@ -14,12 +14,12 @@ set(SOURCES ${SOURCES_DIR}/PerlinNoise.cpp ) -if (WIN32) +if(METHANE_GFX_API EQUAL METHANE_GFX_DIRECTX) set(HEADERS ${HEADERS} - ${INCLUDE_PLATFORM_DIR}/ErrorHandling.h + ${INCLUDE_PLATFORM_DIR}/DirectXErrorHandling.h ) set(SOURCES ${SOURCES} - ${SOURCES_PLATFORM_DIR}/ErrorHandling.cpp + ${SOURCES_PLATFORM_DIR}/DirectXErrorHandling.cpp ) endif() diff --git a/Modules/Graphics/Primitives/Include/Methane/Graphics/Windows/ErrorHandling.h b/Modules/Graphics/Primitives/Include/Methane/Graphics/Windows/DirectXErrorHandling.h similarity index 98% rename from Modules/Graphics/Primitives/Include/Methane/Graphics/Windows/ErrorHandling.h rename to Modules/Graphics/Primitives/Include/Methane/Graphics/Windows/DirectXErrorHandling.h index f0fff8916..8581ef16c 100644 --- a/Modules/Graphics/Primitives/Include/Methane/Graphics/Windows/ErrorHandling.h +++ b/Modules/Graphics/Primitives/Include/Methane/Graphics/Windows/DirectXErrorHandling.h @@ -25,7 +25,7 @@ Windows platform graphics primitives. #include #include -#include +#include #include #include diff --git a/Modules/Graphics/Primitives/Sources/Methane/Graphics/Windows/ErrorHandling.cpp b/Modules/Graphics/Primitives/Sources/Methane/Graphics/Windows/DirectXErrorHandling.cpp similarity index 97% rename from Modules/Graphics/Primitives/Sources/Methane/Graphics/Windows/ErrorHandling.cpp rename to Modules/Graphics/Primitives/Sources/Methane/Graphics/Windows/DirectXErrorHandling.cpp index 75a8e3cc3..cf3bb1863 100644 --- a/Modules/Graphics/Primitives/Sources/Methane/Graphics/Windows/ErrorHandling.cpp +++ b/Modules/Graphics/Primitives/Sources/Methane/Graphics/Windows/DirectXErrorHandling.cpp @@ -21,7 +21,7 @@ Windows platform graphics primitives. ******************************************************************************/ -#include +#include #include #include diff --git a/README.md b/README.md index 09e800de0..20a2711ce 100644 --- a/README.md +++ b/README.md @@ -16,23 +16,23 @@ See [Build Instructions](/Build/README.md) topic for manual build instructions a [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/egorodet/MethaneKit) -| Platform | Graphics API | Master Build Status | Develop Build Status | -| ---------------- | -------------| --------------------- | ---------------------- | +| Platform | Graphics API | Master Build Status | Develop Build Status | +|-------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **Windows x64** | DirectX 12 | [![Windows x64 Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win64_DX_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows x64 Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win64_DX_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | | **Windows x86** | DirectX 12 | [![Windows x86 Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win32_DX_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows x86 Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win32_DX_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | -| **Windows x64** | Vulkan | [![Windows x64 Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win64_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows x64 Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win64_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | -| **Windows x86** | Vulkan | [![Windows x86 Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win32_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows x86 Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win32_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | -| **Linux** | Vulkan | [![Ubuntu Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Ubuntu_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Ubuntu Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Ubuntu_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | -| **MacOS** | Metal | [![MacOS Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=MacOS_MTL_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![MacOS Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=MacOS_MTL_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | +| **Windows x64** | Vulkan | [![Windows x64 Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win64_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows x64 Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win64_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | +| **Windows x86** | Vulkan | [![Windows x86 Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win32_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows x86 Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win32_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | +| **Linux** | Vulkan | [![Ubuntu Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Ubuntu_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Ubuntu Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Ubuntu_VK_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | +| **MacOS** | Metal | [![MacOS Master Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=MacOS_MTL_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![MacOS Develop Build Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=MacOS_MTL_Release)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | [Static code analysis](#static-code-analysis) scans are performed as a part of automated CI build process on master and develop branches with up-to-date results published on [Sonar Cloud](https://sonarcloud.io/organizations/egorodet-github). -| Platform | Sonar Quality Gate | Master Scan Status | Develop Scan Status | -| ---------------- | ------------------ | -------------------- | --------------------- | +| Platform | Sonar Quality Gate | Master Scan Status | Develop Scan Status | +|-----------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | **Windows** DirectX | [![Windows Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![Windows Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win64_DX_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Windows Develop Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Win64_DX_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | -| **Linux** Vulkan | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | [![Linux Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Ubuntu_VK_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Linux Develop Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Ubuntu_VK_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | -| **MacOS** Metal | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![MacOS Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=MacOS_MTL_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![MacOS Develop Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=MacOS_MTL_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | +| **Linux** Vulkan | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | [![Linux Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Ubuntu_VK_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Linux Develop Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=Ubuntu_VK_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | +| **MacOS** Metal | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![MacOS Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=MacOS_MTL_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![MacOS Develop Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=develop&jobName=MacOS_MTL_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=develop) | [![Windows Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) [![Windows Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) @@ -78,8 +78,8 @@ and continue with others. Methane samples demonstrate advanced techniques and usage scenarios with more complex implementation than tutorials above. -|
Name / Link
|
Screenshot
|
Description                                         
| -| ----------------------------- | ---------------------------- | ---------------------------------------------------------------------- | +|
Name / Link
|
Screenshot
|
Description                                         
| +|--------------------------------------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Asteroids](/Apps/Samples/Asteroids) | ![Asteroids on Windows](Apps/Samples/Asteroids/Screenshots/AsteroidsWinDirectX12.jpg) | Benchmark demonstrating parallel render commands encoding in a single render pass for the large number of heterogeneous asteroid objects processed in multiple threads. | ### Features @@ -124,19 +124,20 @@ Methane samples demonstrate advanced techniques and usage scenarios with more co For detailed features description and development plans please refer to [Modules documentation](Modules). -# [Build Instructions](/Build/README.md) +## [Build Instructions](/Build/README.md) - [Prerequisites](/Build/README.md#prerequisites) - [Fetch Sources](/Build/README.md#fetch-sources) +- - [Notes](/Build/README.md#notes) - [First time initialization](/Build/README.md#first-time-initialization) - [Update sources to latest revision](/Build/README.md#update-sources-to-latest-revision) - [Building from Sources](/Build/README.md#building-from-sources) - - [Windows Build with Visual Studio](/Build/README.md#-windows-build-with-visual-studio) - - [MacOS Build with XCode](/Build/README.md#-macos-build-with-xcode) - - [Linux Build with Unix Makefiles](/Build/README.md#-linux-build-with-unix-makefiles) + - [Windows Build with Visual Studio](/Build/README.md#windows-build-with-visual-studio) + - [Linux Build with Unix Makefiles](/Build/README.md#linux-build-with-unix-makefiles) + - [MacOS Build with XCode](/Build/README.md#macos-build-with-xcode) - [CMake Generator](/Build/README.md#cmake-generator) - [CMake Options](/Build/README.md#cmake-options) - - [CMake Presets](/Build/README.md#cMake-presets) + - [CMake Presets](/Build/README.md#cmake-presets) ## Supported Development Tools @@ -161,28 +162,28 @@ Methane Kit comes with continuous C++ static code and code coverage analysis per with up-to-date results published on [Sonar Cloud](https://sonarcloud.io/organizations/egorodet-github) separately for all supported platforms. -| Master Scan Results | Windows | MacOS | Linux | -| -------------------- | ------------- |------------- |------------- | -| Scan Build Status | [![Windows Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win64_DX_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![MacOS Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=MacOS_MTL_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Linux Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Ubuntu_VK_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | -| Quality Gate | [![Windows Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Maintainability | [![Windows Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Reliability | [![Windows Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Security | [![Windows Security Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=security_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Security Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=security_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Security Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=security_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Technical Debt | [![Windows Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=sqale_index)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=sqale_index)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=sqale_index)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) -| Bugs | [![Windows Bugs](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=bugs)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Bugs](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=bugs)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Bugs](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=bugs)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Vulnerabilities | [![Windows Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) -| Code Smells | [![Windows Code Smells](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=code_smells)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Code Smells](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=code_smells)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Code Smells](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=code_smells)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Duplicated Lines | [![Windows Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Tests Coverage | [![Windows Coverage](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=coverage)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Coverage](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=coverage)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Coverage](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=coverage)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | -| Lines of Code | [![Windows Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=ncloc)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=ncloc)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=ncloc)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Master Scan Results | Windows | MacOS | Linux | +|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Scan Build Status | [![Windows Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Win64_DX_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![MacOS Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=MacOS_MTL_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | [![Linux Master Scan Status](https://egorodet.visualstudio.com/MethaneKit/_apis/build/status/egorodet.MethaneKit?branchName=master&jobName=Ubuntu_VK_SonarScan)](https://egorodet.visualstudio.com/MethaneKit/_build/latest?definitionId=5&branchName=master) | +| Quality Gate | [![Windows Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=alert_status)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Maintainability | [![Windows Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Reliability | [![Windows Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Security | [![Windows Security Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=security_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Security Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=security_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Security Rating](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=security_rating)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Technical Debt | [![Windows Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=sqale_index)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=sqale_index)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=sqale_index)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Bugs | [![Windows Bugs](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=bugs)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Bugs](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=bugs)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Bugs](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=bugs)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Vulnerabilities | [![Windows Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Code Smells | [![Windows Code Smells](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=code_smells)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Code Smells](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=code_smells)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Code Smells](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=code_smells)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Duplicated Lines | [![Windows Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Tests Coverage | [![Windows Coverage](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=coverage)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Coverage](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=coverage)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Coverage](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=coverage)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | +| Lines of Code | [![Windows Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Windows&metric=ncloc)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Windows) | [![MacOS Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_MacOS&metric=ncloc)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_MacOS) | [![Linux Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=egorodet_MethaneKit_Linux&metric=ncloc)](https://sonarcloud.io/dashboard?id=egorodet_MethaneKit_Linux) | ### Trace Profiling Tools Methane Kit contains integrated instrumentation of all libraries for performance analysis with trace collection using following tools. Please refer to [Methane Instrumentation](Modules/Common/Instrumentation) document for more details on trace collection instructions and related build options. -| [Tracy Frame Profiler](https://github.com/wolfpld/tracy) | [Intel Graphics Trace Analyzer](https://software.intel.com/en-us/gpa/graphics-trace-analyzer) | -| -------------------- | ----------------------------- | +| [Tracy Frame Profiler](https://github.com/wolfpld/tracy) | [Intel Graphics Trace Analyzer](https://software.intel.com/en-us/gpa/graphics-trace-analyzer) | +|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| | ![Asteroids Trace in Tracy](Apps/Samples/Asteroids/Screenshots/AsteroidsWinTracyProfiling.jpg) | ![Asteroids Trace in GPA Trace Analyzer](Apps/Samples/Asteroids/Screenshots/AsteroidsWinGPATraceAnalyzer.jpg) | ### Frame Profiling and Debugging Tools @@ -193,12 +194,14 @@ Please refer to [Methane Instrumentation](Modules/Common/Instrumentation) docume - [Microsoft PIX](https://devblogs.microsoft.com/pix/) - [NVidia Nsight Graphics](https://developer.nvidia.com/nsight-graphics) -## External Dependencies +## [External Dependencies](/Externals/README.md) -All external dependencies of Methane Kit are listed in [MethaneExternals](https://github.com/egorodet/MethaneExternals) repository. See [MethaneExternals/README.md](https://github.com/egorodet/MethaneExternals/blob/master/README.md) for more details. +- [Libraries](/Externals/README.md#libraries) +- [Build Tools](/Externals/README.md#build-tools) +- [Assets](/Externals/README.md#assets) ## License Methane Kit is distributed under [Apache 2.0 License](LICENSE): it is free to use and open for contributions! -*Copyright 2019-2021 © Evgeny Gorodetskiy* [![Follow](https://img.shields.io/twitter/follow/egorodet.svg?style=social)](https://twitter.com/egorodet) +*Copyright 2019-2022 © Evgeny Gorodetskiy* [![Follow](https://img.shields.io/twitter/follow/egorodet.svg?style=social)](https://twitter.com/egorodet) diff --git a/Tests/CatchHelpers/Include/Methane/HlslCatchHelpers.hpp b/Tests/CatchHelpers/Include/Methane/HlslCatchHelpers.hpp index ec2be9326..e69ac017b 100644 --- a/Tests/CatchHelpers/Include/Methane/HlslCatchHelpers.hpp +++ b/Tests/CatchHelpers/Include/Methane/HlslCatchHelpers.hpp @@ -24,7 +24,7 @@ Catch2 unit-test helpers for HLSL++ vector types #include #include -#include +#include namespace Catch { @@ -42,7 +42,7 @@ namespace Methane template class HlslVectorEqualsMatcher - : public Catch::Matchers::Impl::MatcherBase + : public Catch::Matchers::MatcherBase { public: HlslVectorEqualsMatcher(const HlslVectorType& reference_vector) @@ -71,7 +71,7 @@ auto HlslVectorEquals(const HlslVectorType& reference_vector) -> decltype(auto) template class HlslVectorApproxEqualsMatcher - : public Catch::Matchers::Impl::MatcherBase + : public Catch::Matchers::MatcherBase { public: template diff --git a/Tests/Data/Events/CMakeLists.txt b/Tests/Data/Events/CMakeLists.txt index e8c392e13..1f8377e50 100644 --- a/Tests/Data/Events/CMakeLists.txt +++ b/Tests/Data/Events/CMakeLists.txt @@ -4,7 +4,7 @@ include(Catch) set(TARGET MethaneDataEventsTest) set(SOURCES - Main.cpp + #Main.cpp EventWrappers.hpp EventsTest.cpp ) @@ -31,7 +31,7 @@ target_link_libraries(${TARGET} MethaneBuildOptions MethanePrecompiledHeaders $<$:TracyClient> - Catch2 + Catch2WithMain ) catch_discover_tests(${TARGET}) diff --git a/Tests/Data/Events/EventWrappers.hpp b/Tests/Data/Events/EventWrappers.hpp index 88fe4043e..dc05eed28 100644 --- a/Tests/Data/Events/EventWrappers.hpp +++ b/Tests/Data/Events/EventWrappers.hpp @@ -21,7 +21,7 @@ Emitter and Recever wrappers for events testing. ******************************************************************************/ -#include +#include #include diff --git a/Tests/Data/Events/EventsBenchmark.cpp b/Tests/Data/Events/EventsBenchmark.cpp index 401ee8885..4b9f2cd7a 100644 --- a/Tests/Data/Events/EventsBenchmark.cpp +++ b/Tests/Data/Events/EventsBenchmark.cpp @@ -23,7 +23,8 @@ Benchmark connection and emit of events with emitter and receiver classes. #include "EventWrappers.hpp" -#include +#include +#include using namespace Methane::Data; diff --git a/Tests/Data/Events/EventsTest.cpp b/Tests/Data/Events/EventsTest.cpp index d20914320..bcbf925f8 100644 --- a/Tests/Data/Events/EventsTest.cpp +++ b/Tests/Data/Events/EventsTest.cpp @@ -23,7 +23,7 @@ Unit tests of event connections with Emitter and Receiver classes #include "EventWrappers.hpp" -#include +#include #include diff --git a/Tests/Data/Events/Main.cpp b/Tests/Data/Events/Main.cpp index 410ab3e63..8067f8082 100644 --- a/Tests/Data/Events/Main.cpp +++ b/Tests/Data/Events/Main.cpp @@ -23,5 +23,5 @@ FILE: Test/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 #define CATCH_CONFIG_MAIN -#include +#include #include \ No newline at end of file diff --git a/Tests/Data/RangeSet/CMakeLists.txt b/Tests/Data/RangeSet/CMakeLists.txt index 12349b378..d46746f07 100644 --- a/Tests/Data/RangeSet/CMakeLists.txt +++ b/Tests/Data/RangeSet/CMakeLists.txt @@ -4,7 +4,6 @@ include(Catch) set(TARGET MethaneDataRangeSetTest) add_executable(${TARGET} - Main.cpp RangeTest.cpp RangeSetTest.cpp ) @@ -17,7 +16,7 @@ target_link_libraries(${TARGET} MethaneBuildOptions MethanePrecompiledHeaders $<$:TracyClient> - Catch2 + Catch2WithMain ) catch_discover_tests(${TARGET}) diff --git a/Tests/Data/RangeSet/Main.cpp b/Tests/Data/RangeSet/Main.cpp index 589acf6cc..02ba7dd5c 100644 --- a/Tests/Data/RangeSet/Main.cpp +++ b/Tests/Data/RangeSet/Main.cpp @@ -23,5 +23,5 @@ FILE: Tests/Data/RangeSet/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 #define CATCH_CONFIG_MAIN -#include +#include #include diff --git a/Tests/Data/RangeSet/RangeSetTest.cpp b/Tests/Data/RangeSet/RangeSetTest.cpp index 292af23e2..307dddec0 100644 --- a/Tests/Data/RangeSet/RangeSetTest.cpp +++ b/Tests/Data/RangeSet/RangeSetTest.cpp @@ -21,7 +21,7 @@ Unit tests of the RangeSet data type ******************************************************************************/ -#include +#include #include diff --git a/Tests/Data/RangeSet/RangeTest.cpp b/Tests/Data/RangeSet/RangeTest.cpp index 31f68c7af..bdc17f1e7 100644 --- a/Tests/Data/RangeSet/RangeTest.cpp +++ b/Tests/Data/RangeSet/RangeTest.cpp @@ -21,7 +21,7 @@ Unit tests of the Range data type ******************************************************************************/ -#include +#include #include diff --git a/Tests/Data/Types/CMakeLists.txt b/Tests/Data/Types/CMakeLists.txt index bf5bf8563..102938686 100644 --- a/Tests/Data/Types/CMakeLists.txt +++ b/Tests/Data/Types/CMakeLists.txt @@ -4,7 +4,6 @@ include(Catch) set(TARGET MethaneDataTypesTest) add_executable(${TARGET} - Main.cpp RawVectorTest.cpp PointTest.cpp RectSizeTest.cpp @@ -19,7 +18,7 @@ target_link_libraries(${TARGET} MethaneBuildOptions MethanePrecompiledExtraHeaders $<$:TracyClient> - Catch2 + Catch2WithMain ) catch_discover_tests(${TARGET}) diff --git a/Tests/Data/Types/Main.cpp b/Tests/Data/Types/Main.cpp index d9ea09771..d42f0632f 100644 --- a/Tests/Data/Types/Main.cpp +++ b/Tests/Data/Types/Main.cpp @@ -23,5 +23,5 @@ FILE: Tests/Data/Types/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 #define CATCH_CONFIG_MAIN -#include +#include #include diff --git a/Tests/Data/Types/PointTest.cpp b/Tests/Data/Types/PointTest.cpp index dbe8411f0..53cec0404 100644 --- a/Tests/Data/Types/PointTest.cpp +++ b/Tests/Data/Types/PointTest.cpp @@ -25,10 +25,21 @@ Unit-tests of the Point data type wrapping HLSL++ vector #include -#include +#include +#include #include using namespace Methane::Data; +using Catch::Approx; + +template +struct Catch::StringMaker> +{ + static std::string convert(const Point& v) + { + return static_cast(v); + } +}; template> void CheckPoint(const Point& point, const std::array& components) @@ -189,7 +200,7 @@ TEMPLATE_TEST_CASE_SIG("Point Conversions to Other Types", "[point][convert]", V SECTION("Convert to HLSL vector") { - CHECK(hlslpp::all(test_point.AsHlsl() == CreateHlslVector(test_arr))); + CHECK(hlslpp::all(test_point.AsVector() == CreateHlslVector(test_arr))); } } @@ -202,6 +213,7 @@ TEMPLATE_TEST_CASE_SIG("Point Coordinate Accessors and Property Getters", "[poin SECTION("X-coordinate getter and setter") { CHECK(test_point.GetX() == Approx(test_arr[0])); + CHECK(test_point[0] == Approx(test_arr[0])); auto new_arr = test_arr; new_arr[0] = new_value; CheckPoint(Point(test_arr).SetX(new_value), new_arr); } @@ -209,6 +221,7 @@ TEMPLATE_TEST_CASE_SIG("Point Coordinate Accessors and Property Getters", "[poin SECTION("Y-coordinate getter and setter") { CHECK(test_point.GetY() == Approx(test_arr[1])); + CHECK(test_point[1] == Approx(test_arr[1])); auto new_arr = test_arr; new_arr[1] = new_value; CheckPoint(Point(test_arr).SetY(new_value), new_arr); } @@ -218,6 +231,7 @@ TEMPLATE_TEST_CASE_SIG("Point Coordinate Accessors and Property Getters", "[poin SECTION("Z-coordinate getter and setter") { CHECK(test_point.GetZ() == Approx(test_arr[2])); + CHECK(test_point[2] == Approx(test_arr[2])); auto new_arr = test_arr; new_arr[2] = new_value; CheckPoint(Point(test_arr).SetZ(new_value), new_arr); } @@ -228,6 +242,7 @@ TEMPLATE_TEST_CASE_SIG("Point Coordinate Accessors and Property Getters", "[poin SECTION("W-coordinate getter and setter") { CHECK(test_point.GetW() == Approx(test_arr[3])); + CHECK(test_point[3] == Approx(test_arr[3])); auto new_arr = test_arr; new_arr[3] = new_value; CheckPoint(Point(test_arr).SetW(new_value), new_arr); } diff --git a/Tests/Data/Types/RawVectorTest.cpp b/Tests/Data/Types/RawVectorTest.cpp index c2e43ef38..576fd4c61 100644 --- a/Tests/Data/Types/RawVectorTest.cpp +++ b/Tests/Data/Types/RawVectorTest.cpp @@ -25,10 +25,21 @@ Unit-tests of the RawVector data type #include -#include +#include +#include #include using namespace Methane::Data; +using Catch::Approx; + +template +struct Catch::StringMaker> +{ + static std::string convert(const RawVector& v) + { + return static_cast(v); + } +}; template> void CheckRawVector(const RawVector& vec, const std::array& components) diff --git a/Tests/Data/Types/RectSizeTest.cpp b/Tests/Data/Types/RectSizeTest.cpp index 0d8ea09fb..9d114d400 100644 --- a/Tests/Data/Types/RectSizeTest.cpp +++ b/Tests/Data/Types/RectSizeTest.cpp @@ -23,10 +23,19 @@ Unit-tests of the RectSize data type #include -#include +#include using namespace Methane::Data; +template +struct Catch::StringMaker> +{ + static std::string convert(const RectSize& v) + { + return static_cast(v); + } +}; + #define RECT_SIZE_TYPES int32_t, uint32_t, float, double TEMPLATE_TEST_CASE("Rectangle Size Initialization", "[rect][size][init]", RECT_SIZE_TYPES) diff --git a/Tests/Data/Types/RectTest.cpp b/Tests/Data/Types/RectTest.cpp index f19ff2d4c..abca99197 100644 --- a/Tests/Data/Types/RectTest.cpp +++ b/Tests/Data/Types/RectTest.cpp @@ -24,10 +24,28 @@ Unit-tests of the Rect data type #include #include -#include +#include using namespace Methane::Data; +template +struct Catch::StringMaker> +{ + static std::string convert(const Point& v) + { + return static_cast(v); + } +}; + +template +struct Catch::StringMaker> +{ + static std::string convert(const RectSize& v) + { + return static_cast(v); + } +}; + template using RectPtInt = Rect; template using RectPtUint = Rect; template using RectPtFloat = Rect; diff --git a/Tests/Graphics/Camera/ArcBallCameraTest.cpp b/Tests/Graphics/Camera/ArcBallCameraTest.cpp index 2c601e351..261c47c7a 100644 --- a/Tests/Graphics/Camera/ArcBallCameraTest.cpp +++ b/Tests/Graphics/Camera/ArcBallCameraTest.cpp @@ -26,7 +26,7 @@ Arc-Ball camera unit tests #include #include -#include +#include #include using namespace Methane::Graphics; diff --git a/Tests/Graphics/Camera/CMakeLists.txt b/Tests/Graphics/Camera/CMakeLists.txt index 9b5cc2a19..b64d3e812 100644 --- a/Tests/Graphics/Camera/CMakeLists.txt +++ b/Tests/Graphics/Camera/CMakeLists.txt @@ -4,7 +4,6 @@ include(Catch) set(TARGET MethaneGraphicsCameraTest) add_executable(${TARGET} - Main.cpp ArcBallCameraTest.cpp ) @@ -17,7 +16,7 @@ target_link_libraries(${TARGET} MethanePrecompiledHeaders MethaneTestsCatchHelpers $<$:TracyClient> - Catch2 + Catch2WithMain ) catch_discover_tests(${TARGET}) diff --git a/Tests/Graphics/Camera/Main.cpp b/Tests/Graphics/Camera/Main.cpp index cd3d71f64..7a2d6f791 100644 --- a/Tests/Graphics/Camera/Main.cpp +++ b/Tests/Graphics/Camera/Main.cpp @@ -23,5 +23,5 @@ FILE: Test/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 // Required for VS Code Test Explorer to work #define CATCH_CONFIG_MAIN -#include +#include #include \ No newline at end of file diff --git a/Tests/Graphics/Types/CMakeLists.txt b/Tests/Graphics/Types/CMakeLists.txt index 216bc7ec1..8658ada97 100644 --- a/Tests/Graphics/Types/CMakeLists.txt +++ b/Tests/Graphics/Types/CMakeLists.txt @@ -4,7 +4,6 @@ include(Catch) set(TARGET MethaneGraphicsTypesTest) add_executable(${TARGET} - Main.cpp VolumeSizeTest.cpp VolumeTest.cpp ColorTest.cpp @@ -18,7 +17,7 @@ target_link_libraries(${TARGET} MethaneBuildOptions MethanePrecompiledExtraHeaders $<$:TracyClient> - Catch2 + Catch2WithMain ) catch_discover_tests(${TARGET}) diff --git a/Tests/Graphics/Types/ColorTest.cpp b/Tests/Graphics/Types/ColorTest.cpp index 275961787..e62dbdfe1 100644 --- a/Tests/Graphics/Types/ColorTest.cpp +++ b/Tests/Graphics/Types/ColorTest.cpp @@ -23,10 +23,12 @@ Unit-tests of the Color data type wrapping HLSL++ vector #include -#include +#include +#include using namespace Methane::Graphics; using namespace Methane::Data; +using Catch::Approx; #define COLOR_TYPES_MATRIX \ ((typename T, size_t size), T, size), \ diff --git a/Tests/Graphics/Types/Main.cpp b/Tests/Graphics/Types/Main.cpp index d9ea09771..d42f0632f 100644 --- a/Tests/Graphics/Types/Main.cpp +++ b/Tests/Graphics/Types/Main.cpp @@ -23,5 +23,5 @@ FILE: Tests/Data/Types/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 #define CATCH_CONFIG_MAIN -#include +#include #include diff --git a/Tests/Graphics/Types/VolumeSizeTest.cpp b/Tests/Graphics/Types/VolumeSizeTest.cpp index 4a28fc8ae..dc7e76794 100644 --- a/Tests/Graphics/Types/VolumeSizeTest.cpp +++ b/Tests/Graphics/Types/VolumeSizeTest.cpp @@ -23,7 +23,7 @@ Unit-tests of the VolumeSize data type #include -#include +#include using namespace Methane::Graphics; diff --git a/Tests/Graphics/Types/VolumeTest.cpp b/Tests/Graphics/Types/VolumeTest.cpp index 2c02cd43b..ca393a8fc 100644 --- a/Tests/Graphics/Types/VolumeTest.cpp +++ b/Tests/Graphics/Types/VolumeTest.cpp @@ -24,7 +24,7 @@ Unit-tests of the Volume data type #include #include -#include +#include using namespace Methane::Graphics; diff --git a/Tests/Platform/Input/CMakeLists.txt b/Tests/Platform/Input/CMakeLists.txt index 63234dda6..a2de3496f 100644 --- a/Tests/Platform/Input/CMakeLists.txt +++ b/Tests/Platform/Input/CMakeLists.txt @@ -4,7 +4,6 @@ include(Catch) set(TARGET MethanePlatformInputTest) add_executable(${TARGET} - Main.cpp KeyboardTest.cpp MouseTest.cpp ) @@ -17,7 +16,7 @@ target_link_libraries(${TARGET} MethaneBuildOptions MethanePrecompiledHeaders $<$:TracyClient> - Catch2 + Catch2WithMain magic_enum ) diff --git a/Tests/Platform/Input/KeyboardTest.cpp b/Tests/Platform/Input/KeyboardTest.cpp index cca674ce6..9515d8e6f 100644 --- a/Tests/Platform/Input/KeyboardTest.cpp +++ b/Tests/Platform/Input/KeyboardTest.cpp @@ -21,7 +21,7 @@ Unit tests of the Keyboard data types ******************************************************************************/ -#include +#include #include diff --git a/Tests/Platform/Input/Main.cpp b/Tests/Platform/Input/Main.cpp index a442a98f4..6f8fbab4e 100644 --- a/Tests/Platform/Input/Main.cpp +++ b/Tests/Platform/Input/Main.cpp @@ -23,5 +23,5 @@ FILE: Test/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 #define CATCH_CONFIG_MAIN -#include +#include #include \ No newline at end of file diff --git a/Tests/Platform/Input/MouseTest.cpp b/Tests/Platform/Input/MouseTest.cpp index bb31084d4..cf22773b8 100644 --- a/Tests/Platform/Input/MouseTest.cpp +++ b/Tests/Platform/Input/MouseTest.cpp @@ -21,7 +21,7 @@ Unit tests of the Mouse data types ******************************************************************************/ -#include +#include #include diff --git a/Tests/UserInterface/Types/CMakeLists.txt b/Tests/UserInterface/Types/CMakeLists.txt index 6cefa2caa..8f67586d9 100644 --- a/Tests/UserInterface/Types/CMakeLists.txt +++ b/Tests/UserInterface/Types/CMakeLists.txt @@ -4,7 +4,6 @@ include(Catch) set(TARGET MethaneUserInterfaceTypesTest) add_executable(${TARGET} - Main.cpp UnitTypeCatchHelpers.hpp UnitTypesTest.cpp FakeRenderContext.hpp @@ -21,7 +20,7 @@ target_link_libraries(${TARGET} MethaneBuildOptions MethanePrecompiledExtraHeaders $<$:TracyClient> - Catch2 + Catch2WithMain ) catch_discover_tests(${TARGET}) diff --git a/Tests/UserInterface/Types/ContextTest.cpp b/Tests/UserInterface/Types/ContextTest.cpp index b4426b238..8141c6dda 100644 --- a/Tests/UserInterface/Types/ContextTest.cpp +++ b/Tests/UserInterface/Types/ContextTest.cpp @@ -27,7 +27,8 @@ Unit-tests of the User Interface Context #include #include -#include +#include +#include using namespace Methane; using namespace Methane::Graphics; @@ -54,7 +55,7 @@ TEST_CASE("UI Context Accessors", "[ui][context][accessor]") SECTION("Get UI content scale factor and font DPI") { - CHECK(ui_context.GetDotsToPixelsFactor() == Approx(g_dot_to_px_factor)); + CHECK(ui_context.GetDotsToPixelsFactor() == Catch::Approx(g_dot_to_px_factor)); CHECK(ui_context.GetFontResolutionDpi() == g_font_resolution_dpi); } diff --git a/Tests/UserInterface/Types/Main.cpp b/Tests/UserInterface/Types/Main.cpp index a4d3e1331..4c897e7af 100644 --- a/Tests/UserInterface/Types/Main.cpp +++ b/Tests/UserInterface/Types/Main.cpp @@ -23,5 +23,5 @@ FILE: Tests/UserInterface/Types/Main.cpp #define CATCH_CONFIG_CONSOLE_WIDTH 300 #define CATCH_CONFIG_MAIN -#include +#include #include diff --git a/Tests/UserInterface/Types/UnitTypeCatchHelpers.hpp b/Tests/UserInterface/Types/UnitTypeCatchHelpers.hpp index a0cbe3c6e..141b3c120 100644 --- a/Tests/UserInterface/Types/UnitTypeCatchHelpers.hpp +++ b/Tests/UserInterface/Types/UnitTypeCatchHelpers.hpp @@ -25,7 +25,7 @@ Unit-test helpers for User Interface Unit types #include -#include +#include #define POINT_BASE_TYPES Methane::Data::FramePoint, Methane::Data::FloatPoint #define SIZE_BASE_TYPES Methane::Data::FrameSize, Methane::Data::FloatSize diff --git a/Tests/UserInterface/Types/UnitTypesTest.cpp b/Tests/UserInterface/Types/UnitTypesTest.cpp index 81ea4d351..122df57ff 100644 --- a/Tests/UserInterface/Types/UnitTypesTest.cpp +++ b/Tests/UserInterface/Types/UnitTypesTest.cpp @@ -25,6 +25,8 @@ Unit-tests of the Unit Types #include +#include + using namespace Methane; using namespace Methane::UserInterface; diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 89819f81d..890c42d61 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -31,8 +31,6 @@ pr: resources: repositories: - repository: self - checkoutOptions: - submodules: recursive variables: @@ -47,9 +45,13 @@ variables: sonar.CacheDir: '$(Pipeline.Workspace)/SonarCache' sonar.ScannerVersion: '4.4.0.2170' + coverage.OpenCppCoverageUrl: 'https://github.com/MethanePowered/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverage.zip' + + cmake.ExternalsCacheDir: '$(Pipeline.Workspace)/ExternalsCache' cmake.ConfigureFlags: '-DMETHANE_VERSION_MAJOR=$(product.Version.Major) -DMETHANE_VERSION_MINOR=$(product.Version.Minor) - -DMETHANE_VERSION_BUILD=$(Build.BuildNumber)' + -DMETHANE_VERSION_BUILD=$(Build.BuildNumber) + -DCPM_SOURCE_CACHE="$(cmake.ExternalsCacheDir)"' jobs: @@ -75,6 +77,7 @@ jobs: cmake.ConfigurePreset: 'VS2019-Win64-DX-Profile' cmake.BuildPreset: 'VS2019-Win64-DX-Profile' installDir: 'Build\Output\$(cmake.ConfigurePreset)\Install' + TRACY_NO_INVARIANT_CHECK: 1 steps: - template: Build/Windows/AzureBuild.yml @@ -103,6 +106,7 @@ jobs: cmake.ConfigurePreset: 'VS2019-Win32-DX-Profile' cmake.BuildPreset: 'VS2019-Win32-DX-Profile' installDir: 'Build\Output\$(cmake.ConfigurePreset)\Install' + TRACY_NO_INVARIANT_CHECK: 1 steps: - template: Build/Windows/AzureBuild.yml @@ -133,6 +137,7 @@ jobs: cmake.ConfigurePreset: 'VS2019-Win64-VK-Profile' cmake.BuildPreset: 'VS2019-Win64-VK-Profile' installDir: 'Build\Output\$(cmake.ConfigurePreset)\Install' + TRACY_NO_INVARIANT_CHECK: 1 steps: - template: Build/Windows/AzureBuild.yml @@ -163,6 +168,7 @@ jobs: cmake.ConfigurePreset: 'VS2019-Win32-VK-Profile' cmake.BuildPreset: 'VS2019-Win32-VK-Profile' installDir: 'Build\Output\$(cmake.ConfigurePreset)\Install' + TRACY_NO_INVARIANT_CHECK: 1 steps: - template: Build/Windows/AzureBuild.yml @@ -191,7 +197,7 @@ jobs: - job: MacOS_MTL_Release pool: - vmImage: 'macOS-10.15' + vmImage: 'macos-11' variables: cmake.ConfigurePreset: 'Xcode-Mac-MTL-Default' @@ -204,12 +210,13 @@ jobs: - job: MacOS_MTL_Profiling pool: - vmImage: 'macOS-10.15' + vmImage: 'macos-11' variables: cmake.ConfigurePreset: 'Xcode-Mac-MTL-Profile' cmake.BuildPreset: 'Xcode-Mac-MTL-Profile' installDir: 'Build/Output/$(cmake.ConfigurePreset)/Install' + TRACY_NO_INVARIANT_CHECK: 1 steps: - template: Build/Unix/AzureBuild.yml @@ -220,7 +227,7 @@ jobs: continueOnError: true pool: - vmImage: 'macOS-10.15' + vmImage: 'macos-11' variables: cmake.ConfigurePreset: 'Xcode-Mac-MTL-Scan' @@ -290,6 +297,7 @@ jobs: cmake.ConfigurePreset: 'Make-Lin-VK-Profile' cmake.BuildPreset: 'Make-Lin-VK-Profile' installDir: 'Build/Output/$(cmake.ConfigurePreset)/Install' + TRACY_NO_INVARIANT_CHECK: 1 steps: - template: Build/Unix/AzureBuild.yml