Skip to content

Commit c6d7093

Browse files
authored
Merge pull request #2 from getsentry/feature/gpu-interface
feat: GPU interface
2 parents 92b6d22 + 970e25e commit c6d7093

File tree

1 file changed

+98
-11
lines changed

1 file changed

+98
-11
lines changed

Assets/Sentry/Scripts/Sentry.cs

Lines changed: 98 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,88 @@
44

55
namespace Sentry
66
{
7+
/// <summary>
8+
/// Graphics device unit
9+
/// </summary>
10+
/// <remarks>
11+
/// The value types are not made nullable due to limitation of <see cref="JsonUtility"/>
12+
/// </remarks>
13+
/// <seealso href="https://feedback.unity3d.com/suggestions/add-support-for-nullable-types-to-jsonutility"/>
14+
[Serializable]
15+
public class Gpu
16+
{
17+
/// <summary>
18+
/// The name of the graphics device
19+
/// </summary>
20+
/// <example>
21+
/// iPod touch: Apple A8 GPU
22+
/// Samsung S7: Mali-T880
23+
/// </example>
24+
public string name;
25+
26+
/// <summary>
27+
/// The PCI Id of the graphics device
28+
/// </summary>
29+
/// <remarks>
30+
/// Combined with <see cref="vendor_id"/> uniquely identifies the GPU
31+
/// </remarks>
32+
public int id;
33+
34+
/// <summary>
35+
/// The PCI vendor Id of the graphics device
36+
/// </summary>
37+
/// <remarks>
38+
/// Combined with <see cref="Id"/> uniquely identifies the GPU
39+
/// </remarks>
40+
/// <seealso href="https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-pci-devices"/>
41+
/// <seealso href="http://pci-ids.ucw.cz/read/PC/"/>
42+
public int vendor_id;
43+
44+
/// <summary>
45+
/// The vendor name reported by the graphic device
46+
/// </summary>
47+
/// <example>
48+
/// Apple, ARM, WebKit
49+
/// </example>
50+
public string vendor_name;
51+
52+
/// <summary>
53+
/// Total GPU memory available in mega-bytes.
54+
/// </summary>
55+
public int memory_size;
56+
57+
/// <summary>
58+
/// Device type
59+
/// </summary>
60+
/// <remarks>The low level API used</remarks>
61+
/// <example>Metal, Direct3D11, OpenGLES3, PlayStation4, XboxOne</example>
62+
public string api_type;
63+
64+
/// <summary>
65+
/// Whether the GPU is multi-threaded rendering or not.
66+
/// </summary>
67+
/// <remarks>Type hre should be Nullable{bool} which isn't supported by JsonUtility></remarks>
68+
public bool multi_threaded_rendering;
69+
70+
/// <summary>
71+
/// The Version of the API of the graphics device
72+
/// </summary>
73+
/// <example>
74+
/// iPod touch: Metal
75+
/// Android: OpenGL ES 3.2 v1.r22p0-01rel0.f294e54ceb2cb2d81039204fa4b0402e
76+
/// WebGL Windows: OpenGL ES 3.0 (WebGL 2.0 (OpenGL ES 3.0 Chromium))
77+
/// OpenGL 2.0, Direct3D 9.0c
78+
/// </example>
79+
public string version;
80+
81+
/// <summary>
82+
/// The Non-Power-Of-Two support level
83+
/// </summary>
84+
/// <example>
85+
/// Full
86+
/// </example>
87+
public string npot_support;
88+
}
789
[Serializable]
890
public class SdkVersion
991
{
@@ -32,32 +114,37 @@ public class Context
32114
public ContextPair device_model;
33115
public ContextPair device_name;
34116
public ContextPair device_type;
35-
public ContextPair gpu_name;
36-
public ContextPair gpu_id;
37-
public ContextPair gpu_type;
38-
public ContextPair gpu_vendor;
39-
public ContextPair gpu_vendor_id;
40117
public ContextPair app_build;
41118
public ContextPair app_version;
42119

120+
public Gpu gpu;
121+
43122
public Context(string app_version)
44123
{
45124
os = new ContextPair("os", SystemInfo.operatingSystem);
46125
os_family = new ContextPair("os_family", SystemInfo.operatingSystemFamily.ToString());
47126
device_model = new ContextPair("device_model", SystemInfo.deviceModel);
48127
device_name = new ContextPair("device_name", SystemInfo.deviceName);
49128
device_type = new ContextPair("device_type", SystemInfo.deviceType.ToString());
50-
gpu_name = new ContextPair("gpu_name", SystemInfo.graphicsDeviceName);
51-
gpu_id = new ContextPair("gpu_id", SystemInfo.graphicsDeviceID.ToString());
52-
gpu_type = new ContextPair("gpu_name", SystemInfo.graphicsDeviceName);
53-
gpu_vendor = new ContextPair("gpu_id", SystemInfo.graphicsDeviceVendor);
54-
gpu_vendor_id = new ContextPair("gpu_name", SystemInfo.graphicsDeviceVendorID.ToString());
55129
#if UNITY_EDITOR
56130
app_build = new ContextPair("app_build", "editor");
57131
#else
58132
app_build = new _ContextPair("app_build", "build");
59133
#endif
60134
this.app_version = new ContextPair("app_version", app_version);
135+
136+
gpu = new Gpu
137+
{
138+
id = SystemInfo.graphicsDeviceID,
139+
name = SystemInfo.graphicsDeviceName,
140+
vendor_id = SystemInfo.graphicsDeviceVendorID,
141+
vendor_name = SystemInfo.graphicsDeviceVendor,
142+
memory_size = SystemInfo.graphicsMemorySize,
143+
multi_threaded_rendering = SystemInfo.graphicsMultiThreaded,
144+
npot_support = SystemInfo.npotSupport.ToString(),
145+
version = SystemInfo.graphicsDeviceVersion,
146+
api_type = SystemInfo.graphicsDeviceType.ToString()
147+
};
61148
}
62149
}
63150

@@ -206,4 +293,4 @@ public Dsn(string dsn)
206293
callUri = builder.Uri;
207294
}
208295
}
209-
}
296+
}

0 commit comments

Comments
 (0)