diff --git a/.github/workflows/build-nabla.yml b/.github/workflows/build-nabla.yml index e0447edfb0..8894e31c05 100644 --- a/.github/workflows/build-nabla.yml +++ b/.github/workflows/build-nabla.yml @@ -364,6 +364,13 @@ jobs: sparse-checkout: | smoke + - name: Download VulkanSDK + uses: humbletim/setup-vulkan-sdk@v1.2.1 + with: + vulkan-query-version: latest + vulkan-use-cache: true + vulkan-components: Vulkan-Headers, Vulkan-Loader + - name: Download Nabla install artifact uses: actions/download-artifact@v4 with: @@ -385,4 +392,4 @@ jobs: run: cmake --build smoke/out --config ${{ matrix.config }} - name: CTest Smoke - run: ctest --test-dir smoke/out --force-new-ctest-process --output-on-failure --no-tests=error -C ${{ matrix.config }} \ No newline at end of file + run: ctest --verbose --test-dir smoke/out --force-new-ctest-process --output-on-failure --no-tests=error -C ${{ matrix.config }} \ No newline at end of file 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..29e7e7e6a8 --- /dev/null +++ b/3rdparty/Vulkan-Tools @@ -0,0 +1 @@ +Subproject commit 29e7e7e6a8fa26d85ad223bc032ab45b6b685623 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..b02f12f1de 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: @@ -27,6 +29,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection 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..924ce5640e 100644 --- a/smoke/main.cpp +++ b/smoke/main.cpp @@ -36,11 +36,44 @@ class Smoke final : public system::IApplicationFramework return false; } + exportGpuProfiles(); + return true; } void workLoopBody() override {} bool keepRunning() override { return false; } + +private: + static void exportGpuProfiles() + { + std::string arg2 = "-o"; + std::string buf; + std::string arg1; + std::string arg3; + + for (size_t i = 0;; i++) + { + auto stringifiedIndex = std::to_string(i); + auto outFile = "device_" + stringifiedIndex + ".json"; + std::array args = { arg1.data(), arg2.data(), outFile.data() }; + + int code = nbl::video::vulkaninfo(args); + + if (code != 0) + break; + + // print out file content + std::ifstream input(outFile); + + while (input >> buf) + { + std::cout << buf; + } + + std::cout << "\n\n"; + } + } }; 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..5f58eaae93 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(int, char**); + 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,9 @@ bool CVulkanConnection::endCapture() return true; } +int vulkaninfo(const std::span args) +{ + return ::vulkaninfo(args.size(), args.data()); +} + } 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))); }