diff --git a/.github/workflows/build-nabla.yml b/.github/workflows/build-nabla.yml index e0447edfb0..6824449abb 100644 --- a/.github/workflows/build-nabla.yml +++ b/.github/workflows/build-nabla.yml @@ -364,6 +364,17 @@ jobs: sparse-checkout: | smoke + - name: Download VulkanSDK + uses: jakoch/install-vulkan-sdk-action@v1 + with: + install_runtime: true + cache: false + stripdown: true + install_lavapipe: true + + - name: Add lavapipe driver + run: reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers" /v "C:\lavapipe\share\vulkan\icd.d\lvp_icd.x86_64.json" /t REG_DWORD /d 0 /f + - name: Download Nabla install artifact uses: actions/download-artifact@v4 with: @@ -385,4 +396,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..761e7bf273 --- /dev/null +++ b/3rdparty/Vulkan-Tools @@ -0,0 +1 @@ +Subproject commit 761e7bf2736f3ad326fdfc1b3c1543f4e669fd5c 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..f95c11e6b7 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..69c986369d 100644 --- a/smoke/main.cpp +++ b/smoke/main.cpp @@ -36,11 +36,45 @@ 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); + arg1 = "--json=" + stringifiedIndex; + arg3 = "device_" + stringifiedIndex + ".json"; + std::array args = { arg1.data(), arg2.data(), arg3.data() }; + + int code = nbl::video::vulkaninfo(args); + + if (code != 0) + break; + + // print out file content + std::ifstream input(arg3); + + while (std::getline(input, buf)) + { + std::cout << buf << "\n"; + } + + 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..42122937a6 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(), const_cast(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))); }