relay_event_schema/protocol/contexts/
gpu.rs

1use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};
2
3use crate::processor::ProcessValue;
4
5/// GPU information.
6///
7/// Example:
8///
9/// ```json
10/// "gpu": {
11///   "name": "AMD Radeon Pro 560",
12///   "vendor_name": "Apple",
13///   "memory_size": 4096,
14///   "api_type": "Metal",
15///   "multi_threaded_rendering": true,
16///   "version": "Metal",
17///   "npot_support": "Full"
18/// }
19/// ```
20#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
21pub struct GpuContext {
22    /// The name of the graphics device.
23    #[metastructure(pii = "maybe")]
24    pub name: Annotated<String>,
25
26    /// The Version of the graphics device.
27    #[metastructure(pii = "maybe")]
28    pub version: Annotated<String>,
29
30    /// The PCI identifier of the graphics device.
31    #[metastructure(pii = "maybe")]
32    pub id: Annotated<Value>,
33
34    /// The PCI vendor identifier of the graphics device.
35    #[metastructure(pii = "maybe")]
36    pub vendor_id: Annotated<String>,
37
38    /// The vendor name as reported by the graphics device.
39    #[metastructure(pii = "maybe")]
40    pub vendor_name: Annotated<String>,
41
42    /// The driver version as reported by the graphics device.
43    #[metastructure(pii = "maybe")]
44    pub driver_version: Annotated<String>,
45
46    /// The total GPU memory available in Megabytes.
47    #[metastructure(pii = "maybe")]
48    pub memory_size: Annotated<u64>,
49
50    /// The device low-level API type.
51    ///
52    /// Examples: `"Apple Metal"` or `"Direct3D11"`
53    #[metastructure(pii = "maybe")]
54    pub api_type: Annotated<String>,
55
56    /// Whether the GPU has multi-threaded rendering or not.
57    #[metastructure(pii = "maybe")]
58    pub multi_threaded_rendering: Annotated<bool>,
59
60    /// The Non-Power-Of-Two support.
61    #[metastructure(pii = "maybe")]
62    pub npot_support: Annotated<String>,
63
64    /// Largest size of a texture that is supported by the graphics hardware.
65    ///
66    /// For Example: 16384
67    pub max_texture_size: Annotated<u64>,
68
69    /// Approximate "shader capability" level of the graphics device.
70    ///
71    /// For Example: Shader Model 2.0, OpenGL ES 3.0, Metal / OpenGL ES 3.1, 27 (unknown)
72    pub graphics_shader_level: Annotated<String>,
73
74    /// Whether GPU draw call instancing is supported.
75    pub supports_draw_call_instancing: Annotated<bool>,
76
77    /// Whether ray tracing is available on the device.
78    pub supports_ray_tracing: Annotated<bool>,
79
80    /// Whether compute shaders are available on the device.
81    pub supports_compute_shaders: Annotated<bool>,
82
83    /// Whether geometry shaders are available on the device.
84    pub supports_geometry_shaders: Annotated<bool>,
85
86    /// Additional arbitrary fields for forwards compatibility.
87    #[metastructure(additional_properties, retain = true, pii = "maybe")]
88    pub other: Object<Value>,
89}
90
91impl super::DefaultContext for GpuContext {
92    fn default_key() -> &'static str {
93        "gpu"
94    }
95
96    fn from_context(context: super::Context) -> Option<Self> {
97        match context {
98            super::Context::Gpu(c) => Some(*c),
99            _ => None,
100        }
101    }
102
103    fn cast(context: &super::Context) -> Option<&Self> {
104        match context {
105            super::Context::Gpu(c) => Some(c),
106            _ => None,
107        }
108    }
109
110    fn cast_mut(context: &mut super::Context) -> Option<&mut Self> {
111        match context {
112            super::Context::Gpu(c) => Some(c),
113            _ => None,
114        }
115    }
116
117    fn into_context(self) -> super::Context {
118        super::Context::Gpu(Box::new(self))
119    }
120}