diff --git a/.gitmodules b/.gitmodules index c3667f0301..74d12b8c6e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -121,3 +121,6 @@ [submodule "3rdparty/gtl"] path = 3rdparty/gtl url = https://github.com/greg7mdp/gtl.git +[submodule "3rdparty/Vulkan-Tools"] + path = 3rdparty/Vulkan-Tools + url = git@github.com:Devsh-Graphics-Programming/Vulkan-Tools.git diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index a83dc936ca..a3bf95ce53 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -451,6 +451,11 @@ if (NBL_BUILD_BULLET) set(BULLET_INCLUDE_PATH ${BULLET_INCLUDE_PATH} PARENT_SCOPE) endif() +add_library(Vulkan-Headers INTERFACE) +target_include_directories(Vulkan-Headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include") +add_library(Vulkan::Headers ALIAS Vulkan-Headers) +add_subdirectory(Vulkan-Tools/vulkaninfo vulkaninfo EXCLUDE_FROM_ALL) + # Final gather set(NBL_3RDPARTY_TARGETS lzma @@ -472,6 +477,7 @@ set(NBL_3RDPARTY_TARGETS SPIRV SPIRV-Tools-static # SPIRV-Tools-shared in case of SHARED lib SPIRV-Tools-opt + vulkaninfo Imath freetype ${NBL_MSDFGEN_TARGETS} diff --git a/3rdparty/Vulkan-Headers b/3rdparty/Vulkan-Headers index 234c4b7370..33d7f51258 160000 --- a/3rdparty/Vulkan-Headers +++ b/3rdparty/Vulkan-Headers @@ -1 +1 @@ -Subproject commit 234c4b7370a8ea3239a214c9e871e4b17c89f4ab +Subproject commit 33d7f512583b8de44d1b6384aa1cf482f92e53e9 diff --git a/3rdparty/Vulkan-Tools b/3rdparty/Vulkan-Tools new file mode 160000 index 0000000000..f3fc824f10 --- /dev/null +++ b/3rdparty/Vulkan-Tools @@ -0,0 +1 @@ +Subproject commit f3fc824f10d68b4d61398404403956d67c5c3e7e diff --git a/include/nbl/video/CVulkanConnection.h b/include/nbl/video/CVulkanConnection.h index c8d3882c50..d7177096ef 100644 --- a/include/nbl/video/CVulkanConnection.h +++ b/include/nbl/video/CVulkanConnection.h @@ -27,6 +27,8 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection inline IDebugCallback* getDebugCallback() const override {return m_debugCallback.get();} + void exportGpuProfile() const; + bool startCapture() override; bool endCapture() override; diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 935beffe2c..b4f70e9015 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -601,6 +601,11 @@ if (NBL_COMPILE_WITH_CUDA) target_include_directories(Nabla PUBLIC ${CUDAToolkit_INCLUDE_DIRS}) endif() +# vulkaninfo +if (NOT VULKANINFO_BUILD_EXECUTABLE) + target_link_libraries(Nabla PRIVATE vulkaninfo) +endif() + # Include dirs for self target_include_directories(Nabla PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include" diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 3f1cb68380..d19d8d5b43 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -4,6 +4,8 @@ #include "nbl/video/CVulkanCommon.h" #include "nbl/video/debug/CVulkanDebugCallback.h" +#include "vulkaninfo/vulkaninfo.h" + // TODO: move inside `create` and call it LOG_FAIL and return nullptr #define LOG(logger, ...) if (logger) {logger->log(__VA_ARGS__);} @@ -306,6 +308,7 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ continue; } api->m_physicalDevices.emplace_back(std::move(device)); + // device enumeration } #undef LOF @@ -321,6 +324,13 @@ CVulkanConnection::~CVulkanConnection() vkDestroyInstance(m_vkInstance,nullptr); } +void CVulkanConnection::exportGpuProfile() const +{ + constexpr char arg1[] = "--json"; + char* argv = const_cast(arg1); + vulkaninfo(1, &argv); +} + bool CVulkanConnection::startCapture() { if (flag.test_and_set()) diff --git a/src/nbl/video/CVulkanPhysicalDevice.cpp b/src/nbl/video/CVulkanPhysicalDevice.cpp index 256b717f52..e0dad4039e 100644 --- a/src/nbl/video/CVulkanPhysicalDevice.cpp +++ b/src/nbl/video/CVulkanPhysicalDevice.cpp @@ -1,6 +1,8 @@ #include "nbl/video/CVulkanPhysicalDevice.h" #include "nbl/video/CVulkanLogicalDevice.h" +#include "nlohmann/json.hpp" // TODO/FIXME: this is probably a mess making, consult someone how to do it better. + namespace nbl::video { @@ -25,7 +27,6 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart } }); - auto& properties = initData.properties; auto& features = initData.features; // First call just with Vulkan 1.0 API because: @@ -1365,7 +1366,7 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart // bufferUsages.opticalFlowVector = anyFlag(bufferFeatures,VK_FORMAT_FEATURE_2_OPTICAL_FLOW_VECTOR_BIT_NV); // bufferUsages.opticalFlowCost = anyFlag(bufferFeatures,VK_FORMAT_FEATURE_2_OPTICAL_FLOW_COST_BIT_NV); } - + success = true; return std::unique_ptr(new CVulkanPhysicalDevice(std::move(initData),rdoc,vk_physicalDevice,std::move(availableFeatureSet))); }