Skip to content

Commit 1c1b9c7

Browse files
committed
expose vulkaninfo to clients and parse args properly
1 parent 211ad29 commit 1c1b9c7

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

3rdparty/Vulkan-Tools

include/nbl/video/CVulkanConnection.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
namespace nbl::video
1414
{
1515

16+
NBL_API2 int vulkaninfo(const std::span<const std::string_view> args);
17+
1618
class NBL_API2 CVulkanConnection final : public IAPIConnection
1719
{
1820
public:
@@ -21,6 +23,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection
2123
core::smart_refctd_ptr<system::ILogger>&& logger, const SFeatures& featuresToEnable
2224
);
2325

26+
static void exportGpuProfiles();
2427

2528
inline VkInstance getInternalObject() const {return m_vkInstance;}
2629

@@ -48,8 +51,6 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection
4851
std::atomic_flag flag;
4952
};
5053

51-
NBL_API2 void vulkaninfo();
52-
5354
}
5455

5556
#endif

src/nbl/video/CVulkanConnection.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,17 @@ bool CVulkanConnection::endCapture()
375375
return true;
376376
}
377377

378-
NBL_API2 void vulkaninfo() {
379-
uint32_t gpuIndex = 0;
380-
std::string jsonArg = "--json=" + std::to_string(gpuIndex);
381-
std::array<std::string_view, 2> args = { "", jsonArg };
382-
383-
while (::vulkaninfo(args) == 0)
384-
jsonArg = "--json=" + std::to_string(++gpuIndex);
378+
void CVulkanConnection::exportGpuProfiles()
379+
{
380+
for (size_t i = 0;; i++)
381+
{
382+
auto arg = "--json=" + std::to_string(i);
383+
int code = ::vulkaninfo(std::array<const std::string_view, 1>{ arg });
384+
if (code != 0)
385+
break;
386+
}
385387
}
386388

389+
NBL_API2 int vulkaninfo(const std::span<const std::string_view> args) { return ::vulkaninfo(args); }
390+
387391
}

0 commit comments

Comments
 (0)