Skip to content
Open
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c65001f
feat: Implement the GPU Info gathering within the Native SDK
mujacica Aug 11, 2025
fab50a7
Fix file format
mujacica Aug 11, 2025
e1854e3
Add changelog entry
mujacica Aug 11, 2025
dc72b0e
Extend README with new SENTRY_WITH_GPU_INFO option
mujacica Aug 11, 2025
093d100
Skip apple silicon tests on non darwin platforms
mujacica Aug 11, 2025
c3fc125
Enable GPU Info per default to test cmake on github runners
mujacica Aug 11, 2025
de8516a
Resolve compiler issues on Linux
mujacica Aug 11, 2025
1bf85b3
Fix Windows builds
mujacica Aug 11, 2025
cfb142b
Fix failing tests
mujacica Aug 11, 2025
63285cd
Fix IOS builds
mujacica Aug 11, 2025
0be6800
Fix remaining failing tests
mujacica Aug 11, 2025
6d5d211
Fix format
mujacica Aug 11, 2025
75436f6
Keep GPU Info disabled by default
mujacica Aug 11, 2025
b337dc9
Fix CMake for all platforms
mujacica Aug 11, 2025
324aa86
Fix comments, and findings from testing
mujacica Aug 12, 2025
15cbc84
Further testing fixes
mujacica Aug 12, 2025
90e801e
Fix failing test
mujacica Aug 12, 2025
a56f85d
Use Sentry wstr function instead of custom implementation
mujacica Aug 12, 2025
4c9023f
Simplify Unix implementation and CMakeLists
mujacica Aug 14, 2025
a5bc079
Add nvml support, add multi-gpu support
mujacica Aug 14, 2025
18edccc
Fix linux complier warnings
mujacica Aug 14, 2025
86ba123
Fix file formats
mujacica Aug 14, 2025
abd63a8
Fix build issues after refactoring
mujacica Aug 14, 2025
47e0626
Fix file formats
mujacica Aug 14, 2025
b08c744
Use Vulkan for GPU info with multi-platform support
mujacica Aug 17, 2025
fa3b147
Fix file format
mujacica Aug 17, 2025
8db38fb
Fix None implementation
mujacica Aug 17, 2025
d362fc9
Don't use singleton
mujacica Aug 17, 2025
41a291e
Fix format
mujacica Aug 17, 2025
4454b4d
Simplify driver version, remove test script
mujacica Aug 20, 2025
dea2782
Use Vulkan headers, dynamically load
mujacica Aug 20, 2025
9491418
Fix format
mujacica Aug 20, 2025
13d1561
Fix CMake to include headers only
mujacica Aug 20, 2025
0f8e7fa
Fix 32-bit builds
mujacica Aug 20, 2025
b8f3072
Fix GPU test pritnf formats
mujacica Aug 20, 2025
966dc77
Fix format
mujacica Aug 20, 2025
7ef5f42
One more test fix
mujacica Aug 20, 2025
7d1ce41
Fix format
mujacica Aug 20, 2025
0c22332
Fix cursor comment
mujacica Oct 2, 2025
924aef3
Update src/gpu/sentry_gpu_vulkan.c
mujacica Oct 9, 2025
641744d
Update src/gpu/sentry_gpu_vulkan.c
mujacica Oct 9, 2025
921f817
Update tests/unit/test_gpu.c
mujacica Oct 9, 2025
150e542
Update README.md
mujacica Oct 9, 2025
899d2fb
Fix PR Comments
mujacica Oct 9, 2025
6b37c65
Update tests/unit/test_gpu.c
mujacica Oct 9, 2025
284dfd0
Further fixes
mujacica Oct 9, 2025
d610338
Fix memory units
mujacica Oct 9, 2025
022ec51
Fix docs
mujacica Oct 9, 2025
6b4e712
Fix more comments
mujacica Oct 9, 2025
7de05b4
Fix Mac compatibility
mujacica Oct 9, 2025
bb12c54
Fix Vendor ID's
mujacica Oct 13, 2025
f7eef2b
Fix memory size to MB
mujacica Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ jobs:
if: ${{ runner.os == 'Linux' && matrix.os != 'ubuntu-22.04' && !env['TEST_X86'] && !matrix.container }}
run: |
sudo apt update
sudo apt install cmake clang-19 llvm g++-12 valgrind zlib1g-dev libcurl4-openssl-dev
sudo apt install cmake clang-19 llvm g++-12 valgrind zlib1g-dev libcurl4-openssl-dev libvulkan-dev
# Install kcov from source
sudo apt-get install binutils-dev libssl-dev libelf-dev libstdc++-12-dev libdw-dev libiberty-dev
git clone https://github.com/SimonKagstrom/kcov.git
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
[submodule "external/benchmark"]
path = external/benchmark
url = https://github.com/google/benchmark.git
[submodule "external/vulkan-headers"]
path = external/vulkan-headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Use proper SDK name determination for structured logs `sdk.name` attribute. ([#1399](https://github.com/getsentry/sentry-native/pull/1399))

**Features**:

- Implement the GPU Info gathering within the Native SDK ([#1336](https://github.com/getsentry/sentry-native/pull/1336))

## 0.11.2

**Fixes**:
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ option(SENTRY_PIC "Build sentry (and dependent) libraries as position independen

option(SENTRY_TRANSPORT_COMPRESSION "Enable transport gzip compression" OFF)

# GPU information gathering support - enabled by default on supported platforms only
set(SENTRY_GPU_INFO_DEFAULT OFF)

# Only enable GPU info on supported platforms
if(WIN32)
set(SENTRY_GPU_INFO_DEFAULT ON)
elseif(APPLE AND NOT IOS)
set(SENTRY_GPU_INFO_DEFAULT ON)
elseif(LINUX)
set(SENTRY_GPU_INFO_DEFAULT ON)
else()
# Disable GPU info on all other platforms (Android, iOS, AIX, etc.)
message(STATUS "GPU Info: Platform not supported, GPU information gathering disabled")
endif()

option(SENTRY_WITH_GPU_INFO "Build with GPU information gathering support" ${SENTRY_GPU_INFO_DEFAULT})

# GPU info enabled - no longer requires Vulkan SDK (uses headers submodule + dynamic linking)
if(SENTRY_WITH_GPU_INFO)
message(STATUS "GPU information gathering enabled (using vulkan-headers submodule)")
endif()

option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}")
option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}")
option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF)
Expand Down Expand Up @@ -563,6 +585,12 @@ if(NOT XBOX)
endif()
endif()

# handle Vulkan headers for GPU info
if(SENTRY_WITH_GPU_INFO)
target_include_directories(sentry PRIVATE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/vulkan-headers/include>")
endif()

# apply platform libraries to sentry library
target_link_libraries(sentry PRIVATE ${_SENTRY_PLATFORM_LIBS})

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ per platform, and can also be configured for cross-compilation.
System-wide installation of the resulting sentry library is also possible via
CMake.

The prerequisites for building differ depending on the platform and backend. You will always need `CMake` to build the code. Additionally, when using the `crashpad` backend, `zlib` is required. On Linux and macOS, `libcurl` is a prerequisite. For more details, check out the [contribution guide](./CONTRIBUTING.md).
The prerequisites for building differ depending on the platform and backend. You will always need `CMake` to build the code. Additionally, when using the `crashpad` backend, `zlib` is required. On Linux and macOS, `libcurl` is a prerequisite. When GPU information gathering is enabled (`SENTRY_WITH_GPU_INFO=ON`), the **Vulkan SDK** is required for cross-platform GPU detection. For more details, check out the [contribution guide](./CONTRIBUTING.md).

Building the Breakpad and Crashpad backends requires a `C++17` compatible compiler.

Expand Down Expand Up @@ -299,6 +299,13 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`.
tuning the thread stack guarantee parameters. Warnings and errors in the process of setting thread stack guarantees
will always be logged.

- `SENTRY_WITH_GPU_INFO` (Default: `OFF`):
Enables GPU information collection and reporting. When enabled, the SDK will attempt to gather GPU details such as
GPU name, vendor, memory size, and driver version, which are included in event contexts. The implementation uses
the Vulkan API for cross-platform GPU detection. **Requires the Vulkan SDK to be installed** - if not found,
GPU information gathering will be automatically disabled during build. Setting this to `OFF` disables GPU
information collection entirely, which can reduce dependencies and binary size.

### Support Matrix

| Feature | Windows | macOS | Linux | Android | iOS |
Expand Down
1 change: 1 addition & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,4 @@ target_include_directories(breakpad_client
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
)

1 change: 1 addition & 0 deletions external/vulkan-headers
Submodule vulkan-headers added at 2efaa5
27 changes: 27 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,30 @@ else()
screenshot/sentry_screenshot_none.c
)
endif()

# gpu
if(SENTRY_WITH_GPU_INFO)
target_compile_definitions(sentry PRIVATE SENTRY_WITH_GPU_INFO)
sentry_target_sources_cwd(sentry
sentry_gpu.h
gpu/sentry_gpu_common.c
)

if(WIN32 OR (APPLE AND NOT IOS) OR LINUX)
sentry_target_sources_cwd(sentry
gpu/sentry_gpu_vulkan.h
gpu/sentry_gpu_vulkan.c
)
else()
# For platforms that do not support GPU info gathering, we provide a no-op implementation
sentry_target_sources_cwd(sentry
gpu/sentry_gpu_none.c
)
endif()
else()
sentry_target_sources_cwd(sentry
sentry_gpu.h
gpu/sentry_gpu_common.c
gpu/sentry_gpu_none.c
)
endif()
153 changes: 153 additions & 0 deletions src/gpu/sentry_gpu_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#include "sentry_gpu.h"
#include "sentry_string.h"

char *
sentry__gpu_vendor_id_to_name(unsigned int vendor_id)
{
switch (vendor_id) {
case 0x10DE:
return sentry__string_clone("NVIDIA Corporation");
case 0x1002:
return sentry__string_clone("Advanced Micro Devices, Inc. [AMD/ATI]");
case 0x8086:
return sentry__string_clone("Intel Corporation");
case 0x106B:
return sentry__string_clone("Apple Inc.");
case 0x1414:
return sentry__string_clone("Microsoft Corporation");
case 0x5143:
return sentry__string_clone("Qualcomm");
case 0x1AE0:
return sentry__string_clone("Google");
case 0x1010:
return sentry__string_clone("VideoLogic");
case 0x1023:
return sentry__string_clone("Trident Microsystems");
case 0x102B:
return sentry__string_clone("Matrox Graphics");
case 0x121A:
return sentry__string_clone("3dfx Interactive");
case 0x18CA:
return sentry__string_clone("XGI Technology");
case 0x1039:
return sentry__string_clone("Silicon Integrated Systems [SiS]");
case 0x126F:
return sentry__string_clone("Silicon Motion");
default: {
char unknown_vendor[64];
snprintf(unknown_vendor, sizeof(unknown_vendor), "Unknown (0x%04X)",
vendor_id);
return sentry__string_clone(unknown_vendor);
}
}
}

static sentry_value_t
create_gpu_context_from_info(sentry_gpu_info_t *gpu_info)
{
sentry_value_t gpu_context = sentry_value_new_object();
if (sentry_value_is_null(gpu_context)) {
return gpu_context;
}

// Add type field for frontend recognition
sentry_value_set_by_key(
gpu_context, "type", sentry_value_new_string("gpu"));

// Add GPU name
if (gpu_info->name) {
sentry_value_set_by_key(
gpu_context, "name", sentry_value_new_string(gpu_info->name));
}

// Add vendor information
if (gpu_info->vendor_name) {
sentry_value_set_by_key(gpu_context, "vendor_name",
sentry_value_new_string(gpu_info->vendor_name));
}

if (gpu_info->vendor_id != 0) {
char vendor_id_str[32];
snprintf(
vendor_id_str, sizeof(vendor_id_str), "%u", gpu_info->vendor_id);
sentry_value_set_by_key(
gpu_context, "vendor_id", sentry_value_new_string(vendor_id_str));
}

// Add device ID
if (gpu_info->device_id != 0) {
char device_id_str[32];
snprintf(
device_id_str, sizeof(device_id_str), "%u", gpu_info->device_id);
sentry_value_set_by_key(
gpu_context, "device_id", sentry_value_new_string(device_id_str));
}

// Add memory size
if (gpu_info->memory_size > 0) {
sentry_value_set_by_key(gpu_context, "memory_size",
sentry_value_new_uint64(gpu_info->memory_size));
}

// Add driver version
if (gpu_info->driver_version) {
sentry_value_set_by_key(gpu_context, "driver_version",
sentry_value_new_string(gpu_info->driver_version));
}

sentry_value_freeze(gpu_context);
return gpu_context;
}

void
sentry__free_gpu_info(sentry_gpu_info_t *gpu_info)
{
if (!gpu_info) {
return;
}

sentry_free(gpu_info->name);
sentry_free(gpu_info->vendor_name);
sentry_free(gpu_info->driver_version);
sentry_free(gpu_info);
}

void
sentry__free_gpu_list(sentry_gpu_list_t *gpu_list)
{
if (!gpu_list) {
return;
}

for (unsigned int i = 0; i < gpu_list->count; i++) {
sentry__free_gpu_info(gpu_list->gpus[i]);
}

sentry_free(gpu_list->gpus);
sentry_free(gpu_list);
}

void
sentry__add_gpu_contexts(sentry_value_t contexts)
{
sentry_gpu_list_t *gpu_list = sentry__get_gpu_info();
if (!gpu_list) {
return;
}

for (unsigned int i = 0; i < gpu_list->count; i++) {
sentry_value_t gpu_context
= create_gpu_context_from_info(gpu_list->gpus[i]);
if (!sentry_value_is_null(gpu_context)) {
char context_key[16];
if (i == 0) {
snprintf(context_key, sizeof(context_key), "gpu");
} else {
snprintf(context_key, sizeof(context_key), "gpu%u", i + 1);
}
sentry_value_set_by_key(contexts, context_key, gpu_context);
}
}

sentry__free_gpu_list(gpu_list);
}
7 changes: 7 additions & 0 deletions src/gpu/sentry_gpu_none.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "sentry_gpu.h"

sentry_gpu_list_t *
sentry__get_gpu_info(void)
{
return NULL;
}
Loading
Loading