Engine is now installable
This commit is contained in:
@@ -34,3 +34,9 @@
|
|||||||
[submodule "external/thread-pool"]
|
[submodule "external/thread-pool"]
|
||||||
path = external/thread-pool
|
path = external/thread-pool
|
||||||
url = https://github.com/DeveloperPaul123/thread-pool.git
|
url = https://github.com/DeveloperPaul123/thread-pool.git
|
||||||
|
[submodule "external/zlib"]
|
||||||
|
path = external/zlib
|
||||||
|
url = https://github.com/madler/zlib.git
|
||||||
|
[submodule "external/CRCpp"]
|
||||||
|
path = external/CRCpp
|
||||||
|
url = https://github.com/d-bahr/CRCpp.git
|
||||||
+71
-31
@@ -19,6 +19,7 @@ set(BOOST_ROOT ${EXTERNAL_ROOT}/boost)
|
|||||||
set(SLANG_ROOT ${EXTERNAL_ROOT}/slang)
|
set(SLANG_ROOT ${EXTERNAL_ROOT}/slang)
|
||||||
set(GLM_ROOT ${EXTERNAL_ROOT}/glm)
|
set(GLM_ROOT ${EXTERNAL_ROOT}/glm)
|
||||||
set(GLFW_ROOT ${EXTERNAL_ROOT}/glfw)
|
set(GLFW_ROOT ${EXTERNAL_ROOT}/glfw)
|
||||||
|
set(CRCPP_ROOT ${EXTERNAL_ROOT}/crcpp)
|
||||||
set(JSON_ROOT ${EXTERNAL_ROOT}/json)
|
set(JSON_ROOT ${EXTERNAL_ROOT}/json)
|
||||||
set(KTX_ROOT ${EXTERNAL_ROOT}/ktx)
|
set(KTX_ROOT ${EXTERNAL_ROOT}/ktx)
|
||||||
set(STB_ROOT ${EXTERNAL_ROOT}/stb)
|
set(STB_ROOT ${EXTERNAL_ROOT}/stb)
|
||||||
@@ -28,6 +29,7 @@ set(SPIRV_ROOT ${EXTERNAL_ROOT}/SPIRV-Cross)
|
|||||||
set(ENTT_ROOT ${EXTERNAL_ROOT}/entt)
|
set(ENTT_ROOT ${EXTERNAL_ROOT}/entt)
|
||||||
set(NSAM_ROOT ${EXTERNAL_ROOT}/aftermath)
|
set(NSAM_ROOT ${EXTERNAL_ROOT}/aftermath)
|
||||||
set(THREADPOOL_ROOT ${EXTERNAL_ROOT}/thread-pool)
|
set(THREADPOOL_ROOT ${EXTERNAL_ROOT}/thread-pool)
|
||||||
|
set(ZLIB_ROOT ${EXTERNAL_ROOT}/zlib)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
|
||||||
set(Boost_NO_WARN_NEW_VERSIONS 1)
|
set(Boost_NO_WARN_NEW_VERSIONS 1)
|
||||||
@@ -36,48 +38,50 @@ project (Seele)
|
|||||||
|
|
||||||
include(cmake/Superbuild.cmake)
|
include(cmake/Superbuild.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
|
||||||
#Workaround for vs, because it places artifacts into an additional subfolder
|
#Workaround for vs, because it places artifacts into an additional subfolder
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug)
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/bin/Release)
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(Boost_LIB_PREFIX lib)
|
set(Boost_LIB_PREFIX lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Vulkan REQUIRED)
|
find_package(Vulkan REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS serialization)
|
find_package(Boost REQUIRED serialization)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_compile_definitions(USE_EXTENSIONS)
|
add_compile_definitions(USE_EXTENSIONS)
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_DEBUG_POSTFIX)
|
if(CMAKE_DEBUG_POSTFIX)
|
||||||
add_compile_definitions(ENABLE_VALIDATION)
|
add_compile_definitions(ENABLE_VALIDATION)
|
||||||
add_compile_definitions(SEELE_DEBUG)
|
add_compile_definitions(SEELE_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(Engine STATIC "")
|
add_library(Engine STATIC "")
|
||||||
target_compile_definitions(Engine PUBLIC GLFW_WINDOWS)
|
target_compile_definitions(Engine PRIVATE GLFW_WINDOWS)
|
||||||
target_include_directories(Engine PUBLIC src/Engine)
|
target_include_directories(Engine PRIVATE src/Engine)
|
||||||
target_link_libraries(Engine PUBLIC Vulkan::Vulkan)
|
target_link_libraries(Engine PUBLIC Vulkan::Vulkan)
|
||||||
target_link_libraries(Engine PUBLIC Boost::headers)
|
|
||||||
target_link_libraries(Engine PUBLIC Boost::serialization)
|
|
||||||
target_link_libraries(Engine PUBLIC EnTT::EnTT)
|
target_link_libraries(Engine PUBLIC EnTT::EnTT)
|
||||||
target_link_libraries(Engine PUBLIC glfw)
|
target_link_libraries(Engine PUBLIC glfw)
|
||||||
target_link_libraries(Engine PUBLIC glm::glm)
|
target_link_libraries(Engine PUBLIC glm)
|
||||||
target_link_libraries(Engine PUBLIC freetype)
|
target_link_libraries(Engine PUBLIC freetype)
|
||||||
target_link_libraries(Engine PUBLIC slang)
|
target_link_libraries(Engine PUBLIC slang)
|
||||||
target_link_libraries(Engine PUBLIC assimp)
|
target_link_libraries(Engine PUBLIC assimp)
|
||||||
target_link_libraries(Engine PUBLIC nsam)
|
|
||||||
target_link_libraries(Engine PUBLIC ktx)
|
target_link_libraries(Engine PUBLIC ktx)
|
||||||
target_link_libraries(Engine PUBLIC stb)
|
target_link_libraries(Engine PUBLIC stb)
|
||||||
target_link_libraries(Engine PUBLIC nlohmann_json::nlohmann_json)
|
target_link_libraries(Engine PUBLIC nlohmann_json::nlohmann_json)
|
||||||
target_link_libraries(Engine PUBLIC dp::thread-pool)
|
target_link_libraries(Engine PUBLIC dp::thread-pool)
|
||||||
|
target_link_libraries(Engine PUBLIC crcpp)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(Engine PUBLIC Threads::Threads)
|
target_link_libraries(Engine PUBLIC Threads::Threads)
|
||||||
target_link_libraries(Engine PUBLIC dl)
|
target_link_libraries(Engine PUBLIC dl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_precompile_headers(Engine
|
target_precompile_headers(Engine
|
||||||
PUBLIC
|
PUBLIC
|
||||||
<assert.h>
|
<assert.h>
|
||||||
@@ -92,34 +96,70 @@ target_precompile_headers(Engine
|
|||||||
<memory>
|
<memory>
|
||||||
<mutex>
|
<mutex>
|
||||||
<string>
|
<string>
|
||||||
<thread>
|
<thread>)
|
||||||
<boost/serialization/serialization.hpp>)
|
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(_CRT_SECURE_NO_WARNINGS)
|
set(_CRT_SECURE_NO_WARNINGS)
|
||||||
target_compile_options(Engine PUBLIC /Zi /MP15 /W4 /DEBUG "/WX-")
|
target_compile_options(Engine PUBLIC /Zi /MP14 /W4 /DEBUG "/WX-")
|
||||||
else()
|
else()
|
||||||
target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
|
target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(Editor "")
|
|
||||||
|
|
||||||
target_include_directories(Editor PRIVATE src/Editor)
|
|
||||||
|
|
||||||
target_link_libraries(Editor PUBLIC Engine)
|
|
||||||
|
|
||||||
add_subdirectory(src/)
|
add_subdirectory(src/)
|
||||||
|
|
||||||
add_executable(Seele_unit_tests "")
|
add_executable(Seele_unit_tests "")
|
||||||
add_subdirectory(test/)
|
add_subdirectory(test/)
|
||||||
|
|
||||||
add_custom_target(SeeleEngine ALL
|
add_custom_target(SeeleEngine ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:Editor>
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:Engine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:Editor> $<TARGET_FILE_DIR:Editor>
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:slang,SLANG_BINARY> $<TARGET_FILE_DIR:Engine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:slang,SLANG_BINARY> $<TARGET_FILE_DIR:Editor>
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:slang,GLSLANG_BINARY> $<TARGET_FILE_DIR:Engine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:slang,GLSLANG_BINARY> $<TARGET_FILE_DIR:Editor>
|
COMMAND_EXPAND_LISTS
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:nsam,NSAM_BINARY> $<TARGET_FILE_DIR:Editor>
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:nsam,LLVM_BINARY> $<TARGET_FILE_DIR:Editor>
|
|
||||||
COMMAND_EXPAND_LISTS
|
|
||||||
DEPENDS Editor slang-build)
|
DEPENDS Editor slang-build)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS
|
||||||
|
Engine
|
||||||
|
EnTT
|
||||||
|
glfw
|
||||||
|
glm
|
||||||
|
freetype
|
||||||
|
slang
|
||||||
|
assimp
|
||||||
|
ktx
|
||||||
|
stb
|
||||||
|
crcpp
|
||||||
|
nlohmann_json
|
||||||
|
ThreadPool
|
||||||
|
zlib
|
||||||
|
zlibstatic
|
||||||
|
EXPORT
|
||||||
|
EngineTargets
|
||||||
|
FILE_SET HEADERS
|
||||||
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
|
|
||||||
|
export(EXPORT EngineTargets
|
||||||
|
FILE "${CMAKE_BINARY_DIR}/EngineTargets.cmake"
|
||||||
|
NAMESPACE Seele::)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
configure_package_config_file(cmake/EngineConfig.cmake.in
|
||||||
|
"SeeleConfig.cmake"
|
||||||
|
INSTALL_DESTINATION ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
|
install(EXPORT EngineTargets
|
||||||
|
FILE
|
||||||
|
EngineTargets.cmake
|
||||||
|
NAMESPACE
|
||||||
|
Seele::
|
||||||
|
DESTINATION
|
||||||
|
${CMAKE_INSTALL_PREFIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${CMAKE_BINARY_DIR}/SeeleConfig.cmake
|
||||||
|
DESTINATION
|
||||||
|
${CMAKE_INSTALL_PREFIX}
|
||||||
|
)
|
||||||
|
|||||||
@@ -35,25 +35,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"superbuild": {
|
|
||||||
"default": "off",
|
|
||||||
"description": "Use Superbuild",
|
|
||||||
"choices": {
|
|
||||||
"off": {
|
|
||||||
"short": "off",
|
|
||||||
"long": "Don't rebuild superbuild",
|
|
||||||
"settings": {
|
|
||||||
"USE_SUPERBUILD": "OFF"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"on": {
|
|
||||||
"short": "on",
|
|
||||||
"long": "Rebuild dependencies",
|
|
||||||
"settings": {
|
|
||||||
"USE_SUPERBUILD": "ON"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/EngineTargets.cmake")
|
||||||
|
|
||||||
|
check_required_components(Engine)
|
||||||
+65
-25
@@ -1,8 +1,9 @@
|
|||||||
include (ExternalProject)
|
include (ExternalProject)
|
||||||
|
|
||||||
#--------------FreeType------------------------------
|
#--------------ZLIB------------------------------
|
||||||
set(FT_DISABLE_ZLIB ON)
|
add_subdirectory(${ZLIB_ROOT})
|
||||||
|
|
||||||
|
#--------------FreeType------------------------------
|
||||||
add_subdirectory(${FREETYPE_ROOT})
|
add_subdirectory(${FREETYPE_ROOT})
|
||||||
|
|
||||||
#------------ASSIMP---------------
|
#------------ASSIMP---------------
|
||||||
@@ -17,8 +18,6 @@ else()
|
|||||||
target_compile_options(assimp PRIVATE -Wno-error -fPIC)
|
target_compile_options(assimp PRIVATE -Wno-error -fPIC)
|
||||||
target_compile_options(IrrXML PRIVATE -fPIC)
|
target_compile_options(IrrXML PRIVATE -fPIC)
|
||||||
endif()
|
endif()
|
||||||
#-------------BOOST----------------
|
|
||||||
add_subdirectory(${BOOST_ROOT})
|
|
||||||
|
|
||||||
#-----------------KTX----------------------------
|
#-----------------KTX----------------------------
|
||||||
set(KTX_FEATURE_TESTS off)
|
set(KTX_FEATURE_TESTS off)
|
||||||
@@ -28,13 +27,10 @@ add_subdirectory(${KTX_ROOT} ${KTX_ROOT})
|
|||||||
#--------------------JSON------------------
|
#--------------------JSON------------------
|
||||||
set(JSON_MultipleHeaders ON CACHE INTERNAL "")
|
set(JSON_MultipleHeaders ON CACHE INTERNAL "")
|
||||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||||
set(JSON_Install OFF CACHE INTERNAL "")
|
set(JSON_Install ON CACHE INTERNAL "")
|
||||||
|
|
||||||
add_subdirectory(${JSON_ROOT})
|
add_subdirectory(${JSON_ROOT})
|
||||||
|
|
||||||
#--------------GLM------------------------------
|
|
||||||
add_subdirectory(${GLM_ROOT})
|
|
||||||
target_compile_options(glm INTERFACE /W0)
|
|
||||||
|
|
||||||
#--------------GLFW------------------------------
|
#--------------GLFW------------------------------
|
||||||
set(ENKITS_BUILD_EXAMPLES OFF CACHE BOOL "Build basic example applications" )
|
set(ENKITS_BUILD_EXAMPLES OFF CACHE BOOL "Build basic example applications" )
|
||||||
@@ -49,19 +45,6 @@ add_subdirectory(${GLFW_ROOT})
|
|||||||
#--------------EnTT------------------------------
|
#--------------EnTT------------------------------
|
||||||
add_subdirectory(${ENTT_ROOT})
|
add_subdirectory(${ENTT_ROOT})
|
||||||
|
|
||||||
#--------------STB-----------------------------------
|
|
||||||
add_library(stb INTERFACE)
|
|
||||||
|
|
||||||
target_include_directories(stb INTERFACE ${STB_ROOT})
|
|
||||||
|
|
||||||
#--------------Aftermath------------------------------
|
|
||||||
add_library(nsam INTERFACE)
|
|
||||||
|
|
||||||
target_include_directories(nsam INTERFACE ${NSAM_ROOT}/include)
|
|
||||||
target_link_libraries(nsam INTERFACE ${NSAM_ROOT}/lib/${CMAKE_PLATFORM}/*.lib)
|
|
||||||
set_target_properties(nsam PROPERTIES NSAM_BINARY ${NSAM_ROOT}/lib/${CMAKE_PLATFORM}/GFSDK_Aftermath_Lib.${CMAKE_PLATFORM}.dll)
|
|
||||||
set_target_properties(nsam PROPERTIES LLVM_BINARY ${NSAM_ROOT}/lib/${CMAKE_PLATFORM}/llvm_7_0_1.dll)
|
|
||||||
|
|
||||||
#--------------thread-pool------------------------------
|
#--------------thread-pool------------------------------
|
||||||
add_subdirectory(${THREADPOOL_ROOT})
|
add_subdirectory(${THREADPOOL_ROOT})
|
||||||
|
|
||||||
@@ -74,22 +57,79 @@ string(TOLOWER ${SLANG_ROOT}/bin/windows-${CMAKE_PLATFORM}/release SLANG_BINARY_
|
|||||||
ExternalProject_Add(slang-build
|
ExternalProject_Add(slang-build
|
||||||
SOURCE_DIR ${SLANG_ROOT}
|
SOURCE_DIR ${SLANG_ROOT}
|
||||||
BINARY_DIR ${SLANG_ROOT}
|
BINARY_DIR ${SLANG_ROOT}
|
||||||
CONFIGURE_COMMAND ${SLANG_ROOT}/premake.bat vs2019 --file=${CMAKE_SOURCE_DIR}/external/slang/premake5.lua gmake --arch=${CMAKE_PLATFORM} --deps=true
|
CONFIGURE_COMMAND ${SLANG_ROOT}/premake.bat vs2019 --file=${SLANG_ROOT}/premake5.lua gmake --arch=${CMAKE_PLATFORM} --deps=true
|
||||||
BUILD_COMMAND msbuild slang.sln -p:Configuration=Release -p:Platform=${CMAKE_PLATFORM}
|
BUILD_COMMAND msbuild slang.sln -p:Configuration=Release -p:Platform=${CMAKE_PLATFORM}
|
||||||
INSTALL_COMMAND "")
|
INSTALL_COMMAND ""
|
||||||
|
)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
ExternalProject_Add(slang-build
|
ExternalProject_Add(slang-build
|
||||||
SOURCE_DIR ${SLANG_ROOT}
|
SOURCE_DIR ${SLANG_ROOT}
|
||||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
CONFIGURE_COMMAND ${CMAKE_SOURCE_DIR}/premake5 --file=${CMAKE_SOURCE_DIR}/external/slang/premake5.lua gmake --arch=${CMAKE_PLATFORM} --deps=true --build-location=build/linux
|
CONFIGURE_COMMAND ${CMAKE_SOURCE_DIR}/premake5 --file=${CMAKE_SOURCE_DIR}/external/slang/premake5.lua gmake --arch=${CMAKE_PLATFORM} --deps=true --build-location=build/linux
|
||||||
BUILD_COMMAND make -C ${CMAKE_SOURCE_DIR}/external/slang/build/linux config=${SLANG_CONFIG}
|
BUILD_COMMAND make -C ${CMAKE_SOURCE_DIR}/external/slang/build/linux config=${SLANG_CONFIG}
|
||||||
INSTALL_COMMAND "")
|
INSTALL_COMMAND ""
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(slang INTERFACE)
|
add_library(slang INTERFACE)
|
||||||
|
|
||||||
target_include_directories(slang INTERFACE ${SLANG_ROOT})
|
target_include_directories(slang INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${SLANG_ROOT}/>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
target_link_libraries(slang INTERFACE ${SLANG_BINARY_DIR}/*.lib)
|
target_link_libraries(slang INTERFACE ${SLANG_BINARY_DIR}/*.lib)
|
||||||
set_target_properties(slang PROPERTIES SLANG_BINARY ${SLANG_BINARY_DIR}/slang.dll)
|
set_target_properties(slang PROPERTIES SLANG_BINARY ${SLANG_BINARY_DIR}/slang.dll)
|
||||||
set_target_properties(slang PROPERTIES GLSLANG_BINARY ${SLANG_BINARY_DIR}/slang-glslang.dll)
|
set_target_properties(slang PROPERTIES GLSLANG_BINARY ${SLANG_BINARY_DIR}/slang-glslang.dll)
|
||||||
|
|
||||||
|
install(DIRECTORY
|
||||||
|
${SLANG_ROOT}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
#--------------CRC++------------------------------
|
||||||
|
add_library(crcpp INTERFACE)
|
||||||
|
|
||||||
|
target_include_directories(crcpp INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CRCPP_ROOT}/inc>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${CRCPP_ROOT}/inc/CRC.h
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
#--------------GLM------------------------------
|
||||||
|
add_library(glm INTERFACE)
|
||||||
|
target_include_directories(glm INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${GLM_ROOT}>
|
||||||
|
$<INSTALL_INTERFACE:include/glm>
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY
|
||||||
|
${GLM_ROOT}/glm
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
FILES_MATCHING PATTERN "*.h*"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY
|
||||||
|
${GLM_ROOT}/glm
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
FILES_MATCHING PATTERN "*.inl"
|
||||||
|
)
|
||||||
|
|
||||||
|
#--------------STB-----------------------------------
|
||||||
|
add_library(stb INTERFACE)
|
||||||
|
|
||||||
|
target_include_directories(stb INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${STB_ROOT}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY
|
||||||
|
${STB_HEADERS}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
+1
Submodule external/CRCpp added at 71f2152b63
Vendored
+1
-1
Submodule external/glm updated: 8e58cdbbf8...bf71a83494
+1
Submodule external/zlib added at 04f42ceca4
@@ -1,2 +1 @@
|
|||||||
add_subdirectory(Editor/)
|
|
||||||
add_subdirectory(Engine/)
|
add_subdirectory(Engine/)
|
||||||
@@ -6,3 +6,10 @@ target_sources(Engine
|
|||||||
CameraActor.h
|
CameraActor.h
|
||||||
Entity.cpp
|
Entity.cpp
|
||||||
Entity.h)
|
Entity.h)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Actor.h
|
||||||
|
CameraActor.h
|
||||||
|
Entity.h)
|
||||||
|
|||||||
@@ -18,3 +18,16 @@ target_sources(Engine
|
|||||||
TextureAsset.cpp
|
TextureAsset.cpp
|
||||||
TextureLoader.h
|
TextureLoader.h
|
||||||
TextureLoader.cpp)
|
TextureLoader.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Asset.h
|
||||||
|
AssetRegistry.h
|
||||||
|
FontAsset.h
|
||||||
|
FontLoader.h
|
||||||
|
MaterialLoader.h
|
||||||
|
MeshAsset.h
|
||||||
|
MeshLoader.h
|
||||||
|
TextureAsset.h
|
||||||
|
TextureLoader.h)
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
#include "MeshAsset.h"
|
#include "MeshAsset.h"
|
||||||
#include "Graphics/Mesh.h"
|
#include "Graphics/Mesh.h"
|
||||||
#include "Graphics/VertexShaderInput.h"
|
#include "Graphics/VertexShaderInput.h"
|
||||||
#include <boost/archive/text_iarchive.hpp>
|
|
||||||
#include <boost/archive/text_oarchive.hpp>
|
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
|
|
||||||
MeshAsset::MeshAsset()
|
MeshAsset::MeshAsset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ target_sources(Engine
|
|||||||
MinimalEngine.h
|
MinimalEngine.h
|
||||||
MinimalEngine.cpp)
|
MinimalEngine.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
EngineTypes.h
|
||||||
|
MinimalEngine.h)
|
||||||
|
|
||||||
add_subdirectory(Actor/)
|
add_subdirectory(Actor/)
|
||||||
add_subdirectory(Asset/)
|
add_subdirectory(Asset/)
|
||||||
add_subdirectory(Component/)
|
add_subdirectory(Component/)
|
||||||
|
|||||||
@@ -6,3 +6,11 @@ target_sources(Engine
|
|||||||
StaticMesh.h
|
StaticMesh.h
|
||||||
Transform.h
|
Transform.h
|
||||||
Transform.cpp)
|
Transform.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Camera.h
|
||||||
|
Component.h
|
||||||
|
StaticMesh.h
|
||||||
|
Transform.h)
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <memory_resource>
|
#include <memory_resource>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/serialization/serialization.hpp>
|
|
||||||
|
|
||||||
#ifndef DEFAULT_ALLOC_SIZE
|
#ifndef DEFAULT_ALLOC_SIZE
|
||||||
#define DEFAULT_ALLOC_SIZE 16
|
#define DEFAULT_ALLOC_SIZE 16
|
||||||
@@ -548,16 +547,6 @@ private:
|
|||||||
}
|
}
|
||||||
markIteratorDirty();
|
markIteratorDirty();
|
||||||
}
|
}
|
||||||
friend class boost::serialization::access;
|
|
||||||
template<class Archive>
|
|
||||||
void serialize(Archive& ar, const unsigned int)
|
|
||||||
{
|
|
||||||
ar & arraySize;
|
|
||||||
resize(arraySize);
|
|
||||||
for(size_type i = 0; i < arraySize; ++i)
|
|
||||||
ar & _data[i];
|
|
||||||
markIteratorDirty();
|
|
||||||
}
|
|
||||||
size_type arraySize = 0;
|
size_type arraySize = 0;
|
||||||
size_type allocated = 0;
|
size_type allocated = 0;
|
||||||
Iterator beginIt;
|
Iterator beginIt;
|
||||||
@@ -745,13 +734,5 @@ private:
|
|||||||
T _data[N];
|
T _data[N];
|
||||||
iterator beginIt;
|
iterator beginIt;
|
||||||
iterator endIt;
|
iterator endIt;
|
||||||
friend class boost::serialization::access;
|
|
||||||
template<class Archive>
|
|
||||||
void serialize(Archive& ar, const unsigned int version)
|
|
||||||
{
|
|
||||||
ar & version;
|
|
||||||
ar & N;
|
|
||||||
ar & _data;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
@@ -3,3 +3,11 @@ target_sources(Engine
|
|||||||
Array.h
|
Array.h
|
||||||
Map.h
|
Map.h
|
||||||
List.h)
|
List.h)
|
||||||
|
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Array.h
|
||||||
|
Map.h
|
||||||
|
List.h)
|
||||||
@@ -20,5 +20,19 @@ target_sources(Engine
|
|||||||
StaticMeshVertexInput.h
|
StaticMeshVertexInput.h
|
||||||
StaticMeshVertexInput.cpp)
|
StaticMeshVertexInput.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
GraphicsResources.h
|
||||||
|
GraphicsInitializer.h
|
||||||
|
GraphicsEnums.h
|
||||||
|
Graphics.h
|
||||||
|
Mesh.h
|
||||||
|
MeshBatch.h
|
||||||
|
RenderMaterial.h
|
||||||
|
ShaderCompiler.h
|
||||||
|
VertexShaderInput.h
|
||||||
|
StaticMeshVertexInput.h)
|
||||||
|
|
||||||
add_subdirectory(RenderPass/)
|
add_subdirectory(RenderPass/)
|
||||||
add_subdirectory(Vulkan/)
|
add_subdirectory(Vulkan/)
|
||||||
@@ -401,9 +401,7 @@ static Map<uint32, PVertexDeclaration> vertexDeclarationCache;
|
|||||||
PVertexDeclaration VertexDeclaration::createDeclaration(PGraphics graphics, const Array<VertexElement>& elementList)
|
PVertexDeclaration VertexDeclaration::createDeclaration(PGraphics graphics, const Array<VertexElement>& elementList)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(vertexDeclarationLock);
|
std::scoped_lock lock(vertexDeclarationLock);
|
||||||
boost::crc_32_type result;
|
uint32 key = CRC::Calculate(&elementList, sizeof(VertexElement) * elementList.size(), CRC::CRC_32());
|
||||||
result.process_bytes(&elementList, sizeof(VertexElement) * elementList.size());
|
|
||||||
uint32 key = result.checksum();
|
|
||||||
|
|
||||||
auto found = vertexDeclarationCache[key];
|
auto found = vertexDeclarationCache[key];
|
||||||
if(found == nullptr)
|
if(found == nullptr)
|
||||||
|
|||||||
@@ -3,10 +3,7 @@
|
|||||||
#include "Containers/Array.h"
|
#include "Containers/Array.h"
|
||||||
#include "Containers/List.h"
|
#include "Containers/List.h"
|
||||||
#include "GraphicsInitializer.h"
|
#include "GraphicsInitializer.h"
|
||||||
#pragma warning(push)
|
#include "CRC.h"
|
||||||
#pragma warning(disable: 4701)
|
|
||||||
#include <boost/crc.hpp>
|
|
||||||
#pragma warning(pop)
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
@@ -103,9 +100,7 @@ struct PermutationId
|
|||||||
{}
|
{}
|
||||||
PermutationId(ShaderPermutation permutation)
|
PermutationId(ShaderPermutation permutation)
|
||||||
{
|
{
|
||||||
boost::crc_32_type result;
|
hash = CRC::Calculate(&permutation, sizeof(ShaderPermutation), CRC::CRC_32());
|
||||||
result.process_bytes(&permutation, sizeof(ShaderPermutation));
|
|
||||||
hash = result.checksum();
|
|
||||||
}
|
}
|
||||||
friend inline bool operator==(const PermutationId& lhs, const PermutationId& rhs)
|
friend inline bool operator==(const PermutationId& lhs, const PermutationId& rhs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
BasePassMeshProcessor::BasePassMeshProcessor(Gfx::PGraphics graphics, uint8 translucentBasePass)
|
BasePassMeshProcessor::BasePassMeshProcessor(Gfx::PGraphics graphics)
|
||||||
: MeshProcessor(graphics)
|
: MeshProcessor(graphics)
|
||||||
, translucentBasePass(translucentBasePass)
|
// , translucentBasePass(translucentBasePass)
|
||||||
//, cachedPrimitiveIndex(0)
|
//, cachedPrimitiveIndex(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ void BasePassMeshProcessor::processMeshBatch(
|
|||||||
|
|
||||||
BasePass::BasePass(Gfx::PGraphics graphics)
|
BasePass::BasePass(Gfx::PGraphics graphics)
|
||||||
: RenderPass(graphics)
|
: RenderPass(graphics)
|
||||||
, processor(new BasePassMeshProcessor(graphics, false))
|
, processor(new BasePassMeshProcessor(graphics))
|
||||||
, descriptorSets(4)
|
, descriptorSets(4)
|
||||||
{
|
{
|
||||||
UniformBufferCreateInfo uniformInitializer;
|
UniformBufferCreateInfo uniformInitializer;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Seele
|
|||||||
class BasePassMeshProcessor : public MeshProcessor
|
class BasePassMeshProcessor : public MeshProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BasePassMeshProcessor(Gfx::PGraphics graphics, uint8 translucentBasePass);
|
BasePassMeshProcessor(Gfx::PGraphics graphics);
|
||||||
virtual ~BasePassMeshProcessor();
|
virtual ~BasePassMeshProcessor();
|
||||||
|
|
||||||
virtual void processMeshBatch(
|
virtual void processMeshBatch(
|
||||||
@@ -21,8 +21,7 @@ public:
|
|||||||
int32 staticMeshId = -1) override;
|
int32 staticMeshId = -1) override;
|
||||||
private:
|
private:
|
||||||
//Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
|
//Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
|
||||||
Gfx::PViewport target;
|
//uint8 translucentBasePass;
|
||||||
uint8 translucentBasePass;
|
|
||||||
//uint32 cachedPrimitiveIndex;
|
//uint32 cachedPrimitiveIndex;
|
||||||
};
|
};
|
||||||
DEFINE_REF(BasePassMeshProcessor)
|
DEFINE_REF(BasePassMeshProcessor)
|
||||||
|
|||||||
@@ -16,3 +16,16 @@ target_sources(Engine
|
|||||||
TextPass.cpp
|
TextPass.cpp
|
||||||
UIPass.h
|
UIPass.h
|
||||||
UIPass.cpp)
|
UIPass.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
BasePass.h
|
||||||
|
DepthPrepass.h
|
||||||
|
LightCullingPass.h
|
||||||
|
MeshProcessor.h
|
||||||
|
RenderGraph.h
|
||||||
|
RenderGraphResources.h
|
||||||
|
RenderPass.h
|
||||||
|
TextPass.h
|
||||||
|
UIPass.h)
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
target_sources(Engine
|
target_sources(Engine
|
||||||
PRIVATE
|
PRIVATE
|
||||||
NsightAftermathGpuCrashTracker.h
|
|
||||||
NsightAftermathGpuCrashTracker.cpp
|
|
||||||
NsightAftermathHelpers.h
|
|
||||||
NsightAftermathShaderDatabase.h
|
|
||||||
NsightAftermathShaderDatabase.cpp
|
|
||||||
VulkanAllocator.h
|
VulkanAllocator.h
|
||||||
VulkanAllocator.cpp
|
VulkanAllocator.cpp
|
||||||
VulkanBuffer.cpp
|
VulkanBuffer.cpp
|
||||||
@@ -34,3 +29,22 @@ target_sources(Engine
|
|||||||
VulkanQueue.h
|
VulkanQueue.h
|
||||||
VulkanQueue.cpp
|
VulkanQueue.cpp
|
||||||
VulkanViewport.cpp)
|
VulkanViewport.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
VulkanAllocator.h
|
||||||
|
VulkanBuffer.cpp
|
||||||
|
VulkanCommandBuffer.h
|
||||||
|
VulkanFramebuffer.h
|
||||||
|
VulkanGraphics.h
|
||||||
|
VulkanGraphicsResources.h
|
||||||
|
VulkanDescriptorSets.h
|
||||||
|
VulkanGraphicsEnums.h
|
||||||
|
VulkanInitializer.h
|
||||||
|
VulkanRenderPass.h
|
||||||
|
VulkanPipeline.h
|
||||||
|
VulkanPipelineCache.h
|
||||||
|
VulkanShader.h
|
||||||
|
VulkanQueue.h)
|
||||||
|
|
||||||
@@ -1,346 +0,0 @@
|
|||||||
//*********************************************************
|
|
||||||
//
|
|
||||||
// Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "NsightAftermathGpuCrashTracker.h"
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// GpuCrashTracker implementation
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
GpuCrashTracker::GpuCrashTracker()
|
|
||||||
: m_initialized(false)
|
|
||||||
, m_mutex()
|
|
||||||
, m_shaderDebugInfo()
|
|
||||||
, m_shaderDatabase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GpuCrashTracker::~GpuCrashTracker()
|
|
||||||
{
|
|
||||||
// If initialized, disable GPU crash dumps
|
|
||||||
if (m_initialized)
|
|
||||||
{
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_DisableGpuCrashDumps());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the GPU Crash Dump Tracker
|
|
||||||
void GpuCrashTracker::Initialize()
|
|
||||||
{
|
|
||||||
// Enable GPU crash dumps and set up the callbacks for crash dump notifications,
|
|
||||||
// shader debug information notifications, and providing additional crash
|
|
||||||
// dump description data.Only the crash dump callback is mandatory. The other two
|
|
||||||
// callbacks are optional and can be omitted, by passing nullptr, if the corresponding
|
|
||||||
// functionality is not used.
|
|
||||||
// The DeferDebugInfoCallbacks flag enables caching of shader debug information data
|
|
||||||
// in memory. If the flag is set, ShaderDebugInfoCallback will be called only
|
|
||||||
// in the event of a crash, right before GpuCrashDumpCallback. If the flag is not set,
|
|
||||||
// ShaderDebugInfoCallback will be called for every shader that is compiled.
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_EnableGpuCrashDumps(
|
|
||||||
GFSDK_Aftermath_Version_API,
|
|
||||||
GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_Vulkan,
|
|
||||||
GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks, // Let the Nsight Aftermath library cache shader debug information.
|
|
||||||
GpuCrashDumpCallback, // Register callback for GPU crash dumps.
|
|
||||||
ShaderDebugInfoCallback, // Register callback for shader debug information.
|
|
||||||
CrashDumpDescriptionCallback, // Register callback for GPU crash dump description.
|
|
||||||
this)); // Set the GpuCrashTracker object as user data for the above callbacks.
|
|
||||||
|
|
||||||
m_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handler for GPU crash dump callbacks from Nsight Aftermath
|
|
||||||
void GpuCrashTracker::OnCrashDump(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize)
|
|
||||||
{
|
|
||||||
// Make sure only one thread at a time...
|
|
||||||
std::scoped_lock<std::mutex> lock(m_mutex);
|
|
||||||
|
|
||||||
// Write to file for later in-depth analysis with Nsight Graphics.
|
|
||||||
WriteGpuCrashDumpToFile(pGpuCrashDump, gpuCrashDumpSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handler for shader debug information callbacks
|
|
||||||
void GpuCrashTracker::OnShaderDebugInfo(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize)
|
|
||||||
{
|
|
||||||
// Make sure only one thread at a time...
|
|
||||||
std::scoped_lock<std::mutex> lock(m_mutex);
|
|
||||||
|
|
||||||
// Get shader debug information identifier
|
|
||||||
GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier = {};
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetShaderDebugInfoIdentifier(
|
|
||||||
GFSDK_Aftermath_Version_API,
|
|
||||||
pShaderDebugInfo,
|
|
||||||
shaderDebugInfoSize,
|
|
||||||
&identifier));
|
|
||||||
|
|
||||||
// Store information for decoding of GPU crash dumps with shader address mapping
|
|
||||||
// from within the application.
|
|
||||||
std::vector<uint8_t> data((uint8_t*)pShaderDebugInfo, (uint8_t*)pShaderDebugInfo + shaderDebugInfoSize);
|
|
||||||
m_shaderDebugInfo[identifier].swap(data);
|
|
||||||
|
|
||||||
// Write to file for later in-depth analysis of crash dumps with Nsight Graphics
|
|
||||||
WriteShaderDebugInformationToFile(identifier, pShaderDebugInfo, shaderDebugInfoSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handler for GPU crash dump description callbacks
|
|
||||||
void GpuCrashTracker::OnDescription(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription)
|
|
||||||
{
|
|
||||||
// Add some basic description about the crash. This is called after the GPU crash happens, but before
|
|
||||||
// the actual GPU crash dump callback. The provided data is included in the crash dump and can be
|
|
||||||
// retrieved using GFSDK_Aftermath_GpuCrashDump_GetDescription().
|
|
||||||
addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName, "VkHelloNsightAftermath");
|
|
||||||
addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationVersion, "v1.0");
|
|
||||||
addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined, "This is a GPU crash dump example.");
|
|
||||||
addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined + 1, "Engine State: Rendering.");
|
|
||||||
addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined + 2, "More user-defined information...");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper for writing a GPU crash dump to a file
|
|
||||||
void GpuCrashTracker::WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize)
|
|
||||||
{
|
|
||||||
// Create a GPU crash dump decoder object for the GPU crash dump.
|
|
||||||
GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {};
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_CreateDecoder(
|
|
||||||
GFSDK_Aftermath_Version_API,
|
|
||||||
pGpuCrashDump,
|
|
||||||
gpuCrashDumpSize,
|
|
||||||
&decoder));
|
|
||||||
|
|
||||||
// Use the decoder object to read basic information, like application
|
|
||||||
// name, PID, etc. from the GPU crash dump.
|
|
||||||
GFSDK_Aftermath_GpuCrashDump_BaseInfo baseInfo = {};
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetBaseInfo(decoder, &baseInfo));
|
|
||||||
|
|
||||||
// Use the decoder object to query the application name that was set
|
|
||||||
// in the GPU crash dump description.
|
|
||||||
uint32_t applicationNameLength = 0;
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize(
|
|
||||||
decoder,
|
|
||||||
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName,
|
|
||||||
&applicationNameLength));
|
|
||||||
|
|
||||||
std::vector<char> applicationName(applicationNameLength, '\0');
|
|
||||||
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetDescription(
|
|
||||||
decoder,
|
|
||||||
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName,
|
|
||||||
uint32_t(applicationName.size()),
|
|
||||||
applicationName.data()));
|
|
||||||
|
|
||||||
// Create a unique file name for writing the crash dump data to a file.
|
|
||||||
// Note: due to an Nsight Aftermath bug (will be fixed in an upcoming
|
|
||||||
// driver release) we may see redundant crash dumps. As a workaround,
|
|
||||||
// attach a unique count to each generated file name.
|
|
||||||
static int count = 0;
|
|
||||||
const std::string baseFileName =
|
|
||||||
std::string(applicationName.data())
|
|
||||||
+ "-"
|
|
||||||
+ std::to_string(baseInfo.pid)
|
|
||||||
+ "-"
|
|
||||||
+ std::to_string(++count);
|
|
||||||
|
|
||||||
// Write the the crash dump data to a file using the .nv-gpudmp extension
|
|
||||||
// registered with Nsight Graphics.
|
|
||||||
const std::string crashDumpFileName = baseFileName + ".nv-gpudmp";
|
|
||||||
std::ofstream dumpFile(crashDumpFileName, std::ios::out | std::ios::binary);
|
|
||||||
if (dumpFile)
|
|
||||||
{
|
|
||||||
dumpFile.write((const char*)pGpuCrashDump, gpuCrashDumpSize);
|
|
||||||
dumpFile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode the crash dump to a JSON string.
|
|
||||||
// Step 1: Generate the JSON and get the size.
|
|
||||||
uint32_t jsonSize = 0;
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GenerateJSON(
|
|
||||||
decoder,
|
|
||||||
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO,
|
|
||||||
GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE,
|
|
||||||
ShaderDebugInfoLookupCallback,
|
|
||||||
ShaderLookupCallback,
|
|
||||||
nullptr,
|
|
||||||
ShaderSourceDebugInfoLookupCallback,
|
|
||||||
this,
|
|
||||||
&jsonSize));
|
|
||||||
// Step 2: Allocate a buffer and fetch the generated JSON.
|
|
||||||
std::vector<char> json(jsonSize);
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetJSON(
|
|
||||||
decoder,
|
|
||||||
uint32_t(json.size()),
|
|
||||||
json.data()));
|
|
||||||
|
|
||||||
// Write the the crash dump data as JSON to a file.
|
|
||||||
const std::string jsonFileName = crashDumpFileName + ".json";
|
|
||||||
std::ofstream jsonFile(jsonFileName, std::ios::out | std::ios::binary);
|
|
||||||
if (jsonFile)
|
|
||||||
{
|
|
||||||
jsonFile.write(json.data(), json.size());
|
|
||||||
jsonFile.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroy the GPU crash dump decoder object.
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper for writing shader debug information to a file
|
|
||||||
void GpuCrashTracker::WriteShaderDebugInformationToFile(
|
|
||||||
GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier,
|
|
||||||
const void* pShaderDebugInfo,
|
|
||||||
const uint32_t shaderDebugInfoSize)
|
|
||||||
{
|
|
||||||
// Create a unique file name.
|
|
||||||
const std::string filePath = "shader-" + std::to_string(identifier) + ".nvdbg";
|
|
||||||
|
|
||||||
std::ofstream f(filePath, std::ios::out | std::ios::binary);
|
|
||||||
if (f)
|
|
||||||
{
|
|
||||||
f.write((const char*)pShaderDebugInfo, shaderDebugInfoSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handler for shader debug information lookup callbacks.
|
|
||||||
// This is used by the JSON decoder for mapping shader instruction
|
|
||||||
// addresses to DXIL lines or HLSl source lines.
|
|
||||||
void GpuCrashTracker::OnShaderDebugInfoLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const
|
|
||||||
{
|
|
||||||
// Search the list of shader debug information blobs received earlier.
|
|
||||||
auto i_debugInfo = m_shaderDebugInfo.find(identifier);
|
|
||||||
if (i_debugInfo == m_shaderDebugInfo.end())
|
|
||||||
{
|
|
||||||
// Early exit, nothing found. No need to call setShaderDebugInfo.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let the GPU crash dump decoder know about the shader debug information
|
|
||||||
// that was found.
|
|
||||||
setShaderDebugInfo(i_debugInfo->second.data(), uint32_t(i_debugInfo->second.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handler for shader lookup callbacks.
|
|
||||||
// This is used by the JSON decoder for mapping shader instruction
|
|
||||||
// addresses to DXIL lines or HLSL source lines.
|
|
||||||
// NOTE: If the application loads stripped shader binaries (-Qstrip_debug),
|
|
||||||
// Aftermath will require access to both the stripped and the not stripped
|
|
||||||
// shader binaries.
|
|
||||||
void GpuCrashTracker::OnShaderLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderHash& shaderHash,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary) const
|
|
||||||
{
|
|
||||||
// Find shader binary data for the shader hash in the shader database.
|
|
||||||
std::vector<uint8_t> shaderBinary;
|
|
||||||
if (!m_shaderDatabase.FindShaderBinary(shaderHash, shaderBinary))
|
|
||||||
{
|
|
||||||
// Early exit, nothing found. No need to call setShaderBinary.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let the GPU crash dump decoder know about the shader data
|
|
||||||
// that was found.
|
|
||||||
setShaderBinary(shaderBinary.data(), uint32_t(shaderBinary.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handler for shader source debug info lookup callbacks.
|
|
||||||
// This is used by the JSON decoder for mapping shader instruction addresses to
|
|
||||||
// HLSL source lines, if the shaders used by the application were compiled with
|
|
||||||
// separate debug info data files.
|
|
||||||
void GpuCrashTracker::OnShaderSourceDebugInfoLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugName& shaderDebugName,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary) const
|
|
||||||
{
|
|
||||||
// Find source debug info for the shader DebugName in the shader database.
|
|
||||||
std::vector<uint8_t> shaderBinary;
|
|
||||||
if (!m_shaderDatabase.FindShaderBinaryWithDebugData(shaderDebugName, shaderBinary))
|
|
||||||
{
|
|
||||||
// Early exit, nothing found. No need to call setShaderBinary.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let the GPU crash dump decoder know about the shader debug data that was
|
|
||||||
// found.
|
|
||||||
setShaderBinary(shaderBinary.data(), uint32_t(shaderBinary.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback wrapper for OnCrashDump
|
|
||||||
void GpuCrashTracker::GpuCrashDumpCallback(
|
|
||||||
const void* pGpuCrashDump,
|
|
||||||
const uint32_t gpuCrashDumpSize,
|
|
||||||
void* pUserData)
|
|
||||||
{
|
|
||||||
GpuCrashTracker* pGpuCrashTracker = reinterpret_cast<GpuCrashTracker*>(pUserData);
|
|
||||||
pGpuCrashTracker->OnCrashDump(pGpuCrashDump, gpuCrashDumpSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback wrapper for OnShaderDebugInfo
|
|
||||||
void GpuCrashTracker::ShaderDebugInfoCallback(
|
|
||||||
const void* pShaderDebugInfo,
|
|
||||||
const uint32_t shaderDebugInfoSize,
|
|
||||||
void* pUserData)
|
|
||||||
{
|
|
||||||
GpuCrashTracker* pGpuCrashTracker = reinterpret_cast<GpuCrashTracker*>(pUserData);
|
|
||||||
pGpuCrashTracker->OnShaderDebugInfo(pShaderDebugInfo, shaderDebugInfoSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback wrapper for OnDescription
|
|
||||||
void GpuCrashTracker::CrashDumpDescriptionCallback(
|
|
||||||
PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription,
|
|
||||||
void* pUserData)
|
|
||||||
{
|
|
||||||
GpuCrashTracker* pGpuCrashTracker = reinterpret_cast<GpuCrashTracker*>(pUserData);
|
|
||||||
pGpuCrashTracker->OnDescription(addDescription);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback wrapper for OnShaderDebugInfoLookup
|
|
||||||
void GpuCrashTracker::ShaderDebugInfoLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderDebugInfo,
|
|
||||||
void* pUserData)
|
|
||||||
{
|
|
||||||
GpuCrashTracker* pGpuCrashTracker = reinterpret_cast<GpuCrashTracker*>(pUserData);
|
|
||||||
pGpuCrashTracker->OnShaderDebugInfoLookup(*pIdentifier, setShaderDebugInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback wrapper for OnShaderLookup
|
|
||||||
void GpuCrashTracker::ShaderLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderHash* pShaderHash,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary,
|
|
||||||
void* pUserData)
|
|
||||||
{
|
|
||||||
GpuCrashTracker* pGpuCrashTracker = reinterpret_cast<GpuCrashTracker*>(pUserData);
|
|
||||||
pGpuCrashTracker->OnShaderLookup(*pShaderHash, setShaderBinary);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static callback wrapper for OnShaderSourceDebugInfoLookup
|
|
||||||
void GpuCrashTracker::ShaderSourceDebugInfoLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugName* pShaderDebugName,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary,
|
|
||||||
void* pUserData)
|
|
||||||
{
|
|
||||||
GpuCrashTracker* pGpuCrashTracker = reinterpret_cast<GpuCrashTracker*>(pUserData);
|
|
||||||
pGpuCrashTracker->OnShaderSourceDebugInfoLookup(*pShaderDebugName, setShaderBinary);
|
|
||||||
}
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
//*********************************************************
|
|
||||||
//
|
|
||||||
// Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "NsightAftermathHelpers.h"
|
|
||||||
#include "NsightAftermathShaderDatabase.h"
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Implements GPU crash dump tracking using the Nsight
|
|
||||||
// Aftermath API.
|
|
||||||
//
|
|
||||||
class GpuCrashTracker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GpuCrashTracker();
|
|
||||||
~GpuCrashTracker();
|
|
||||||
|
|
||||||
// Initialize the GPU crash dump tracker.
|
|
||||||
void Initialize();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Callback handlers for GPU crash dumps and related data.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Handler for GPU crash dump callbacks.
|
|
||||||
void OnCrashDump(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize);
|
|
||||||
|
|
||||||
// Handler for shader debug information callbacks.
|
|
||||||
void OnShaderDebugInfo(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize);
|
|
||||||
|
|
||||||
// Handler for GPU crash dump description callbacks.
|
|
||||||
void OnDescription(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription);
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Helpers for writing a GPU crash dump and debug information
|
|
||||||
// data to files.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Helper for writing a GPU crash dump to a file.
|
|
||||||
void WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize);
|
|
||||||
|
|
||||||
// Helper for writing shader debug information to a file
|
|
||||||
void WriteShaderDebugInformationToFile(
|
|
||||||
GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier,
|
|
||||||
const void* pShaderDebugInfo,
|
|
||||||
const uint32_t shaderDebugInfoSize);
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Helpers for decoding GPU crash dump to JSON.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Handler for shader debug info lookup callbacks.
|
|
||||||
void OnShaderDebugInfoLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const;
|
|
||||||
|
|
||||||
// Handler for shader lookup callbacks.
|
|
||||||
void OnShaderLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderHash& shaderHash,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary) const;
|
|
||||||
|
|
||||||
// Handler for shader instructions lookup callbacks.
|
|
||||||
void OnShaderInstructionsLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderInstructionsHash& shaderInstructionsHash,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary) const;
|
|
||||||
|
|
||||||
// Handler for shader source debug info lookup callbacks.
|
|
||||||
void OnShaderSourceDebugInfoLookup(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugName& shaderDebugName,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary) const;
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Static callback wrappers.
|
|
||||||
//
|
|
||||||
|
|
||||||
// GPU crash dump callback.
|
|
||||||
static void GpuCrashDumpCallback(
|
|
||||||
const void* pGpuCrashDump,
|
|
||||||
const uint32_t gpuCrashDumpSize,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
// Shader debug information callback.
|
|
||||||
static void ShaderDebugInfoCallback(
|
|
||||||
const void* pShaderDebugInfo,
|
|
||||||
const uint32_t shaderDebugInfoSize,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
// GPU crash dump description callback.
|
|
||||||
static void CrashDumpDescriptionCallback(
|
|
||||||
PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
// Shader debug information lookup callback.
|
|
||||||
static void ShaderDebugInfoLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderDebugInfo,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
// Shader lookup callback.
|
|
||||||
static void ShaderLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderHash* pShaderHash,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
// Shader instructions lookup callback.
|
|
||||||
static void ShaderInstructionsLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderInstructionsHash* pShaderInstructionsHash,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
// Shader source debug info lookup callback.
|
|
||||||
static void ShaderSourceDebugInfoLookupCallback(
|
|
||||||
const GFSDK_Aftermath_ShaderDebugName* pShaderDebugName,
|
|
||||||
PFN_GFSDK_Aftermath_SetData setShaderBinary,
|
|
||||||
void* pUserData);
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// GPU crash tracker state.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Is the GPU crash dump tracker initialized?
|
|
||||||
bool m_initialized;
|
|
||||||
|
|
||||||
// For thread-safe access of GPU crash tracker state.
|
|
||||||
mutable std::mutex m_mutex;
|
|
||||||
|
|
||||||
// List of Shader Debug Information by ShaderDebugInfoIdentifier.
|
|
||||||
std::map<GFSDK_Aftermath_ShaderDebugInfoIdentifier, std::vector<uint8_t>> m_shaderDebugInfo;
|
|
||||||
|
|
||||||
// The mock shader database.
|
|
||||||
ShaderDatabase m_shaderDatabase;
|
|
||||||
};
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
//*********************************************************
|
|
||||||
//
|
|
||||||
// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <iomanip>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <vulkan/vulkan.hpp>
|
|
||||||
#include "GFSDK_Aftermath.h"
|
|
||||||
#include "GFSDK_Aftermath_GpuCrashDump.h"
|
|
||||||
#include "GFSDK_Aftermath_GpuCrashDumpDecoding.h"
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Some std::to_string overloads for some Nsight Aftermath
|
|
||||||
// API types.
|
|
||||||
//
|
|
||||||
|
|
||||||
namespace std
|
|
||||||
{
|
|
||||||
template<typename T>
|
|
||||||
inline std::string to_hex_string(T n)
|
|
||||||
{
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::setfill('0') << std::setw(2 * sizeof(T)) << std::hex << n;
|
|
||||||
return stream.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string to_string(GFSDK_Aftermath_Result result)
|
|
||||||
{
|
|
||||||
return std::string("0x") + to_hex_string(static_cast<uint32_t>(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string to_string(const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier)
|
|
||||||
{
|
|
||||||
return to_hex_string(identifier.id[0]) + "-" + to_hex_string(identifier.id[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string to_string(const GFSDK_Aftermath_ShaderHash& hash)
|
|
||||||
{
|
|
||||||
return to_hex_string(hash.hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string to_string(const GFSDK_Aftermath_ShaderInstructionsHash& hash)
|
|
||||||
{
|
|
||||||
return to_hex_string(hash.hash) + "-" + to_hex_string(hash.hash);
|
|
||||||
}
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Helper for comparing shader hashes and debug info identifier.
|
|
||||||
//
|
|
||||||
|
|
||||||
// Helper for comparing GFSDK_Aftermath_ShaderDebugInfoIdentifier.
|
|
||||||
inline bool operator<(const GFSDK_Aftermath_ShaderDebugInfoIdentifier& lhs, const GFSDK_Aftermath_ShaderDebugInfoIdentifier& rhs)
|
|
||||||
{
|
|
||||||
if (lhs.id[0] == rhs.id[0])
|
|
||||||
{
|
|
||||||
return lhs.id[1] < rhs.id[1];
|
|
||||||
}
|
|
||||||
return lhs.id[0] < rhs.id[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper for comparing GFSDK_Aftermath_ShaderHash.
|
|
||||||
inline bool operator<(const GFSDK_Aftermath_ShaderHash& lhs, const GFSDK_Aftermath_ShaderHash& rhs)
|
|
||||||
{
|
|
||||||
return lhs.hash < rhs.hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper for comparing GFSDK_Aftermath_ShaderInstructionsHash.
|
|
||||||
inline bool operator<(const GFSDK_Aftermath_ShaderInstructionsHash& lhs, const GFSDK_Aftermath_ShaderInstructionsHash& rhs)
|
|
||||||
{
|
|
||||||
return lhs.hash < rhs.hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper for comparing GFSDK_Aftermath_ShaderDebugName.
|
|
||||||
inline bool operator<(const GFSDK_Aftermath_ShaderDebugName& lhs, const GFSDK_Aftermath_ShaderDebugName& rhs)
|
|
||||||
{
|
|
||||||
return strncmp(lhs.name, rhs.name, sizeof(lhs.name)) < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Helper for checking Nsight Aftermath failures.
|
|
||||||
//
|
|
||||||
|
|
||||||
inline std::string AftermathErrorMessage(GFSDK_Aftermath_Result result)
|
|
||||||
{
|
|
||||||
switch (result)
|
|
||||||
{
|
|
||||||
case GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported:
|
|
||||||
return "Unsupported driver version - requires a recent NVIDIA R445 display driver or newer.";
|
|
||||||
default:
|
|
||||||
return "Aftermath Error 0x" + std::to_hex_string(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper macro for checking Nsight Aftermath results and throwing exception
|
|
||||||
// in case of a failure.
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define AFTERMATH_CHECK_ERROR(FC) \
|
|
||||||
[&]() { \
|
|
||||||
GFSDK_Aftermath_Result _result = FC; \
|
|
||||||
if (!GFSDK_Aftermath_SUCCEED(_result)) \
|
|
||||||
{ \
|
|
||||||
std::cout << AftermathErrorMessage(_result).c_str() << std::endl; \
|
|
||||||
exit(1); \
|
|
||||||
} \
|
|
||||||
}()
|
|
||||||
#else
|
|
||||||
#define AFTERMATH_CHECK_ERROR(FC) \
|
|
||||||
[&]() { \
|
|
||||||
GFSDK_Aftermath_Result _result = FC; \
|
|
||||||
if (!GFSDK_Aftermath_SUCCEED(_result)) \
|
|
||||||
{ \
|
|
||||||
printf("%s\n", AftermathErrorMessage(_result).c_str()); \
|
|
||||||
fflush(stdout); \
|
|
||||||
exit(1); \
|
|
||||||
} \
|
|
||||||
}()
|
|
||||||
#endif
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
//*********************************************************
|
|
||||||
//
|
|
||||||
// Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
#include "NsightAftermathShaderDatabase.h"
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// ShaderDatabase implementation
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
ShaderDatabase::ShaderDatabase()
|
|
||||||
: m_shaderBinaries()
|
|
||||||
, m_shaderBinariesWithDebugInfo()
|
|
||||||
{
|
|
||||||
// Add shader binaries to database
|
|
||||||
AddShaderBinary("cube.vert.spirv");
|
|
||||||
AddShaderBinary("cube.frag.spirv");
|
|
||||||
|
|
||||||
// Add the not stripped shader binaries to the database, too.
|
|
||||||
AddShaderBinaryWithDebugInfo("cube.vert.spirv", "cube.vert.full.spirv");
|
|
||||||
AddShaderBinaryWithDebugInfo("cube.frag.spirv", "cube.frag.full.spirv");
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderDatabase::~ShaderDatabase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ShaderDatabase::ReadFile(const char* filename, std::vector<uint8_t>& data)
|
|
||||||
{
|
|
||||||
std::ifstream fs(filename, std::ios::in | std::ios::binary);
|
|
||||||
if (!fs)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.seekg(0, std::ios::end);
|
|
||||||
data.resize(fs.tellg());
|
|
||||||
fs.seekg(0, std::ios::beg);
|
|
||||||
fs.read(reinterpret_cast<char*>(data.data()), data.size());
|
|
||||||
fs.close();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShaderDatabase::AddShaderBinary(const char* shaderFilePath)
|
|
||||||
{
|
|
||||||
// Read the shader binary code from the file
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
if (!ReadFile(shaderFilePath, data))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create shader hash for the shader
|
|
||||||
const GFSDK_Aftermath_SpirvCode shader{ data.data(), uint32_t(data.size()) };
|
|
||||||
GFSDK_Aftermath_ShaderHash shaderHash;
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetShaderHashSpirv(
|
|
||||||
GFSDK_Aftermath_Version_API,
|
|
||||||
&shader,
|
|
||||||
&shaderHash));
|
|
||||||
|
|
||||||
// Store the data for shader mapping when decoding GPU crash dumps.
|
|
||||||
// cf. FindShaderBinary()
|
|
||||||
m_shaderBinaries[shaderHash].swap(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShaderDatabase::AddShaderBinaryWithDebugInfo(const char* strippedShaderFilePath, const char* shaderFilePath)
|
|
||||||
{
|
|
||||||
// Read the shader debug data from the file
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
if (!ReadFile(shaderFilePath, data))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::vector<uint8_t> strippedData;
|
|
||||||
if (!ReadFile(strippedShaderFilePath, strippedData))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate shader debug name.
|
|
||||||
GFSDK_Aftermath_ShaderDebugName debugName;
|
|
||||||
const GFSDK_Aftermath_SpirvCode shader{ data.data(), uint32_t(data.size()) };
|
|
||||||
const GFSDK_Aftermath_SpirvCode strippedShader{ strippedData.data(), uint32_t(strippedData.size()) };
|
|
||||||
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetShaderDebugNameSpirv(
|
|
||||||
GFSDK_Aftermath_Version_API,
|
|
||||||
&shader,
|
|
||||||
&strippedShader,
|
|
||||||
&debugName));
|
|
||||||
|
|
||||||
// Store the data for shader instruction address mapping when decoding GPU crash dumps.
|
|
||||||
// cf. FindShaderBinaryWithDebugData()
|
|
||||||
m_shaderBinariesWithDebugInfo[debugName].swap(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a shader binary by shader hash.
|
|
||||||
bool ShaderDatabase::FindShaderBinary(const GFSDK_Aftermath_ShaderHash& shaderHash, std::vector<uint8_t>& shader) const
|
|
||||||
{
|
|
||||||
// Find shader binary data for the shader hash
|
|
||||||
auto i_shader = m_shaderBinaries.find(shaderHash);
|
|
||||||
if (i_shader == m_shaderBinaries.end())
|
|
||||||
{
|
|
||||||
// Nothing found.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
shader = i_shader->second;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a shader binary with debug information by shader debug name.
|
|
||||||
bool ShaderDatabase::FindShaderBinaryWithDebugData(const GFSDK_Aftermath_ShaderDebugName& shaderDebugName, std::vector<uint8_t>& shader) const
|
|
||||||
{
|
|
||||||
// Find shader binary for the shader debug name.
|
|
||||||
auto i_shader = m_shaderBinariesWithDebugInfo.find(shaderDebugName);
|
|
||||||
if (i_shader == m_shaderBinariesWithDebugInfo.end())
|
|
||||||
{
|
|
||||||
// Nothing found.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
shader = i_shader->second;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
//*********************************************************
|
|
||||||
//
|
|
||||||
// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
//*********************************************************
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "NsightAftermathHelpers.h"
|
|
||||||
|
|
||||||
//*********************************************************
|
|
||||||
// Implements a very simple shader database to help demonstrate
|
|
||||||
// how to use the Nsight Aftermath GPU crash dump decoder API.
|
|
||||||
//
|
|
||||||
// In a real world scenario this would be part of an offline
|
|
||||||
// analysis tool. This is for demonstration purposes only!
|
|
||||||
//
|
|
||||||
class ShaderDatabase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ShaderDatabase();
|
|
||||||
~ShaderDatabase();
|
|
||||||
|
|
||||||
// Find a shader bytecode binary by shader hash.
|
|
||||||
bool FindShaderBinary(const GFSDK_Aftermath_ShaderHash& shaderHash, std::vector<uint8_t>& shader) const;
|
|
||||||
|
|
||||||
// Find a source shader debug info by shader debug name generated by the DXC compiler.
|
|
||||||
bool FindShaderBinaryWithDebugData(const GFSDK_Aftermath_ShaderDebugName& shaderDebugName, std::vector<uint8_t>& shader) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void AddShaderBinary(const char* shaderFilePath);
|
|
||||||
void AddShaderBinaryWithDebugInfo(const char* strippedShaderFilePath, const char* shaderFilePath);
|
|
||||||
|
|
||||||
static bool ReadFile(const char* filename, std::vector<uint8_t>& data);
|
|
||||||
|
|
||||||
// List of shader binaries by ShaderHash.
|
|
||||||
std::map<GFSDK_Aftermath_ShaderHash, std::vector<uint8_t>> m_shaderBinaries;
|
|
||||||
|
|
||||||
// List of available shader binaries with source debug information by ShaderDebugName.
|
|
||||||
std::map<GFSDK_Aftermath_ShaderDebugName, std::vector<uint8_t>> m_shaderBinariesWithDebugInfo;
|
|
||||||
};
|
|
||||||
@@ -53,9 +53,7 @@ void DescriptorLayout::create()
|
|||||||
|
|
||||||
allocator = new DescriptorAllocator(graphics, *this);
|
allocator = new DescriptorAllocator(graphics, *this);
|
||||||
|
|
||||||
boost::crc_32_type result;
|
hash = CRC::Calculate(bindings.data(), sizeof(VkDescriptorSetLayoutBinding) * bindings.size(), CRC::CRC_32());
|
||||||
result.process_bytes(bindings.data(), sizeof(VkDescriptorSetLayoutBinding) * bindings.size());
|
|
||||||
hash = result.checksum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineLayout::~PipelineLayout()
|
PipelineLayout::~PipelineLayout()
|
||||||
@@ -96,10 +94,8 @@ void PipelineLayout::create()
|
|||||||
createInfo.pushConstantRangeCount = (uint32)vkPushConstants.size();
|
createInfo.pushConstantRangeCount = (uint32)vkPushConstants.size();
|
||||||
createInfo.pPushConstantRanges = vkPushConstants.data();
|
createInfo.pPushConstantRanges = vkPushConstants.data();
|
||||||
|
|
||||||
boost::crc_32_type result;
|
layoutHash = CRC::Calculate(createInfo.pPushConstantRanges, sizeof(VkPushConstantRange) * createInfo.pushConstantRangeCount, CRC::CRC_32());
|
||||||
result.process_bytes(createInfo.pPushConstantRanges, sizeof(VkPushConstantRange) * createInfo.pushConstantRangeCount);
|
layoutHash = CRC::Calculate(createInfo.pSetLayouts, sizeof(VkDescriptorSetLayout) * createInfo.setLayoutCount, CRC::CRC_32(), layoutHash);
|
||||||
result.process_bytes(createInfo.pSetLayouts, sizeof(VkDescriptorSetLayout) * createInfo.setLayoutCount);
|
|
||||||
layoutHash = result.checksum();
|
|
||||||
|
|
||||||
if(layoutCache[layoutHash] != VK_NULL_HANDLE)
|
if(layoutCache[layoutHash] != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::PRende
|
|||||||
|
|
||||||
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
|
VK_CHECK(vkCreateFramebuffer(graphics->getDevice(), &createInfo, nullptr, &handle));
|
||||||
|
|
||||||
boost::crc_32_type result;
|
hash = CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
|
||||||
result.process_bytes(&description, sizeof(FramebufferDescription));
|
|
||||||
hash = result.checksum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Framebuffer::~Framebuffer()
|
Framebuffer::~Framebuffer()
|
||||||
|
|||||||
@@ -417,8 +417,6 @@ void Graphics::setupDebugCallback()
|
|||||||
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT);
|
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT);
|
||||||
|
|
||||||
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
||||||
|
|
||||||
crashTracker.Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::pickPhysicalDevice()
|
void Graphics::pickPhysicalDevice()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "VulkanGraphicsResources.h"
|
#include "VulkanGraphicsResources.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "NsightAftermathGpuCrashTracker.h"
|
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -100,7 +99,6 @@ protected:
|
|||||||
Map<uint32, PFramebuffer> allocatedFramebuffers;
|
Map<uint32, PFramebuffer> allocatedFramebuffers;
|
||||||
PAllocator allocator;
|
PAllocator allocator;
|
||||||
PStagingManager stagingManager;
|
PStagingManager stagingManager;
|
||||||
GpuCrashTracker crashTracker;
|
|
||||||
|
|
||||||
friend class Window;
|
friend class Window;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -318,9 +318,7 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
PPipelineLayout layout = gfxInfo.pipelineLayout.cast<PipelineLayout>();
|
PPipelineLayout layout = gfxInfo.pipelineLayout.cast<PipelineLayout>();
|
||||||
hashStruct.pipelineLayoutHash = layout->getHash();
|
hashStruct.pipelineLayoutHash = layout->getHash();
|
||||||
|
|
||||||
boost::crc_32_type crc;
|
uint32 hash = CRC::Calculate(&hashStruct, sizeof(PipelineCreateHashStruct), CRC::CRC_32());
|
||||||
crc.process_bytes(&hashStruct, sizeof(PipelineCreateHashStruct));
|
|
||||||
uint32 hash = crc.checksum();
|
|
||||||
VkPipeline pipelineHandle;
|
VkPipeline pipelineHandle;
|
||||||
|
|
||||||
std::scoped_lock lock(createdPipelinesLock);
|
std::scoped_lock lock(createdPipelinesLock);
|
||||||
|
|||||||
@@ -142,7 +142,5 @@ uint32 RenderPass::getFramebufferHash()
|
|||||||
PTexture2D tex = layout->depthAttachment->getTexture().cast<Texture2D>();
|
PTexture2D tex = layout->depthAttachment->getTexture().cast<Texture2D>();
|
||||||
description.depthAttachment = tex->getView();
|
description.depthAttachment = tex->getView();
|
||||||
}
|
}
|
||||||
boost::crc_32_type result;
|
return CRC::Calculate(&description, sizeof(FramebufferDescription), CRC::CRC_32());
|
||||||
result.process_bytes(&description, sizeof(FramebufferDescription));
|
|
||||||
return result.checksum();
|
|
||||||
}
|
}
|
||||||
@@ -155,8 +155,6 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
|||||||
moduleInfo.pCode = (uint32_t*)kernelBlob->getBufferPointer();
|
moduleInfo.pCode = (uint32_t*)kernelBlob->getBufferPointer();
|
||||||
VK_CHECK(vkCreateShaderModule(graphics->getDevice(), &moduleInfo, nullptr, &module));
|
VK_CHECK(vkCreateShaderModule(graphics->getDevice(), &moduleInfo, nullptr, &module));
|
||||||
|
|
||||||
boost::crc_32_type result;
|
hash = CRC::Calculate(entryPointName.data(), entryPointName.size(), CRC::CRC_32());
|
||||||
result.process_bytes(entryPointName.data(), entryPointName.size());
|
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash);
|
||||||
result.process_bytes(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize());
|
|
||||||
hash = result.checksum();
|
|
||||||
}
|
}
|
||||||
@@ -6,3 +6,11 @@ target_sources(Engine
|
|||||||
MaterialAsset.cpp
|
MaterialAsset.cpp
|
||||||
ShaderExpression.h
|
ShaderExpression.h
|
||||||
ShaderExpression.cpp)
|
ShaderExpression.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
BRDF.h
|
||||||
|
MaterialAsset.h
|
||||||
|
ShaderExpression.h)
|
||||||
|
|
||||||
|
|||||||
@@ -6,3 +6,11 @@ target_sources(Engine
|
|||||||
Transform.cpp
|
Transform.cpp
|
||||||
Vector.h
|
Vector.h
|
||||||
Vector.cpp)
|
Vector.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Math.h
|
||||||
|
Matrix.h
|
||||||
|
Transform.h
|
||||||
|
Vector.h)
|
||||||
|
|||||||
@@ -263,12 +263,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
RefObject<T, Deleter> *object;
|
RefObject<T, Deleter> *object;
|
||||||
friend class boost::serialization::access;
|
|
||||||
template<class Archive>
|
|
||||||
void serialize(Archive& ar, const unsigned int)
|
|
||||||
{
|
|
||||||
ar & *object->getHandle();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class UniquePtr
|
class UniquePtr
|
||||||
@@ -326,12 +320,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
T *handle;
|
T *handle;
|
||||||
friend class boost::serialization::access;
|
|
||||||
template<class Archive>
|
|
||||||
void serialize(Archive& ar, const unsigned int version)
|
|
||||||
{
|
|
||||||
ar & *handle;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
//A weak pointer has no ownership over an object and thus cant delete it
|
//A weak pointer has no ownership over an object and thus cant delete it
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
target_sources(Engine
|
target_sources(Engine
|
||||||
PRIVATE
|
PRIVATE
|
||||||
Util.h
|
Util.h
|
||||||
Scene.cpp
|
Scene.cpp
|
||||||
Scene.h)
|
Scene.h)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Util.h
|
||||||
|
Scene.h)
|
||||||
@@ -3,3 +3,9 @@ target_sources(Engine
|
|||||||
Executor.h
|
Executor.h
|
||||||
Executor.cpp
|
Executor.cpp
|
||||||
SystemBase.h)
|
SystemBase.h)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Executor.h
|
||||||
|
SystemBase.h)
|
||||||
@@ -348,7 +348,7 @@ public:
|
|||||||
std::scoped_lock lock(mainJobLock);
|
std::scoped_lock lock(mainJobLock);
|
||||||
for(auto job : jobs)
|
for(auto job : jobs)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(job.promise->promiseLock);
|
std::scoped_lock l(job.promise->promiseLock);
|
||||||
job.promise->validate();
|
job.promise->validate();
|
||||||
job.promise->state = JobPromiseBase<true>::State::SCHEDULED;
|
job.promise->state = JobPromiseBase<true>::State::SCHEDULED;
|
||||||
mainJobs.add(job);
|
mainJobs.add(job);
|
||||||
@@ -362,7 +362,7 @@ public:
|
|||||||
std::scoped_lock lock(jobQueueLock);
|
std::scoped_lock lock(jobQueueLock);
|
||||||
for(auto job : jobs)
|
for(auto job : jobs)
|
||||||
{
|
{
|
||||||
std::scoped_lock lock(job.promise->promiseLock);
|
std::scoped_lock l(job.promise->promiseLock);
|
||||||
job.promise->validate();
|
job.promise->validate();
|
||||||
job.promise->state = JobPromiseBase<false>::State::SCHEDULED;
|
job.promise->state = JobPromiseBase<false>::State::SCHEDULED;
|
||||||
jobQueue.add(job);
|
jobQueue.add(job);
|
||||||
|
|||||||
@@ -11,4 +11,14 @@ target_sources(Engine
|
|||||||
VerticalLayout.h
|
VerticalLayout.h
|
||||||
VerticalLayout.cpp)
|
VerticalLayout.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
HorizontalLayout.h
|
||||||
|
Layout.h
|
||||||
|
RenderHierarchy.h
|
||||||
|
System.h
|
||||||
|
VerticalLayout.h)
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(Elements/)
|
add_subdirectory(Elements/)
|
||||||
@@ -8,3 +8,11 @@ target_sources(Engine
|
|||||||
Label.cpp
|
Label.cpp
|
||||||
Panel.h
|
Panel.h
|
||||||
Panel.cpp)
|
Panel.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
Button.h
|
||||||
|
Element.h
|
||||||
|
Label.h
|
||||||
|
Panel.h)
|
||||||
|
|||||||
@@ -6,3 +6,10 @@ target_sources(Engine
|
|||||||
Window.h
|
Window.h
|
||||||
WindowManager.h
|
WindowManager.h
|
||||||
WindowManager.cpp)
|
WindowManager.cpp)
|
||||||
|
|
||||||
|
target_sources(Engine
|
||||||
|
PUBLIC FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
View.h
|
||||||
|
Window.h
|
||||||
|
WindowManager.h)
|
||||||
|
|||||||
+1
-2
@@ -7,9 +7,8 @@ add_subdirectory(Engine/)
|
|||||||
|
|
||||||
target_include_directories(Seele_unit_tests PRIVATE ${ENGINE_ROOT})
|
target_include_directories(Seele_unit_tests PRIVATE ${ENGINE_ROOT})
|
||||||
|
|
||||||
|
target_link_libraries(Seele_unit_tests PRIVATE Engine)
|
||||||
target_link_libraries(Seele_unit_tests PRIVATE Boost::unit_test_framework)
|
target_link_libraries(Seele_unit_tests PRIVATE Boost::unit_test_framework)
|
||||||
target_link_libraries(Seele_unit_tests PRIVATE Vulkan::Vulkan)
|
|
||||||
target_link_libraries(Seele_unit_tests PRIVATE nsam)
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_compile_definitions(Seele_unit_tests PRIVATE -DBOOST_TEST_DYN_LINK)
|
target_compile_definitions(Seele_unit_tests PRIVATE -DBOOST_TEST_DYN_LINK)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(remove_keeporder)
|
|||||||
BOOST_AUTO_TEST_CASE(find)
|
BOOST_AUTO_TEST_CASE(find)
|
||||||
{
|
{
|
||||||
Array<uint8> array;
|
Array<uint8> array;
|
||||||
for(uint32 i = 0; i < 100; ++i)
|
for(uint8 i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
array.add(i);
|
array.add(i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
using namespace Seele::Math;
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(VectorParse)
|
BOOST_AUTO_TEST_SUITE(VectorParse)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user