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 total GPU memory available in Megabytes.
43    #[metastructure(pii = "maybe")]
44    pub memory_size: Annotated<u64>,
45
46    /// The device low-level API type.
47    ///
48    /// Examples: `"Apple Metal"` or `"Direct3D11"`
49    #[metastructure(pii = "maybe")]
50    pub api_type: Annotated<String>,
51
52    /// Whether the GPU has multi-threaded rendering or not.
53    #[metastructure(pii = "maybe")]
54    pub multi_threaded_rendering: Annotated<bool>,
55
56    /// The Non-Power-Of-Two support.
57    #[metastructure(pii = "maybe")]
58    pub npot_support: Annotated<String>,
59
60    /// Largest size of a texture that is supported by the graphics hardware.
61    ///
62    /// For Example: 16384
63    pub max_texture_size: Annotated<u64>,
64
65    /// Approximate "shader capability" level of the graphics device.
66    ///
67    /// For Example: Shader Model 2.0, OpenGL ES 3.0, Metal / OpenGL ES 3.1, 27 (unknown)
68    pub graphics_shader_level: Annotated<String>,
69
70    /// Whether GPU draw call instancing is supported.
71    pub supports_draw_call_instancing: Annotated<bool>,
72
73    /// Whether ray tracing is available on the device.
74    pub supports_ray_tracing: Annotated<bool>,
75
76    /// Whether compute shaders are available on the device.
77    pub supports_compute_shaders: Annotated<bool>,
78
79    /// Whether geometry shaders are available on the device.
80    pub supports_geometry_shaders: Annotated<bool>,
81
82    /// Additional arbitrary fields for forwards compatibility.
83    #[metastructure(additional_properties, retain = true, pii = "maybe")]
84    pub other: Object<Value>,
85}
86
87impl super::DefaultContext for GpuContext {
88    fn default_key() -> &'static str {
89        "gpu"
90    }
91
92    fn from_context(context: super::Context) -> Option<Self> {
93        match context {
94            super::Context::Gpu(c) => Some(*c),
95            _ => None,
96        }
97    }
98
99    fn cast(context: &super::Context) -> Option<&Self> {
100        match context {
101            super::Context::Gpu(c) => Some(c),
102            _ => None,
103        }
104    }
105
106    fn cast_mut(context: &mut super::Context) -> Option<&mut Self> {
107        match context {
108            super::Context::Gpu(c) => Some(c),
109            _ => None,
110        }
111    }
112
113    fn into_context(self) -> super::Context {
114        super::Context::Gpu(Box::new(self))
115    }
116}