Bug 1874684 - Part 20: Tag stack classes with MOZ_STACK_CLASS. r=allstarschh
[gecko.git] / widget / windows / GfxInfo.cpp
blob0e1b4002d3874b50846d2696027cbe77bd3a0dc0
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 "GfxInfo.h"
8 #include "gfxConfig.h"
9 #include "GfxDriverInfo.h"
10 #include "gfxWindowsPlatform.h"
11 #include "jsapi.h"
12 #include "js/PropertyAndElement.h" // JS_SetElement, JS_SetProperty
13 #include "nsExceptionHandler.h"
14 #include "nsPrintfCString.h"
15 #include "nsUnicharUtils.h"
16 #include "prenv.h"
17 #include "prprf.h"
18 #include "xpcpublic.h"
20 #include "mozilla/Components.h"
21 #include "mozilla/Preferences.h"
22 #include "mozilla/gfx/DeviceManagerDx.h"
23 #include "mozilla/gfx/Logging.h"
24 #include "mozilla/SSE.h"
25 #include "mozilla/ArrayUtils.h"
26 #include "mozilla/WindowsProcessMitigations.h"
28 #include <intrin.h>
29 #include <windows.h>
30 #include <devguid.h> // for GUID_DEVCLASS_BATTERY
31 #include <setupapi.h> // for SetupDi*
32 #include <winioctl.h> // for IOCTL_*
33 #include <batclass.h> // for BATTERY_*
35 using namespace mozilla;
36 using namespace mozilla::gfx;
37 using namespace mozilla::widget;
39 #ifdef DEBUG
40 NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
41 #endif
43 static void AssertNotWin32kLockdown() {
44 // Check that we are not in Win32k lockdown
45 MOZ_DIAGNOSTIC_ASSERT(!IsWin32kLockedDown(),
46 "Invalid Windows GfxInfo API with Win32k lockdown");
49 /* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after
50 * gfxPlatform initialization has occurred because they depend on it for
51 * information. (See bug 591561) */
52 nsresult GfxInfo::GetD2DEnabled(bool* aEnabled) {
53 // Telemetry queries this during XPCOM initialization, and there's no
54 // gfxPlatform by then. Just bail out if gfxPlatform isn't initialized.
55 if (!gfxPlatform::Initialized()) {
56 *aEnabled = false;
57 return NS_OK;
60 // We check gfxConfig rather than the actual render mode, since the UI
61 // process does not use Direct2D if the GPU process is enabled. However,
62 // content processes can still use Direct2D.
63 *aEnabled = gfx::gfxConfig::IsEnabled(gfx::Feature::DIRECT2D);
64 return NS_OK;
67 nsresult GfxInfo::GetDWriteEnabled(bool* aEnabled) {
68 *aEnabled = gfxWindowsPlatform::GetPlatform()->DWriteEnabled();
69 return NS_OK;
72 NS_IMETHODIMP
73 GfxInfo::GetDWriteVersion(nsAString& aDwriteVersion) {
74 gfxWindowsPlatform::GetDLLVersion(L"dwrite.dll", aDwriteVersion);
75 return NS_OK;
78 NS_IMETHODIMP
79 GfxInfo::GetHasBattery(bool* aHasBattery) {
80 AssertNotWin32kLockdown();
82 *aHasBattery = mHasBattery;
83 return NS_OK;
86 NS_IMETHODIMP
87 GfxInfo::GetEmbeddedInFirefoxReality(bool* aEmbeddedInFirefoxReality) {
88 *aEmbeddedInFirefoxReality = gfxVars::FxREmbedded();
89 return NS_OK;
92 #define PIXEL_STRUCT_RGB 1
93 #define PIXEL_STRUCT_BGR 2
95 NS_IMETHODIMP
96 GfxInfo::GetCleartypeParameters(nsAString& aCleartypeParams) {
97 nsTArray<ClearTypeParameterInfo> clearTypeParams;
99 gfxWindowsPlatform::GetPlatform()->GetCleartypeParams(clearTypeParams);
100 uint32_t d, numDisplays = clearTypeParams.Length();
101 bool displayNames = (numDisplays > 1);
102 bool foundData = false;
103 nsString outStr;
105 for (d = 0; d < numDisplays; d++) {
106 ClearTypeParameterInfo& params = clearTypeParams[d];
108 if (displayNames) {
109 outStr.AppendPrintf(
110 "%S [ ", static_cast<const wchar_t*>(params.displayName.get()));
113 if (params.gamma >= 0) {
114 foundData = true;
115 outStr.AppendPrintf("Gamma: %.4g ", params.gamma / 1000.0);
118 if (params.pixelStructure >= 0) {
119 foundData = true;
120 if (params.pixelStructure == PIXEL_STRUCT_RGB ||
121 params.pixelStructure == PIXEL_STRUCT_BGR) {
122 outStr.AppendPrintf(
123 "Pixel Structure: %s ",
124 (params.pixelStructure == PIXEL_STRUCT_RGB ? "RGB" : "BGR"));
125 } else {
126 outStr.AppendPrintf("Pixel Structure: %d ", params.pixelStructure);
130 if (params.clearTypeLevel >= 0) {
131 foundData = true;
132 outStr.AppendPrintf("ClearType Level: %d ", params.clearTypeLevel);
135 if (params.enhancedContrast >= 0) {
136 foundData = true;
137 outStr.AppendPrintf("Enhanced Contrast: %d ", params.enhancedContrast);
140 if (displayNames) {
141 outStr.Append(u"] ");
145 if (foundData) {
146 aCleartypeParams.Assign(outStr);
147 return NS_OK;
149 return NS_ERROR_FAILURE;
152 NS_IMETHODIMP
153 GfxInfo::GetWindowProtocol(nsAString& aWindowProtocol) {
154 return NS_ERROR_NOT_IMPLEMENTED;
157 NS_IMETHODIMP
158 GfxInfo::GetTestType(nsAString& aTestType) { return NS_ERROR_NOT_IMPLEMENTED; }
160 static nsresult GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName,
161 uint32_t& destValue, int type) {
162 MOZ_ASSERT(type == REG_DWORD || type == REG_QWORD);
163 HKEY key;
164 DWORD dwcbData;
165 DWORD dValue;
166 DWORD resultType;
167 LONG result;
168 nsresult retval = NS_OK;
170 result =
171 RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyLocation, 0, KEY_QUERY_VALUE, &key);
172 if (result != ERROR_SUCCESS) {
173 return NS_ERROR_FAILURE;
176 switch (type) {
177 case REG_DWORD: {
178 // We only use this for vram size
179 dwcbData = sizeof(dValue);
180 result = RegQueryValueExW(key, keyName, nullptr, &resultType,
181 (LPBYTE)&dValue, &dwcbData);
182 if (result == ERROR_SUCCESS && resultType == REG_DWORD) {
183 destValue = (uint32_t)(dValue / 1024 / 1024);
184 } else {
185 retval = NS_ERROR_FAILURE;
187 break;
189 case REG_QWORD: {
190 // We only use this for vram size
191 LONGLONG qValue;
192 dwcbData = sizeof(qValue);
193 result = RegQueryValueExW(key, keyName, nullptr, &resultType,
194 (LPBYTE)&qValue, &dwcbData);
195 if (result == ERROR_SUCCESS && resultType == REG_QWORD) {
196 destValue = (uint32_t)(qValue / 1024 / 1024);
197 } else {
198 retval = NS_ERROR_FAILURE;
200 break;
203 RegCloseKey(key);
205 return retval;
208 static nsresult GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName,
209 nsAString& destString, int type) {
210 MOZ_ASSERT(type == REG_MULTI_SZ);
212 HKEY key;
213 DWORD dwcbData;
214 DWORD resultType;
215 LONG result;
216 nsresult retval = NS_OK;
218 result =
219 RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyLocation, 0, KEY_QUERY_VALUE, &key);
220 if (result != ERROR_SUCCESS) {
221 return NS_ERROR_FAILURE;
224 // A chain of null-separated strings; we convert the nulls to spaces
225 WCHAR wCharValue[1024];
226 dwcbData = sizeof(wCharValue);
228 result = RegQueryValueExW(key, keyName, nullptr, &resultType,
229 (LPBYTE)wCharValue, &dwcbData);
230 if (result == ERROR_SUCCESS && resultType == REG_MULTI_SZ) {
231 // This bit here could probably be cleaner.
232 bool isValid = false;
234 DWORD strLen = dwcbData / sizeof(wCharValue[0]);
235 for (DWORD i = 0; i < strLen; i++) {
236 if (wCharValue[i] == '\0') {
237 if (i < strLen - 1 && wCharValue[i + 1] == '\0') {
238 isValid = true;
239 break;
240 } else {
241 wCharValue[i] = ' ';
246 // ensure wCharValue is null terminated
247 wCharValue[strLen - 1] = '\0';
249 if (isValid) destString = wCharValue;
251 } else {
252 retval = NS_ERROR_FAILURE;
255 RegCloseKey(key);
257 return retval;
260 static nsresult GetKeyValues(const WCHAR* keyLocation, const WCHAR* keyName,
261 nsTArray<nsString>& destStrings) {
262 // First ask for the size of the value
263 DWORD size;
264 LONG rv = RegGetValueW(HKEY_LOCAL_MACHINE, keyLocation, keyName,
265 RRF_RT_REG_MULTI_SZ, nullptr, nullptr, &size);
266 if (rv != ERROR_SUCCESS) {
267 return NS_ERROR_FAILURE;
270 // Create a buffer with the proper size and retrieve the value
271 WCHAR* wCharValue = new WCHAR[size / sizeof(WCHAR)];
272 rv = RegGetValueW(HKEY_LOCAL_MACHINE, keyLocation, keyName,
273 RRF_RT_REG_MULTI_SZ, nullptr, (LPBYTE)wCharValue, &size);
274 if (rv != ERROR_SUCCESS) {
275 delete[] wCharValue;
276 return NS_ERROR_FAILURE;
279 // The value is a sequence of null-terminated strings, usually terminated by
280 // an empty string (\0). RegGetValue ensures that the value is properly
281 // terminated with a null character.
282 DWORD i = 0;
283 DWORD strLen = size / sizeof(WCHAR);
284 while (i < strLen) {
285 nsString value(wCharValue + i);
286 if (!value.IsEmpty()) {
287 destStrings.AppendElement(value);
289 i += value.Length() + 1;
291 delete[] wCharValue;
293 return NS_OK;
296 // The device ID is a string like PCI\VEN_15AD&DEV_0405&SUBSYS_040515AD
297 // this function is used to extract the id's out of it
298 uint32_t ParseIDFromDeviceID(const nsAString& key, const nsAString& prefix,
299 int length) {
300 nsAutoString id(key);
301 ToUpperCase(id);
302 int32_t start = id.Find(prefix);
303 if (start != -1) {
304 id.Cut(0, start + prefix.Length());
305 id.Truncate(length);
307 if (id.Equals(L"QCOM", nsCaseInsensitiveStringComparator)) {
308 // String format assumptions are broken, so use a Qualcomm PCI Vendor ID
309 // for now. See also GfxDriverInfo::GetDeviceVendor.
310 return 0x5143;
312 nsresult err;
313 return id.ToInteger(&err, 16);
316 // OS version in 16.16 major/minor form
317 // based on http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx
318 enum {
319 kWindowsUnknown = 0,
320 kWindows7 = 0x60001,
321 kWindows8 = 0x60002,
322 kWindows8_1 = 0x60003,
323 kWindows10 = 0xA0000
326 static bool HasBattery() {
327 // Helper classes to manage lifetimes of Windows structs.
328 class MOZ_STACK_CLASS HDevInfoHolder final {
329 public:
330 explicit HDevInfoHolder(HDEVINFO aHandle) : mHandle(aHandle) {}
332 ~HDevInfoHolder() { ::SetupDiDestroyDeviceInfoList(mHandle); }
334 private:
335 HDEVINFO mHandle;
338 class MOZ_STACK_CLASS HandleHolder final {
339 public:
340 explicit HandleHolder(HANDLE aHandle) : mHandle(aHandle) {}
342 ~HandleHolder() { ::CloseHandle(mHandle); }
344 private:
345 HANDLE mHandle;
348 HDEVINFO hdev =
349 ::SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY, nullptr, nullptr,
350 DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
351 if (hdev == INVALID_HANDLE_VALUE) {
352 return true;
355 HDevInfoHolder hdevHolder(hdev);
357 DWORD i = 0;
358 SP_DEVICE_INTERFACE_DATA did = {0};
359 did.cbSize = sizeof(did);
361 while (::SetupDiEnumDeviceInterfaces(hdev, nullptr, &GUID_DEVCLASS_BATTERY, i,
362 &did)) {
363 DWORD bufferSize = 0;
364 ::SetupDiGetDeviceInterfaceDetail(hdev, &did, nullptr, 0, &bufferSize,
365 nullptr);
366 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
367 return true;
370 UniquePtr<uint8_t[]> buffer(new (std::nothrow) uint8_t[bufferSize]);
371 if (!buffer) {
372 return true;
375 PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd =
376 reinterpret_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA>(buffer.get());
377 pdidd->cbSize = sizeof(*pdidd);
378 if (!::SetupDiGetDeviceInterfaceDetail(hdev, &did, pdidd, bufferSize,
379 &bufferSize, nullptr)) {
380 return true;
383 HANDLE hbat = ::CreateFile(pdidd->DevicePath, GENERIC_READ | GENERIC_WRITE,
384 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
385 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
386 if (hbat == INVALID_HANDLE_VALUE) {
387 return true;
390 HandleHolder hbatHolder(hbat);
392 BATTERY_QUERY_INFORMATION bqi = {0};
393 DWORD dwWait = 0;
394 DWORD dwOut;
396 // We need the tag to query the information below.
397 if (!::DeviceIoControl(hbat, IOCTL_BATTERY_QUERY_TAG, &dwWait,
398 sizeof(dwWait), &bqi.BatteryTag,
399 sizeof(bqi.BatteryTag), &dwOut, nullptr) ||
400 !bqi.BatteryTag) {
401 return true;
404 BATTERY_INFORMATION bi = {0};
405 bqi.InformationLevel = BatteryInformation;
407 if (!::DeviceIoControl(hbat, IOCTL_BATTERY_QUERY_INFORMATION, &bqi,
408 sizeof(bqi), &bi, sizeof(bi), &dwOut, nullptr)) {
409 return true;
412 // If a battery intended for general use (i.e. system use) is not a UPS
413 // (i.e. short term), then we know for certain we have a battery.
414 if ((bi.Capabilities & BATTERY_SYSTEM_BATTERY) &&
415 !(bi.Capabilities & BATTERY_IS_SHORT_TERM)) {
416 return true;
419 // Otherwise we check the next battery.
420 ++i;
423 // If we fail to enumerate because there are no more batteries to check, then
424 // we can safely say there are indeed no system batteries.
425 return ::GetLastError() != ERROR_NO_MORE_ITEMS;
428 /* Other interesting places for info:
429 * IDXGIAdapter::GetDesc()
430 * IDirectDraw7::GetAvailableVidMem()
431 * e->GetAvailableTextureMem()
432 * */
434 #define DEVICE_KEY_PREFIX L"\\Registry\\Machine\\"
435 nsresult GfxInfo::Init() {
436 nsresult rv = GfxInfoBase::Init();
438 // If we are locked down in a content process, we can't call any of the
439 // Win32k APIs below. Any method that accesses members of this class should
440 // assert that it's not used in content
441 if (IsWin32kLockedDown()) {
442 return rv;
445 mHasBattery = HasBattery();
447 DISPLAY_DEVICEW displayDevice;
448 displayDevice.cb = sizeof(displayDevice);
449 int deviceIndex = 0;
451 const char* spoofedWindowsVersion =
452 PR_GetEnv("MOZ_GFX_SPOOF_WINDOWS_VERSION");
453 if (spoofedWindowsVersion) {
454 PR_sscanf(spoofedWindowsVersion, "%x,%u", &mWindowsVersion,
455 &mWindowsBuildNumber);
456 } else {
457 OSVERSIONINFO vinfo;
458 vinfo.dwOSVersionInfoSize = sizeof(vinfo);
459 #ifdef _MSC_VER
460 # pragma warning(push)
461 # pragma warning(disable : 4996)
462 #endif
463 if (!GetVersionEx(&vinfo)) {
464 #ifdef _MSC_VER
465 # pragma warning(pop)
466 #endif
467 mWindowsVersion = kWindowsUnknown;
468 } else {
469 mWindowsVersion =
470 int32_t(vinfo.dwMajorVersion << 16) + vinfo.dwMinorVersion;
471 mWindowsBuildNumber = vinfo.dwBuildNumber;
475 mDeviceKeyDebug = u"PrimarySearch"_ns;
477 while (EnumDisplayDevicesW(nullptr, deviceIndex, &displayDevice, 0)) {
478 if (displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
479 mDeviceKeyDebug = u"NullSearch"_ns;
480 break;
482 deviceIndex++;
485 // make sure the string is nullptr terminated
486 if (wcsnlen(displayDevice.DeviceKey, ArrayLength(displayDevice.DeviceKey)) ==
487 ArrayLength(displayDevice.DeviceKey)) {
488 // we did not find a nullptr
489 return rv;
492 mDeviceKeyDebug = displayDevice.DeviceKey;
494 /* DeviceKey is "reserved" according to MSDN so we'll be careful with it */
495 /* check that DeviceKey begins with DEVICE_KEY_PREFIX */
496 /* some systems have a DeviceKey starting with \REGISTRY\Machine\ so we need
497 * to compare case insenstively */
498 /* If the device key is empty, we are most likely in a remote desktop
499 * environment. In this case we set the devicekey to an empty string so
500 * it can be handled later.
502 if (displayDevice.DeviceKey[0] != '\0') {
503 if (_wcsnicmp(displayDevice.DeviceKey, DEVICE_KEY_PREFIX,
504 ArrayLength(DEVICE_KEY_PREFIX) - 1) != 0) {
505 return rv;
508 // chop off DEVICE_KEY_PREFIX
509 mDeviceKey[0] =
510 displayDevice.DeviceKey + ArrayLength(DEVICE_KEY_PREFIX) - 1;
511 } else {
512 mDeviceKey[0].Truncate();
515 mDeviceID[0] = displayDevice.DeviceID;
516 mDeviceString[0] = displayDevice.DeviceString;
518 // On Windows 8 and Server 2012 hosts, we want to not block RDP
519 // sessions from attempting hardware acceleration. RemoteFX
520 // provides features and functionaltiy that can give a good D3D10 +
521 // D2D + DirectWrite experience emulated via a software GPU.
523 // Unfortunately, the Device ID is nullptr, and we can't enumerate
524 // it using the setup infrastructure (SetupDiGetClassDevsW below
525 // will return INVALID_HANDLE_VALUE).
526 UINT flags = DIGCF_PRESENT | DIGCF_PROFILE | DIGCF_ALLCLASSES;
527 if (mWindowsVersion >= kWindows8 && mDeviceID[0].Length() == 0 &&
528 mDeviceString[0].EqualsLiteral("RDPUDD Chained DD")) {
529 WCHAR sysdir[255];
530 UINT len = GetSystemDirectory(sysdir, sizeof(sysdir));
531 if (len < sizeof(sysdir)) {
532 nsString rdpudd(sysdir);
533 rdpudd.AppendLiteral("\\rdpudd.dll");
534 gfxWindowsPlatform::GetDLLVersion(rdpudd.BeginReading(),
535 mDriverVersion[0]);
536 mDriverDate[0].AssignLiteral("01-01-1970");
538 // 0x1414 is Microsoft; 0xfefe is an invented (and unused) code
539 mDeviceID[0].AssignLiteral("PCI\\VEN_1414&DEV_FEFE&SUBSYS_00000000");
540 flags |= DIGCF_DEVICEINTERFACE;
544 /* create a device information set composed of the current display device */
545 HDEVINFO devinfo =
546 SetupDiGetClassDevsW(nullptr, mDeviceID[0].get(), nullptr, flags);
548 if (devinfo != INVALID_HANDLE_VALUE) {
549 HKEY key;
550 LONG result;
551 WCHAR value[255];
552 DWORD dwcbData;
553 SP_DEVINFO_DATA devinfoData;
554 DWORD memberIndex = 0;
556 devinfoData.cbSize = sizeof(devinfoData);
557 constexpr auto driverKeyPre =
558 u"System\\CurrentControlSet\\Control\\Class\\"_ns;
559 /* enumerate device information elements in the device information set */
560 while (SetupDiEnumDeviceInfo(devinfo, memberIndex++, &devinfoData)) {
561 /* get a string that identifies the device's driver key */
562 if (SetupDiGetDeviceRegistryPropertyW(devinfo, &devinfoData, SPDRP_DRIVER,
563 nullptr, (PBYTE)value,
564 sizeof(value), nullptr)) {
565 nsAutoString driverKey(driverKeyPre);
566 driverKey += value;
567 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey.get(), 0,
568 KEY_QUERY_VALUE, &key);
569 if (result == ERROR_SUCCESS) {
570 /* we've found the driver we're looking for */
571 dwcbData = sizeof(value);
572 result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
573 (LPBYTE)value, &dwcbData);
574 if (result == ERROR_SUCCESS) {
575 mDriverVersion[0] = value;
576 } else {
577 // If the entry wasn't found, assume the worst (0.0.0.0).
578 mDriverVersion[0].AssignLiteral("0.0.0.0");
580 dwcbData = sizeof(value);
581 result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr,
582 (LPBYTE)value, &dwcbData);
583 if (result == ERROR_SUCCESS) {
584 mDriverDate[0] = value;
585 } else {
586 // Again, assume the worst
587 mDriverDate[0].AssignLiteral("01-01-1970");
589 RegCloseKey(key);
590 break;
595 SetupDiDestroyDeviceInfoList(devinfo);
598 // It is convenient to have these as integers
599 uint32_t adapterVendorID[2] = {0, 0};
600 uint32_t adapterDeviceID[2] = {0, 0};
601 uint32_t adapterSubsysID[2] = {0, 0};
603 adapterVendorID[0] = ParseIDFromDeviceID(mDeviceID[0], u"VEN_"_ns, 4);
604 adapterDeviceID[0] = ParseIDFromDeviceID(mDeviceID[0], u"&DEV_"_ns, 4);
605 adapterSubsysID[0] = ParseIDFromDeviceID(mDeviceID[0], u"&SUBSYS_"_ns, 8);
607 // Sometimes we don't get the valid device using this method. For now,
608 // allow zero vendor or device as valid, as long as the other value is
609 // non-zero.
610 bool foundValidDevice = (adapterVendorID[0] != 0 || adapterDeviceID[0] != 0);
612 // We now check for second display adapter. If we didn't find the valid
613 // device using the original approach, we will try the alternative.
615 // Device interface class for display adapters.
616 CLSID GUID_DISPLAY_DEVICE_ARRIVAL;
617 HRESULT hresult = CLSIDFromString(L"{1CA05180-A699-450A-9A0C-DE4FBE3DDD89}",
618 &GUID_DISPLAY_DEVICE_ARRIVAL);
619 if (hresult == NOERROR) {
620 devinfo =
621 SetupDiGetClassDevsW(&GUID_DISPLAY_DEVICE_ARRIVAL, nullptr, nullptr,
622 DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
624 if (devinfo != INVALID_HANDLE_VALUE) {
625 HKEY key;
626 LONG result;
627 WCHAR value[255];
628 DWORD dwcbData;
629 SP_DEVINFO_DATA devinfoData;
630 DWORD memberIndex = 0;
631 devinfoData.cbSize = sizeof(devinfoData);
633 nsAutoString adapterDriver2;
634 nsAutoString deviceID2;
635 nsAutoString driverVersion2;
636 nsAutoString driverDate2;
638 constexpr auto driverKeyPre =
639 u"System\\CurrentControlSet\\Control\\Class\\"_ns;
640 /* enumerate device information elements in the device information set */
641 while (SetupDiEnumDeviceInfo(devinfo, memberIndex++, &devinfoData)) {
642 /* get a string that identifies the device's driver key */
643 if (SetupDiGetDeviceRegistryPropertyW(
644 devinfo, &devinfoData, SPDRP_DRIVER, nullptr, (PBYTE)value,
645 sizeof(value), nullptr)) {
646 nsAutoString driverKey2(driverKeyPre);
647 driverKey2 += value;
648 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey2.get(), 0,
649 KEY_QUERY_VALUE, &key);
650 if (result == ERROR_SUCCESS) {
651 dwcbData = sizeof(value);
652 result = RegQueryValueExW(key, L"MatchingDeviceId", nullptr,
653 nullptr, (LPBYTE)value, &dwcbData);
654 if (result != ERROR_SUCCESS) {
655 continue;
657 deviceID2 = value;
658 adapterVendorID[1] = ParseIDFromDeviceID(deviceID2, u"VEN_"_ns, 4);
659 adapterDeviceID[1] = ParseIDFromDeviceID(deviceID2, u"&DEV_"_ns, 4);
660 // Skip the devices we already considered, as well as any
661 // "zero" ones.
662 if ((adapterVendorID[0] == adapterVendorID[1] &&
663 adapterDeviceID[0] == adapterDeviceID[1]) ||
664 (adapterVendorID[1] == 0 && adapterDeviceID[1] == 0)) {
665 RegCloseKey(key);
666 continue;
669 // If this device is missing driver information, it is unlikely to
670 // be a real display adapter.
671 if (NS_FAILED(GetKeyValue(driverKey2.get(),
672 L"InstalledDisplayDrivers",
673 adapterDriver2, REG_MULTI_SZ))) {
674 RegCloseKey(key);
675 continue;
677 dwcbData = sizeof(value);
678 result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
679 (LPBYTE)value, &dwcbData);
680 if (result != ERROR_SUCCESS) {
681 RegCloseKey(key);
682 continue;
684 driverVersion2 = value;
685 dwcbData = sizeof(value);
686 result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr,
687 (LPBYTE)value, &dwcbData);
688 if (result != ERROR_SUCCESS) {
689 RegCloseKey(key);
690 continue;
692 driverDate2 = value;
693 dwcbData = sizeof(value);
694 result = RegQueryValueExW(key, L"Device Description", nullptr,
695 nullptr, (LPBYTE)value, &dwcbData);
696 if (result != ERROR_SUCCESS) {
697 dwcbData = sizeof(value);
698 result = RegQueryValueExW(key, L"DriverDesc", nullptr, nullptr,
699 (LPBYTE)value, &dwcbData);
701 RegCloseKey(key);
702 if (result == ERROR_SUCCESS) {
703 // If we didn't find a valid device with the original method
704 // take this one, and continue looking for the second GPU.
705 if (!foundValidDevice) {
706 foundValidDevice = true;
707 adapterVendorID[0] = adapterVendorID[1];
708 adapterDeviceID[0] = adapterDeviceID[1];
709 mDeviceString[0] = value;
710 mDeviceID[0] = deviceID2;
711 mDeviceKey[0] = driverKey2;
712 mDriverVersion[0] = driverVersion2;
713 mDriverDate[0] = driverDate2;
714 adapterSubsysID[0] =
715 ParseIDFromDeviceID(mDeviceID[0], u"&SUBSYS_"_ns, 8);
716 continue;
719 mHasDualGPU = true;
720 mDeviceString[1] = value;
721 mDeviceID[1] = deviceID2;
722 mDeviceKey[1] = driverKey2;
723 mDriverVersion[1] = driverVersion2;
724 mDriverDate[1] = driverDate2;
725 adapterSubsysID[1] =
726 ParseIDFromDeviceID(mDeviceID[1], u"&SUBSYS_"_ns, 8);
727 mAdapterVendorID[1].AppendPrintf("0x%04x", adapterVendorID[1]);
728 mAdapterDeviceID[1].AppendPrintf("0x%04x", adapterDeviceID[1]);
729 mAdapterSubsysID[1].AppendPrintf("%08x", adapterSubsysID[1]);
730 break;
736 SetupDiDestroyDeviceInfoList(devinfo);
740 mAdapterVendorID[0].AppendPrintf("0x%04x", adapterVendorID[0]);
741 mAdapterDeviceID[0].AppendPrintf("0x%04x", adapterDeviceID[0]);
742 mAdapterSubsysID[0].AppendPrintf("%08x", adapterSubsysID[0]);
744 // Sometimes, the enumeration is not quite right and the two adapters
745 // end up being swapped. Actually enumerate the adapters that come
746 // back from the DXGI factory to check, and tag the second as active
747 // if found.
748 if (mHasDualGPU) {
749 nsModuleHandle dxgiModule(LoadLibrarySystem32(L"dxgi.dll"));
750 decltype(CreateDXGIFactory)* createDXGIFactory =
751 (decltype(CreateDXGIFactory)*)GetProcAddress(dxgiModule,
752 "CreateDXGIFactory");
754 if (createDXGIFactory) {
755 RefPtr<IDXGIFactory> factory = nullptr;
756 createDXGIFactory(__uuidof(IDXGIFactory), (void**)(&factory));
757 if (factory) {
758 RefPtr<IDXGIAdapter> adapter;
759 if (SUCCEEDED(factory->EnumAdapters(0, getter_AddRefs(adapter)))) {
760 DXGI_ADAPTER_DESC desc;
761 PodZero(&desc);
762 if (SUCCEEDED(adapter->GetDesc(&desc))) {
763 if (desc.VendorId != adapterVendorID[0] &&
764 desc.DeviceId != adapterDeviceID[0] &&
765 desc.VendorId == adapterVendorID[1] &&
766 desc.DeviceId == adapterDeviceID[1]) {
767 mActiveGPUIndex = 1;
775 mHasDriverVersionMismatch = false;
776 if (mAdapterVendorID[mActiveGPUIndex] ==
777 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Intel)) {
778 // we've had big crashers (bugs 590373 and 595364) apparently correlated
779 // with bad Intel driver installations where the DriverVersion reported
780 // by the registry was not the version of the DLL.
782 // Note that these start without the .dll extension but eventually gain it.
783 bool is64bitApp = sizeof(void*) == 8;
784 nsAutoString dllFileName(is64bitApp ? u"igd10umd64" : u"igd10umd32");
785 nsAutoString dllFileName2(is64bitApp ? u"igd10iumd64" : u"igd10iumd32");
787 nsString dllVersion, dllVersion2;
788 uint64_t dllNumericVersion = 0, dllNumericVersion2 = 0,
789 driverNumericVersion = 0, knownSafeMismatchVersion = 0;
791 // Only parse the DLL version for those found in the driver list
792 nsAutoString eligibleDLLs;
793 if (NS_SUCCEEDED(GetAdapterDriver(eligibleDLLs))) {
794 if (FindInReadable(dllFileName, eligibleDLLs)) {
795 dllFileName += u".dll"_ns;
796 gfxWindowsPlatform::GetDLLVersion(dllFileName.get(), dllVersion);
797 ParseDriverVersion(dllVersion, &dllNumericVersion);
799 if (FindInReadable(dllFileName2, eligibleDLLs)) {
800 dllFileName2 += u".dll"_ns;
801 gfxWindowsPlatform::GetDLLVersion(dllFileName2.get(), dllVersion2);
802 ParseDriverVersion(dllVersion2, &dllNumericVersion2);
806 // Sometimes the DLL is not in the System32 nor SysWOW64 directories. But
807 // UserModeDriverName (or UserModeDriverNameWow, if available) might provide
808 // the full path to the DLL in some DriverStore FileRepository.
809 if (dllNumericVersion == 0 && dllNumericVersion2 == 0) {
810 nsTArray<nsString> eligibleDLLpaths;
811 const WCHAR* keyLocation = mDeviceKey[mActiveGPUIndex].get();
812 GetKeyValues(keyLocation, L"UserModeDriverName", eligibleDLLpaths);
813 GetKeyValues(keyLocation, L"UserModeDriverNameWow", eligibleDLLpaths);
814 size_t length = eligibleDLLpaths.Length();
815 for (size_t i = 0;
816 i < length && dllNumericVersion == 0 && dllNumericVersion2 == 0;
817 ++i) {
818 if (FindInReadable(dllFileName, eligibleDLLpaths[i])) {
819 gfxWindowsPlatform::GetDLLVersion(eligibleDLLpaths[i].get(),
820 dllVersion);
821 ParseDriverVersion(dllVersion, &dllNumericVersion);
822 } else if (FindInReadable(dllFileName2, eligibleDLLpaths[i])) {
823 gfxWindowsPlatform::GetDLLVersion(eligibleDLLpaths[i].get(),
824 dllVersion2);
825 ParseDriverVersion(dllVersion2, &dllNumericVersion2);
830 ParseDriverVersion(mDriverVersion[mActiveGPUIndex], &driverNumericVersion);
831 ParseDriverVersion(u"9.17.10.0"_ns, &knownSafeMismatchVersion);
833 // If there's a driver version mismatch, consider this harmful only when
834 // the driver version is less than knownSafeMismatchVersion. See the
835 // above comment about crashes with old mismatches. If the GetDllVersion
836 // call fails, we are not calling it a mismatch.
837 if ((dllNumericVersion != 0 && dllNumericVersion != driverNumericVersion) ||
838 (dllNumericVersion2 != 0 &&
839 dllNumericVersion2 != driverNumericVersion)) {
840 if (driverNumericVersion < knownSafeMismatchVersion ||
841 std::max(dllNumericVersion, dllNumericVersion2) <
842 knownSafeMismatchVersion) {
843 mHasDriverVersionMismatch = true;
844 gfxCriticalNoteOnce
845 << "Mismatched driver versions between the registry "
846 << NS_ConvertUTF16toUTF8(mDriverVersion[mActiveGPUIndex]).get()
847 << " and DLL(s) " << NS_ConvertUTF16toUTF8(dllVersion).get() << ", "
848 << NS_ConvertUTF16toUTF8(dllVersion2).get() << " reported.";
850 } else if (dllNumericVersion == 0 && dllNumericVersion2 == 0) {
851 // Leave it as an asserting error for now, to see if we can find
852 // a system that exhibits this kind of a problem internally.
853 gfxCriticalErrorOnce()
854 << "Potential driver version mismatch ignored due to missing DLLs "
855 << NS_ConvertUTF16toUTF8(dllFileName).get()
856 << " v=" << NS_ConvertUTF16toUTF8(dllVersion).get() << " and "
857 << NS_ConvertUTF16toUTF8(dllFileName2).get()
858 << " v=" << NS_ConvertUTF16toUTF8(dllVersion2).get();
862 const char* spoofedDriverVersionString =
863 PR_GetEnv("MOZ_GFX_SPOOF_DRIVER_VERSION");
864 if (spoofedDriverVersionString) {
865 mDriverVersion[mActiveGPUIndex].AssignASCII(spoofedDriverVersionString);
868 const char* spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_VENDOR_ID");
869 if (spoofedVendor) {
870 mAdapterVendorID[mActiveGPUIndex].AssignASCII(spoofedVendor);
873 const char* spoofedDevice = PR_GetEnv("MOZ_GFX_SPOOF_DEVICE_ID");
874 if (spoofedDevice) {
875 mAdapterDeviceID[mActiveGPUIndex].AssignASCII(spoofedDevice);
878 AddCrashReportAnnotations();
880 return rv;
883 NS_IMETHODIMP
884 GfxInfo::GetAdapterDescription(nsAString& aAdapterDescription) {
885 AssertNotWin32kLockdown();
887 aAdapterDescription = mDeviceString[mActiveGPUIndex];
888 return NS_OK;
891 NS_IMETHODIMP
892 GfxInfo::GetAdapterDescription2(nsAString& aAdapterDescription) {
893 AssertNotWin32kLockdown();
895 aAdapterDescription = mDeviceString[1 - mActiveGPUIndex];
896 return NS_OK;
899 NS_IMETHODIMP
900 GfxInfo::GetAdapterRAM(uint32_t* aAdapterRAM) {
901 AssertNotWin32kLockdown();
903 uint32_t result = 0;
904 if (NS_FAILED(GetKeyValue(mDeviceKey[mActiveGPUIndex].get(),
905 L"HardwareInformation.qwMemorySize", result,
906 REG_QWORD)) ||
907 result == 0) {
908 if (NS_FAILED(GetKeyValue(mDeviceKey[mActiveGPUIndex].get(),
909 L"HardwareInformation.MemorySize", result,
910 REG_DWORD))) {
911 result = 0;
914 *aAdapterRAM = result;
915 return NS_OK;
918 NS_IMETHODIMP
919 GfxInfo::GetAdapterRAM2(uint32_t* aAdapterRAM) {
920 AssertNotWin32kLockdown();
922 uint32_t result = 0;
923 if (mHasDualGPU) {
924 if (NS_FAILED(GetKeyValue(mDeviceKey[1 - mActiveGPUIndex].get(),
925 L"HardwareInformation.qwMemorySize", result,
926 REG_QWORD)) ||
927 result == 0) {
928 if (NS_FAILED(GetKeyValue(mDeviceKey[1 - mActiveGPUIndex].get(),
929 L"HardwareInformation.MemorySize", result,
930 REG_DWORD))) {
931 result = 0;
935 *aAdapterRAM = result;
936 return NS_OK;
939 NS_IMETHODIMP
940 GfxInfo::GetAdapterDriver(nsAString& aAdapterDriver) {
941 AssertNotWin32kLockdown();
943 if (NS_FAILED(GetKeyValue(mDeviceKey[mActiveGPUIndex].get(),
944 L"InstalledDisplayDrivers", aAdapterDriver,
945 REG_MULTI_SZ)))
946 aAdapterDriver = L"Unknown";
947 return NS_OK;
950 NS_IMETHODIMP
951 GfxInfo::GetAdapterDriver2(nsAString& aAdapterDriver) {
952 AssertNotWin32kLockdown();
954 if (!mHasDualGPU) {
955 aAdapterDriver.Truncate();
956 } else if (NS_FAILED(GetKeyValue(mDeviceKey[1 - mActiveGPUIndex].get(),
957 L"InstalledDisplayDrivers", aAdapterDriver,
958 REG_MULTI_SZ))) {
959 aAdapterDriver = L"Unknown";
961 return NS_OK;
964 NS_IMETHODIMP
965 GfxInfo::GetAdapterDriverVendor(nsAString& aAdapterDriverVendor) {
966 aAdapterDriverVendor.Truncate();
967 return NS_OK;
970 NS_IMETHODIMP
971 GfxInfo::GetAdapterDriverVersion(nsAString& aAdapterDriverVersion) {
972 AssertNotWin32kLockdown();
974 aAdapterDriverVersion = mDriverVersion[mActiveGPUIndex];
975 return NS_OK;
978 NS_IMETHODIMP
979 GfxInfo::GetAdapterDriverDate(nsAString& aAdapterDriverDate) {
980 AssertNotWin32kLockdown();
982 aAdapterDriverDate = mDriverDate[mActiveGPUIndex];
983 return NS_OK;
986 NS_IMETHODIMP
987 GfxInfo::GetAdapterDriverVendor2(nsAString& aAdapterDriverVendor) {
988 aAdapterDriverVendor.Truncate();
989 return NS_OK;
992 NS_IMETHODIMP
993 GfxInfo::GetAdapterDriverVersion2(nsAString& aAdapterDriverVersion) {
994 AssertNotWin32kLockdown();
996 aAdapterDriverVersion = mDriverVersion[1 - mActiveGPUIndex];
997 return NS_OK;
1000 NS_IMETHODIMP
1001 GfxInfo::GetAdapterDriverDate2(nsAString& aAdapterDriverDate) {
1002 AssertNotWin32kLockdown();
1004 aAdapterDriverDate = mDriverDate[1 - mActiveGPUIndex];
1005 return NS_OK;
1008 NS_IMETHODIMP
1009 GfxInfo::GetAdapterVendorID(nsAString& aAdapterVendorID) {
1010 AssertNotWin32kLockdown();
1012 aAdapterVendorID = mAdapterVendorID[mActiveGPUIndex];
1013 return NS_OK;
1016 NS_IMETHODIMP
1017 GfxInfo::GetAdapterVendorID2(nsAString& aAdapterVendorID) {
1018 AssertNotWin32kLockdown();
1020 aAdapterVendorID = mAdapterVendorID[1 - mActiveGPUIndex];
1021 return NS_OK;
1024 NS_IMETHODIMP
1025 GfxInfo::GetAdapterDeviceID(nsAString& aAdapterDeviceID) {
1026 AssertNotWin32kLockdown();
1028 aAdapterDeviceID = mAdapterDeviceID[mActiveGPUIndex];
1029 return NS_OK;
1032 NS_IMETHODIMP
1033 GfxInfo::GetAdapterDeviceID2(nsAString& aAdapterDeviceID) {
1034 AssertNotWin32kLockdown();
1036 aAdapterDeviceID = mAdapterDeviceID[1 - mActiveGPUIndex];
1037 return NS_OK;
1040 NS_IMETHODIMP
1041 GfxInfo::GetAdapterSubsysID(nsAString& aAdapterSubsysID) {
1042 AssertNotWin32kLockdown();
1044 aAdapterSubsysID = mAdapterSubsysID[mActiveGPUIndex];
1045 return NS_OK;
1048 NS_IMETHODIMP
1049 GfxInfo::GetAdapterSubsysID2(nsAString& aAdapterSubsysID) {
1050 AssertNotWin32kLockdown();
1052 aAdapterSubsysID = mAdapterSubsysID[1 - mActiveGPUIndex];
1053 return NS_OK;
1056 NS_IMETHODIMP
1057 GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) {
1058 // This is never the case, as the active GPU ends up being
1059 // the first one. It should probably be removed.
1060 *aIsGPU2Active = false;
1061 return NS_OK;
1064 NS_IMETHODIMP
1065 GfxInfo::GetDrmRenderDevice(nsACString& aDrmRenderDevice) {
1066 return NS_ERROR_NOT_IMPLEMENTED;
1069 /* Cisco's VPN software can cause corruption of the floating point state.
1070 * Make a note of this in our crash reports so that some weird crashes
1071 * make more sense */
1072 static void CheckForCiscoVPN() {
1073 LONG result;
1074 HKEY key;
1075 /* This will give false positives, but hopefully no false negatives */
1076 result =
1077 RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client",
1078 0, KEY_QUERY_VALUE, &key);
1079 if (result == ERROR_SUCCESS) {
1080 RegCloseKey(key);
1081 CrashReporter::AppendAppNotesToCrashReport("Cisco VPN\n"_ns);
1085 void GfxInfo::AddCrashReportAnnotations() {
1086 AssertNotWin32kLockdown();
1088 CheckForCiscoVPN();
1090 if (mHasDriverVersionMismatch) {
1091 CrashReporter::AppendAppNotesToCrashReport("DriverVersionMismatch\n"_ns);
1094 nsString deviceID, vendorID, driverVersion, subsysID;
1096 GetAdapterDeviceID(deviceID);
1097 GetAdapterVendorID(vendorID);
1098 GetAdapterDriverVersion(driverVersion);
1099 GetAdapterSubsysID(subsysID);
1101 CrashReporter::RecordAnnotationNSString(
1102 CrashReporter::Annotation::AdapterVendorID, vendorID);
1103 CrashReporter::RecordAnnotationNSString(
1104 CrashReporter::Annotation::AdapterDeviceID, deviceID);
1105 CrashReporter::RecordAnnotationNSString(
1106 CrashReporter::Annotation::AdapterDriverVersion, driverVersion);
1107 CrashReporter::RecordAnnotationNSString(
1108 CrashReporter::Annotation::AdapterSubsysID, subsysID);
1110 /* Add an App Note, this contains extra information. */
1111 nsAutoCString note;
1113 // TODO: We should probably convert this into a proper annotation
1114 if (vendorID == GfxDriverInfo::GetDeviceVendor(DeviceVendor::All)) {
1115 /* if we didn't find a valid vendorID lets append the mDeviceID string to
1116 * try to find out why */
1117 LossyAppendUTF16toASCII(mDeviceID[mActiveGPUIndex], note);
1118 note.AppendLiteral(", ");
1119 LossyAppendUTF16toASCII(mDeviceKeyDebug, note);
1121 note.AppendLiteral("\n");
1123 if (mHasDualGPU) {
1124 nsString deviceID2, vendorID2, subsysID2;
1125 nsAutoString adapterDriverVersionString2;
1126 nsCString narrowDeviceID2, narrowVendorID2, narrowSubsysID2;
1128 // Make a slight difference between the two cases so that we
1129 // can see it in the crash reports. It may come in handy.
1130 if (mActiveGPUIndex == 1) {
1131 note.AppendLiteral("Has dual GPUs. GPU-#2: ");
1132 } else {
1133 note.AppendLiteral("Has dual GPUs. GPU #2: ");
1135 GetAdapterDeviceID2(deviceID2);
1136 CopyUTF16toUTF8(deviceID2, narrowDeviceID2);
1137 GetAdapterVendorID2(vendorID2);
1138 CopyUTF16toUTF8(vendorID2, narrowVendorID2);
1139 GetAdapterDriverVersion2(adapterDriverVersionString2);
1140 GetAdapterSubsysID(subsysID2);
1141 CopyUTF16toUTF8(subsysID2, narrowSubsysID2);
1142 note.AppendLiteral("AdapterVendorID2: ");
1143 note.Append(narrowVendorID2);
1144 note.AppendLiteral(", AdapterDeviceID2: ");
1145 note.Append(narrowDeviceID2);
1146 note.AppendLiteral(", AdapterSubsysID2: ");
1147 note.Append(narrowSubsysID2);
1148 note.AppendLiteral(", AdapterDriverVersion2: ");
1149 note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2));
1151 CrashReporter::AppendAppNotesToCrashReport(note);
1154 static OperatingSystem WindowsVersionToOperatingSystem(
1155 int32_t aWindowsVersion) {
1156 switch (aWindowsVersion) {
1157 case kWindows7:
1158 return OperatingSystem::Windows7;
1159 case kWindows8:
1160 return OperatingSystem::Windows8;
1161 case kWindows8_1:
1162 return OperatingSystem::Windows8_1;
1163 case kWindows10:
1164 return OperatingSystem::Windows10;
1165 case kWindowsUnknown:
1166 default:
1167 return OperatingSystem::Unknown;
1171 // Return true if the CPU supports AVX, but the operating system does not.
1172 #if defined(_M_X64)
1173 static inline bool DetectBrokenAVX() {
1174 int regs[4];
1175 __cpuid(regs, 0);
1176 if (regs[0] == 0) {
1177 // Level not supported.
1178 return false;
1181 __cpuid(regs, 1);
1183 const unsigned AVX = 1u << 28;
1184 const unsigned XSAVE = 1u << 26;
1185 if ((regs[2] & (AVX | XSAVE)) != (AVX | XSAVE)) {
1186 // AVX is not supported on this CPU.
1187 return false;
1190 const unsigned OSXSAVE = 1u << 27;
1191 if ((regs[2] & OSXSAVE) != OSXSAVE) {
1192 // AVX is supported, but the OS didn't enable it.
1193 // This can be forced via bcdedit /set xsavedisable 1.
1194 return true;
1197 const unsigned AVX_CTRL_BITS = (1 << 1) | (1 << 2);
1198 return (xgetbv(0) & AVX_CTRL_BITS) != AVX_CTRL_BITS;
1200 #endif
1202 const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
1203 if (!sDriverInfo->Length()) {
1205 * It should be noted here that more specialized rules on certain features
1206 * should be inserted -before- more generalized restriction. As the first
1207 * match for feature/OS/device found in the list will be used for the final
1208 * blocklisting call.
1212 * NVIDIA entries
1215 * The last 5 digit of the NVIDIA driver version maps to the version that
1216 * NVIDIA uses. The minor version (15, 16, 17) corresponds roughtly to the
1217 * OS (Vista, Win7, Win7) but they show up in smaller numbers across all
1218 * OS versions (perhaps due to OS upgrades). So we want to support
1219 * October 2009+ drivers across all these minor versions.
1221 * 187.45 (late October 2009) and earlier contain a bug which can cause us
1222 * to crash on shutdown.
1224 APPEND_TO_DRIVER_BLOCKLIST(
1225 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1226 GfxDriverInfo::optionalFeatures,
1227 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1228 V(8, 15, 11, 8745), "FEATURE_FAILURE_NV_W7_15",
1229 "nVidia driver > 187.45");
1230 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1231 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1232 GfxDriverInfo::optionalFeatures,
1233 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1234 DRIVER_BETWEEN_INCLUSIVE_START, V(8, 16, 10, 0000), V(8, 16, 11, 8745),
1235 "FEATURE_FAILURE_NV_W7_16", "nVidia driver > 187.45");
1236 // Telemetry doesn't show any driver in this range so it might not even be
1237 // required.
1238 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1239 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1240 GfxDriverInfo::optionalFeatures,
1241 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1242 DRIVER_BETWEEN_INCLUSIVE_START, V(8, 17, 10, 0000), V(8, 17, 11, 8745),
1243 "FEATURE_FAILURE_NV_W7_17", "nVidia driver > 187.45");
1246 * AMD/ATI entries. 8.56.1.15 is the driver that shipped with Windows 7 RTM
1248 APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::Windows, DeviceFamily::AtiAll,
1249 GfxDriverInfo::optionalFeatures,
1250 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1251 DRIVER_LESS_THAN, V(8, 56, 1, 15),
1252 "FEATURE_FAILURE_AMD1", "8.56.1.15");
1254 // Bug 1099252
1255 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows7, DeviceFamily::AtiAll,
1256 GfxDriverInfo::optionalFeatures,
1257 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1258 DRIVER_EQUAL, V(8, 832, 0, 0),
1259 "FEATURE_FAILURE_BUG_1099252");
1261 // Bug 1118695
1262 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows7, DeviceFamily::AtiAll,
1263 GfxDriverInfo::optionalFeatures,
1264 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1265 DRIVER_EQUAL, V(8, 783, 2, 2000),
1266 "FEATURE_FAILURE_BUG_1118695");
1268 // Bug 1587155
1270 // There are a several reports of strange rendering corruptions with this
1271 // driver version, with and without webrender. We weren't able to
1272 // reproduce these problems, but the users were able to update their
1273 // drivers and it went away. So just to be safe, let's blocklist all
1274 // gpu use with this particular (very old) driver, restricted
1275 // to Win10 since we only have reports from that platform.
1276 APPEND_TO_DRIVER_BLOCKLIST2(
1277 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1278 GfxDriverInfo::optionalFeatures,
1279 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1280 V(22, 19, 162, 4), "FEATURE_FAILURE_BUG_1587155");
1282 // Bug 1829487 - Work around a gen6 driver bug that miscompiles shaders
1283 // resulting
1284 // in black squares. Disabling shader optimization pass
1285 // appears to work around this for now.
1286 APPEND_TO_DRIVER_BLOCKLIST2(
1287 OperatingSystem::Windows, DeviceFamily::IntelSandyBridge,
1288 nsIGfxInfo::FEATURE_WEBRENDER_OPTIMIZED_SHADERS,
1289 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1290 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1829487");
1292 // Bug 1198815
1293 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1294 OperatingSystem::Windows, DeviceFamily::AtiAll,
1295 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1296 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1297 V(15, 200, 0, 0), V(15, 200, 1062, 1004), "FEATURE_FAILURE_BUG_1198815",
1298 "15.200.0.0-15.200.1062.1004");
1300 // Bug 1267970
1301 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1302 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1303 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1304 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1305 V(15, 200, 0, 0), V(15, 301, 2301, 1002), "FEATURE_FAILURE_BUG_1267970",
1306 "15.200.0.0-15.301.2301.1002");
1307 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1308 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1309 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1310 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1311 V(16, 100, 0, 0), V(16, 300, 2311, 0), "FEATURE_FAILURE_BUG_1267970",
1312 "16.100.0.0-16.300.2311.0");
1315 * Bug 783517 - crashes in AMD driver on Windows 8
1317 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1318 OperatingSystem::Windows8, DeviceFamily::AtiAll,
1319 GfxDriverInfo::optionalFeatures,
1320 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1321 DRIVER_BETWEEN_INCLUSIVE_START, V(8, 982, 0, 0), V(8, 983, 0, 0),
1322 "FEATURE_FAILURE_BUG_783517_AMD", "!= 8.982.*.*");
1325 * Bug 1599981 - crashes in AMD driver on Windows 10
1327 APPEND_TO_DRIVER_BLOCKLIST2(
1328 OperatingSystem::Windows10, DeviceFamily::RadeonCaicos,
1329 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1330 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1331 V(15, 301, 1901, 0), "FEATURE_FAILURE_BUG_1599981");
1333 /* OpenGL on any ATI/AMD hardware is discouraged
1334 * See:
1335 * bug 619773 - WebGL: Crash with blue screen : "NMI: Parity Check / Memory
1336 * Parity Error" bugs 584403, 584404, 620924 - crashes in atioglxx
1337 * + many complaints about incorrect rendering
1339 APPEND_TO_DRIVER_BLOCKLIST2(
1340 OperatingSystem::Windows, DeviceFamily::AtiAll,
1341 nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED,
1342 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1343 "FEATURE_FAILURE_OGL_ATI_DIS");
1346 * Intel entries
1349 /* The driver versions used here come from bug 594877. They might not
1350 * be particularly relevant anymore.
1352 #define IMPLEMENT_INTEL_DRIVER_BLOCKLIST(winVer, devFamily, driverVer, ruleId) \
1353 APPEND_TO_DRIVER_BLOCKLIST2(winVer, devFamily, \
1354 GfxDriverInfo::optionalFeatures, \
1355 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \
1356 DRIVER_LESS_THAN, driverVer, ruleId)
1358 #define IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(winVer, devFamily, driverVer, \
1359 ruleId) \
1360 APPEND_TO_DRIVER_BLOCKLIST2(winVer, devFamily, nsIGfxInfo::FEATURE_DIRECT2D, \
1361 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \
1362 DRIVER_BUILD_ID_LESS_THAN, driverVer, ruleId)
1364 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1365 DeviceFamily::IntelGMA500, 2026,
1366 "FEATURE_FAILURE_594877_7");
1367 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(
1368 OperatingSystem::Windows7, DeviceFamily::IntelGMA900,
1369 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_594877_8");
1370 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1371 DeviceFamily::IntelGMA950, 1930,
1372 "FEATURE_FAILURE_594877_9");
1373 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1374 DeviceFamily::IntelGMA3150, 2117,
1375 "FEATURE_FAILURE_594877_10");
1376 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1377 DeviceFamily::IntelGMAX3000, 1930,
1378 "FEATURE_FAILURE_594877_11");
1379 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(
1380 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1381 2202, "FEATURE_FAILURE_594877_12");
1383 /* Disable Direct2D on Intel GMAX4500 devices because of rendering
1384 * corruption discovered in bug 1180379. These seems to affect even the most
1385 * recent drivers. We're black listing all of the devices to be safe even
1386 * though we've only confirmed the issue on the G45
1388 APPEND_TO_DRIVER_BLOCKLIST2(
1389 OperatingSystem::Windows, DeviceFamily::IntelGMAX4500HD,
1390 nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1391 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1392 "FEATURE_FAILURE_1180379");
1394 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1395 OperatingSystem::Windows7, DeviceFamily::IntelGMA500, V(5, 0, 0, 2026),
1396 "FEATURE_FAILURE_INTEL_16");
1397 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1398 OperatingSystem::Windows7, DeviceFamily::IntelGMA900,
1399 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_INTEL_17");
1400 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1401 OperatingSystem::Windows7, DeviceFamily::IntelGMA950,
1402 V(8, 15, 10, 1930), "FEATURE_FAILURE_INTEL_18");
1403 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1404 OperatingSystem::Windows7, DeviceFamily::IntelGMA3150,
1405 V(8, 14, 10, 1972), "FEATURE_FAILURE_INTEL_19");
1406 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1407 OperatingSystem::Windows7, DeviceFamily::IntelGMAX3000,
1408 V(7, 15, 10, 1666), "FEATURE_FAILURE_INTEL_20");
1409 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1410 OperatingSystem::Windows7, DeviceFamily::IntelGMAX4500HD,
1411 V(7, 15, 10, 1666), "FEATURE_FAILURE_INTEL_21");
1412 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1413 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1414 V(7, 15, 10, 1666), "FEATURE_FAILURE_INTEL_22");
1416 // Bug 1074378
1417 APPEND_TO_DRIVER_BLOCKLIST(
1418 OperatingSystem::Windows7, DeviceFamily::IntelGMAX4500HD,
1419 GfxDriverInfo::optionalFeatures,
1420 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1421 V(8, 15, 10, 1749), "FEATURE_FAILURE_BUG_1074378_1", "8.15.10.2342");
1422 APPEND_TO_DRIVER_BLOCKLIST(
1423 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1424 GfxDriverInfo::optionalFeatures,
1425 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1426 V(8, 15, 10, 1749), "FEATURE_FAILURE_BUG_1074378_2", "8.15.10.2342");
1428 /* OpenGL on any Intel hardware is discouraged */
1429 APPEND_TO_DRIVER_BLOCKLIST2(
1430 OperatingSystem::Windows, DeviceFamily::IntelAll,
1431 nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED,
1432 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1433 "FEATURE_FAILURE_INTEL_OGL_DIS");
1436 * Disable acceleration on Intel HD 3000 for graphics drivers
1437 * <= 8.15.10.2321. See bug 1018278 and bug 1060736.
1439 APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::Windows,
1440 DeviceFamily::IntelSandyBridge,
1441 GfxDriverInfo::optionalFeatures,
1442 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1443 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 2321,
1444 "FEATURE_FAILURE_BUG_1018278", "X.X.X.2342");
1447 * Disable D2D on Win7 on Intel Haswell for graphics drivers build id <=
1448 * 4578. See bug 1432610
1450 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows7,
1451 DeviceFamily::IntelHaswell,
1452 nsIGfxInfo::FEATURE_DIRECT2D,
1453 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1454 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 4578,
1455 "FEATURE_FAILURE_BUG_1432610");
1457 * Disable VP8 HW decoding on Windows 8.1 on Intel Haswel and a certain
1458 * driver version. See bug 1760464 comment 6 and bug 1761332.
1460 APPEND_TO_DRIVER_BLOCKLIST2(
1461 OperatingSystem::Windows8_1, DeviceFamily::IntelHaswell,
1462 nsIGfxInfo::FEATURE_VP8_HW_DECODE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1463 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1464 "FEATURE_FAILURE_BUG_1760464");
1466 APPEND_TO_DRIVER_BLOCKLIST2(
1467 OperatingSystem::Windows8_1, DeviceFamily::IntelAll,
1468 nsIGfxInfo::FEATURE_VP8_HW_DECODE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1469 DRIVER_EQUAL, V(10, 18, 14, 4264), "FEATURE_FAILURE_BUG_1761332");
1471 /* Disable D2D on Win7 on Intel HD Graphics on driver <= 8.15.10.2302
1472 * See bug 806786
1474 APPEND_TO_DRIVER_BLOCKLIST2(
1475 OperatingSystem::Windows7, DeviceFamily::IntelMobileHDGraphics,
1476 nsIGfxInfo::FEATURE_DIRECT2D,
1477 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1478 V(8, 15, 10, 2302), "FEATURE_FAILURE_BUG_806786");
1480 /* Disable D2D on Win8 on Intel HD Graphics on driver <= 8.15.10.2302
1481 * See bug 804144 and 863683
1483 APPEND_TO_DRIVER_BLOCKLIST2(
1484 OperatingSystem::Windows8, DeviceFamily::IntelMobileHDGraphics,
1485 nsIGfxInfo::FEATURE_DIRECT2D,
1486 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1487 V(8, 15, 10, 2302), "FEATURE_FAILURE_BUG_804144");
1489 /* Disable D2D on Win7 on Intel HD Graphics on driver == 8.15.10.2418
1490 * See bug 1433790
1492 APPEND_TO_DRIVER_BLOCKLIST2(
1493 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1494 nsIGfxInfo::FEATURE_DIRECT2D,
1495 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1496 V(8, 15, 10, 2418), "FEATURE_FAILURE_BUG_1433790");
1498 /* Disable D3D11 layers on Intel G41 express graphics and Intel GM965, Intel
1499 * X3100, for causing device resets. See bug 1116812.
1501 APPEND_TO_DRIVER_BLOCKLIST2(
1502 OperatingSystem::Windows, DeviceFamily::Bug1116812,
1503 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1504 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1505 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1116812");
1507 /* Disable D3D11 layers on Intel GMA 3150 for failing to allocate a shared
1508 * handle for textures. See bug 1207665. Additionally block D2D so we don't
1509 * accidentally use WARP.
1511 APPEND_TO_DRIVER_BLOCKLIST2(
1512 OperatingSystem::Windows, DeviceFamily::Bug1207665,
1513 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1514 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1515 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1207665_1");
1516 APPEND_TO_DRIVER_BLOCKLIST2(
1517 OperatingSystem::Windows, DeviceFamily::Bug1207665,
1518 nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1519 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1520 "FEATURE_FAILURE_BUG_1207665_2");
1522 APPEND_TO_DRIVER_BLOCKLIST2(
1523 OperatingSystem::Windows10, DeviceFamily::QualcommAll,
1524 nsIGfxInfo::FEATURE_DIRECT2D,
1525 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1526 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_QUALCOMM");
1528 // Bug 1548410. Disable hardware accelerated video decoding on
1529 // Qualcomm drivers used on Windows on ARM64 which are known to
1530 // cause BSOD's and output suprious green frames while decoding video.
1531 // Bug 1592826 expands the blocklist.
1532 APPEND_TO_DRIVER_BLOCKLIST2(
1533 OperatingSystem::Windows10, DeviceFamily::QualcommAll,
1534 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1535 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1536 V(25, 18, 10440, 0), "FEATURE_FAILURE_BUG_1592826");
1538 /* Disable D2D on AMD Catalyst 14.4 until 14.6
1539 * See bug 984488
1541 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1542 OperatingSystem::Windows, DeviceFamily::AtiAll,
1543 nsIGfxInfo::FEATURE_DIRECT2D,
1544 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1545 DRIVER_BETWEEN_INCLUSIVE_START, V(14, 1, 0, 0), V(14, 2, 0, 0),
1546 "FEATURE_FAILURE_BUG_984488_1", "ATI Catalyst 14.6+");
1548 /* Disable D3D9 layers on NVIDIA 6100/6150/6200 series due to glitches
1549 * whilst scrolling. See bugs: 612007, 644787 & 645872.
1551 APPEND_TO_DRIVER_BLOCKLIST2(
1552 OperatingSystem::Windows, DeviceFamily::NvidiaBlockD3D9Layers,
1553 nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
1554 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1555 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_612007");
1557 /* Microsoft RemoteFX; blocked less than 6.2.0.0 */
1558 APPEND_TO_DRIVER_BLOCKLIST(
1559 OperatingSystem::Windows, DeviceFamily::MicrosoftAll,
1560 GfxDriverInfo::optionalFeatures,
1561 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1562 V(6, 2, 0, 0), "< 6.2.0.0", "FEATURE_FAILURE_REMOTE_FX");
1564 /* Bug 1008759: Optimus (NVidia) crash. Disable D2D on NV 310M. */
1565 APPEND_TO_DRIVER_BLOCKLIST2(
1566 OperatingSystem::Windows, DeviceFamily::Nvidia310M,
1567 nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1568 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1569 "FEATURE_FAILURE_BUG_1008759");
1571 /* Bug 1139503: DXVA crashes with ATI cards on windows 10. */
1572 APPEND_TO_DRIVER_BLOCKLIST2(
1573 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1574 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1575 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1576 V(15, 200, 1006, 0), "FEATURE_FAILURE_BUG_1139503");
1578 /* Bug 1213107: D3D9 crashes with ATI cards on Windows 7. */
1579 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1580 OperatingSystem::Windows7, DeviceFamily::AtiAll,
1581 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1582 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1583 V(8, 861, 0, 0), V(8, 862, 6, 5000), "FEATURE_FAILURE_BUG_1213107_1",
1584 "Radeon driver > 8.862.6.5000");
1585 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1586 OperatingSystem::Windows7, DeviceFamily::AtiAll,
1587 nsIGfxInfo::FEATURE_WEBGL_ANGLE,
1588 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1589 V(8, 861, 0, 0), V(8, 862, 6, 5000), "FEATURE_FAILURE_BUG_1213107_2",
1590 "Radeon driver > 8.862.6.5000");
1592 /* This may not be needed at all */
1593 APPEND_TO_DRIVER_BLOCKLIST2(
1594 OperatingSystem::Windows7, DeviceFamily::Bug1155608,
1595 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1596 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1597 V(8, 15, 10, 2869), "FEATURE_FAILURE_INTEL_W7_HW_DECODING");
1599 /* Bug 1203199/1092166: DXVA startup crashes on some intel drivers. */
1600 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1601 OperatingSystem::Windows, DeviceFamily::IntelAll,
1602 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1603 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1604 V(9, 17, 10, 0), V(9, 17, 10, 2849), "FEATURE_FAILURE_BUG_1203199_1",
1605 "Intel driver > 9.17.10.2849");
1607 APPEND_TO_DRIVER_BLOCKLIST2(
1608 OperatingSystem::Windows, DeviceFamily::Nvidia8800GTS,
1609 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1610 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1611 V(9, 18, 13, 4052), "FEATURE_FAILURE_BUG_1203199_2");
1613 /* Bug 1137716: XXX this should really check for the matching Intel piece as
1614 * well. Unfortunately, we don't have the infrastructure to do that */
1615 APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2(
1616 OperatingSystem::Windows7, DeviceFamily::Bug1137716,
1617 GfxDriverInfo::optionalFeatures,
1618 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1619 V(8, 17, 12, 5730), V(8, 17, 12, 6901), "FEATURE_FAILURE_BUG_1137716",
1620 "Nvidia driver > 8.17.12.6901");
1622 /* Bug 1336710: Crash in rx::Blit9::initialize. */
1623 APPEND_TO_DRIVER_BLOCKLIST2(
1624 OperatingSystem::WindowsXP, DeviceFamily::IntelGMAX4500HD,
1625 nsIGfxInfo::FEATURE_WEBGL_ANGLE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1626 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1627 "FEATURE_FAILURE_BUG_1336710");
1629 APPEND_TO_DRIVER_BLOCKLIST2(
1630 OperatingSystem::WindowsXP, DeviceFamily::IntelHDGraphicsToSandyBridge,
1631 nsIGfxInfo::FEATURE_WEBGL_ANGLE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1632 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1633 "FEATURE_FAILURE_BUG_1336710");
1635 /* Bug 1304360: Graphical artifacts with D3D9 on Windows 7. */
1636 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows7,
1637 DeviceFamily::IntelGMAX3000,
1638 nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
1639 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1640 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 1749,
1641 "FEATURE_FAILURE_INTEL_W7_D3D9_LAYERS");
1643 /* Bug 1717519/1717911: Crashes while drawing with swgl.
1644 * Reproducible but not investigated yet.*/
1645 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1646 OperatingSystem::Windows, DeviceFamily::IntelAll,
1647 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1648 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1649 V(8, 15, 10, 2125), V(8, 15, 10, 2141), "FEATURE_FAILURE_BUG_1717911",
1650 "Intel driver > 8.15.10.2141");
1652 #if defined(_M_X64)
1653 if (DetectBrokenAVX()) {
1654 APPEND_TO_DRIVER_BLOCKLIST2(
1655 OperatingSystem::Windows7, DeviceFamily::IntelAll,
1656 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1657 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1658 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1403353");
1660 #endif
1662 ////////////////////////////////////
1663 // WebGL
1665 // Older than 5-15-2016
1666 APPEND_TO_DRIVER_BLOCKLIST2(
1667 OperatingSystem::Windows, DeviceFamily::AtiAll,
1668 nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED,
1669 DRIVER_LESS_THAN, V(16, 200, 1010, 1002), "WEBGL_NATIVE_GL_OLD_AMD");
1671 // Older than 11-18-2015
1672 APPEND_TO_DRIVER_BLOCKLIST2(
1673 OperatingSystem::Windows, DeviceFamily::IntelAll,
1674 nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED,
1675 DRIVER_BUILD_ID_LESS_THAN, 4331, "WEBGL_NATIVE_GL_OLD_INTEL");
1677 // Older than 2-23-2016
1678 APPEND_TO_DRIVER_BLOCKLIST2(
1679 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1680 nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED,
1681 DRIVER_LESS_THAN, V(10, 18, 13, 6200), "WEBGL_NATIVE_GL_OLD_NVIDIA");
1683 ////////////////////////////////////
1684 // FEATURE_DX_INTEROP2
1686 // All AMD.
1687 APPEND_TO_DRIVER_BLOCKLIST2(
1688 OperatingSystem::Windows, DeviceFamily::AtiAll,
1689 nsIGfxInfo::FEATURE_DX_INTEROP2,
1690 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1691 GfxDriverInfo::allDriverVersions, "DX_INTEROP2_AMD_CRASH");
1693 ////////////////////////////////////
1694 // FEATURE_D3D11_KEYED_MUTEX
1696 // bug 1359416
1697 APPEND_TO_DRIVER_BLOCKLIST2(
1698 OperatingSystem::Windows, DeviceFamily::IntelHDGraphicsToSandyBridge,
1699 nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX,
1700 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1701 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1359416");
1703 // Bug 1447141, for causing device creation crashes.
1704 APPEND_TO_DRIVER_BLOCKLIST2(
1705 OperatingSystem::Windows7, DeviceFamily::Bug1447141,
1706 GfxDriverInfo::optionalFeatures, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1707 DRIVER_EQUAL, V(15, 201, 2201, 0), "FEATURE_FAILURE_BUG_1447141_1");
1708 APPEND_TO_DRIVER_BLOCKLIST2(
1709 OperatingSystem::Windows7, DeviceFamily::Bug1447141,
1710 GfxDriverInfo::optionalFeatures, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1711 DRIVER_EQUAL, V(15, 201, 1701, 0), "FEATURE_FAILURE_BUG_1447141_1");
1713 // bug 1457758
1714 APPEND_TO_DRIVER_BLOCKLIST2(
1715 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1716 GfxDriverInfo::optionalFeatures, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1717 DRIVER_EQUAL, V(24, 21, 13, 9731), "FEATURE_FAILURE_BUG_1457758");
1719 ////////////////////////////////////
1720 // FEATURE_DX_NV12
1722 // Bug 1437334
1723 APPEND_TO_DRIVER_BLOCKLIST2(
1724 OperatingSystem::Windows, DeviceFamily::IntelHDGraphicsToSandyBridge,
1725 nsIGfxInfo::FEATURE_DX_NV12, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1726 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 4459,
1727 "FEATURE_BLOCKED_DRIVER_VERSION");
1729 ////////////////////////////////////
1730 // FEATURE_DX_P010
1732 APPEND_TO_DRIVER_BLOCKLIST2(
1733 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1734 nsIGfxInfo::FEATURE_DX_P010, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1735 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1736 "FEATURE_UNQUALIFIED_P010_NVIDIA");
1738 ////////////////////////////////////
1739 // FEATURE_HW_DECODED_VIDEO_ZERO_COPY
1741 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1742 OperatingSystem::Windows10, DeviceFamily::IntelSkylake,
1743 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1744 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1745 V(20, 19, 15, 4285), V(20, 19, 15, 4390), "FEATURE_FAILURE_BUG_1763280",
1746 "Intel driver 20.19.15.*");
1748 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1749 OperatingSystem::Windows10, DeviceFamily::IntelSkylake,
1750 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1751 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1752 V(10, 18, 15, 4256), V(10, 18, 15, 4293), "FEATURE_FAILURE_BUG_1763280",
1753 "Intel driver 10.18.15.*");
1755 APPEND_TO_DRIVER_BLOCKLIST2(
1756 OperatingSystem::Windows10, DeviceFamily::IntelKabyLake,
1757 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1758 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1759 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1802357");
1761 APPEND_TO_DRIVER_BLOCKLIST2(
1762 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1763 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1764 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1765 V(21, 21, 13, 7576), "FEATURE_FAILURE_BUG_1767212");
1767 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows, DeviceFamily::AtiAll,
1768 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1769 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1770 DRIVER_LESS_THAN, V(23, 20, 826, 5120),
1771 "FEATURE_FAILURE_BUG_1767212");
1773 APPEND_TO_DRIVER_BLOCKLIST2(
1774 OperatingSystem::Windows, DeviceFamily::RadeonBlockZeroVideoCopy,
1775 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1776 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1777 V(26, 20, 15000, 37), "FEATURE_FAILURE_BUG_1767212");
1779 ////////////////////////////////////
1780 // FEATURE_HW_DECODED_VIDEO_ZERO_COPY - ALLOWLIST
1781 #ifdef EARLY_BETA_OR_EARLIER
1782 APPEND_TO_DRIVER_BLOCKLIST2(
1783 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1784 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1785 nsIGfxInfo::FEATURE_ALLOW_ALWAYS, DRIVER_COMPARISON_IGNORED,
1786 V(0, 0, 0, 0), "FEATURE_ROLLOUT_ALL");
1787 #endif
1788 APPEND_TO_DRIVER_BLOCKLIST2(
1789 OperatingSystem::Windows, DeviceFamily::IntelAll,
1790 nsIGfxInfo::FEATURE_HW_DECODED_VIDEO_ZERO_COPY,
1791 nsIGfxInfo::FEATURE_ALLOW_ALWAYS, DRIVER_COMPARISON_IGNORED,
1792 V(0, 0, 0, 0), "FEATURE_ROLLOUT_ALL");
1794 ////////////////////////////////////
1795 // FEATURE_REUSE_DECODER_DEVICE
1797 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1798 OperatingSystem::Windows10, DeviceFamily::IntelSkylake,
1799 nsIGfxInfo::FEATURE_REUSE_DECODER_DEVICE,
1800 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1801 V(20, 19, 15, 4285), V(20, 19, 15, 4390), "FEATURE_FAILURE_BUG_1833809",
1802 "Intel driver 20.19.15.*");
1804 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1805 OperatingSystem::Windows10, DeviceFamily::IntelSkylake,
1806 nsIGfxInfo::FEATURE_REUSE_DECODER_DEVICE,
1807 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1808 V(10, 18, 15, 4256), V(10, 18, 15, 4293), "FEATURE_FAILURE_BUG_1833809",
1809 "Intel driver 10.18.15.*");
1811 ////////////////////////////////////
1812 // FEATURE_OVERLAY_VP_AUTO_HDR
1814 APPEND_TO_DRIVER_BLOCKLIST(
1815 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1816 nsIGfxInfo::FEATURE_OVERLAY_VP_AUTO_HDR,
1817 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1818 V(31, 0, 15, 5050), "FEATURE_FAILURE_VP_AUTO_HDR",
1819 "nVidia driver > 550.50");
1821 ////////////////////////////////////
1822 // FEATURE_OVERLAY_VP_SUPER_RESOLUTION
1824 APPEND_TO_DRIVER_BLOCKLIST(
1825 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1826 nsIGfxInfo::FEATURE_OVERLAY_VP_SUPER_RESOLUTION,
1827 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1828 V(31, 0, 15, 3000), "FEATURE_FAILURE_VP_AUTO_HDR",
1829 "nVidia driver > 530.00");
1831 ////////////////////////////////////
1832 // FEATURE_WEBRENDER
1833 // Block 8.56.1.15/16
1834 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows, DeviceFamily::AtiAll,
1835 nsIGfxInfo::FEATURE_WEBRENDER,
1836 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1837 DRIVER_LESS_THAN_OR_EQUAL, V(8, 56, 1, 16),
1838 "CRASHY_DRIVERS_BUG_1678808");
1840 // Shader compilation startup crashes with WebRender on Windows 7.
1841 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1842 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1843 nsIGfxInfo::FEATURE_WEBRENDER,
1844 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1845 V(8, 17, 12, 8019), V(8, 17, 12, 8026), "FEATURE_FAILURE_BUG_1709629",
1846 "nVidia driver > 280.26");
1848 APPEND_TO_DRIVER_BLOCKLIST2(
1849 OperatingSystem::Windows, DeviceFamily::IntelWebRenderBlocked,
1850 nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1851 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1852 "INTEL_DEVICE_GEN5_OR_OLDER");
1854 APPEND_TO_DRIVER_BLOCKLIST2(
1855 OperatingSystem::Windows, DeviceFamily::NvidiaWebRenderBlocked,
1856 nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1857 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions, "EARLY_NVIDIA");
1859 ////////////////////////////////////
1860 // FEATURE_WEBRENDER_COMPOSITOR
1862 #ifndef EARLY_BETA_OR_EARLIER
1863 // See also bug 1616874
1864 APPEND_TO_DRIVER_BLOCKLIST2(
1865 OperatingSystem::Windows, DeviceFamily::IntelAll,
1866 nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR,
1867 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_EQUAL, V(24, 20, 100, 6293),
1868 "FEATURE_FAILURE_BUG_1602511");
1870 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows, DeviceFamily::AtiAll,
1871 nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR,
1872 nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1873 DRIVER_LESS_THAN_OR_EQUAL, V(8, 17, 10, 1129),
1874 "FEATURE_FAILURE_CHROME_BUG_800950");
1875 #endif
1877 // WebRender is unable to use scissored clears in some cases
1878 APPEND_TO_DRIVER_BLOCKLIST2(
1879 OperatingSystem::Windows, DeviceFamily::IntelAll,
1880 nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS,
1881 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
1882 V(0, 0, 0, 0), "FEATURE_FAILURE_BUG_1603515");
1884 ////////////////////////////////////
1885 // FEATURE_BACKDROP_FILTER
1887 // Backdrop filter crashes the driver. See bug 1785366 and bug 1784093.
1888 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1889 OperatingSystem::Windows, DeviceFamily::IntelHDGraphicsToIvyBridge,
1890 nsIGfxInfo::FEATURE_BACKDROP_FILTER,
1891 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_EXCLUSIVE,
1892 V(8, 15, 10, 2879), V(10, 18, 10, 4425), "FEATURE_FAILURE_BUG_1785366",
1893 "Intel driver >= 10.18.10.4425");
1895 return *sDriverInfo;
1898 OperatingSystem GfxInfo::GetOperatingSystem() {
1899 return WindowsVersionToOperatingSystem(mWindowsVersion);
1902 nsresult GfxInfo::GetFeatureStatusImpl(
1903 int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
1904 const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId,
1905 OperatingSystem* aOS /* = nullptr */) {
1906 AssertNotWin32kLockdown();
1908 NS_ENSURE_ARG_POINTER(aStatus);
1909 aSuggestedDriverVersion.SetIsVoid(true);
1910 OperatingSystem os = WindowsVersionToOperatingSystem(mWindowsVersion);
1911 *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
1912 if (aOS) *aOS = os;
1914 if (sShutdownOccurred) {
1915 return NS_OK;
1918 // Don't evaluate special cases if we're checking the downloaded blocklist.
1919 if (!aDriverInfo.Length()) {
1920 nsAutoString adapterVendorID;
1921 nsAutoString adapterDeviceID;
1922 nsAutoString adapterDriverVersionString;
1923 if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) ||
1924 NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) ||
1925 NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) {
1926 if (OnlyAllowFeatureOnKnownConfig(aFeature)) {
1927 aFailureId = "FEATURE_FAILURE_GET_ADAPTER";
1928 *aStatus = FEATURE_BLOCKED_DEVICE;
1929 } else {
1930 *aStatus = FEATURE_STATUS_OK;
1932 return NS_OK;
1935 if (OnlyAllowFeatureOnKnownConfig(aFeature) &&
1936 !adapterVendorID.Equals(
1937 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Intel),
1938 nsCaseInsensitiveStringComparator) &&
1939 !adapterVendorID.Equals(
1940 GfxDriverInfo::GetDeviceVendor(DeviceVendor::NVIDIA),
1941 nsCaseInsensitiveStringComparator) &&
1942 !adapterVendorID.Equals(
1943 GfxDriverInfo::GetDeviceVendor(DeviceVendor::ATI),
1944 nsCaseInsensitiveStringComparator) &&
1945 !adapterVendorID.Equals(
1946 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Microsoft),
1947 nsCaseInsensitiveStringComparator) &&
1948 !adapterVendorID.Equals(
1949 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Parallels),
1950 nsCaseInsensitiveStringComparator) &&
1951 !adapterVendorID.Equals(
1952 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Qualcomm),
1953 nsCaseInsensitiveStringComparator) &&
1954 // FIXME - these special hex values are currently used in xpcshell tests
1955 // introduced by bug 625160 patch 8/8. Maybe these tests need to be
1956 // adjusted now that we're only whitelisting intel/ati/nvidia.
1957 !adapterVendorID.LowerCaseEqualsLiteral("0xabcd") &&
1958 !adapterVendorID.LowerCaseEqualsLiteral("0xdcba") &&
1959 !adapterVendorID.LowerCaseEqualsLiteral("0xabab") &&
1960 !adapterVendorID.LowerCaseEqualsLiteral("0xdcdc")) {
1961 if (adapterVendorID.Equals(
1962 GfxDriverInfo::GetDeviceVendor(DeviceVendor::MicrosoftHyperV),
1963 nsCaseInsensitiveStringComparator) ||
1964 adapterVendorID.Equals(
1965 GfxDriverInfo::GetDeviceVendor(DeviceVendor::VMWare),
1966 nsCaseInsensitiveStringComparator) ||
1967 adapterVendorID.Equals(
1968 GfxDriverInfo::GetDeviceVendor(DeviceVendor::VirtualBox),
1969 nsCaseInsensitiveStringComparator)) {
1970 aFailureId = "FEATURE_FAILURE_VM_VENDOR";
1971 } else if (adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(
1972 DeviceVendor::MicrosoftBasic),
1973 nsCaseInsensitiveStringComparator)) {
1974 aFailureId = "FEATURE_FAILURE_MICROSOFT_BASIC_VENDOR";
1975 } else if (adapterVendorID.IsEmpty()) {
1976 aFailureId = "FEATURE_FAILURE_EMPTY_DEVICE_VENDOR";
1977 } else {
1978 aFailureId = "FEATURE_FAILURE_UNKNOWN_DEVICE_VENDOR";
1980 *aStatus = FEATURE_BLOCKED_DEVICE;
1981 return NS_OK;
1984 if (adapterDriverVersionString.Length() == 0) {
1985 if (OnlyAllowFeatureOnKnownConfig(aFeature)) {
1986 aFailureId = "FEATURE_FAILURE_EMPTY_DRIVER_VERSION";
1987 *aStatus = FEATURE_BLOCKED_DRIVER_VERSION;
1988 } else {
1989 *aStatus = FEATURE_STATUS_OK;
1991 return NS_OK;
1994 uint64_t driverVersion;
1995 if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) {
1996 if (OnlyAllowFeatureOnKnownConfig(aFeature)) {
1997 aFailureId = "FEATURE_FAILURE_PARSE_DRIVER";
1998 *aStatus = FEATURE_BLOCKED_DRIVER_VERSION;
1999 } else {
2000 *aStatus = FEATURE_STATUS_OK;
2002 return NS_OK;
2006 return GfxInfoBase::GetFeatureStatusImpl(
2007 aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aFailureId, &os);
2010 void GfxInfo::DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> aObj) {
2011 // Add the platform neutral features
2012 GfxInfoBase::DescribeFeatures(aCx, aObj);
2014 JS::Rooted<JSObject*> obj(aCx);
2016 gfx::FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
2017 if (!InitFeatureObject(aCx, aObj, "d3d11", d3d11, &obj)) {
2018 return;
2020 if (d3d11.GetValue() == gfx::FeatureStatus::Available) {
2021 DeviceManagerDx* dm = DeviceManagerDx::Get();
2022 JS::Rooted<JS::Value> val(aCx,
2023 JS::Int32Value(dm->GetCompositorFeatureLevel()));
2024 JS_SetProperty(aCx, obj, "version", val);
2026 val = JS::BooleanValue(dm->IsWARP());
2027 JS_SetProperty(aCx, obj, "warp", val);
2029 val = JS::BooleanValue(dm->TextureSharingWorks());
2030 JS_SetProperty(aCx, obj, "textureSharing", val);
2032 bool blocklisted = false;
2033 if (nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service()) {
2034 int32_t status;
2035 nsCString discardFailureId;
2036 if (SUCCEEDED(
2037 gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
2038 discardFailureId, &status))) {
2039 blocklisted = (status != nsIGfxInfo::FEATURE_STATUS_OK);
2043 val = JS::BooleanValue(blocklisted);
2044 JS_SetProperty(aCx, obj, "blocklisted", val);
2047 gfx::FeatureState& d2d = gfxConfig::GetFeature(Feature::DIRECT2D);
2048 if (!InitFeatureObject(aCx, aObj, "d2d", d2d, &obj)) {
2049 return;
2052 const char* version = "1.1";
2053 JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, version));
2054 JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
2055 JS_SetProperty(aCx, obj, "version", val);
2059 #ifdef DEBUG
2061 // Implement nsIGfxInfoDebug
2063 NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString& aVendorID) {
2064 mAdapterVendorID[mActiveGPUIndex] = aVendorID;
2065 return NS_OK;
2068 NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString& aDeviceID) {
2069 mAdapterDeviceID[mActiveGPUIndex] = aDeviceID;
2070 return NS_OK;
2073 NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString& aDriverVersion) {
2074 mDriverVersion[mActiveGPUIndex] = aDriverVersion;
2075 return NS_OK;
2078 NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion) {
2079 mWindowsVersion = aVersion;
2080 return NS_OK;
2083 #endif