diff --git a/.gitmodules b/.gitmodules index 6dd0644c13..8a04f82d9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -125,4 +125,7 @@ path = ci url = git@github.com:Devsh-Graphics-Programming/Nabla-CI.git branch = ditt - update = none \ No newline at end of file + update = none +[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 eac4158320..4ee86dcfcd 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -454,6 +454,10 @@ 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_subdirectory(Vulkan-Tools/vulkaninfo vulkaninfo EXCLUDE_FROM_ALL) + # Final gather set(NBL_3RDPARTY_TARGETS lzma @@ -475,6 +479,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..fc7c26a55f --- /dev/null +++ b/3rdparty/Vulkan-Tools @@ -0,0 +1 @@ +Subproject commit fc7c26a55f5bfe5a182cd9e333f470cf028a92cb diff --git a/examples_tests b/examples_tests index 2b4db21239..b4807ad1bd 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 2b4db2123918f380cc0a35f6889315a02f84ea73 +Subproject commit b4807ad1bd4e6bab9e01f2fd6ad624f799195744 diff --git a/include/nbl/video/CVulkanConnection.h b/include/nbl/video/CVulkanConnection.h index c8d3882c50..376000bb13 100644 --- a/include/nbl/video/CVulkanConnection.h +++ b/include/nbl/video/CVulkanConnection.h @@ -13,6 +13,8 @@ namespace nbl::video { +NBL_API2 int vulkaninfo(const std::span args); + class NBL_API2 CVulkanConnection final : public IAPIConnection { public: @@ -21,12 +23,15 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection core::smart_refctd_ptr&& logger, const SFeatures& featuresToEnable ); + static void exportGpuProfiles(); + inline VkInstance getInternalObject() const {return m_vkInstance;} inline E_API_TYPE getAPIType() const override {return EAT_VULKAN;} inline IDebugCallback* getDebugCallback() const override {return m_debugCallback.get();} + bool startCapture() override; bool endCapture() override; diff --git a/smoke/main.cpp b/smoke/main.cpp index efb09712a1..6fb0cb30b6 100644 --- a/smoke/main.cpp +++ b/smoke/main.cpp @@ -36,11 +36,16 @@ class Smoke final : public system::IApplicationFramework return false; } + nbl::video::vulkaninfo(); + return true; } void workLoopBody() override {} bool keepRunning() override { return false; } + +private: + smart_refctd_ptr m_api; }; NBL_MAIN_FUNC(Smoke) diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt old mode 100755 new mode 100644 index 6bf9e9abdd..d932715fe4 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -753,6 +753,13 @@ list(APPEND INTERFACE_BUILD_DEFINITIONS # TODO: private target_link_libraries(Nabla PUBLIC $) +# vulkaninfo +if (NBL_STATIC_BUILD) + target_link_libraries(Nabla PUBLIC $) +else() + target_link_libraries(Nabla PRIVATE $) +endif() + # NGFX if(TARGET ngfx) if(NBL_STATIC_BUILD) diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 3f1cb68380..2f5baf5ab6 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -7,6 +7,8 @@ // TODO: move inside `create` and call it LOG_FAIL and return nullptr #define LOG(logger, ...) if (logger) {logger->log(__VA_ARGS__);} +extern int vulkaninfo(const std::span); + namespace nbl::video { @@ -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 @@ -372,4 +375,17 @@ bool CVulkanConnection::endCapture() return true; } +void CVulkanConnection::exportGpuProfiles() +{ + for (size_t i = 0;; i++) + { + auto arg = "--json=" + std::to_string(i); + int code = ::vulkaninfo(std::array{ arg }); + if (code != 0) + break; + } +} + +NBL_API2 int vulkaninfo(const std::span args) { return ::vulkaninfo(args); } + } 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))); }