-
-
Notifications
You must be signed in to change notification settings - Fork 427
/
Gpu.java
249 lines (219 loc) · 7.05 KB
/
Gpu.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
package io.sentry.protocol;
import io.sentry.ILogger;
import io.sentry.JsonDeserializer;
import io.sentry.JsonObjectReader;
import io.sentry.JsonObjectWriter;
import io.sentry.JsonSerializable;
import io.sentry.JsonUnknown;
import io.sentry.util.CollectionUtils;
import io.sentry.vendor.gson.stream.JsonToken;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class Gpu implements JsonUnknown, JsonSerializable {
public static final String TYPE = "gpu";
/** The name of the graphics device. */
private @Nullable String name;
/** The PCI identifier of the graphics device. */
private @Nullable Integer id;
/** The PCI vendor identifier of the graphics device. */
private @Nullable String vendorId;
/** The vendor name as reported by the graphics device. */
private @Nullable String vendorName;
/** The total GPU memory available in Megabytes. */
private @Nullable Integer memorySize;
/**
* The device low-level API type.
*
* <p>Examples: `"Apple Metal"` or `"Direct3D11"`
*/
private @Nullable String apiType;
/** Whether the GPU has multi-threaded rendering or not. */
private @Nullable Boolean multiThreadedRendering;
/** The Version of the graphics device. */
private @Nullable String version;
/** The Non-Power-Of-Two support. */
private @Nullable String npotSupport;
@SuppressWarnings("unused")
private @Nullable Map<String, @NotNull Object> unknown;
public Gpu() {}
Gpu(final @NotNull Gpu gpu) {
this.name = gpu.name;
this.id = gpu.id;
this.vendorId = gpu.vendorId;
this.vendorName = gpu.vendorName;
this.memorySize = gpu.memorySize;
this.apiType = gpu.apiType;
this.multiThreadedRendering = gpu.multiThreadedRendering;
this.version = gpu.version;
this.npotSupport = gpu.npotSupport;
this.unknown = CollectionUtils.newConcurrentHashMap(gpu.unknown);
}
public @Nullable String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public @Nullable Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public @Nullable String getVendorId() {
return vendorId;
}
public void setVendorId(@Nullable String vendorId) {
this.vendorId = vendorId;
}
public @Nullable String getVendorName() {
return vendorName;
}
public void setVendorName(final @Nullable String vendorName) {
this.vendorName = vendorName;
}
public @Nullable Integer getMemorySize() {
return memorySize;
}
public void setMemorySize(final @Nullable Integer memorySize) {
this.memorySize = memorySize;
}
public @Nullable String getApiType() {
return apiType;
}
public void setApiType(final @Nullable String apiType) {
this.apiType = apiType;
}
public @Nullable Boolean isMultiThreadedRendering() {
return multiThreadedRendering;
}
public void setMultiThreadedRendering(final @Nullable Boolean multiThreadedRendering) {
this.multiThreadedRendering = multiThreadedRendering;
}
public @Nullable String getVersion() {
return version;
}
public void setVersion(final @Nullable String version) {
this.version = version;
}
public @Nullable String getNpotSupport() {
return npotSupport;
}
public void setNpotSupport(final @Nullable String npotSupport) {
this.npotSupport = npotSupport;
}
// region JsonSerializable
public static final class JsonKeys {
public static final String NAME = "name";
public static final String ID = "id";
public static final String VENDOR_ID = "vendor_id";
public static final String VENDOR_NAME = "vendor_name";
public static final String MEMORY_SIZE = "memory_size";
public static final String API_TYPE = "api_type";
public static final String MULTI_THREADED_RENDERING = "multi_threaded_rendering";
public static final String VERSION = "version";
public static final String NPOT_SUPPORT = "npot_support";
}
@Override
public void serialize(@NotNull JsonObjectWriter writer, @NotNull ILogger logger)
throws IOException {
writer.beginObject();
if (name != null) {
writer.name(JsonKeys.NAME).value(name);
}
if (id != null) {
writer.name(JsonKeys.ID).value(id);
}
if (vendorId != null) {
writer.name(JsonKeys.VENDOR_ID).value(vendorId);
}
if (vendorName != null) {
writer.name(JsonKeys.VENDOR_NAME).value(vendorName);
}
if (memorySize != null) {
writer.name(JsonKeys.MEMORY_SIZE).value(memorySize);
}
if (apiType != null) {
writer.name(JsonKeys.API_TYPE).value(apiType);
}
if (multiThreadedRendering != null) {
writer.name(JsonKeys.MULTI_THREADED_RENDERING).value(multiThreadedRendering);
}
if (version != null) {
writer.name(JsonKeys.VERSION).value(version);
}
if (npotSupport != null) {
writer.name(JsonKeys.NPOT_SUPPORT).value(npotSupport);
}
if (unknown != null) {
for (String key : unknown.keySet()) {
Object value = unknown.get(key);
writer.name(key);
writer.value(logger, value);
}
}
writer.endObject();
}
@Nullable
@Override
public Map<String, Object> getUnknown() {
return unknown;
}
@Override
public void setUnknown(@Nullable Map<String, Object> unknown) {
this.unknown = unknown;
}
public static final class Deserializer implements JsonDeserializer<Gpu> {
@Override
public @NotNull Gpu deserialize(@NotNull JsonObjectReader reader, @NotNull ILogger logger)
throws Exception {
reader.beginObject();
Gpu gpu = new Gpu();
Map<String, Object> unknown = null;
while (reader.peek() == JsonToken.NAME) {
final String nextName = reader.nextName();
switch (nextName) {
case JsonKeys.NAME:
gpu.name = reader.nextStringOrNull();
break;
case JsonKeys.ID:
gpu.id = reader.nextIntegerOrNull();
break;
case JsonKeys.VENDOR_ID:
gpu.vendorId = reader.nextStringOrNull();
break;
case JsonKeys.VENDOR_NAME:
gpu.vendorName = reader.nextStringOrNull();
break;
case JsonKeys.MEMORY_SIZE:
gpu.memorySize = reader.nextIntegerOrNull();
break;
case JsonKeys.API_TYPE:
gpu.apiType = reader.nextStringOrNull();
break;
case JsonKeys.MULTI_THREADED_RENDERING:
gpu.multiThreadedRendering = reader.nextBooleanOrNull();
break;
case JsonKeys.VERSION:
gpu.version = reader.nextStringOrNull();
break;
case JsonKeys.NPOT_SUPPORT:
gpu.npotSupport = reader.nextStringOrNull();
break;
default:
if (unknown == null) {
unknown = new ConcurrentHashMap<>();
}
reader.nextUnknown(logger, unknown, nextName);
break;
}
}
gpu.setUnknown(unknown);
reader.endObject();
return gpu;
}
}
}