From 0cd59c1d56c45b82bd1f880c2b2827ecd39042e0 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Wed, 2 Feb 2022 10:35:13 +0100 Subject: [PATCH 1/2] Add GpuContext --- sentry-types/src/protocol/v7.rs | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sentry-types/src/protocol/v7.rs b/sentry-types/src/protocol/v7.rs index 1d3f9038..9c7d8813 100644 --- a/sentry-types/src/protocol/v7.rs +++ b/sentry-types/src/protocol/v7.rs @@ -1105,6 +1105,8 @@ pub enum Context { Browser(Box), /// Tracing data. Trace(Box), + /// GPU data + Gpu(Box), /// Generic other context data. #[serde(rename = "unknown")] Other(Map), @@ -1120,6 +1122,7 @@ impl Context { Context::App(..) => "app", Context::Browser(..) => "browser", Context::Trace(..) => "trace", + Context::Gpu(..) => "gpu", Context::Other(..) => "unknown", } } @@ -1282,6 +1285,62 @@ pub struct BrowserContext { pub other: Map, } +/// GPU context describes the GPU of the device. +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)] +pub struct GpuContext { + /// The name of the graphics device. + pub name: String, + /// The Version of the graphics device. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, + /// The version of the graphic device driver. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub driver_version: Option, + /// The PCI identifier of the graphics device. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub id: Option, + /// The PCI vendor identifier of the graphics device. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub vendor_id: Option, + /// The vendor name as reported by the graphics device. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub vendor_name: Option, + /// The total GPU memory available in Megabytes. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub memory_size: Option, + /// The device low-level API type. Examples: "Apple Metal" or "Direct3D11" + #[serde(default, skip_serializing_if = "Option::is_none")] + pub api_type: Option, + /// Whether the GPU has multi-threaded rendering or not. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub multi_threaded_rendering: Option, + /// The Non-Power-Of-Two-Support support. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub npot_support: Option, + /// Largest size of a texture that is supported by the graphics hardware. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub max_texture_size: Option, + /// Approximate "shader capability" level of the graphics device. For example, + /// `Shader Model 2.0, OpenGL ES 3.0, Metal / OpenGL ES 3.1, 27 (unknown)`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub graphics_shader_level: Option, + /// Is GPU draw call instancing supported? + #[serde(default, skip_serializing_if = "Option::is_none")] + pub supports_draw_call_instancing: Option, + /// Is ray tracing available on the device? + #[serde(default, skip_serializing_if = "Option::is_none")] + pub supports_ray_tracing: Option, + /// Are compute shaders available on the device? + #[serde(default, skip_serializing_if = "Option::is_none")] + pub supports_compute_shaders: Option, + /// Are geometry shaders available on the device? + #[serde(default, skip_serializing_if = "Option::is_none")] + pub supports_geometry_shaders: Option, + /// Additional arbitrary fields for forwards compatibility. + #[serde(flatten)] + pub other: Map, +} + /// Holds the identifier for a Span #[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Hash)] #[serde(try_from = "String", into = "String")] @@ -1413,6 +1472,7 @@ into_context!(Os, OsContext); into_context!(Runtime, RuntimeContext); into_context!(Browser, BrowserContext); into_context!(Trace, TraceContext); +into_context!(Gpu, GpuContext); mod event { use super::*; From c8a8c4885464fea6fcbac70a358c3ede6a6a8d64 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Wed, 2 Feb 2022 10:39:18 +0100 Subject: [PATCH 2/2] Cleanup --- sentry-types/src/protocol/v7.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry-types/src/protocol/v7.rs b/sentry-types/src/protocol/v7.rs index 9c7d8813..268572b1 100644 --- a/sentry-types/src/protocol/v7.rs +++ b/sentry-types/src/protocol/v7.rs @@ -1286,7 +1286,7 @@ pub struct BrowserContext { } /// GPU context describes the GPU of the device. -#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Default)] +#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)] pub struct GpuContext { /// The name of the graphics device. pub name: String,