Skip to content

Commit 4c7386b

Browse files
committed
make vulkaninfo a standalone function and export a profile for all gpus in the system
1 parent 2725307 commit 4c7386b

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

include/nbl/video/CVulkanConnection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection
2121
core::smart_refctd_ptr<system::ILogger>&& logger, const SFeatures& featuresToEnable
2222
);
2323

24-
static void exportGpuProfile();
2524

2625
inline VkInstance getInternalObject() const {return m_vkInstance;}
2726

@@ -49,6 +48,8 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection
4948
std::atomic_flag flag;
5049
};
5150

51+
NBL_API2 void vulkaninfo();
52+
5253
}
5354

5455
#endif

smoke/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Smoke final : public system::IApplicationFramework
3636
return false;
3737
}
3838

39-
CVulkanConnection::exportGpuProfile();
39+
nbl::video::vulkaninfo();
4040

4141
return true;
4242
}

src/nbl/video/CVulkanConnection.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#include "nbl/video/CVulkanCommon.h"
55
#include "nbl/video/debug/CVulkanDebugCallback.h"
66

7-
#include "vulkaninfo/vulkaninfo.h"
8-
97
// TODO: move inside `create` and call it LOG_FAIL and return nullptr
108
#define LOG(logger, ...) if (logger) {logger->log(__VA_ARGS__);}
119

10+
extern int vulkaninfo(const std::span<const std::string_view>);
11+
1212
namespace nbl::video
1313
{
1414

@@ -316,13 +316,6 @@ core::smart_refctd_ptr<CVulkanConnection> CVulkanConnection::create(core::smart_
316316
return api;
317317
}
318318

319-
void CVulkanConnection::exportGpuProfile()
320-
{
321-
constexpr char arg1[] = "--json";
322-
char* argv = const_cast<char*>(arg1);
323-
vulkaninfo(1, &argv);
324-
}
325-
326319
CVulkanConnection::~CVulkanConnection()
327320
{
328321
if (m_vkDebugUtilsMessengerEXT!=VK_NULL_HANDLE)
@@ -382,4 +375,13 @@ bool CVulkanConnection::endCapture()
382375
return true;
383376
}
384377

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);
385+
}
386+
385387
}

0 commit comments

Comments
 (0)