From de89a25b9d901243f0164fa2afa0d021c0d1e3dd Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sun, 28 Sep 2025 17:57:10 +0200 Subject: [PATCH 01/11] add a structure that holds information about vulkan devices --- include/nbl/video/CVulkanConnection.h | 3 +++ src/nbl/video/CVulkanConnection.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/nbl/video/CVulkanConnection.h b/include/nbl/video/CVulkanConnection.h index c8d3882c50..619d57bd50 100644 --- a/include/nbl/video/CVulkanConnection.h +++ b/include/nbl/video/CVulkanConnection.h @@ -26,6 +26,8 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection inline E_API_TYPE getAPIType() const override {return EAT_VULKAN;} inline IDebugCallback* getDebugCallback() const override {return m_debugCallback.get();} + + inline const core::vector& getVulkanDevicesInfo() const { return m_vulkanDevicesInfo; } bool startCapture() override; bool endCapture() override; @@ -44,6 +46,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection const VkDebugUtilsMessengerEXT m_vkDebugUtilsMessengerEXT; const std::unique_ptr m_debugCallback; // this needs to live longer than VkDebugUtilsMessengerEXT handle above std::atomic_flag flag; + core::vector m_vulkanDevicesInfo; }; } diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 3f1cb68380..8cd36bebbb 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -297,6 +297,7 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ core::smart_refctd_ptr api(new CVulkanConnection(vk_instance,enabledFeatures,std::move(debugCallback),vk_debugMessenger),core::dont_grab); api->m_physicalDevices.reserve(vk_physicalDevices.size()); + api->m_vulkanDevicesInfo.reserve(vk_physicalDevices.size()); for (auto vk_physicalDevice : vk_physicalDevices) { auto device = CVulkanPhysicalDevice::create(core::smart_refctd_ptr(sys),api.get(),api->m_rdoc_api,vk_physicalDevice); @@ -306,6 +307,7 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ continue; } api->m_physicalDevices.emplace_back(std::move(device)); + // device enumeration } #undef LOF From 92fd0f0696419b61e95de6c5a5fe191bac4bd4f7 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Tue, 30 Sep 2025 13:17:01 +0200 Subject: [PATCH 02/11] small change in naming --- include/nbl/video/CVulkanConnection.h | 4 ++-- src/nbl/video/CVulkanConnection.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nbl/video/CVulkanConnection.h b/include/nbl/video/CVulkanConnection.h index 619d57bd50..dc063eab40 100644 --- a/include/nbl/video/CVulkanConnection.h +++ b/include/nbl/video/CVulkanConnection.h @@ -27,7 +27,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection inline IDebugCallback* getDebugCallback() const override {return m_debugCallback.get();} - inline const core::vector& getVulkanDevicesInfo() const { return m_vulkanDevicesInfo; } + inline const core::vector& getVulkanProfiles() const { return m_vulkanProfiles; } bool startCapture() override; bool endCapture() override; @@ -46,7 +46,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection const VkDebugUtilsMessengerEXT m_vkDebugUtilsMessengerEXT; const std::unique_ptr m_debugCallback; // this needs to live longer than VkDebugUtilsMessengerEXT handle above std::atomic_flag flag; - core::vector m_vulkanDevicesInfo; + core::vector m_vulkanProfiles; }; } diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 8cd36bebbb..8cdb33316e 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -297,7 +297,7 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ core::smart_refctd_ptr api(new CVulkanConnection(vk_instance,enabledFeatures,std::move(debugCallback),vk_debugMessenger),core::dont_grab); api->m_physicalDevices.reserve(vk_physicalDevices.size()); - api->m_vulkanDevicesInfo.reserve(vk_physicalDevices.size()); + api->m_vulkanProfiles.reserve(vk_physicalDevices.size()); for (auto vk_physicalDevice : vk_physicalDevices) { auto device = CVulkanPhysicalDevice::create(core::smart_refctd_ptr(sys),api.get(),api->m_rdoc_api,vk_physicalDevice); From a8f4dbba7f7197120b1900b2caa91fd7f051c817 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Tue, 30 Sep 2025 13:39:48 +0200 Subject: [PATCH 03/11] store a reference to a coresponding profile in CVulkanPhysicalDevice, write information about available extensions --- src/nbl/video/CVulkanConnection.cpp | 3 ++- src/nbl/video/CVulkanPhysicalDevice.cpp | 13 +++++++++++-- src/nbl/video/CVulkanPhysicalDevice.h | 9 ++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 8cdb33316e..8306984df7 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -300,7 +300,8 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ api->m_vulkanProfiles.reserve(vk_physicalDevices.size()); for (auto vk_physicalDevice : vk_physicalDevices) { - auto device = CVulkanPhysicalDevice::create(core::smart_refctd_ptr(sys),api.get(),api->m_rdoc_api,vk_physicalDevice); + auto& profile = api->m_vulkanProfiles.emplace_back(); + auto device = CVulkanPhysicalDevice::create(core::smart_refctd_ptr(sys),api.get(),api->m_rdoc_api,vk_physicalDevice, profile); if (!device) { LOG(api->getDebugCallback()->getLogger(), "Vulkan device %p found but doesn't meet minimum Nabla requirements. Skipping!", system::ILogger::ELL_WARNING, vk_physicalDevice); diff --git a/src/nbl/video/CVulkanPhysicalDevice.cpp b/src/nbl/video/CVulkanPhysicalDevice.cpp index 256b717f52..58db6c1d10 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 { @@ -10,7 +12,7 @@ do { \ return nullptr; \ } while(0) -std::unique_ptr CVulkanPhysicalDevice::create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice) +std::unique_ptr CVulkanPhysicalDevice::create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::string& profile) { system::logger_opt_ptr logger = api->getDebugCallback()->getLogger(); @@ -25,6 +27,8 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart } }); + using json = nlohmann::json; + json profileObject = { {"$schema", "https://schema.khronos.org/vulkan/profiles-0.8-latest.json"} }; auto& properties = initData.properties; auto& features = initData.features; @@ -263,7 +267,10 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart assert(VK_SUCCESS==res); for (const auto& vk_extension : vk_extensions) + { + profileObject["capabilities"]["device"]["extensions"][vk_extension.extensionName] = vk_extension.specVersion; availableFeatureSet.insert(vk_extension.extensionName); + } } auto isExtensionSupported = [&availableFeatureSet](const char* name)->bool { @@ -1366,8 +1373,10 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart // bufferUsages.opticalFlowCost = anyFlag(bufferFeatures,VK_FORMAT_FEATURE_2_OPTICAL_FLOW_COST_BIT_NV); } + profile = profileObject.dump(4); // nicely indented json + success = true; - return std::unique_ptr(new CVulkanPhysicalDevice(std::move(initData),rdoc,vk_physicalDevice,std::move(availableFeatureSet))); + return std::unique_ptr(new CVulkanPhysicalDevice(std::move(initData),rdoc,vk_physicalDevice,std::move(availableFeatureSet),profile)); } #undef RETURN_NULL_PHYSICAL_DEVICE diff --git a/src/nbl/video/CVulkanPhysicalDevice.h b/src/nbl/video/CVulkanPhysicalDevice.h index c1552c88f1..c94a4325d3 100644 --- a/src/nbl/video/CVulkanPhysicalDevice.h +++ b/src/nbl/video/CVulkanPhysicalDevice.h @@ -12,15 +12,17 @@ namespace nbl::video class CVulkanPhysicalDevice final : public IPhysicalDevice { public: - static std::unique_ptr create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice); + static std::unique_ptr create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::string& profile); inline VkPhysicalDevice getInternalObject() const { return m_vkPhysicalDevice; } inline E_API_TYPE getAPIType() const override { return EAT_VULKAN; } + inline const core::string& getProfile() const { return m_profile; } + protected: - inline CVulkanPhysicalDevice(IPhysicalDevice::SInitData&& _initData, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::unordered_set&& _extensions) - : IPhysicalDevice(std::move(_initData)), m_rdoc_api(rdoc), m_vkPhysicalDevice(vk_physicalDevice), m_extensions(std::move(_extensions)) {} + inline CVulkanPhysicalDevice(IPhysicalDevice::SInitData&& _initData, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::unordered_set&& _extensions, core::string& profile) + : IPhysicalDevice(std::move(_initData)), m_rdoc_api(rdoc), m_vkPhysicalDevice(vk_physicalDevice), m_extensions(std::move(_extensions)), m_profile(profile) {} //! This function makes sure requirements of a requested feature is also set to `true` in SPhysicalDeviceFeatures //! Note that this will only fix what is exposed, some may require extensions not exposed currently, that will happen later on. @@ -115,6 +117,7 @@ class CVulkanPhysicalDevice final : public IPhysicalDevice renderdoc_api_t* const m_rdoc_api; const VkPhysicalDevice m_vkPhysicalDevice; + core::string& m_profile; const core::unordered_set m_extensions; }; From a8d9ea34737c7741fcc0d86fe5178cf918059f94 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Mon, 6 Oct 2025 15:17:09 +0200 Subject: [PATCH 04/11] add vulkan-tools submodule and include it in nabla --- .gitmodules | 3 +++ 3rdparty/CMakeLists.txt | 4 ++++ 3rdparty/Vulkan-Tools | 1 + 3 files changed, 8 insertions(+) create mode 160000 3rdparty/Vulkan-Tools 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..2014495b2e 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -451,6 +451,9 @@ if (NBL_BUILD_BULLET) set(BULLET_INCLUDE_PATH ${BULLET_INCLUDE_PATH} PARENT_SCOPE) endif() +add_library(Vulkan-Tools OBJECT "Vulkan-Tools/vulkaninfo/vulkaninfo.cpp") +target_include_directories(Vulkan-Tools INTERFACE "Vulkan-Tools/vulkaninfo") + # Final gather set(NBL_3RDPARTY_TARGETS lzma @@ -472,6 +475,7 @@ set(NBL_3RDPARTY_TARGETS SPIRV SPIRV-Tools-static # SPIRV-Tools-shared in case of SHARED lib SPIRV-Tools-opt + Vulkan-Tools Imath freetype ${NBL_MSDFGEN_TARGETS} diff --git a/3rdparty/Vulkan-Tools b/3rdparty/Vulkan-Tools new file mode 160000 index 0000000000..5568ce1470 --- /dev/null +++ b/3rdparty/Vulkan-Tools @@ -0,0 +1 @@ +Subproject commit 5568ce14705e512113df5b459fc86d857b3d7789 From 67ee1639f77cea8745fafd004811d962b167fbc5 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Wed, 8 Oct 2025 22:07:00 +0200 Subject: [PATCH 05/11] update vulkan headers, link vulkaninfo to nabla --- 3rdparty/CMakeLists.txt | 8 +++++--- 3rdparty/Vulkan-Headers | 2 +- src/nbl/CMakeLists.txt | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 2014495b2e..050fb39cc3 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -451,8 +451,10 @@ if (NBL_BUILD_BULLET) set(BULLET_INCLUDE_PATH ${BULLET_INCLUDE_PATH} PARENT_SCOPE) endif() -add_library(Vulkan-Tools OBJECT "Vulkan-Tools/vulkaninfo/vulkaninfo.cpp") -target_include_directories(Vulkan-Tools INTERFACE "Vulkan-Tools/vulkaninfo") +set(_VULKANINFO_PREFIX "Vulkan-Tools/vulkaninfo") +add_library(vulkaninfo OBJECT "${_VULKANINFO_PREFIX}/vulkaninfo.cpp") +target_include_directories(vulkaninfo PRIVATE "${_VULKANINFO_PREFIX}" "${_VULKANINFO_PREFIX}/generated") +target_link_libraries(vulkaninfo PRIVATE Vulkan::Headers) # Final gather set(NBL_3RDPARTY_TARGETS @@ -475,7 +477,7 @@ set(NBL_3RDPARTY_TARGETS SPIRV SPIRV-Tools-static # SPIRV-Tools-shared in case of SHARED lib SPIRV-Tools-opt - Vulkan-Tools + vulkaninfo Imath freetype ${NBL_MSDFGEN_TARGETS} diff --git a/3rdparty/Vulkan-Headers b/3rdparty/Vulkan-Headers index 234c4b7370..f5fad0a209 160000 --- a/3rdparty/Vulkan-Headers +++ b/3rdparty/Vulkan-Headers @@ -1 +1 @@ -Subproject commit 234c4b7370a8ea3239a214c9e871e4b17c89f4ab +Subproject commit f5fad0a209a2e09eb5e622d930d5eade1a235b13 diff --git a/src/nbl/CMakeLists.txt b/src/nbl/CMakeLists.txt index 935beffe2c..8437b5c90c 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -329,6 +329,7 @@ set(NBL_LIBRARY_CREATION_SOURCES $ $ $ + $ ) if(NBL_STATIC_BUILD) From e4207b8ff025ef85fd27382793421d88e1f27f05 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 10 Oct 2025 16:01:13 +0200 Subject: [PATCH 06/11] link vulkaninfo as static library --- 3rdparty/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 050fb39cc3..dcfdb55ad8 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -451,10 +451,7 @@ if (NBL_BUILD_BULLET) set(BULLET_INCLUDE_PATH ${BULLET_INCLUDE_PATH} PARENT_SCOPE) endif() -set(_VULKANINFO_PREFIX "Vulkan-Tools/vulkaninfo") -add_library(vulkaninfo OBJECT "${_VULKANINFO_PREFIX}/vulkaninfo.cpp") -target_include_directories(vulkaninfo PRIVATE "${_VULKANINFO_PREFIX}" "${_VULKANINFO_PREFIX}/generated") -target_link_libraries(vulkaninfo PRIVATE Vulkan::Headers) +add_subdirectory(Vulkan-Tools/vulkaninfo vulkaninfo EXCLUDE_FROM_ALL) # Final gather set(NBL_3RDPARTY_TARGETS From dd4c7fd69c8472807d3c0f70ecda090bef0e49d6 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 10 Oct 2025 16:12:06 +0200 Subject: [PATCH 07/11] update vulkan-tools --- 3rdparty/Vulkan-Tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/Vulkan-Tools b/3rdparty/Vulkan-Tools index 5568ce1470..1fb52d6ed4 160000 --- a/3rdparty/Vulkan-Tools +++ b/3rdparty/Vulkan-Tools @@ -1 +1 @@ -Subproject commit 5568ce14705e512113df5b459fc86d857b3d7789 +Subproject commit 1fb52d6ed449d70d4e0c3cfae5cf0893778b69aa From e645f4f5f650601ef9c88b5d2bfb6c6e65e29b4f Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 10 Oct 2025 17:03:22 +0200 Subject: [PATCH 08/11] update vulkan-headers --- 3rdparty/Vulkan-Headers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/Vulkan-Headers b/3rdparty/Vulkan-Headers index f5fad0a209..33d7f51258 160000 --- a/3rdparty/Vulkan-Headers +++ b/3rdparty/Vulkan-Headers @@ -1 +1 @@ -Subproject commit f5fad0a209a2e09eb5e622d930d5eade1a235b13 +Subproject commit 33d7f512583b8de44d1b6384aa1cf482f92e53e9 From 824662aa68cf33edb3e060d09c61e4c2a11b78f5 Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Fri, 10 Oct 2025 17:52:05 +0200 Subject: [PATCH 09/11] fixed silly mistake in Vulkan-Tools, mimic headers from vulkansdk for vulkaninfo --- 3rdparty/CMakeLists.txt | 3 +++ 3rdparty/Vulkan-Tools | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index dcfdb55ad8..a3bf95ce53 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -451,6 +451,9 @@ 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 diff --git a/3rdparty/Vulkan-Tools b/3rdparty/Vulkan-Tools index 1fb52d6ed4..f3fc824f10 160000 --- a/3rdparty/Vulkan-Tools +++ b/3rdparty/Vulkan-Tools @@ -1 +1 @@ -Subproject commit 1fb52d6ed449d70d4e0c3cfae5cf0893778b69aa +Subproject commit f3fc824f10d68b4d61398404403956d67c5c3e7e From 0002aef0069e538deb504958f0db941bda33e5aa Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sun, 12 Oct 2025 17:52:19 +0200 Subject: [PATCH 10/11] remove unused stuff --- include/nbl/video/CVulkanConnection.h | 3 --- src/nbl/video/CVulkanConnection.cpp | 4 +--- src/nbl/video/CVulkanPhysicalDevice.cpp | 12 ++---------- src/nbl/video/CVulkanPhysicalDevice.h | 9 +++------ 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/include/nbl/video/CVulkanConnection.h b/include/nbl/video/CVulkanConnection.h index dc063eab40..c8d3882c50 100644 --- a/include/nbl/video/CVulkanConnection.h +++ b/include/nbl/video/CVulkanConnection.h @@ -26,8 +26,6 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection inline E_API_TYPE getAPIType() const override {return EAT_VULKAN;} inline IDebugCallback* getDebugCallback() const override {return m_debugCallback.get();} - - inline const core::vector& getVulkanProfiles() const { return m_vulkanProfiles; } bool startCapture() override; bool endCapture() override; @@ -46,7 +44,6 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection const VkDebugUtilsMessengerEXT m_vkDebugUtilsMessengerEXT; const std::unique_ptr m_debugCallback; // this needs to live longer than VkDebugUtilsMessengerEXT handle above std::atomic_flag flag; - core::vector m_vulkanProfiles; }; } diff --git a/src/nbl/video/CVulkanConnection.cpp b/src/nbl/video/CVulkanConnection.cpp index 8306984df7..1ff55f8edf 100644 --- a/src/nbl/video/CVulkanConnection.cpp +++ b/src/nbl/video/CVulkanConnection.cpp @@ -297,11 +297,9 @@ core::smart_refctd_ptr CVulkanConnection::create(core::smart_ core::smart_refctd_ptr api(new CVulkanConnection(vk_instance,enabledFeatures,std::move(debugCallback),vk_debugMessenger),core::dont_grab); api->m_physicalDevices.reserve(vk_physicalDevices.size()); - api->m_vulkanProfiles.reserve(vk_physicalDevices.size()); for (auto vk_physicalDevice : vk_physicalDevices) { - auto& profile = api->m_vulkanProfiles.emplace_back(); - auto device = CVulkanPhysicalDevice::create(core::smart_refctd_ptr(sys),api.get(),api->m_rdoc_api,vk_physicalDevice, profile); + auto device = CVulkanPhysicalDevice::create(core::smart_refctd_ptr(sys),api.get(),api->m_rdoc_api,vk_physicalDevice); if (!device) { LOG(api->getDebugCallback()->getLogger(), "Vulkan device %p found but doesn't meet minimum Nabla requirements. Skipping!", system::ILogger::ELL_WARNING, vk_physicalDevice); diff --git a/src/nbl/video/CVulkanPhysicalDevice.cpp b/src/nbl/video/CVulkanPhysicalDevice.cpp index 58db6c1d10..e0dad4039e 100644 --- a/src/nbl/video/CVulkanPhysicalDevice.cpp +++ b/src/nbl/video/CVulkanPhysicalDevice.cpp @@ -12,7 +12,7 @@ do { \ return nullptr; \ } while(0) -std::unique_ptr CVulkanPhysicalDevice::create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::string& profile) +std::unique_ptr CVulkanPhysicalDevice::create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice) { system::logger_opt_ptr logger = api->getDebugCallback()->getLogger(); @@ -27,9 +27,6 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart } }); - using json = nlohmann::json; - json profileObject = { {"$schema", "https://schema.khronos.org/vulkan/profiles-0.8-latest.json"} }; - auto& properties = initData.properties; auto& features = initData.features; // First call just with Vulkan 1.0 API because: @@ -267,10 +264,7 @@ std::unique_ptr CVulkanPhysicalDevice::create(core::smart assert(VK_SUCCESS==res); for (const auto& vk_extension : vk_extensions) - { - profileObject["capabilities"]["device"]["extensions"][vk_extension.extensionName] = vk_extension.specVersion; availableFeatureSet.insert(vk_extension.extensionName); - } } auto isExtensionSupported = [&availableFeatureSet](const char* name)->bool { @@ -1372,11 +1366,9 @@ 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); } - - profile = profileObject.dump(4); // nicely indented json success = true; - return std::unique_ptr(new CVulkanPhysicalDevice(std::move(initData),rdoc,vk_physicalDevice,std::move(availableFeatureSet),profile)); + return std::unique_ptr(new CVulkanPhysicalDevice(std::move(initData),rdoc,vk_physicalDevice,std::move(availableFeatureSet))); } #undef RETURN_NULL_PHYSICAL_DEVICE diff --git a/src/nbl/video/CVulkanPhysicalDevice.h b/src/nbl/video/CVulkanPhysicalDevice.h index c94a4325d3..c1552c88f1 100644 --- a/src/nbl/video/CVulkanPhysicalDevice.h +++ b/src/nbl/video/CVulkanPhysicalDevice.h @@ -12,17 +12,15 @@ namespace nbl::video class CVulkanPhysicalDevice final : public IPhysicalDevice { public: - static std::unique_ptr create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::string& profile); + static std::unique_ptr create(core::smart_refctd_ptr&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice); inline VkPhysicalDevice getInternalObject() const { return m_vkPhysicalDevice; } inline E_API_TYPE getAPIType() const override { return EAT_VULKAN; } - inline const core::string& getProfile() const { return m_profile; } - protected: - inline CVulkanPhysicalDevice(IPhysicalDevice::SInitData&& _initData, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::unordered_set&& _extensions, core::string& profile) - : IPhysicalDevice(std::move(_initData)), m_rdoc_api(rdoc), m_vkPhysicalDevice(vk_physicalDevice), m_extensions(std::move(_extensions)), m_profile(profile) {} + inline CVulkanPhysicalDevice(IPhysicalDevice::SInitData&& _initData, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice, core::unordered_set&& _extensions) + : IPhysicalDevice(std::move(_initData)), m_rdoc_api(rdoc), m_vkPhysicalDevice(vk_physicalDevice), m_extensions(std::move(_extensions)) {} //! This function makes sure requirements of a requested feature is also set to `true` in SPhysicalDeviceFeatures //! Note that this will only fix what is exposed, some may require extensions not exposed currently, that will happen later on. @@ -117,7 +115,6 @@ class CVulkanPhysicalDevice final : public IPhysicalDevice renderdoc_api_t* const m_rdoc_api; const VkPhysicalDevice m_vkPhysicalDevice; - core::string& m_profile; const core::unordered_set m_extensions; }; From 13617172aec088be4fbab3fcdea9651df2394dbf Mon Sep 17 00:00:00 2001 From: YasInvolved Date: Sun, 12 Oct 2025 18:29:34 +0200 Subject: [PATCH 11/11] make vulkaninfo "callable" from nabla --- include/nbl/video/CVulkanConnection.h | 2 ++ src/nbl/CMakeLists.txt | 6 +++++- src/nbl/video/CVulkanConnection.cpp | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) 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 8437b5c90c..b4f70e9015 100755 --- a/src/nbl/CMakeLists.txt +++ b/src/nbl/CMakeLists.txt @@ -329,7 +329,6 @@ set(NBL_LIBRARY_CREATION_SOURCES $ $ $ - $ ) if(NBL_STATIC_BUILD) @@ -602,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 1ff55f8edf..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__);} @@ -322,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())