Bug 1715716 [wpt PR 29323] - Use unittest.mock instead of the mock package, a=testonly
[gecko.git] / widget / GfxDriverInfo.cpp
blob0000f3d7aca84633eda6dea87a1fc529ee521fb1
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "GfxDriverInfo.h"
8 #include "nsIGfxInfo.h"
9 #include "nsTArray.h"
10 #include "nsUnicharUtils.h"
12 using namespace mozilla::widget;
14 int32_t GfxDriverInfo::allFeatures = 0;
15 uint64_t GfxDriverInfo::allDriverVersions = ~(uint64_t(0));
17 GfxDeviceFamily*
18 GfxDriverInfo::sDeviceFamilies[static_cast<size_t>(DeviceFamily::Max)];
19 nsAString* GfxDriverInfo::sDesktopEnvironment[static_cast<size_t>(
20 DesktopEnvironment::Max)];
21 nsAString*
22 GfxDriverInfo::sWindowProtocol[static_cast<size_t>(WindowProtocol::Max)];
23 nsAString*
24 GfxDriverInfo::sDeviceVendors[static_cast<size_t>(DeviceVendor::Max)];
25 nsAString*
26 GfxDriverInfo::sDriverVendors[static_cast<size_t>(DriverVendor::Max)];
28 GfxDriverInfo::GfxDriverInfo()
29 : mOperatingSystem(OperatingSystem::Unknown),
30 mOperatingSystemVersion(0),
31 mScreen(ScreenSizeStatus::All),
32 mBattery(BatteryStatus::All),
33 mDesktopEnvironment(
34 GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::All)),
35 mWindowProtocol(GfxDriverInfo::GetWindowProtocol(WindowProtocol::All)),
36 mAdapterVendor(GfxDriverInfo::GetDeviceVendor(DeviceFamily::All)),
37 mDriverVendor(GfxDriverInfo::GetDriverVendor(DriverVendor::All)),
38 mDevices(GfxDriverInfo::GetDeviceFamily(DeviceFamily::All)),
39 mDeleteDevices(false),
40 mFeature(allFeatures),
41 mFeatureStatus(nsIGfxInfo::FEATURE_STATUS_OK),
42 mComparisonOp(DRIVER_COMPARISON_IGNORED),
43 mDriverVersion(0),
44 mDriverVersionMax(0),
45 mSuggestedVersion(nullptr),
46 mRuleId(nullptr),
47 mGpu2(false) {}
49 GfxDriverInfo::GfxDriverInfo(
50 OperatingSystem os, ScreenSizeStatus screen, BatteryStatus battery,
51 const nsAString& desktopEnv, const nsAString& windowProtocol,
52 const nsAString& vendor, const nsAString& driverVendor,
53 GfxDeviceFamily* devices, int32_t feature, int32_t featureStatus,
54 VersionComparisonOp op, uint64_t driverVersion, const char* ruleId,
55 const char* suggestedVersion /* = nullptr */, bool ownDevices /* = false */,
56 bool gpu2 /* = false */)
57 : mOperatingSystem(os),
58 mOperatingSystemVersion(0),
59 mScreen(screen),
60 mBattery(battery),
61 mDesktopEnvironment(desktopEnv),
62 mWindowProtocol(windowProtocol),
63 mAdapterVendor(vendor),
64 mDriverVendor(driverVendor),
65 mDevices(devices),
66 mDeleteDevices(ownDevices),
67 mFeature(feature),
68 mFeatureStatus(featureStatus),
69 mComparisonOp(op),
70 mDriverVersion(driverVersion),
71 mDriverVersionMax(0),
72 mSuggestedVersion(suggestedVersion),
73 mRuleId(ruleId),
74 mGpu2(gpu2) {}
76 GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
77 : mOperatingSystem(aOrig.mOperatingSystem),
78 mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
79 mScreen(aOrig.mScreen),
80 mBattery(aOrig.mBattery),
81 mDesktopEnvironment(aOrig.mDesktopEnvironment),
82 mWindowProtocol(aOrig.mWindowProtocol),
83 mAdapterVendor(aOrig.mAdapterVendor),
84 mDriverVendor(aOrig.mDriverVendor),
85 mFeature(aOrig.mFeature),
86 mFeatureStatus(aOrig.mFeatureStatus),
87 mComparisonOp(aOrig.mComparisonOp),
88 mDriverVersion(aOrig.mDriverVersion),
89 mDriverVersionMax(aOrig.mDriverVersionMax),
90 mSuggestedVersion(aOrig.mSuggestedVersion),
91 mRuleId(aOrig.mRuleId),
92 mGpu2(aOrig.mGpu2) {
93 // If we're managing the lifetime of the device family, we have to make a
94 // copy of the original's device family.
95 if (aOrig.mDeleteDevices && aOrig.mDevices) {
96 GfxDeviceFamily* devices = new GfxDeviceFamily;
97 *devices = *aOrig.mDevices;
98 mDevices = devices;
99 } else {
100 mDevices = aOrig.mDevices;
103 mDeleteDevices = aOrig.mDeleteDevices;
106 GfxDriverInfo::~GfxDriverInfo() {
107 if (mDeleteDevices) {
108 delete mDevices;
112 void GfxDeviceFamily::Append(const nsAString& aDeviceId) {
113 mIds.AppendElement(aDeviceId);
116 void GfxDeviceFamily::AppendRange(int32_t aBeginDeviceId,
117 int32_t aEndDeviceId) {
118 mRanges.AppendElement(
119 GfxDeviceFamily::DeviceRange{aBeginDeviceId, aEndDeviceId});
122 nsresult GfxDeviceFamily::Contains(nsAString& aDeviceId) const {
123 for (const auto& id : mIds) {
124 if (id.Equals(aDeviceId, nsCaseInsensitiveStringComparator)) {
125 return NS_OK;
129 if (mRanges.IsEmpty()) {
130 return NS_ERROR_NOT_AVAILABLE;
133 nsresult valid = NS_OK;
134 int32_t deviceId = aDeviceId.ToInteger(&valid, 16);
135 if (valid != NS_OK) {
136 return NS_ERROR_INVALID_ARG;
139 for (const auto& range : mRanges) {
140 if (deviceId >= range.mBegin && deviceId <= range.mEnd) {
141 return NS_OK;
145 return NS_ERROR_NOT_AVAILABLE;
148 // Macros for appending a device to the DeviceFamily.
149 #define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
150 #define APPEND_DEVICE2(device) \
151 deviceFamily->Append(NS_LITERAL_STRING_FROM_CSTRING(device))
152 #define APPEND_RANGE(start, end) deviceFamily->AppendRange(start, end)
154 const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) {
155 if (id >= DeviceFamily::Max) {
156 MOZ_ASSERT_UNREACHABLE("DeviceFamily id is out of range");
157 return nullptr;
160 // All of these have no specific device ID filtering.
161 switch (id) {
162 case DeviceFamily::All:
163 case DeviceFamily::IntelAll:
164 case DeviceFamily::NvidiaAll:
165 case DeviceFamily::AtiAll:
166 case DeviceFamily::MicrosoftAll:
167 case DeviceFamily::ParallelsAll:
168 case DeviceFamily::QualcommAll:
169 case DeviceFamily::AppleAll:
170 case DeviceFamily::AmazonAll:
171 return nullptr;
172 default:
173 break;
176 // If it already exists, we must have processed it once, so return it now.
177 auto idx = static_cast<size_t>(id);
178 if (sDeviceFamilies[idx]) {
179 return sDeviceFamilies[idx];
182 sDeviceFamilies[idx] = new GfxDeviceFamily;
183 GfxDeviceFamily* deviceFamily = sDeviceFamilies[idx];
185 switch (id) {
186 case DeviceFamily::IntelGMA500:
187 APPEND_DEVICE(0x8108); /* IntelGMA500_1 */
188 APPEND_DEVICE(0x8109); /* IntelGMA500_2 */
189 break;
190 case DeviceFamily::IntelGMA900:
191 APPEND_DEVICE(0x2582); /* IntelGMA900_1 */
192 APPEND_DEVICE(0x2782); /* IntelGMA900_2 */
193 APPEND_DEVICE(0x2592); /* IntelGMA900_3 */
194 APPEND_DEVICE(0x2792); /* IntelGMA900_4 */
195 break;
196 case DeviceFamily::IntelGMA950:
197 APPEND_DEVICE(0x2772); /* Intel945G_1 */
198 APPEND_DEVICE(0x2776); /* Intel945G_2 */
199 APPEND_DEVICE(0x27a2); /* Intel945_1 */
200 APPEND_DEVICE(0x27a6); /* Intel945_2 */
201 APPEND_DEVICE(0x27ae); /* Intel945_3 */
202 break;
203 case DeviceFamily::IntelGMA3150:
204 APPEND_DEVICE(0xa001); /* IntelGMA3150_Nettop_1 */
205 APPEND_DEVICE(0xa002); /* IntelGMA3150_Nettop_2 */
206 APPEND_DEVICE(0xa011); /* IntelGMA3150_Netbook_1 */
207 APPEND_DEVICE(0xa012); /* IntelGMA3150_Netbook_2 */
208 break;
209 case DeviceFamily::IntelGMAX3000:
210 APPEND_DEVICE(0x2972); /* Intel946GZ_1 */
211 APPEND_DEVICE(0x2973); /* Intel946GZ_2 */
212 APPEND_DEVICE(0x2982); /* IntelG35_1 */
213 APPEND_DEVICE(0x2983); /* IntelG35_2 */
214 APPEND_DEVICE(0x2992); /* IntelQ965_1 */
215 APPEND_DEVICE(0x2993); /* IntelQ965_2 */
216 APPEND_DEVICE(0x29a2); /* IntelG965_1 */
217 APPEND_DEVICE(0x29a3); /* IntelG965_2 */
218 APPEND_DEVICE(0x29b2); /* IntelQ35_1 */
219 APPEND_DEVICE(0x29b3); /* IntelQ35_2 */
220 APPEND_DEVICE(0x29c2); /* IntelG33_1 */
221 APPEND_DEVICE(0x29c3); /* IntelG33_2 */
222 APPEND_DEVICE(0x29d2); /* IntelQ33_1 */
223 APPEND_DEVICE(0x29d3); /* IntelQ33_2 */
224 APPEND_DEVICE(0x2a02); /* IntelGL960_1 */
225 APPEND_DEVICE(0x2a03); /* IntelGL960_2 */
226 APPEND_DEVICE(0x2a12); /* IntelGM965_1 */
227 APPEND_DEVICE(0x2a13); /* IntelGM965_2 */
228 break;
229 case DeviceFamily::IntelGMAX4500HD:
230 APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */
231 APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */
232 APPEND_DEVICE(0x2e42); /* IntelB43_1 */
233 APPEND_DEVICE(0x2e43); /* IntelB43_2 */
234 APPEND_DEVICE(0x2e92); /* IntelB43_3 */
235 APPEND_DEVICE(0x2e93); /* IntelB43_4 */
236 APPEND_DEVICE(0x2e32); /* IntelG41_1 */
237 APPEND_DEVICE(0x2e33); /* IntelG41_2 */
238 APPEND_DEVICE(0x2e22); /* IntelG45_1 */
239 APPEND_DEVICE(0x2e23); /* IntelG45_2 */
240 APPEND_DEVICE(0x2e12); /* IntelQ45_1 */
241 APPEND_DEVICE(0x2e13); /* IntelQ45_2 */
242 break;
243 case DeviceFamily::IntelHDGraphicsToIvyBridge:
244 APPEND_DEVICE(0x015A); /* IntelIvyBridge_GT1_1 (HD Graphics) */
245 // clang-format off
246 APPEND_DEVICE(0x0152); /* IntelIvyBridge_GT1_2 (HD Graphics 2500, desktop) */
247 APPEND_DEVICE(0x0162); /* IntelIvyBridge_GT2_1 (HD Graphics 4000, desktop) */
248 APPEND_DEVICE(0x0166); /* IntelIvyBridge_GT2_2 (HD Graphics 4000, mobile) */
249 APPEND_DEVICE(0x016A); /* IntelIvyBridge_GT2_3 (HD Graphics P4000, workstation) */
250 // clang-format on
251 [[fallthrough]];
252 case DeviceFamily::IntelHDGraphicsToSandyBridge:
253 APPEND_DEVICE(0x0042); /* IntelHDGraphics */
254 APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
255 APPEND_DEVICE(0x0102); /* IntelSandyBridge_1 */
256 APPEND_DEVICE(0x0106); /* IntelSandyBridge_2 */
257 APPEND_DEVICE(0x0112); /* IntelSandyBridge_3 */
258 APPEND_DEVICE(0x0116); /* IntelSandyBridge_4 */
259 APPEND_DEVICE(0x0122); /* IntelSandyBridge_5 */
260 APPEND_DEVICE(0x0126); /* IntelSandyBridge_6 */
261 APPEND_DEVICE(0x010a); /* IntelSandyBridge_7 */
262 break;
263 case DeviceFamily::IntelHaswell:
264 APPEND_DEVICE(0x0402); /* IntelHaswell_GT1_1 */
265 APPEND_DEVICE(0x0406); /* IntelHaswell_GT1_2 */
266 APPEND_DEVICE(0x040A); /* IntelHaswell_GT1_3 */
267 APPEND_DEVICE(0x040B); /* IntelHaswell_GT1_4 */
268 APPEND_DEVICE(0x040E); /* IntelHaswell_GT1_5 */
269 APPEND_DEVICE(0x0A02); /* IntelHaswell_GT1_6 */
270 APPEND_DEVICE(0x0A06); /* IntelHaswell_GT1_7 */
271 APPEND_DEVICE(0x0A0A); /* IntelHaswell_GT1_8 */
272 APPEND_DEVICE(0x0A0B); /* IntelHaswell_GT1_9 */
273 APPEND_DEVICE(0x0A0E); /* IntelHaswell_GT1_10 */
274 APPEND_DEVICE(0x0412); /* IntelHaswell_GT2_1 */
275 APPEND_DEVICE(0x0416); /* IntelHaswell_GT2_2 */
276 APPEND_DEVICE(0x041A); /* IntelHaswell_GT2_3 */
277 APPEND_DEVICE(0x041B); /* IntelHaswell_GT2_4 */
278 APPEND_DEVICE(0x041E); /* IntelHaswell_GT2_5 */
279 APPEND_DEVICE(0x0A12); /* IntelHaswell_GT2_6 */
280 APPEND_DEVICE(0x0A16); /* IntelHaswell_GT2_7 */
281 APPEND_DEVICE(0x0A1A); /* IntelHaswell_GT2_8 */
282 APPEND_DEVICE(0x0A1B); /* IntelHaswell_GT2_9 */
283 APPEND_DEVICE(0x0A1E); /* IntelHaswell_GT2_10 */
284 APPEND_DEVICE(0x0422); /* IntelHaswell_GT3_1 */
285 APPEND_DEVICE(0x0426); /* IntelHaswell_GT3_2 */
286 APPEND_DEVICE(0x042A); /* IntelHaswell_GT3_3 */
287 APPEND_DEVICE(0x042B); /* IntelHaswell_GT3_4 */
288 APPEND_DEVICE(0x042E); /* IntelHaswell_GT3_5 */
289 APPEND_DEVICE(0x0A22); /* IntelHaswell_GT3_6 */
290 APPEND_DEVICE(0x0A26); /* IntelHaswell_GT3_7 */
291 APPEND_DEVICE(0x0A2A); /* IntelHaswell_GT3_8 */
292 APPEND_DEVICE(0x0A2B); /* IntelHaswell_GT3_9 */
293 APPEND_DEVICE(0x0A2E); /* IntelHaswell_GT3_10 */
294 APPEND_DEVICE(0x0D22); /* IntelHaswell_GT3e_1 */
295 APPEND_DEVICE(0x0D26); /* IntelHaswell_GT3e_2 */
296 APPEND_DEVICE(0x0D2A); /* IntelHaswell_GT3e_3 */
297 APPEND_DEVICE(0x0D2B); /* IntelHaswell_GT3e_4 */
298 APPEND_DEVICE(0x0D2E); /* IntelHaswell_GT3e_5 */
299 break;
300 case DeviceFamily::IntelSandyBridge:
301 APPEND_DEVICE(0x0102);
302 APPEND_DEVICE(0x0106);
303 APPEND_DEVICE(0x010a);
304 APPEND_DEVICE(0x0112);
305 APPEND_DEVICE(0x0116);
306 APPEND_DEVICE(0x0122);
307 APPEND_DEVICE(0x0126);
308 break;
309 case DeviceFamily::IntelGen7Baytrail:
310 APPEND_DEVICE(0x0f30);
311 APPEND_DEVICE(0x0f31);
312 APPEND_DEVICE(0x0f33);
313 APPEND_DEVICE(0x0155);
314 APPEND_DEVICE(0x0157);
315 break;
316 case DeviceFamily::IntelHD520:
317 APPEND_DEVICE(0x1916);
318 break;
319 case DeviceFamily::IntelMobileHDGraphics:
320 APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
321 break;
322 case DeviceFamily::NvidiaBlockD3D9Layers:
323 // Glitches whilst scrolling (see bugs 612007, 644787, 645872)
324 APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */
325 APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */
326 APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */
327 APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */
328 APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */
329 APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */
330 APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */
331 APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */
332 APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */
333 APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */
334 APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */
335 APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */
336 APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */
337 APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */
338 APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */
339 APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */
340 APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */
341 APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */
342 APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */
343 APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */
344 break;
345 case DeviceFamily::RadeonX1000:
346 // This list is from the ATIRadeonX1000.kext Info.plist
347 APPEND_DEVICE(0x7187);
348 APPEND_DEVICE(0x7210);
349 APPEND_DEVICE(0x71de);
350 APPEND_DEVICE(0x7146);
351 APPEND_DEVICE(0x7142);
352 APPEND_DEVICE(0x7109);
353 APPEND_DEVICE(0x71c5);
354 APPEND_DEVICE(0x71c0);
355 APPEND_DEVICE(0x7240);
356 APPEND_DEVICE(0x7249);
357 APPEND_DEVICE(0x7291);
358 break;
359 case DeviceFamily::RadeonCaicos:
360 APPEND_DEVICE(0x6766);
361 APPEND_DEVICE(0x6767);
362 APPEND_DEVICE(0x6768);
363 APPEND_DEVICE(0x6770);
364 APPEND_DEVICE(0x6771);
365 APPEND_DEVICE(0x6772);
366 APPEND_DEVICE(0x6778);
367 APPEND_DEVICE(0x6779);
368 APPEND_DEVICE(0x677b);
369 break;
370 case DeviceFamily::Geforce7300GT:
371 APPEND_DEVICE(0x0393);
372 break;
373 case DeviceFamily::Nvidia310M:
374 APPEND_DEVICE(0x0A70);
375 break;
376 case DeviceFamily::Nvidia8800GTS:
377 APPEND_DEVICE(0x0193);
378 break;
379 case DeviceFamily::Bug1137716:
380 APPEND_DEVICE(0x0a29);
381 APPEND_DEVICE(0x0a2b);
382 APPEND_DEVICE(0x0a2d);
383 APPEND_DEVICE(0x0a35);
384 APPEND_DEVICE(0x0a6c);
385 APPEND_DEVICE(0x0a70);
386 APPEND_DEVICE(0x0a72);
387 APPEND_DEVICE(0x0a7a);
388 APPEND_DEVICE(0x0caf);
389 APPEND_DEVICE(0x0dd2);
390 APPEND_DEVICE(0x0dd3);
391 // GF180M ids
392 APPEND_DEVICE(0x0de3);
393 APPEND_DEVICE(0x0de8);
394 APPEND_DEVICE(0x0de9);
395 APPEND_DEVICE(0x0dea);
396 APPEND_DEVICE(0x0deb);
397 APPEND_DEVICE(0x0dec);
398 APPEND_DEVICE(0x0ded);
399 APPEND_DEVICE(0x0dee);
400 APPEND_DEVICE(0x0def);
401 APPEND_DEVICE(0x0df0);
402 APPEND_DEVICE(0x0df1);
403 APPEND_DEVICE(0x0df2);
404 APPEND_DEVICE(0x0df3);
405 APPEND_DEVICE(0x0df4);
406 APPEND_DEVICE(0x0df5);
407 APPEND_DEVICE(0x0df6);
408 APPEND_DEVICE(0x0df7);
409 APPEND_DEVICE(0x1050);
410 APPEND_DEVICE(0x1051);
411 APPEND_DEVICE(0x1052);
412 APPEND_DEVICE(0x1054);
413 APPEND_DEVICE(0x1055);
414 break;
415 case DeviceFamily::Bug1116812:
416 APPEND_DEVICE(0x2e32);
417 APPEND_DEVICE(0x2a02);
418 break;
419 case DeviceFamily::Bug1155608:
420 APPEND_DEVICE(0x2e22); /* IntelG45_1 */
421 break;
422 case DeviceFamily::Bug1447141:
423 APPEND_DEVICE(0x9991);
424 APPEND_DEVICE(0x9993);
425 APPEND_DEVICE(0x9996);
426 APPEND_DEVICE(0x9998);
427 APPEND_DEVICE(0x9901);
428 APPEND_DEVICE(0x990b);
429 break;
430 case DeviceFamily::Bug1207665:
431 APPEND_DEVICE(0xa001); /* Intel Media Accelerator 3150 */
432 APPEND_DEVICE(0xa002);
433 APPEND_DEVICE(0xa011);
434 APPEND_DEVICE(0xa012);
435 break;
436 case DeviceFamily::AmdR600:
437 // AMD R600 generation GPUs
438 // R600
439 APPEND_RANGE(0x9400, 0x9403);
440 APPEND_DEVICE(0x9405);
441 APPEND_RANGE(0x940a, 0x940b);
442 APPEND_DEVICE(0x940f);
443 // RV610
444 APPEND_RANGE(0x94c0, 0x94c1);
445 APPEND_RANGE(0x94c3, 0x94c9);
446 APPEND_RANGE(0x94cb, 0x94cd);
447 // RV630
448 APPEND_RANGE(0x9580, 0x9581);
449 APPEND_DEVICE(0x9583);
450 APPEND_RANGE(0x9586, 0x958f);
451 // RV670
452 APPEND_RANGE(0x9500, 0x9501);
453 APPEND_RANGE(0x9504, 0x9509);
454 APPEND_DEVICE(0x950f);
455 APPEND_DEVICE(0x9511);
456 APPEND_DEVICE(0x9515);
457 APPEND_DEVICE(0x9517);
458 APPEND_DEVICE(0x9519);
459 // RV620
460 APPEND_DEVICE(0x95c0);
461 APPEND_DEVICE(0x95c2);
462 APPEND_RANGE(0x95c4, 0x95c7);
463 APPEND_DEVICE(0x95c9);
464 APPEND_RANGE(0x95cc, 0x95cf);
465 // RV635
466 APPEND_RANGE(0x9590, 0x9591);
467 APPEND_DEVICE(0x9593);
468 APPEND_RANGE(0x9595, 0x9599);
469 APPEND_DEVICE(0x959b);
470 // RS780
471 APPEND_RANGE(0x9610, 0x9616);
472 // RS880
473 APPEND_RANGE(0x9710, 0x9715);
474 break;
475 case DeviceFamily::NvidiaRolloutWebRender:
476 APPEND_RANGE(0x0400, 0x04ff);
477 APPEND_RANGE(0x05e0, 0x05ff);
478 APPEND_RANGE(0x0600, INT32_MAX);
479 APPEND_RANGE(0x06c0, INT32_MAX);
480 break;
481 case DeviceFamily::IntelRolloutWebRender:
482 #ifdef EARLY_BETA_OR_EARLIER
483 // gen4.5 - G45
484 APPEND_DEVICE(0x2e22);
486 // gen5 (ironlake)
487 APPEND_DEVICE(0x0042);
488 APPEND_DEVICE(0x0046);
489 #endif
491 // cherryview
492 APPEND_DEVICE(0x22b0);
493 APPEND_DEVICE(0x22b1);
494 APPEND_DEVICE(0x22b2);
495 APPEND_DEVICE(0x22b3);
497 [[fallthrough]];
498 case DeviceFamily::IntelModernRolloutWebRender:
499 // sandybridge gen6 gt1
500 APPEND_DEVICE(0x0102);
501 APPEND_DEVICE(0x0106);
502 APPEND_DEVICE(0x010a);
504 // sandybridge gen6 gt2
505 APPEND_DEVICE(0x0112);
506 APPEND_DEVICE(0x0116);
507 APPEND_DEVICE(0x0122);
508 APPEND_DEVICE(0x0126);
510 // ivybridge gen7 baytrail
511 APPEND_DEVICE(0x0f30);
512 APPEND_DEVICE(0x0f31);
513 APPEND_DEVICE(0x0f33);
514 APPEND_DEVICE(0x0155);
515 APPEND_DEVICE(0x0157);
517 // ivybridge gen7 gt1
518 APPEND_DEVICE(0x0152);
519 APPEND_DEVICE(0x0156);
520 APPEND_DEVICE(0x015a);
522 // ivybridge gen7 gt2
523 APPEND_DEVICE(0x0162);
524 APPEND_DEVICE(0x0166);
525 APPEND_DEVICE(0x016a);
527 // haswell gen7.5 gt1
528 APPEND_DEVICE(0x0402);
529 APPEND_DEVICE(0x0406);
530 APPEND_DEVICE(0x040a);
531 APPEND_DEVICE(0x040b);
532 APPEND_DEVICE(0x040e);
533 APPEND_DEVICE(0x0a02);
534 APPEND_DEVICE(0x0a06);
535 APPEND_DEVICE(0x0a0a);
536 APPEND_DEVICE(0x0a0b);
537 APPEND_DEVICE(0x0a0e);
538 APPEND_DEVICE(0x0c02);
539 APPEND_DEVICE(0x0c06);
540 APPEND_DEVICE(0x0c0c);
541 APPEND_DEVICE(0x0c0b);
542 APPEND_DEVICE(0x0c0e);
543 APPEND_DEVICE(0x0d02);
544 APPEND_DEVICE(0x0d06);
545 APPEND_DEVICE(0x0d0a);
546 APPEND_DEVICE(0x0d0b);
547 APPEND_DEVICE(0x0d0e);
549 // haswell gen7.5 gt2
550 APPEND_DEVICE(0x0412);
551 APPEND_DEVICE(0x0416);
552 APPEND_DEVICE(0x041a);
553 APPEND_DEVICE(0x041b);
554 APPEND_DEVICE(0x041e);
555 APPEND_DEVICE(0x0a12);
556 APPEND_DEVICE(0x0a16);
557 APPEND_DEVICE(0x0a1a);
558 APPEND_DEVICE(0x0a1b);
559 APPEND_DEVICE(0x0a1e);
561 // haswell gen7.5 gt3
562 APPEND_DEVICE(0x0422);
563 APPEND_DEVICE(0x0426);
564 APPEND_DEVICE(0x042a);
565 APPEND_DEVICE(0x042b);
566 APPEND_DEVICE(0x042e);
567 APPEND_DEVICE(0x0a22);
568 APPEND_DEVICE(0x0a26);
569 APPEND_DEVICE(0x0a0a);
570 APPEND_DEVICE(0x0a1a);
571 APPEND_DEVICE(0x0a2a);
572 APPEND_DEVICE(0x0a2b);
573 APPEND_DEVICE(0x0a2e);
574 APPEND_DEVICE(0x0c22);
575 APPEND_DEVICE(0x0c26);
576 APPEND_DEVICE(0x0c2c);
577 APPEND_DEVICE(0x0c2b);
578 APPEND_DEVICE(0x0c2e);
579 APPEND_DEVICE(0x0d22);
580 APPEND_DEVICE(0x0d26);
581 APPEND_DEVICE(0x0d2b);
582 APPEND_DEVICE(0x0d2e);
584 // broxton (apollolake)
585 APPEND_DEVICE(0x0a84);
586 APPEND_DEVICE(0x1a84);
587 APPEND_DEVICE(0x1a85);
588 APPEND_DEVICE(0x5a84);
589 APPEND_DEVICE(0x5a85);
591 // geminilake
592 APPEND_DEVICE(0x3184);
593 APPEND_DEVICE(0x3185);
595 // broadwell gt1 (gen8)
596 APPEND_DEVICE(0x1602);
597 APPEND_DEVICE(0x1606);
598 APPEND_DEVICE(0x160a);
599 APPEND_DEVICE(0x160b);
600 APPEND_DEVICE(0x160d);
601 APPEND_DEVICE(0x160e);
603 // broadwell gt2+ (gen8)
604 APPEND_DEVICE(0x1612);
605 APPEND_DEVICE(0x1616);
606 APPEND_DEVICE(0x161a);
607 APPEND_DEVICE(0x161b);
608 APPEND_DEVICE(0x161d);
609 APPEND_DEVICE(0x161e);
610 APPEND_DEVICE(0x1622);
611 APPEND_DEVICE(0x1626);
612 APPEND_DEVICE(0x162a);
613 APPEND_DEVICE(0x162b);
614 APPEND_DEVICE(0x162d);
615 APPEND_DEVICE(0x162e);
616 APPEND_DEVICE(0x1632);
617 APPEND_DEVICE(0x1636);
618 APPEND_DEVICE(0x163a);
619 APPEND_DEVICE(0x163b);
620 APPEND_DEVICE(0x163d);
621 APPEND_DEVICE(0x163e);
623 // skylake gt1
624 APPEND_DEVICE(0x1902);
625 APPEND_DEVICE(0x1906);
626 APPEND_DEVICE(0x190a);
627 APPEND_DEVICE(0x190e);
629 // skylake gt2
630 APPEND_DEVICE(0x1912);
631 APPEND_DEVICE(0x1913);
632 APPEND_DEVICE(0x1915);
633 APPEND_DEVICE(0x1916);
634 APPEND_DEVICE(0x1917);
635 APPEND_DEVICE(0x191a);
636 APPEND_DEVICE(0x191b);
637 APPEND_DEVICE(0x191d);
638 APPEND_DEVICE(0x191e);
639 APPEND_DEVICE(0x1921);
641 // skylake gt3
642 APPEND_DEVICE(0x1923);
643 APPEND_DEVICE(0x1926);
644 APPEND_DEVICE(0x1927);
645 APPEND_DEVICE(0x192b);
647 // skylake gt4
648 APPEND_DEVICE(0x1932);
649 APPEND_DEVICE(0x193a);
650 APPEND_DEVICE(0x193b);
651 APPEND_DEVICE(0x193d);
653 // kabylake gt1
654 APPEND_DEVICE(0x5902);
655 APPEND_DEVICE(0x5906);
656 APPEND_DEVICE(0x5908);
657 APPEND_DEVICE(0x590a);
658 APPEND_DEVICE(0x590b);
659 APPEND_DEVICE(0x590e);
661 // kabylake gt1.5
662 APPEND_DEVICE(0x5913);
663 APPEND_DEVICE(0x5915);
664 APPEND_DEVICE(0x5917);
666 // kabylake gt2
667 APPEND_DEVICE(0x5912);
668 APPEND_DEVICE(0x5916);
669 APPEND_DEVICE(0x591a);
670 APPEND_DEVICE(0x591b);
671 APPEND_DEVICE(0x591c);
672 APPEND_DEVICE(0x591d);
673 APPEND_DEVICE(0x591e);
674 APPEND_DEVICE(0x5921);
675 APPEND_DEVICE(0x5926);
676 APPEND_DEVICE(0x5923);
677 APPEND_DEVICE(0x5927);
678 APPEND_DEVICE(0x593b);
679 APPEND_DEVICE(0x87c0);
681 // coffeelake gt1
682 APPEND_DEVICE(0x3e90);
683 APPEND_DEVICE(0x3e93);
684 APPEND_DEVICE(0x3e99);
685 APPEND_DEVICE(0x3e9c);
686 APPEND_DEVICE(0x3ea1);
687 APPEND_DEVICE(0x3ea4);
688 APPEND_DEVICE(0x9b21);
689 APPEND_DEVICE(0x9ba0);
690 APPEND_DEVICE(0x9ba2);
691 APPEND_DEVICE(0x9ba4);
692 APPEND_DEVICE(0x9ba5);
693 APPEND_DEVICE(0x9ba8);
694 APPEND_DEVICE(0x9baa);
695 APPEND_DEVICE(0x9bab);
696 APPEND_DEVICE(0x9bac);
698 // coffeelake gt2+
699 APPEND_RANGE(0x3e91, 0x3e92);
700 APPEND_DEVICE(0x3e94);
701 APPEND_DEVICE(0x3e96);
702 APPEND_DEVICE(0x3e98);
703 APPEND_RANGE(0x3e9a, 0x3e9b);
704 APPEND_DEVICE(0x3ea0);
705 APPEND_DEVICE(0x3ea2);
706 APPEND_RANGE(0x3ea5, 0x3ea9);
707 APPEND_DEVICE(0x87ca);
708 APPEND_DEVICE(0x9b41);
709 APPEND_DEVICE(0x9bc0);
710 APPEND_DEVICE(0x9bc2);
711 APPEND_RANGE(0x9bc4, 0x9bf6);
713 // icelake gt1,gt1.5,gt2
714 APPEND_RANGE(0x8a50, 0x8a5d);
716 // rocketlake
717 APPEND_RANGE(0x4c8a, 0x4c9a);
719 // tigerlake
720 APPEND_RANGE(0x9a40, 0x9af8);
721 break;
722 case DeviceFamily::AtiRolloutWebRender:
723 APPEND_RANGE(0x6600, 0x66af);
724 APPEND_RANGE(0x6700, 0x671f);
725 APPEND_RANGE(0x6780, 0x683f);
726 APPEND_RANGE(0x6860, 0x687f);
727 APPEND_RANGE(0x6900, 0x69ff);
728 APPEND_DEVICE(0x6fdf);
729 APPEND_DEVICE(0x7300);
730 APPEND_RANGE(0x7310, 0x73ff);
731 APPEND_RANGE(0x9830, 0x986f);
732 APPEND_RANGE(0x9900, 0x99ff);
733 // Raven
734 APPEND_DEVICE(0x15dd);
735 APPEND_DEVICE(0x15d8);
736 // Renoir
737 APPEND_DEVICE(0x1636);
739 // Evergreen
740 APPEND_RANGE(0x6840, 0x684b);
741 APPEND_RANGE(0x6850, 0x685f);
742 APPEND_RANGE(0x6880, 0x68ff);
743 APPEND_RANGE(0x9800, 0x980a);
744 APPEND_RANGE(0x9640, 0x964f);
745 APPEND_RANGE(0x6720, 0x677f);
747 // Stoney
748 APPEND_DEVICE(0x98e4);
750 // Carrizo
751 APPEND_RANGE(0x9870, 0x9877);
753 // Kaveri
754 APPEND_RANGE(0x1304, 0x131d);
756 // R700
757 APPEND_RANGE(0x9440, 0x949f);
758 APPEND_RANGE(0x94a0, 0x94b9);
759 APPEND_RANGE(0x9540, 0x955f);
761 break;
762 // This should never happen, but we get a warning if we don't handle this.
763 case DeviceFamily::Max:
764 case DeviceFamily::All:
765 case DeviceFamily::IntelAll:
766 case DeviceFamily::NvidiaAll:
767 case DeviceFamily::AtiAll:
768 case DeviceFamily::MicrosoftAll:
769 case DeviceFamily::ParallelsAll:
770 case DeviceFamily::QualcommAll:
771 case DeviceFamily::AppleAll:
772 case DeviceFamily::AmazonAll:
773 NS_WARNING("Invalid DeviceFamily id");
774 break;
777 return deviceFamily;
780 // Macro for assigning a desktop environment to a string.
781 #define DECLARE_DESKTOP_ENVIRONMENT_ID(name, desktopEnvId) \
782 case DesktopEnvironment::name: \
783 sDesktopEnvironment[idx]->AssignLiteral(desktopEnvId); \
784 break;
786 const nsAString& GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment id) {
787 if (id >= DesktopEnvironment::Max) {
788 MOZ_ASSERT_UNREACHABLE("DesktopEnvironment id is out of range");
789 id = DesktopEnvironment::All;
792 auto idx = static_cast<size_t>(id);
793 if (sDesktopEnvironment[idx]) {
794 return *sDesktopEnvironment[idx];
797 sDesktopEnvironment[idx] = new nsString();
799 switch (id) {
800 DECLARE_DESKTOP_ENVIRONMENT_ID(GNOME, "gnome");
801 DECLARE_DESKTOP_ENVIRONMENT_ID(KDE, "kde");
802 DECLARE_DESKTOP_ENVIRONMENT_ID(XFCE, "xfce");
803 DECLARE_DESKTOP_ENVIRONMENT_ID(Cinnamon, "cinnamon");
804 DECLARE_DESKTOP_ENVIRONMENT_ID(Enlightenment, "enlightment");
805 DECLARE_DESKTOP_ENVIRONMENT_ID(LXDE, "lxde");
806 DECLARE_DESKTOP_ENVIRONMENT_ID(Openbox, "openbox");
807 DECLARE_DESKTOP_ENVIRONMENT_ID(i3, "i3");
808 DECLARE_DESKTOP_ENVIRONMENT_ID(Mate, "mate");
809 DECLARE_DESKTOP_ENVIRONMENT_ID(Unity, "unity");
810 DECLARE_DESKTOP_ENVIRONMENT_ID(Pantheon, "pantheon");
811 DECLARE_DESKTOP_ENVIRONMENT_ID(LXQT, "lxqt");
812 DECLARE_DESKTOP_ENVIRONMENT_ID(Deepin, "deepin");
813 DECLARE_DESKTOP_ENVIRONMENT_ID(Dwm, "dwm");
814 DECLARE_DESKTOP_ENVIRONMENT_ID(Budgie, "budgie");
815 DECLARE_DESKTOP_ENVIRONMENT_ID(Unknown, "unknown");
816 case DesktopEnvironment::Max: // Suppress a warning.
817 DECLARE_DESKTOP_ENVIRONMENT_ID(All, "");
820 return *sDesktopEnvironment[idx];
823 // Macro for assigning a window protocol id to a string.
824 #define DECLARE_WINDOW_PROTOCOL_ID(name, windowProtocolId) \
825 case WindowProtocol::name: \
826 sWindowProtocol[idx]->AssignLiteral(windowProtocolId); \
827 break;
829 const nsAString& GfxDriverInfo::GetWindowProtocol(WindowProtocol id) {
830 if (id >= WindowProtocol::Max) {
831 MOZ_ASSERT_UNREACHABLE("WindowProtocol id is out of range");
832 id = WindowProtocol::All;
835 auto idx = static_cast<size_t>(id);
836 if (sWindowProtocol[idx]) {
837 return *sWindowProtocol[idx];
840 sWindowProtocol[idx] = new nsString();
842 switch (id) {
843 DECLARE_WINDOW_PROTOCOL_ID(X11, "x11");
844 DECLARE_WINDOW_PROTOCOL_ID(XWayland, "xwayland");
845 DECLARE_WINDOW_PROTOCOL_ID(Wayland, "wayland");
846 DECLARE_WINDOW_PROTOCOL_ID(WaylandDRM, "wayland/drm");
847 DECLARE_WINDOW_PROTOCOL_ID(WaylandAll, "wayland/all");
848 DECLARE_WINDOW_PROTOCOL_ID(X11All, "x11/all");
849 case WindowProtocol::Max: // Suppress a warning.
850 DECLARE_WINDOW_PROTOCOL_ID(All, "");
853 return *sWindowProtocol[idx];
856 // Macro for assigning a device vendor id to a string.
857 #define DECLARE_VENDOR_ID(name, deviceId) \
858 case DeviceVendor::name: \
859 sDeviceVendors[idx]->AssignLiteral(deviceId); \
860 break;
862 const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceFamily id) {
863 if (id >= DeviceFamily::Max) {
864 MOZ_ASSERT_UNREACHABLE("DeviceVendor id is out of range");
865 id = DeviceFamily::All;
868 DeviceVendor vendor = DeviceVendor::All;
869 switch (id) {
870 case DeviceFamily::IntelAll:
871 case DeviceFamily::IntelGMA500:
872 case DeviceFamily::IntelGMA900:
873 case DeviceFamily::IntelGMA950:
874 case DeviceFamily::IntelGMA3150:
875 case DeviceFamily::IntelGMAX3000:
876 case DeviceFamily::IntelGMAX4500HD:
877 case DeviceFamily::IntelHDGraphicsToIvyBridge:
878 case DeviceFamily::IntelHDGraphicsToSandyBridge:
879 case DeviceFamily::IntelHaswell:
880 case DeviceFamily::IntelSandyBridge:
881 case DeviceFamily::IntelGen7Baytrail:
882 case DeviceFamily::IntelHD520:
883 case DeviceFamily::IntelMobileHDGraphics:
884 case DeviceFamily::IntelRolloutWebRender:
885 case DeviceFamily::IntelModernRolloutWebRender:
886 case DeviceFamily::Bug1116812:
887 case DeviceFamily::Bug1155608:
888 case DeviceFamily::Bug1207665:
889 vendor = DeviceVendor::Intel;
890 break;
891 case DeviceFamily::NvidiaAll:
892 case DeviceFamily::NvidiaBlockD3D9Layers:
893 case DeviceFamily::NvidiaRolloutWebRender:
894 case DeviceFamily::Geforce7300GT:
895 case DeviceFamily::Nvidia310M:
896 case DeviceFamily::Nvidia8800GTS:
897 case DeviceFamily::Bug1137716:
898 vendor = DeviceVendor::NVIDIA;
899 break;
900 case DeviceFamily::AtiAll:
901 case DeviceFamily::RadeonCaicos:
902 case DeviceFamily::RadeonX1000:
903 case DeviceFamily::Bug1447141:
904 case DeviceFamily::AmdR600:
905 case DeviceFamily::AtiRolloutWebRender:
906 vendor = DeviceVendor::ATI;
907 break;
908 case DeviceFamily::MicrosoftAll:
909 vendor = DeviceVendor::Microsoft;
910 break;
911 case DeviceFamily::ParallelsAll:
912 vendor = DeviceVendor::Parallels;
913 break;
914 case DeviceFamily::AppleAll:
915 vendor = DeviceVendor::Apple;
916 break;
917 case DeviceFamily::AmazonAll:
918 vendor = DeviceVendor::Amazon;
919 break;
920 case DeviceFamily::QualcommAll:
921 // Choose an arbitrary Qualcomm PCI VENdor ID for now.
922 // TODO: This should be "QCOM" when Windows device ID parsing is reworked.
923 vendor = DeviceVendor::Qualcomm;
924 break;
925 case DeviceFamily::All:
926 case DeviceFamily::Max:
927 break;
930 return GetDeviceVendor(vendor);
933 const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id) {
934 if (id >= DeviceVendor::Max) {
935 MOZ_ASSERT_UNREACHABLE("DeviceVendor id is out of range");
936 id = DeviceVendor::All;
939 auto idx = static_cast<size_t>(id);
940 if (sDeviceVendors[idx]) {
941 return *sDeviceVendors[idx];
944 sDeviceVendors[idx] = new nsString();
946 switch (id) {
947 DECLARE_VENDOR_ID(Intel, "0x8086");
948 DECLARE_VENDOR_ID(NVIDIA, "0x10de");
949 DECLARE_VENDOR_ID(ATI, "0x1002");
950 // AMD has 0x1022 but continues to release GPU hardware under ATI.
951 DECLARE_VENDOR_ID(Microsoft, "0x1414");
952 DECLARE_VENDOR_ID(MicrosoftBasic, "0x00ba");
953 DECLARE_VENDOR_ID(MicrosoftHyperV, "0x000b");
954 DECLARE_VENDOR_ID(Parallels, "0x1ab8");
955 DECLARE_VENDOR_ID(VMWare, "0x15ad");
956 DECLARE_VENDOR_ID(VirtualBox, "0x80ee");
957 DECLARE_VENDOR_ID(Apple, "0x106b");
958 DECLARE_VENDOR_ID(Amazon, "0x1d0f");
959 // Choose an arbitrary Qualcomm PCI VENdor ID for now.
960 // TODO: This should be "QCOM" when Windows device ID parsing is reworked.
961 DECLARE_VENDOR_ID(Qualcomm, "0x5143");
962 case DeviceVendor::Max: // Suppress a warning.
963 DECLARE_VENDOR_ID(All, "");
966 return *sDeviceVendors[idx];
969 // Macro for assigning a driver vendor id to a string.
970 #define DECLARE_DRIVER_VENDOR_ID(name, driverVendorId) \
971 case DriverVendor::name: \
972 sDriverVendors[idx]->AssignLiteral(driverVendorId); \
973 break;
975 const nsAString& GfxDriverInfo::GetDriverVendor(DriverVendor id) {
976 if (id >= DriverVendor::Max) {
977 MOZ_ASSERT_UNREACHABLE("DriverVendor id is out of range");
978 id = DriverVendor::All;
981 auto idx = static_cast<size_t>(id);
982 if (sDriverVendors[idx]) {
983 return *sDriverVendors[idx];
986 sDriverVendors[idx] = new nsString();
988 switch (id) {
989 DECLARE_DRIVER_VENDOR_ID(MesaAll, "mesa/all");
990 DECLARE_DRIVER_VENDOR_ID(MesaLLVMPipe, "mesa/llvmpipe");
991 DECLARE_DRIVER_VENDOR_ID(MesaSoftPipe, "mesa/softpipe");
992 DECLARE_DRIVER_VENDOR_ID(MesaSWRast, "mesa/swrast");
993 DECLARE_DRIVER_VENDOR_ID(MesaUnknown, "mesa/unknown");
994 DECLARE_DRIVER_VENDOR_ID(MesaR600, "mesa/r600");
995 DECLARE_DRIVER_VENDOR_ID(MesaNouveau, "mesa/nouveau");
996 DECLARE_DRIVER_VENDOR_ID(NonMesaAll, "non-mesa/all");
997 DECLARE_DRIVER_VENDOR_ID(HardwareMesaAll, "mesa/hw-all");
998 DECLARE_DRIVER_VENDOR_ID(SoftwareMesaAll, "mesa/sw-all");
999 case DriverVendor::Max: // Suppress a warning.
1000 DECLARE_DRIVER_VENDOR_ID(All, "");
1003 return *sDriverVendors[idx];