Bug 1837620 - Part 7: Keep JitScripts in a linked list to avoid iterating all BaseScr...
[gecko.git] / widget / GfxDriverInfo.cpp
blobd0afb0dca53166904d6f06bfcfba419b7f9b811f
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*
20 GfxDriverInfo::sWindowProtocol[static_cast<size_t>(WindowProtocol::Max)];
21 nsAString*
22 GfxDriverInfo::sDeviceVendors[static_cast<size_t>(DeviceVendor::Max)];
23 nsAString*
24 GfxDriverInfo::sDriverVendors[static_cast<size_t>(DriverVendor::Max)];
26 GfxDriverInfo::GfxDriverInfo()
27 : mOperatingSystem(OperatingSystem::Unknown),
28 mOperatingSystemVersion(0),
29 mScreen(ScreenSizeStatus::All),
30 mBattery(BatteryStatus::All),
31 mWindowProtocol(GfxDriverInfo::GetWindowProtocol(WindowProtocol::All)),
32 mAdapterVendor(GfxDriverInfo::GetDeviceVendor(DeviceFamily::All)),
33 mDriverVendor(GfxDriverInfo::GetDriverVendor(DriverVendor::All)),
34 mDevices(GfxDriverInfo::GetDeviceFamily(DeviceFamily::All)),
35 mDeleteDevices(false),
36 mFeature(allFeatures),
37 mFeatureStatus(nsIGfxInfo::FEATURE_STATUS_OK),
38 mComparisonOp(DRIVER_COMPARISON_IGNORED),
39 mDriverVersion(0),
40 mDriverVersionMax(0),
41 mSuggestedVersion(nullptr),
42 mRuleId(nullptr),
43 mGpu2(false) {}
45 GfxDriverInfo::GfxDriverInfo(
46 OperatingSystem os, ScreenSizeStatus screen, BatteryStatus battery,
47 const nsAString& windowProtocol, const nsAString& vendor,
48 const nsAString& driverVendor, GfxDeviceFamily* devices, int32_t feature,
49 int32_t featureStatus, VersionComparisonOp op, uint64_t driverVersion,
50 const char* ruleId, const char* suggestedVersion /* = nullptr */,
51 bool ownDevices /* = false */, bool gpu2 /* = false */)
52 : mOperatingSystem(os),
53 mOperatingSystemVersion(0),
54 mScreen(screen),
55 mBattery(battery),
56 mWindowProtocol(windowProtocol),
57 mAdapterVendor(vendor),
58 mDriverVendor(driverVendor),
59 mDevices(devices),
60 mDeleteDevices(ownDevices),
61 mFeature(feature),
62 mFeatureStatus(featureStatus),
63 mComparisonOp(op),
64 mDriverVersion(driverVersion),
65 mDriverVersionMax(0),
66 mSuggestedVersion(suggestedVersion),
67 mRuleId(ruleId),
68 mGpu2(gpu2) {}
70 GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
71 : mOperatingSystem(aOrig.mOperatingSystem),
72 mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
73 mScreen(aOrig.mScreen),
74 mBattery(aOrig.mBattery),
75 mWindowProtocol(aOrig.mWindowProtocol),
76 mAdapterVendor(aOrig.mAdapterVendor),
77 mDriverVendor(aOrig.mDriverVendor),
78 mFeature(aOrig.mFeature),
79 mFeatureStatus(aOrig.mFeatureStatus),
80 mComparisonOp(aOrig.mComparisonOp),
81 mDriverVersion(aOrig.mDriverVersion),
82 mDriverVersionMax(aOrig.mDriverVersionMax),
83 mSuggestedVersion(aOrig.mSuggestedVersion),
84 mRuleId(aOrig.mRuleId),
85 mGpu2(aOrig.mGpu2) {
86 // If we're managing the lifetime of the device family, we have to make a
87 // copy of the original's device family.
88 if (aOrig.mDeleteDevices && aOrig.mDevices) {
89 GfxDeviceFamily* devices = new GfxDeviceFamily;
90 *devices = *aOrig.mDevices;
91 mDevices = devices;
92 } else {
93 mDevices = aOrig.mDevices;
96 mDeleteDevices = aOrig.mDeleteDevices;
99 GfxDriverInfo::~GfxDriverInfo() {
100 if (mDeleteDevices) {
101 delete mDevices;
105 void GfxDeviceFamily::Append(const nsAString& aDeviceId) {
106 mIds.AppendElement(aDeviceId);
109 void GfxDeviceFamily::AppendRange(int32_t aBeginDeviceId,
110 int32_t aEndDeviceId) {
111 mRanges.AppendElement(
112 GfxDeviceFamily::DeviceRange{aBeginDeviceId, aEndDeviceId});
115 nsresult GfxDeviceFamily::Contains(nsAString& aDeviceId) const {
116 for (const auto& id : mIds) {
117 if (id.Equals(aDeviceId, nsCaseInsensitiveStringComparator)) {
118 return NS_OK;
122 if (mRanges.IsEmpty()) {
123 return NS_ERROR_NOT_AVAILABLE;
126 nsresult valid = NS_OK;
127 int32_t deviceId = aDeviceId.ToInteger(&valid, 16);
128 if (valid != NS_OK) {
129 return NS_ERROR_INVALID_ARG;
132 for (const auto& range : mRanges) {
133 if (deviceId >= range.mBegin && deviceId <= range.mEnd) {
134 return NS_OK;
138 return NS_ERROR_NOT_AVAILABLE;
141 // Macros for appending a device to the DeviceFamily.
142 #define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
143 #define APPEND_DEVICE2(device) \
144 deviceFamily->Append(NS_LITERAL_STRING_FROM_CSTRING(device))
145 #define APPEND_RANGE(start, end) deviceFamily->AppendRange(start, end)
147 const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) {
148 if (id >= DeviceFamily::Max) {
149 MOZ_ASSERT_UNREACHABLE("DeviceFamily id is out of range");
150 return nullptr;
153 // All of these have no specific device ID filtering.
154 switch (id) {
155 case DeviceFamily::All:
156 case DeviceFamily::IntelAll:
157 case DeviceFamily::NvidiaAll:
158 case DeviceFamily::AtiAll:
159 case DeviceFamily::MicrosoftAll:
160 case DeviceFamily::ParallelsAll:
161 case DeviceFamily::QualcommAll:
162 case DeviceFamily::AppleAll:
163 case DeviceFamily::AmazonAll:
164 return nullptr;
165 default:
166 break;
169 // If it already exists, we must have processed it once, so return it now.
170 auto idx = static_cast<size_t>(id);
171 if (sDeviceFamilies[idx]) {
172 return sDeviceFamilies[idx];
175 sDeviceFamilies[idx] = new GfxDeviceFamily;
176 GfxDeviceFamily* deviceFamily = sDeviceFamilies[idx];
178 switch (id) {
179 case DeviceFamily::IntelGMA500:
180 APPEND_DEVICE(0x8108); /* IntelGMA500_1 */
181 APPEND_DEVICE(0x8109); /* IntelGMA500_2 */
182 break;
183 case DeviceFamily::IntelGMA900:
184 APPEND_DEVICE(0x2582); /* IntelGMA900_1 */
185 APPEND_DEVICE(0x2782); /* IntelGMA900_2 */
186 APPEND_DEVICE(0x2592); /* IntelGMA900_3 */
187 APPEND_DEVICE(0x2792); /* IntelGMA900_4 */
188 break;
189 case DeviceFamily::IntelGMA950:
190 APPEND_DEVICE(0x2772); /* Intel945G_1 */
191 APPEND_DEVICE(0x2776); /* Intel945G_2 */
192 APPEND_DEVICE(0x27a2); /* Intel945_1 */
193 APPEND_DEVICE(0x27a6); /* Intel945_2 */
194 APPEND_DEVICE(0x27ae); /* Intel945_3 */
195 break;
196 case DeviceFamily::IntelGMA3150:
197 APPEND_DEVICE(0xa001); /* IntelGMA3150_Nettop_1 */
198 APPEND_DEVICE(0xa002); /* IntelGMA3150_Nettop_2 */
199 APPEND_DEVICE(0xa011); /* IntelGMA3150_Netbook_1 */
200 APPEND_DEVICE(0xa012); /* IntelGMA3150_Netbook_2 */
201 break;
202 case DeviceFamily::IntelGMAX3000:
203 APPEND_DEVICE(0x2972); /* Intel946GZ_1 */
204 APPEND_DEVICE(0x2973); /* Intel946GZ_2 */
205 APPEND_DEVICE(0x2982); /* IntelG35_1 */
206 APPEND_DEVICE(0x2983); /* IntelG35_2 */
207 APPEND_DEVICE(0x2992); /* IntelQ965_1 */
208 APPEND_DEVICE(0x2993); /* IntelQ965_2 */
209 APPEND_DEVICE(0x29a2); /* IntelG965_1 */
210 APPEND_DEVICE(0x29a3); /* IntelG965_2 */
211 APPEND_DEVICE(0x29b2); /* IntelQ35_1 */
212 APPEND_DEVICE(0x29b3); /* IntelQ35_2 */
213 APPEND_DEVICE(0x29c2); /* IntelG33_1 */
214 APPEND_DEVICE(0x29c3); /* IntelG33_2 */
215 APPEND_DEVICE(0x29d2); /* IntelQ33_1 */
216 APPEND_DEVICE(0x29d3); /* IntelQ33_2 */
217 APPEND_DEVICE(0x2a02); /* IntelGL960_1 */
218 APPEND_DEVICE(0x2a03); /* IntelGL960_2 */
219 APPEND_DEVICE(0x2a12); /* IntelGM965_1 */
220 APPEND_DEVICE(0x2a13); /* IntelGM965_2 */
221 break;
222 case DeviceFamily::IntelGMAX4500HD:
223 APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */
224 APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */
225 APPEND_DEVICE(0x2e42); /* IntelB43_1 */
226 APPEND_DEVICE(0x2e43); /* IntelB43_2 */
227 APPEND_DEVICE(0x2e92); /* IntelB43_3 */
228 APPEND_DEVICE(0x2e93); /* IntelB43_4 */
229 APPEND_DEVICE(0x2e32); /* IntelG41_1 */
230 APPEND_DEVICE(0x2e33); /* IntelG41_2 */
231 APPEND_DEVICE(0x2e22); /* IntelG45_1 */
232 APPEND_DEVICE(0x2e23); /* IntelG45_2 */
233 APPEND_DEVICE(0x2e12); /* IntelQ45_1 */
234 APPEND_DEVICE(0x2e13); /* IntelQ45_2 */
235 break;
236 case DeviceFamily::IntelHDGraphicsToIvyBridge:
237 APPEND_DEVICE(0x015A); /* IntelIvyBridge_GT1_1 (HD Graphics) */
238 // clang-format off
239 APPEND_DEVICE(0x0152); /* IntelIvyBridge_GT1_2 (HD Graphics 2500, desktop) */
240 APPEND_DEVICE(0x0162); /* IntelIvyBridge_GT2_1 (HD Graphics 4000, desktop) */
241 APPEND_DEVICE(0x0166); /* IntelIvyBridge_GT2_2 (HD Graphics 4000, mobile) */
242 APPEND_DEVICE(0x016A); /* IntelIvyBridge_GT2_3 (HD Graphics P4000, workstation) */
243 // clang-format on
244 [[fallthrough]];
245 case DeviceFamily::IntelHDGraphicsToSandyBridge:
246 APPEND_DEVICE(0x0042); /* IntelHDGraphics */
247 APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
248 APPEND_DEVICE(0x0102); /* IntelSandyBridge_1 */
249 APPEND_DEVICE(0x0106); /* IntelSandyBridge_2 */
250 APPEND_DEVICE(0x0112); /* IntelSandyBridge_3 */
251 APPEND_DEVICE(0x0116); /* IntelSandyBridge_4 */
252 APPEND_DEVICE(0x0122); /* IntelSandyBridge_5 */
253 APPEND_DEVICE(0x0126); /* IntelSandyBridge_6 */
254 APPEND_DEVICE(0x010a); /* IntelSandyBridge_7 */
255 break;
256 case DeviceFamily::IntelHaswell:
257 APPEND_DEVICE(0x0402); /* IntelHaswell_GT1_1 */
258 APPEND_DEVICE(0x0406); /* IntelHaswell_GT1_2 */
259 APPEND_DEVICE(0x040A); /* IntelHaswell_GT1_3 */
260 APPEND_DEVICE(0x040B); /* IntelHaswell_GT1_4 */
261 APPEND_DEVICE(0x040E); /* IntelHaswell_GT1_5 */
262 APPEND_DEVICE(0x0A02); /* IntelHaswell_GT1_6 */
263 APPEND_DEVICE(0x0A06); /* IntelHaswell_GT1_7 */
264 APPEND_DEVICE(0x0A0A); /* IntelHaswell_GT1_8 */
265 APPEND_DEVICE(0x0A0B); /* IntelHaswell_GT1_9 */
266 APPEND_DEVICE(0x0A0E); /* IntelHaswell_GT1_10 */
267 APPEND_DEVICE(0x0412); /* IntelHaswell_GT2_1 */
268 APPEND_DEVICE(0x0416); /* IntelHaswell_GT2_2 */
269 APPEND_DEVICE(0x041A); /* IntelHaswell_GT2_3 */
270 APPEND_DEVICE(0x041B); /* IntelHaswell_GT2_4 */
271 APPEND_DEVICE(0x041E); /* IntelHaswell_GT2_5 */
272 APPEND_DEVICE(0x0A12); /* IntelHaswell_GT2_6 */
273 APPEND_DEVICE(0x0A16); /* IntelHaswell_GT2_7 */
274 APPEND_DEVICE(0x0A1A); /* IntelHaswell_GT2_8 */
275 APPEND_DEVICE(0x0A1B); /* IntelHaswell_GT2_9 */
276 APPEND_DEVICE(0x0A1E); /* IntelHaswell_GT2_10 */
277 APPEND_DEVICE(0x0422); /* IntelHaswell_GT3_1 */
278 APPEND_DEVICE(0x0426); /* IntelHaswell_GT3_2 */
279 APPEND_DEVICE(0x042A); /* IntelHaswell_GT3_3 */
280 APPEND_DEVICE(0x042B); /* IntelHaswell_GT3_4 */
281 APPEND_DEVICE(0x042E); /* IntelHaswell_GT3_5 */
282 APPEND_DEVICE(0x0A22); /* IntelHaswell_GT3_6 */
283 APPEND_DEVICE(0x0A26); /* IntelHaswell_GT3_7 */
284 APPEND_DEVICE(0x0A2A); /* IntelHaswell_GT3_8 */
285 APPEND_DEVICE(0x0A2B); /* IntelHaswell_GT3_9 */
286 APPEND_DEVICE(0x0A2E); /* IntelHaswell_GT3_10 */
287 APPEND_DEVICE(0x0D22); /* IntelHaswell_GT3e_1 */
288 APPEND_DEVICE(0x0D26); /* IntelHaswell_GT3e_2 */
289 APPEND_DEVICE(0x0D2A); /* IntelHaswell_GT3e_3 */
290 APPEND_DEVICE(0x0D2B); /* IntelHaswell_GT3e_4 */
291 APPEND_DEVICE(0x0D2E); /* IntelHaswell_GT3e_5 */
292 break;
293 case DeviceFamily::IntelSandyBridge:
294 APPEND_DEVICE(0x0102);
295 APPEND_DEVICE(0x0106);
296 APPEND_DEVICE(0x010a);
297 APPEND_DEVICE(0x0112);
298 APPEND_DEVICE(0x0116);
299 APPEND_DEVICE(0x0122);
300 APPEND_DEVICE(0x0126);
301 break;
302 case DeviceFamily::IntelGen7Baytrail:
303 APPEND_DEVICE(0x0f30);
304 APPEND_DEVICE(0x0f31);
305 APPEND_DEVICE(0x0f33);
306 APPEND_DEVICE(0x0155);
307 APPEND_DEVICE(0x0157);
308 break;
309 case DeviceFamily::IntelSkylake:
310 APPEND_DEVICE(0x1902);
311 APPEND_DEVICE(0x1906);
312 APPEND_DEVICE(0x190a);
313 APPEND_DEVICE(0x190B);
314 APPEND_DEVICE(0x190e);
315 APPEND_DEVICE(0x1912);
316 APPEND_DEVICE(0x1913);
317 APPEND_DEVICE(0x1915);
318 APPEND_DEVICE(0x1916);
319 APPEND_DEVICE(0x1917);
320 APPEND_DEVICE(0x191a);
321 APPEND_DEVICE(0x191b);
322 APPEND_DEVICE(0x191d);
323 APPEND_DEVICE(0x191e);
324 APPEND_DEVICE(0x1921);
325 APPEND_DEVICE(0x1923);
326 APPEND_DEVICE(0x1926);
327 APPEND_DEVICE(0x1927);
328 APPEND_DEVICE(0x192a);
329 APPEND_DEVICE(0x192b);
330 APPEND_DEVICE(0x192d);
331 APPEND_DEVICE(0x1932);
332 APPEND_DEVICE(0x193a);
333 APPEND_DEVICE(0x193b);
334 APPEND_DEVICE(0x193d);
335 break;
336 case DeviceFamily::IntelKabyLake:
337 APPEND_DEVICE(0x5902);
338 APPEND_DEVICE(0x5906);
339 APPEND_DEVICE(0x5908);
340 APPEND_DEVICE(0x590A);
341 APPEND_DEVICE(0x590B);
342 APPEND_DEVICE(0x590E);
343 APPEND_DEVICE(0x5913);
344 APPEND_DEVICE(0x5915);
345 APPEND_DEVICE(0x5912);
346 APPEND_DEVICE(0x5916);
347 APPEND_DEVICE(0x5917);
348 APPEND_DEVICE(0x591A);
349 APPEND_DEVICE(0x591B);
350 APPEND_DEVICE(0x591D);
351 APPEND_DEVICE(0x591E);
352 APPEND_DEVICE(0x5921);
353 APPEND_DEVICE(0x5923);
354 APPEND_DEVICE(0x5926);
355 APPEND_DEVICE(0x5927);
356 APPEND_DEVICE(0x593B);
357 APPEND_DEVICE(0x591C);
358 APPEND_DEVICE(0x87C0);
359 break;
360 case DeviceFamily::IntelHD520:
361 APPEND_DEVICE(0x1916);
362 break;
363 case DeviceFamily::IntelMobileHDGraphics:
364 APPEND_DEVICE(0x0046); /* IntelMobileHDGraphics */
365 break;
366 case DeviceFamily::NvidiaBlockD3D9Layers:
367 // Glitches whilst scrolling (see bugs 612007, 644787, 645872)
368 APPEND_DEVICE(0x00f3); /* NV43 [GeForce 6200 (TM)] */
369 APPEND_DEVICE(0x0146); /* NV43 [Geforce Go 6600TE/6200TE (TM)] */
370 APPEND_DEVICE(0x014f); /* NV43 [GeForce 6200 (TM)] */
371 APPEND_DEVICE(0x0161); /* NV44 [GeForce 6200 TurboCache (TM)] */
372 APPEND_DEVICE(0x0162); /* NV44 [GeForce 6200SE TurboCache (TM)] */
373 APPEND_DEVICE(0x0163); /* NV44 [GeForce 6200 LE (TM)] */
374 APPEND_DEVICE(0x0164); /* NV44 [GeForce Go 6200 (TM)] */
375 APPEND_DEVICE(0x0167); /* NV43 [GeForce Go 6200/6400 (TM)] */
376 APPEND_DEVICE(0x0168); /* NV43 [GeForce Go 6200/6400 (TM)] */
377 APPEND_DEVICE(0x0169); /* NV44 [GeForce 6250 (TM)] */
378 APPEND_DEVICE(0x0222); /* NV44 [GeForce 6200 A-LE (TM)] */
379 APPEND_DEVICE(0x0240); /* C51PV [GeForce 6150 (TM)] */
380 APPEND_DEVICE(0x0241); /* C51 [GeForce 6150 LE (TM)] */
381 APPEND_DEVICE(0x0244); /* C51 [Geforce Go 6150 (TM)] */
382 APPEND_DEVICE(0x0245); /* C51 [Quadro NVS 210S/GeForce 6150LE (TM)] */
383 APPEND_DEVICE(0x0247); /* C51 [GeForce Go 6100 (TM)] */
384 APPEND_DEVICE(0x03d0); /* C61 [GeForce 6150SE nForce 430 (TM)] */
385 APPEND_DEVICE(0x03d1); /* C61 [GeForce 6100 nForce 405 (TM)] */
386 APPEND_DEVICE(0x03d2); /* C61 [GeForce 6100 nForce 400 (TM)] */
387 APPEND_DEVICE(0x03d5); /* C61 [GeForce 6100 nForce 420 (TM)] */
388 break;
389 case DeviceFamily::RadeonX1000:
390 // This list is from the ATIRadeonX1000.kext Info.plist
391 APPEND_DEVICE(0x7187);
392 APPEND_DEVICE(0x7210);
393 APPEND_DEVICE(0x71de);
394 APPEND_DEVICE(0x7146);
395 APPEND_DEVICE(0x7142);
396 APPEND_DEVICE(0x7109);
397 APPEND_DEVICE(0x71c5);
398 APPEND_DEVICE(0x71c0);
399 APPEND_DEVICE(0x7240);
400 APPEND_DEVICE(0x7249);
401 APPEND_DEVICE(0x7291);
402 break;
403 case DeviceFamily::RadeonCaicos:
404 APPEND_DEVICE(0x6766);
405 APPEND_DEVICE(0x6767);
406 APPEND_DEVICE(0x6768);
407 APPEND_DEVICE(0x6770);
408 APPEND_DEVICE(0x6771);
409 APPEND_DEVICE(0x6772);
410 APPEND_DEVICE(0x6778);
411 APPEND_DEVICE(0x6779);
412 APPEND_DEVICE(0x677b);
413 break;
414 case DeviceFamily::RadeonBlockZeroVideoCopy:
415 // Stoney
416 APPEND_DEVICE(0x98e4);
417 // Carrizo
418 APPEND_RANGE(0x9870, 0x9877);
419 break;
420 case DeviceFamily::Geforce7300GT:
421 APPEND_DEVICE(0x0393);
422 break;
423 case DeviceFamily::Nvidia310M:
424 APPEND_DEVICE(0x0A70);
425 break;
426 case DeviceFamily::Nvidia8800GTS:
427 APPEND_DEVICE(0x0193);
428 break;
429 case DeviceFamily::Bug1137716:
430 APPEND_DEVICE(0x0a29);
431 APPEND_DEVICE(0x0a2b);
432 APPEND_DEVICE(0x0a2d);
433 APPEND_DEVICE(0x0a35);
434 APPEND_DEVICE(0x0a6c);
435 APPEND_DEVICE(0x0a70);
436 APPEND_DEVICE(0x0a72);
437 APPEND_DEVICE(0x0a7a);
438 APPEND_DEVICE(0x0caf);
439 APPEND_DEVICE(0x0dd2);
440 APPEND_DEVICE(0x0dd3);
441 // GF180M ids
442 APPEND_DEVICE(0x0de3);
443 APPEND_DEVICE(0x0de8);
444 APPEND_DEVICE(0x0de9);
445 APPEND_DEVICE(0x0dea);
446 APPEND_DEVICE(0x0deb);
447 APPEND_DEVICE(0x0dec);
448 APPEND_DEVICE(0x0ded);
449 APPEND_DEVICE(0x0dee);
450 APPEND_DEVICE(0x0def);
451 APPEND_DEVICE(0x0df0);
452 APPEND_DEVICE(0x0df1);
453 APPEND_DEVICE(0x0df2);
454 APPEND_DEVICE(0x0df3);
455 APPEND_DEVICE(0x0df4);
456 APPEND_DEVICE(0x0df5);
457 APPEND_DEVICE(0x0df6);
458 APPEND_DEVICE(0x0df7);
459 APPEND_DEVICE(0x1050);
460 APPEND_DEVICE(0x1051);
461 APPEND_DEVICE(0x1052);
462 APPEND_DEVICE(0x1054);
463 APPEND_DEVICE(0x1055);
464 break;
465 case DeviceFamily::Bug1116812:
466 APPEND_DEVICE(0x2e32);
467 APPEND_DEVICE(0x2a02);
468 break;
469 case DeviceFamily::Bug1155608:
470 APPEND_DEVICE(0x2e22); /* IntelG45_1 */
471 break;
472 case DeviceFamily::Bug1447141:
473 APPEND_DEVICE(0x9991);
474 APPEND_DEVICE(0x9993);
475 APPEND_DEVICE(0x9996);
476 APPEND_DEVICE(0x9998);
477 APPEND_DEVICE(0x9901);
478 APPEND_DEVICE(0x990b);
479 break;
480 case DeviceFamily::Bug1207665:
481 APPEND_DEVICE(0xa001); /* Intel Media Accelerator 3150 */
482 APPEND_DEVICE(0xa002);
483 APPEND_DEVICE(0xa011);
484 APPEND_DEVICE(0xa012);
485 break;
486 case DeviceFamily::AmdR600:
487 // AMD R600 generation GPUs
488 // R600
489 APPEND_RANGE(0x9400, 0x9403);
490 APPEND_DEVICE(0x9405);
491 APPEND_RANGE(0x940a, 0x940b);
492 APPEND_DEVICE(0x940f);
493 // RV610
494 APPEND_RANGE(0x94c0, 0x94c1);
495 APPEND_RANGE(0x94c3, 0x94c9);
496 APPEND_RANGE(0x94cb, 0x94cd);
497 // RV630
498 APPEND_RANGE(0x9580, 0x9581);
499 APPEND_DEVICE(0x9583);
500 APPEND_RANGE(0x9586, 0x958f);
501 // RV670
502 APPEND_RANGE(0x9500, 0x9501);
503 APPEND_RANGE(0x9504, 0x9509);
504 APPEND_DEVICE(0x950f);
505 APPEND_DEVICE(0x9511);
506 APPEND_DEVICE(0x9515);
507 APPEND_DEVICE(0x9517);
508 APPEND_DEVICE(0x9519);
509 // RV620
510 APPEND_DEVICE(0x95c0);
511 APPEND_DEVICE(0x95c2);
512 APPEND_RANGE(0x95c4, 0x95c7);
513 APPEND_DEVICE(0x95c9);
514 APPEND_RANGE(0x95cc, 0x95cf);
515 // RV635
516 APPEND_RANGE(0x9590, 0x9591);
517 APPEND_DEVICE(0x9593);
518 APPEND_RANGE(0x9595, 0x9599);
519 APPEND_DEVICE(0x959b);
520 // RS780
521 APPEND_RANGE(0x9610, 0x9616);
522 // RS880
523 APPEND_RANGE(0x9710, 0x9715);
524 break;
525 case DeviceFamily::NvidiaWebRenderBlocked:
526 APPEND_RANGE(0x0190, 0x019e); // early tesla
527 APPEND_RANGE(0x0500, 0x05df); // C67-C68
528 break;
529 case DeviceFamily::IntelWebRenderBlocked:
530 // powervr
531 // sgx535
532 APPEND_DEVICE(0x2e5b);
533 APPEND_DEVICE(0x8108);
534 APPEND_DEVICE(0x8109);
535 APPEND_DEVICE(0x4102);
536 // sgx545
537 APPEND_DEVICE(0x0be0);
538 APPEND_DEVICE(0x0be1);
539 APPEND_DEVICE(0x0be3);
540 APPEND_RANGE(0x08c7, 0x08cf);
542 // gen4
543 APPEND_DEVICE(0x2972);
544 APPEND_DEVICE(0x2973);
545 APPEND_DEVICE(0x2992);
546 APPEND_DEVICE(0x2993);
547 APPEND_DEVICE(0x29a2);
548 APPEND_DEVICE(0x29a3);
550 APPEND_DEVICE(0x2982);
551 APPEND_DEVICE(0x2983);
553 APPEND_DEVICE(0x2a02);
554 APPEND_DEVICE(0x2a03);
555 APPEND_DEVICE(0x2a12);
556 APPEND_DEVICE(0x2a13);
558 // gen4.5
559 APPEND_DEVICE(0x2e02);
560 APPEND_DEVICE(0x2e42); /* IntelB43_1 */
561 APPEND_DEVICE(0x2e43); /* IntelB43_2 */
562 APPEND_DEVICE(0x2e92); /* IntelB43_3 */
563 APPEND_DEVICE(0x2e93); /* IntelB43_4 */
564 APPEND_DEVICE(0x2e12); /* IntelQ45_1 */
565 APPEND_DEVICE(0x2e13); /* IntelQ45_2 */
566 APPEND_DEVICE(0x2e32); /* IntelG41_1 */
567 APPEND_DEVICE(0x2e33); /* IntelG41_2 */
568 APPEND_DEVICE(0x2e22); /* IntelG45_1 */
570 APPEND_DEVICE(0x2e23); /* IntelG45_2 */
571 APPEND_DEVICE(0x2a42); /* IntelGMA4500MHD_1 */
572 APPEND_DEVICE(0x2a43); /* IntelGMA4500MHD_2 */
574 // gen5 (ironlake)
575 APPEND_DEVICE(0x0042);
576 APPEND_DEVICE(0x0046);
577 break;
578 // This should never happen, but we get a warning if we don't handle this.
579 case DeviceFamily::Max:
580 case DeviceFamily::All:
581 case DeviceFamily::IntelAll:
582 case DeviceFamily::NvidiaAll:
583 case DeviceFamily::AtiAll:
584 case DeviceFamily::MicrosoftAll:
585 case DeviceFamily::ParallelsAll:
586 case DeviceFamily::QualcommAll:
587 case DeviceFamily::AppleAll:
588 case DeviceFamily::AmazonAll:
589 NS_WARNING("Invalid DeviceFamily id");
590 break;
593 return deviceFamily;
596 // Macro for assigning a window protocol id to a string.
597 #define DECLARE_WINDOW_PROTOCOL_ID(name, windowProtocolId) \
598 case WindowProtocol::name: \
599 sWindowProtocol[idx]->AssignLiteral(windowProtocolId); \
600 break;
602 const nsAString& GfxDriverInfo::GetWindowProtocol(WindowProtocol id) {
603 if (id >= WindowProtocol::Max) {
604 MOZ_ASSERT_UNREACHABLE("WindowProtocol id is out of range");
605 id = WindowProtocol::All;
608 auto idx = static_cast<size_t>(id);
609 if (sWindowProtocol[idx]) {
610 return *sWindowProtocol[idx];
613 sWindowProtocol[idx] = new nsString();
615 switch (id) {
616 DECLARE_WINDOW_PROTOCOL_ID(X11, "x11");
617 DECLARE_WINDOW_PROTOCOL_ID(XWayland, "xwayland");
618 DECLARE_WINDOW_PROTOCOL_ID(Wayland, "wayland");
619 DECLARE_WINDOW_PROTOCOL_ID(WaylandDRM, "wayland/drm");
620 DECLARE_WINDOW_PROTOCOL_ID(WaylandAll, "wayland/all");
621 DECLARE_WINDOW_PROTOCOL_ID(X11All, "x11/all");
622 case WindowProtocol::Max: // Suppress a warning.
623 DECLARE_WINDOW_PROTOCOL_ID(All, "");
626 return *sWindowProtocol[idx];
629 // Macro for assigning a device vendor id to a string.
630 #define DECLARE_VENDOR_ID(name, deviceId) \
631 case DeviceVendor::name: \
632 sDeviceVendors[idx]->AssignLiteral(deviceId); \
633 break;
635 const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceFamily id) {
636 if (id >= DeviceFamily::Max) {
637 MOZ_ASSERT_UNREACHABLE("DeviceVendor id is out of range");
638 id = DeviceFamily::All;
641 DeviceVendor vendor = DeviceVendor::All;
642 switch (id) {
643 case DeviceFamily::IntelAll:
644 case DeviceFamily::IntelGMA500:
645 case DeviceFamily::IntelGMA900:
646 case DeviceFamily::IntelGMA950:
647 case DeviceFamily::IntelGMA3150:
648 case DeviceFamily::IntelGMAX3000:
649 case DeviceFamily::IntelGMAX4500HD:
650 case DeviceFamily::IntelHDGraphicsToIvyBridge:
651 case DeviceFamily::IntelHDGraphicsToSandyBridge:
652 case DeviceFamily::IntelHaswell:
653 case DeviceFamily::IntelSandyBridge:
654 case DeviceFamily::IntelGen7Baytrail:
655 case DeviceFamily::IntelSkylake:
656 case DeviceFamily::IntelKabyLake:
657 case DeviceFamily::IntelHD520:
658 case DeviceFamily::IntelMobileHDGraphics:
659 case DeviceFamily::IntelWebRenderBlocked:
660 case DeviceFamily::Bug1116812:
661 case DeviceFamily::Bug1155608:
662 case DeviceFamily::Bug1207665:
663 vendor = DeviceVendor::Intel;
664 break;
665 case DeviceFamily::NvidiaAll:
666 case DeviceFamily::NvidiaBlockD3D9Layers:
667 case DeviceFamily::NvidiaWebRenderBlocked:
668 case DeviceFamily::Geforce7300GT:
669 case DeviceFamily::Nvidia310M:
670 case DeviceFamily::Nvidia8800GTS:
671 case DeviceFamily::Bug1137716:
672 vendor = DeviceVendor::NVIDIA;
673 break;
674 case DeviceFamily::AtiAll:
675 case DeviceFamily::RadeonBlockZeroVideoCopy:
676 case DeviceFamily::RadeonCaicos:
677 case DeviceFamily::RadeonX1000:
678 case DeviceFamily::Bug1447141:
679 case DeviceFamily::AmdR600:
680 vendor = DeviceVendor::ATI;
681 break;
682 case DeviceFamily::MicrosoftAll:
683 vendor = DeviceVendor::Microsoft;
684 break;
685 case DeviceFamily::ParallelsAll:
686 vendor = DeviceVendor::Parallels;
687 break;
688 case DeviceFamily::AppleAll:
689 vendor = DeviceVendor::Apple;
690 break;
691 case DeviceFamily::AmazonAll:
692 vendor = DeviceVendor::Amazon;
693 break;
694 case DeviceFamily::QualcommAll:
695 // Choose an arbitrary Qualcomm PCI VENdor ID for now.
696 // TODO: This should be "QCOM" when Windows device ID parsing is reworked.
697 vendor = DeviceVendor::Qualcomm;
698 break;
699 case DeviceFamily::All:
700 case DeviceFamily::Max:
701 break;
704 return GetDeviceVendor(vendor);
707 const nsAString& GfxDriverInfo::GetDeviceVendor(DeviceVendor id) {
708 if (id >= DeviceVendor::Max) {
709 MOZ_ASSERT_UNREACHABLE("DeviceVendor id is out of range");
710 id = DeviceVendor::All;
713 auto idx = static_cast<size_t>(id);
714 if (sDeviceVendors[idx]) {
715 return *sDeviceVendors[idx];
718 sDeviceVendors[idx] = new nsString();
720 switch (id) {
721 DECLARE_VENDOR_ID(Intel, "0x8086");
722 DECLARE_VENDOR_ID(NVIDIA, "0x10de");
723 DECLARE_VENDOR_ID(ATI, "0x1002");
724 // AMD has 0x1022 but continues to release GPU hardware under ATI.
725 DECLARE_VENDOR_ID(Microsoft, "0x1414");
726 DECLARE_VENDOR_ID(MicrosoftBasic, "0x00ba");
727 DECLARE_VENDOR_ID(MicrosoftHyperV, "0x000b");
728 DECLARE_VENDOR_ID(Parallels, "0x1ab8");
729 DECLARE_VENDOR_ID(VMWare, "0x15ad");
730 DECLARE_VENDOR_ID(VirtualBox, "0x80ee");
731 DECLARE_VENDOR_ID(Apple, "0x106b");
732 DECLARE_VENDOR_ID(Amazon, "0x1d0f");
733 // Choose an arbitrary Qualcomm PCI VENdor ID for now.
734 // TODO: This should be "QCOM" when Windows device ID parsing is reworked.
735 DECLARE_VENDOR_ID(Qualcomm, "0x5143");
736 case DeviceVendor::Max: // Suppress a warning.
737 DECLARE_VENDOR_ID(All, "");
740 return *sDeviceVendors[idx];
743 // Macro for assigning a driver vendor id to a string.
744 #define DECLARE_DRIVER_VENDOR_ID(name, driverVendorId) \
745 case DriverVendor::name: \
746 sDriverVendors[idx]->AssignLiteral(driverVendorId); \
747 break;
749 const nsAString& GfxDriverInfo::GetDriverVendor(DriverVendor id) {
750 if (id >= DriverVendor::Max) {
751 MOZ_ASSERT_UNREACHABLE("DriverVendor id is out of range");
752 id = DriverVendor::All;
755 auto idx = static_cast<size_t>(id);
756 if (sDriverVendors[idx]) {
757 return *sDriverVendors[idx];
760 sDriverVendors[idx] = new nsString();
762 switch (id) {
763 DECLARE_DRIVER_VENDOR_ID(MesaAll, "mesa/all");
764 DECLARE_DRIVER_VENDOR_ID(MesaLLVMPipe, "mesa/llvmpipe");
765 DECLARE_DRIVER_VENDOR_ID(MesaSoftPipe, "mesa/softpipe");
766 DECLARE_DRIVER_VENDOR_ID(MesaSWRast, "mesa/swrast");
767 DECLARE_DRIVER_VENDOR_ID(MesaSWUnknown, "mesa/software-unknown");
768 DECLARE_DRIVER_VENDOR_ID(MesaUnknown, "mesa/unknown");
769 DECLARE_DRIVER_VENDOR_ID(MesaR600, "mesa/r600");
770 DECLARE_DRIVER_VENDOR_ID(MesaNouveau, "mesa/nouveau");
771 DECLARE_DRIVER_VENDOR_ID(NonMesaAll, "non-mesa/all");
772 DECLARE_DRIVER_VENDOR_ID(HardwareMesaAll, "mesa/hw-all");
773 DECLARE_DRIVER_VENDOR_ID(SoftwareMesaAll, "mesa/sw-all");
774 DECLARE_DRIVER_VENDOR_ID(MesaNonIntelNvidiaAtiAll,
775 "mesa/non-intel-nvidia-ati-all");
776 DECLARE_DRIVER_VENDOR_ID(MesaVM, "mesa/vmwgfx");
777 case DriverVendor::Max: // Suppress a warning.
778 DECLARE_DRIVER_VENDOR_ID(All, "");
781 return *sDriverVendors[idx];