Skip to content

Commit 6e31d04

Browse files
authored
Merge pull request #938 from Devsh-Graphics-Programming/gpu_info
GPU Diagnostics
2 parents 9b4f730 + 7ed26e8 commit 6e31d04

File tree

11 files changed

+77
-6
lines changed

11 files changed

+77
-6
lines changed

.github/workflows/build-nabla.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,17 @@ jobs:
364364
sparse-checkout: |
365365
smoke
366366
367+
- name: Download VulkanSDK
368+
uses: jakoch/install-vulkan-sdk-action@v1
369+
with:
370+
install_runtime: true
371+
cache: false
372+
stripdown: true
373+
install_lavapipe: true
374+
375+
- name: Add lavapipe driver
376+
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
377+
367378
- name: Download Nabla install artifact
368379
uses: actions/download-artifact@v4
369380
with:
@@ -385,4 +396,4 @@ jobs:
385396
run: cmake --build smoke/out --config ${{ matrix.config }}
386397

387398
- name: CTest Smoke
388-
run: ctest --test-dir smoke/out --force-new-ctest-process --output-on-failure --no-tests=error -C ${{ matrix.config }}
399+
run: ctest --verbose --test-dir smoke/out --force-new-ctest-process --output-on-failure --no-tests=error -C ${{ matrix.config }}

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,7 @@
125125
path = ci
126126
url = git@github.com:Devsh-Graphics-Programming/Nabla-CI.git
127127
branch = ditt
128-
update = none
128+
update = none
129+
[submodule "3rdparty/Vulkan-Tools"]
130+
path = 3rdparty/Vulkan-Tools
131+
url = git@github.com:Devsh-Graphics-Programming/Vulkan-Tools.git

3rdparty/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ if (NBL_BUILD_BULLET)
454454
set(BULLET_INCLUDE_PATH ${BULLET_INCLUDE_PATH} PARENT_SCOPE)
455455
endif()
456456

457+
add_library(Vulkan-Headers INTERFACE)
458+
target_include_directories(Vulkan-Headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include")
459+
add_subdirectory(Vulkan-Tools/vulkaninfo vulkaninfo EXCLUDE_FROM_ALL)
460+
457461
# Final gather
458462
set(NBL_3RDPARTY_TARGETS
459463
lzma
@@ -475,6 +479,7 @@ set(NBL_3RDPARTY_TARGETS
475479
SPIRV
476480
SPIRV-Tools-static # SPIRV-Tools-shared in case of SHARED lib
477481
SPIRV-Tools-opt
482+
vulkaninfo
478483
Imath
479484
freetype
480485
${NBL_MSDFGEN_TARGETS}

3rdparty/Vulkan-Headers

Submodule Vulkan-Headers updated 61 files

3rdparty/Vulkan-Tools

Submodule Vulkan-Tools added at 761e7bf

examples_tests

Submodule examples_tests updated 83 files

include/nbl/video/CVulkanConnection.h

Lines changed: 3 additions & 0 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 char*> args);
17+
1618
class NBL_API2 CVulkanConnection final : public IAPIConnection
1719
{
1820
public:
@@ -27,6 +29,7 @@ class NBL_API2 CVulkanConnection final : public IAPIConnection
2729

2830
inline IDebugCallback* getDebugCallback() const override {return m_debugCallback.get();}
2931

32+
3033
bool startCapture() override;
3134
bool endCapture() override;
3235

smoke/main.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,45 @@ class Smoke final : public system::IApplicationFramework
3636
return false;
3737
}
3838

39+
exportGpuProfiles();
40+
3941
return true;
4042
}
4143

4244
void workLoopBody() override {}
4345
bool keepRunning() override { return false; }
46+
47+
private:
48+
static void exportGpuProfiles()
49+
{
50+
std::string arg2 = "-o";
51+
std::string buf;
52+
std::string arg1;
53+
std::string arg3;
54+
55+
for (size_t i = 0;; i++)
56+
{
57+
auto stringifiedIndex = std::to_string(i);
58+
arg1 = "--json=" + stringifiedIndex;
59+
arg3 = "device_" + stringifiedIndex + ".json";
60+
std::array<const char*, 3> args = { arg1.data(), arg2.data(), arg3.data() };
61+
62+
int code = nbl::video::vulkaninfo(args);
63+
64+
if (code != 0)
65+
break;
66+
67+
// print out file content
68+
std::ifstream input(arg3);
69+
70+
while (std::getline(input, buf))
71+
{
72+
std::cout << buf << "\n";
73+
}
74+
75+
std::cout << "\n\n";
76+
}
77+
}
4478
};
4579

4680
NBL_MAIN_FUNC(Smoke)

src/nbl/CMakeLists.txt

100755100644
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,13 @@ list(APPEND INTERFACE_BUILD_DEFINITIONS
753753
# TODO: private
754754
target_link_libraries(Nabla PUBLIC $<BUILD_INTERFACE:gtml>)
755755

756+
# vulkaninfo
757+
if (NBL_STATIC_BUILD)
758+
target_link_libraries(Nabla PUBLIC $<BUILD_INTERFACE:vulkaninfo>)
759+
else()
760+
target_link_libraries(Nabla PRIVATE $<BUILD_INTERFACE:vulkaninfo>)
761+
endif()
762+
756763
# NGFX
757764
if(TARGET ngfx)
758765
if(NBL_STATIC_BUILD)

src/nbl/video/CVulkanConnection.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// TODO: move inside `create` and call it LOG_FAIL and return nullptr
88
#define LOG(logger, ...) if (logger) {logger->log(__VA_ARGS__);}
99

10+
extern int vulkaninfo(int, char**);
11+
1012
namespace nbl::video
1113
{
1214

@@ -306,6 +308,7 @@ core::smart_refctd_ptr<CVulkanConnection> CVulkanConnection::create(core::smart_
306308
continue;
307309
}
308310
api->m_physicalDevices.emplace_back(std::move(device));
311+
// device enumeration
309312
}
310313
#undef LOF
311314

@@ -372,4 +375,9 @@ bool CVulkanConnection::endCapture()
372375
return true;
373376
}
374377

378+
int vulkaninfo(const std::span<const char*> args)
379+
{
380+
return ::vulkaninfo(args.size(), const_cast<char**>(args.data()));
381+
}
382+
375383
}

0 commit comments

Comments
 (0)