Bug 1761003 [wpt PR 33324] - Add comment pointing to followup bug, and fix typos...
[gecko.git] / widget / windows / GfxInfo.cpp
blob1448243b35c7ef963f0f5a49f30e7263a934b16c
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 int32_t GfxInfo::GetMaxRefreshRate(bool* aMixed) {
87 AssertNotWin32kLockdown();
89 int32_t maxRefreshRate = -1;
90 if (aMixed) {
91 *aMixed = false;
94 for (auto displayInfo : mDisplayInfo) {
95 int32_t refreshRate = int32_t(displayInfo.mRefreshRate);
96 if (aMixed && maxRefreshRate > 0 && maxRefreshRate != refreshRate) {
97 *aMixed = true;
99 maxRefreshRate = std::max(maxRefreshRate, refreshRate);
101 return maxRefreshRate;
104 NS_IMETHODIMP
105 GfxInfo::GetEmbeddedInFirefoxReality(bool* aEmbeddedInFirefoxReality) {
106 *aEmbeddedInFirefoxReality = gfxVars::FxREmbedded();
107 return NS_OK;
110 #define PIXEL_STRUCT_RGB 1
111 #define PIXEL_STRUCT_BGR 2
113 NS_IMETHODIMP
114 GfxInfo::GetCleartypeParameters(nsAString& aCleartypeParams) {
115 nsTArray<ClearTypeParameterInfo> clearTypeParams;
117 gfxWindowsPlatform::GetPlatform()->GetCleartypeParams(clearTypeParams);
118 uint32_t d, numDisplays = clearTypeParams.Length();
119 bool displayNames = (numDisplays > 1);
120 bool foundData = false;
121 nsString outStr;
123 for (d = 0; d < numDisplays; d++) {
124 ClearTypeParameterInfo& params = clearTypeParams[d];
126 if (displayNames) {
127 outStr.AppendPrintf("%S [ ", params.displayName.get());
130 if (params.gamma >= 0) {
131 foundData = true;
132 outStr.AppendPrintf("Gamma: %.4g ", params.gamma / 1000.0);
135 if (params.pixelStructure >= 0) {
136 foundData = true;
137 if (params.pixelStructure == PIXEL_STRUCT_RGB ||
138 params.pixelStructure == PIXEL_STRUCT_BGR) {
139 outStr.AppendPrintf(
140 "Pixel Structure: %S ",
141 (params.pixelStructure == PIXEL_STRUCT_RGB ? u"RGB" : u"BGR"));
142 } else {
143 outStr.AppendPrintf("Pixel Structure: %d ", params.pixelStructure);
147 if (params.clearTypeLevel >= 0) {
148 foundData = true;
149 outStr.AppendPrintf("ClearType Level: %d ", params.clearTypeLevel);
152 if (params.enhancedContrast >= 0) {
153 foundData = true;
154 outStr.AppendPrintf("Enhanced Contrast: %d ", params.enhancedContrast);
157 if (displayNames) {
158 outStr.Append(u"] ");
162 if (foundData) {
163 aCleartypeParams.Assign(outStr);
164 return NS_OK;
166 return NS_ERROR_FAILURE;
169 NS_IMETHODIMP
170 GfxInfo::GetWindowProtocol(nsAString& aWindowProtocol) {
171 return NS_ERROR_NOT_IMPLEMENTED;
174 NS_IMETHODIMP
175 GfxInfo::GetDesktopEnvironment(nsAString& aDesktopEnvironment) {
176 return NS_ERROR_NOT_IMPLEMENTED;
179 NS_IMETHODIMP
180 GfxInfo::GetTestType(nsAString& aTestType) { return NS_ERROR_NOT_IMPLEMENTED; }
182 static nsresult GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName,
183 uint32_t& destValue, int type) {
184 MOZ_ASSERT(type == REG_DWORD || type == REG_QWORD);
185 HKEY key;
186 DWORD dwcbData;
187 DWORD dValue;
188 DWORD resultType;
189 LONG result;
190 nsresult retval = NS_OK;
192 result =
193 RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyLocation, 0, KEY_QUERY_VALUE, &key);
194 if (result != ERROR_SUCCESS) {
195 return NS_ERROR_FAILURE;
198 switch (type) {
199 case REG_DWORD: {
200 // We only use this for vram size
201 dwcbData = sizeof(dValue);
202 result = RegQueryValueExW(key, keyName, nullptr, &resultType,
203 (LPBYTE)&dValue, &dwcbData);
204 if (result == ERROR_SUCCESS && resultType == REG_DWORD) {
205 destValue = (uint32_t)(dValue / 1024 / 1024);
206 } else {
207 retval = NS_ERROR_FAILURE;
209 break;
211 case REG_QWORD: {
212 // We only use this for vram size
213 LONGLONG qValue;
214 dwcbData = sizeof(qValue);
215 result = RegQueryValueExW(key, keyName, nullptr, &resultType,
216 (LPBYTE)&qValue, &dwcbData);
217 if (result == ERROR_SUCCESS && resultType == REG_QWORD) {
218 destValue = (uint32_t)(qValue / 1024 / 1024);
219 } else {
220 retval = NS_ERROR_FAILURE;
222 break;
225 RegCloseKey(key);
227 return retval;
230 static nsresult GetKeyValue(const WCHAR* keyLocation, const WCHAR* keyName,
231 nsAString& destString, int type) {
232 MOZ_ASSERT(type == REG_MULTI_SZ);
234 HKEY key;
235 DWORD dwcbData;
236 DWORD resultType;
237 LONG result;
238 nsresult retval = NS_OK;
240 result =
241 RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyLocation, 0, KEY_QUERY_VALUE, &key);
242 if (result != ERROR_SUCCESS) {
243 return NS_ERROR_FAILURE;
246 // A chain of null-separated strings; we convert the nulls to spaces
247 WCHAR wCharValue[1024];
248 dwcbData = sizeof(wCharValue);
250 result = RegQueryValueExW(key, keyName, nullptr, &resultType,
251 (LPBYTE)wCharValue, &dwcbData);
252 if (result == ERROR_SUCCESS && resultType == REG_MULTI_SZ) {
253 // This bit here could probably be cleaner.
254 bool isValid = false;
256 DWORD strLen = dwcbData / sizeof(wCharValue[0]);
257 for (DWORD i = 0; i < strLen; i++) {
258 if (wCharValue[i] == '\0') {
259 if (i < strLen - 1 && wCharValue[i + 1] == '\0') {
260 isValid = true;
261 break;
262 } else {
263 wCharValue[i] = ' ';
268 // ensure wCharValue is null terminated
269 wCharValue[strLen - 1] = '\0';
271 if (isValid) destString = wCharValue;
273 } else {
274 retval = NS_ERROR_FAILURE;
277 RegCloseKey(key);
279 return retval;
282 static nsresult GetKeyValues(const WCHAR* keyLocation, const WCHAR* keyName,
283 nsTArray<nsString>& destStrings) {
284 // First ask for the size of the value
285 DWORD size;
286 LONG rv = RegGetValueW(HKEY_LOCAL_MACHINE, keyLocation, keyName,
287 RRF_RT_REG_MULTI_SZ, nullptr, nullptr, &size);
288 if (rv != ERROR_SUCCESS) {
289 return NS_ERROR_FAILURE;
292 // Create a buffer with the proper size and retrieve the value
293 WCHAR* wCharValue = new WCHAR[size / sizeof(WCHAR)];
294 rv = RegGetValueW(HKEY_LOCAL_MACHINE, keyLocation, keyName,
295 RRF_RT_REG_MULTI_SZ, nullptr, (LPBYTE)wCharValue, &size);
296 if (rv != ERROR_SUCCESS) {
297 delete[] wCharValue;
298 return NS_ERROR_FAILURE;
301 // The value is a sequence of null-terminated strings, usually terminated by
302 // an empty string (\0). RegGetValue ensures that the value is properly
303 // terminated with a null character.
304 DWORD i = 0;
305 DWORD strLen = size / sizeof(WCHAR);
306 while (i < strLen) {
307 nsString value(wCharValue + i);
308 if (!value.IsEmpty()) {
309 destStrings.AppendElement(value);
311 i += value.Length() + 1;
313 delete[] wCharValue;
315 return NS_OK;
318 // The device ID is a string like PCI\VEN_15AD&DEV_0405&SUBSYS_040515AD
319 // this function is used to extract the id's out of it
320 uint32_t ParseIDFromDeviceID(const nsAString& key, const char* prefix,
321 int length) {
322 nsAutoString id(key);
323 ToUpperCase(id);
324 int32_t start = id.Find(prefix);
325 if (start != -1) {
326 id.Cut(0, start + strlen(prefix));
327 id.Truncate(length);
329 if (id.Equals(L"QCOM", nsCaseInsensitiveStringComparator)) {
330 // String format assumptions are broken, so use a Qualcomm PCI Vendor ID
331 // for now. See also GfxDriverInfo::GetDeviceVendor.
332 return 0x5143;
334 nsresult err;
335 return id.ToInteger(&err, 16);
338 // OS version in 16.16 major/minor form
339 // based on http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx
340 enum {
341 kWindowsUnknown = 0,
342 kWindows7 = 0x60001,
343 kWindows8 = 0x60002,
344 kWindows8_1 = 0x60003,
345 kWindows10 = 0xA0000
348 static bool HasBattery() {
349 // Helper classes to manage lifetimes of Windows structs.
350 class MOZ_STACK_CLASS HDevInfoHolder final {
351 public:
352 explicit HDevInfoHolder(HDEVINFO aHandle) : mHandle(aHandle) {}
354 ~HDevInfoHolder() { ::SetupDiDestroyDeviceInfoList(mHandle); }
356 private:
357 HDEVINFO mHandle;
360 class MOZ_STACK_CLASS HandleHolder final {
361 public:
362 explicit HandleHolder(HANDLE aHandle) : mHandle(aHandle) {}
364 ~HandleHolder() { ::CloseHandle(mHandle); }
366 private:
367 HANDLE mHandle;
370 HDEVINFO hdev =
371 ::SetupDiGetClassDevs(&GUID_DEVCLASS_BATTERY, nullptr, nullptr,
372 DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
373 if (hdev == INVALID_HANDLE_VALUE) {
374 return true;
377 HDevInfoHolder hdevHolder(hdev);
379 DWORD i = 0;
380 SP_DEVICE_INTERFACE_DATA did = {0};
381 did.cbSize = sizeof(did);
383 while (::SetupDiEnumDeviceInterfaces(hdev, nullptr, &GUID_DEVCLASS_BATTERY, i,
384 &did)) {
385 DWORD bufferSize = 0;
386 ::SetupDiGetDeviceInterfaceDetail(hdev, &did, nullptr, 0, &bufferSize,
387 nullptr);
388 if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
389 return true;
392 UniquePtr<uint8_t[]> buffer(new (std::nothrow) uint8_t[bufferSize]);
393 if (!buffer) {
394 return true;
397 PSP_DEVICE_INTERFACE_DETAIL_DATA pdidd =
398 reinterpret_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA>(buffer.get());
399 pdidd->cbSize = sizeof(*pdidd);
400 if (!::SetupDiGetDeviceInterfaceDetail(hdev, &did, pdidd, bufferSize,
401 &bufferSize, nullptr)) {
402 return true;
405 HANDLE hbat = ::CreateFile(pdidd->DevicePath, GENERIC_READ | GENERIC_WRITE,
406 FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
407 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
408 if (hbat == INVALID_HANDLE_VALUE) {
409 return true;
412 HandleHolder hbatHolder(hbat);
414 BATTERY_QUERY_INFORMATION bqi = {0};
415 DWORD dwWait = 0;
416 DWORD dwOut;
418 // We need the tag to query the information below.
419 if (!::DeviceIoControl(hbat, IOCTL_BATTERY_QUERY_TAG, &dwWait,
420 sizeof(dwWait), &bqi.BatteryTag,
421 sizeof(bqi.BatteryTag), &dwOut, nullptr) ||
422 !bqi.BatteryTag) {
423 return true;
426 BATTERY_INFORMATION bi = {0};
427 bqi.InformationLevel = BatteryInformation;
429 if (!::DeviceIoControl(hbat, IOCTL_BATTERY_QUERY_INFORMATION, &bqi,
430 sizeof(bqi), &bi, sizeof(bi), &dwOut, nullptr)) {
431 return true;
434 // If a battery intended for general use (i.e. system use) is not a UPS
435 // (i.e. short term), then we know for certain we have a battery.
436 if ((bi.Capabilities & BATTERY_SYSTEM_BATTERY) &&
437 !(bi.Capabilities & BATTERY_IS_SHORT_TERM)) {
438 return true;
441 // Otherwise we check the next battery.
442 ++i;
445 // If we fail to enumerate because there are no more batteries to check, then
446 // we can safely say there are indeed no system batteries.
447 return ::GetLastError() != ERROR_NO_MORE_ITEMS;
450 /* Other interesting places for info:
451 * IDXGIAdapter::GetDesc()
452 * IDirectDraw7::GetAvailableVidMem()
453 * e->GetAvailableTextureMem()
454 * */
456 #define DEVICE_KEY_PREFIX L"\\Registry\\Machine\\"
457 nsresult GfxInfo::Init() {
458 nsresult rv = GfxInfoBase::Init();
460 // If we are locked down in a content process, we can't call any of the
461 // Win32k APIs below. Any method that accesses members of this class should
462 // assert that it's not used in content
463 if (IsWin32kLockedDown()) {
464 return rv;
467 mHasBattery = HasBattery();
469 DISPLAY_DEVICEW displayDevice;
470 displayDevice.cb = sizeof(displayDevice);
471 int deviceIndex = 0;
473 const char* spoofedWindowsVersion =
474 PR_GetEnv("MOZ_GFX_SPOOF_WINDOWS_VERSION");
475 if (spoofedWindowsVersion) {
476 PR_sscanf(spoofedWindowsVersion, "%x,%u", &mWindowsVersion,
477 &mWindowsBuildNumber);
478 } else {
479 OSVERSIONINFO vinfo;
480 vinfo.dwOSVersionInfoSize = sizeof(vinfo);
481 #ifdef _MSC_VER
482 # pragma warning(push)
483 # pragma warning(disable : 4996)
484 #endif
485 if (!GetVersionEx(&vinfo)) {
486 #ifdef _MSC_VER
487 # pragma warning(pop)
488 #endif
489 mWindowsVersion = kWindowsUnknown;
490 } else {
491 mWindowsVersion =
492 int32_t(vinfo.dwMajorVersion << 16) + vinfo.dwMinorVersion;
493 mWindowsBuildNumber = vinfo.dwBuildNumber;
497 mDeviceKeyDebug = u"PrimarySearch"_ns;
499 while (EnumDisplayDevicesW(nullptr, deviceIndex, &displayDevice, 0)) {
500 if (displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
501 mDeviceKeyDebug = u"NullSearch"_ns;
502 break;
504 deviceIndex++;
507 // make sure the string is nullptr terminated
508 if (wcsnlen(displayDevice.DeviceKey, ArrayLength(displayDevice.DeviceKey)) ==
509 ArrayLength(displayDevice.DeviceKey)) {
510 // we did not find a nullptr
511 return rv;
514 mDeviceKeyDebug = displayDevice.DeviceKey;
516 /* DeviceKey is "reserved" according to MSDN so we'll be careful with it */
517 /* check that DeviceKey begins with DEVICE_KEY_PREFIX */
518 /* some systems have a DeviceKey starting with \REGISTRY\Machine\ so we need
519 * to compare case insenstively */
520 /* If the device key is empty, we are most likely in a remote desktop
521 * environment. In this case we set the devicekey to an empty string so
522 * it can be handled later.
524 if (displayDevice.DeviceKey[0] != '\0') {
525 if (_wcsnicmp(displayDevice.DeviceKey, DEVICE_KEY_PREFIX,
526 ArrayLength(DEVICE_KEY_PREFIX) - 1) != 0) {
527 return rv;
530 // chop off DEVICE_KEY_PREFIX
531 mDeviceKey[0] =
532 displayDevice.DeviceKey + ArrayLength(DEVICE_KEY_PREFIX) - 1;
533 } else {
534 mDeviceKey[0].Truncate();
537 mDeviceID[0] = displayDevice.DeviceID;
538 mDeviceString[0] = displayDevice.DeviceString;
540 // On Windows 8 and Server 2012 hosts, we want to not block RDP
541 // sessions from attempting hardware acceleration. RemoteFX
542 // provides features and functionaltiy that can give a good D3D10 +
543 // D2D + DirectWrite experience emulated via a software GPU.
545 // Unfortunately, the Device ID is nullptr, and we can't enumerate
546 // it using the setup infrastructure (SetupDiGetClassDevsW below
547 // will return INVALID_HANDLE_VALUE).
548 UINT flags = DIGCF_PRESENT | DIGCF_PROFILE | DIGCF_ALLCLASSES;
549 if (mWindowsVersion >= kWindows8 && mDeviceID[0].Length() == 0 &&
550 mDeviceString[0].EqualsLiteral("RDPUDD Chained DD")) {
551 WCHAR sysdir[255];
552 UINT len = GetSystemDirectory(sysdir, sizeof(sysdir));
553 if (len < sizeof(sysdir)) {
554 nsString rdpudd(sysdir);
555 rdpudd.AppendLiteral("\\rdpudd.dll");
556 gfxWindowsPlatform::GetDLLVersion(rdpudd.BeginReading(),
557 mDriverVersion[0]);
558 mDriverDate[0].AssignLiteral("01-01-1970");
560 // 0x1414 is Microsoft; 0xfefe is an invented (and unused) code
561 mDeviceID[0].AssignLiteral("PCI\\VEN_1414&DEV_FEFE&SUBSYS_00000000");
562 flags |= DIGCF_DEVICEINTERFACE;
566 /* create a device information set composed of the current display device */
567 HDEVINFO devinfo =
568 SetupDiGetClassDevsW(nullptr, mDeviceID[0].get(), nullptr, flags);
570 if (devinfo != INVALID_HANDLE_VALUE) {
571 HKEY key;
572 LONG result;
573 WCHAR value[255];
574 DWORD dwcbData;
575 SP_DEVINFO_DATA devinfoData;
576 DWORD memberIndex = 0;
578 devinfoData.cbSize = sizeof(devinfoData);
579 constexpr auto driverKeyPre =
580 u"System\\CurrentControlSet\\Control\\Class\\"_ns;
581 /* enumerate device information elements in the device information set */
582 while (SetupDiEnumDeviceInfo(devinfo, memberIndex++, &devinfoData)) {
583 /* get a string that identifies the device's driver key */
584 if (SetupDiGetDeviceRegistryPropertyW(devinfo, &devinfoData, SPDRP_DRIVER,
585 nullptr, (PBYTE)value,
586 sizeof(value), nullptr)) {
587 nsAutoString driverKey(driverKeyPre);
588 driverKey += value;
589 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey.get(), 0,
590 KEY_QUERY_VALUE, &key);
591 if (result == ERROR_SUCCESS) {
592 /* we've found the driver we're looking for */
593 dwcbData = sizeof(value);
594 result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
595 (LPBYTE)value, &dwcbData);
596 if (result == ERROR_SUCCESS) {
597 mDriverVersion[0] = value;
598 } else {
599 // If the entry wasn't found, assume the worst (0.0.0.0).
600 mDriverVersion[0].AssignLiteral("0.0.0.0");
602 dwcbData = sizeof(value);
603 result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr,
604 (LPBYTE)value, &dwcbData);
605 if (result == ERROR_SUCCESS) {
606 mDriverDate[0] = value;
607 } else {
608 // Again, assume the worst
609 mDriverDate[0].AssignLiteral("01-01-1970");
611 RegCloseKey(key);
612 break;
617 SetupDiDestroyDeviceInfoList(devinfo);
620 // It is convenient to have these as integers
621 uint32_t adapterVendorID[2] = {0, 0};
622 uint32_t adapterDeviceID[2] = {0, 0};
623 uint32_t adapterSubsysID[2] = {0, 0};
625 adapterVendorID[0] = ParseIDFromDeviceID(mDeviceID[0], "VEN_", 4);
626 adapterDeviceID[0] = ParseIDFromDeviceID(mDeviceID[0], "&DEV_", 4);
627 adapterSubsysID[0] = ParseIDFromDeviceID(mDeviceID[0], "&SUBSYS_", 8);
629 // Sometimes we don't get the valid device using this method. For now,
630 // allow zero vendor or device as valid, as long as the other value is
631 // non-zero.
632 bool foundValidDevice = (adapterVendorID[0] != 0 || adapterDeviceID[0] != 0);
634 // We now check for second display adapter. If we didn't find the valid
635 // device using the original approach, we will try the alternative.
637 // Device interface class for display adapters.
638 CLSID GUID_DISPLAY_DEVICE_ARRIVAL;
639 HRESULT hresult = CLSIDFromString(L"{1CA05180-A699-450A-9A0C-DE4FBE3DDD89}",
640 &GUID_DISPLAY_DEVICE_ARRIVAL);
641 if (hresult == NOERROR) {
642 devinfo =
643 SetupDiGetClassDevsW(&GUID_DISPLAY_DEVICE_ARRIVAL, nullptr, nullptr,
644 DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
646 if (devinfo != INVALID_HANDLE_VALUE) {
647 HKEY key;
648 LONG result;
649 WCHAR value[255];
650 DWORD dwcbData;
651 SP_DEVINFO_DATA devinfoData;
652 DWORD memberIndex = 0;
653 devinfoData.cbSize = sizeof(devinfoData);
655 nsAutoString adapterDriver2;
656 nsAutoString deviceID2;
657 nsAutoString driverVersion2;
658 nsAutoString driverDate2;
660 constexpr auto driverKeyPre =
661 u"System\\CurrentControlSet\\Control\\Class\\"_ns;
662 /* enumerate device information elements in the device information set */
663 while (SetupDiEnumDeviceInfo(devinfo, memberIndex++, &devinfoData)) {
664 /* get a string that identifies the device's driver key */
665 if (SetupDiGetDeviceRegistryPropertyW(
666 devinfo, &devinfoData, SPDRP_DRIVER, nullptr, (PBYTE)value,
667 sizeof(value), nullptr)) {
668 nsAutoString driverKey2(driverKeyPre);
669 driverKey2 += value;
670 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey2.get(), 0,
671 KEY_QUERY_VALUE, &key);
672 if (result == ERROR_SUCCESS) {
673 dwcbData = sizeof(value);
674 result = RegQueryValueExW(key, L"MatchingDeviceId", nullptr,
675 nullptr, (LPBYTE)value, &dwcbData);
676 if (result != ERROR_SUCCESS) {
677 continue;
679 deviceID2 = value;
680 adapterVendorID[1] = ParseIDFromDeviceID(deviceID2, "VEN_", 4);
681 adapterDeviceID[1] = ParseIDFromDeviceID(deviceID2, "&DEV_", 4);
682 // Skip the devices we already considered, as well as any
683 // "zero" ones.
684 if ((adapterVendorID[0] == adapterVendorID[1] &&
685 adapterDeviceID[0] == adapterDeviceID[1]) ||
686 (adapterVendorID[1] == 0 && adapterDeviceID[1] == 0)) {
687 RegCloseKey(key);
688 continue;
691 // If this device is missing driver information, it is unlikely to
692 // be a real display adapter.
693 if (NS_FAILED(GetKeyValue(driverKey2.get(),
694 L"InstalledDisplayDrivers",
695 adapterDriver2, REG_MULTI_SZ))) {
696 RegCloseKey(key);
697 continue;
699 dwcbData = sizeof(value);
700 result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
701 (LPBYTE)value, &dwcbData);
702 if (result != ERROR_SUCCESS) {
703 RegCloseKey(key);
704 continue;
706 driverVersion2 = value;
707 dwcbData = sizeof(value);
708 result = RegQueryValueExW(key, L"DriverDate", nullptr, nullptr,
709 (LPBYTE)value, &dwcbData);
710 if (result != ERROR_SUCCESS) {
711 RegCloseKey(key);
712 continue;
714 driverDate2 = value;
715 dwcbData = sizeof(value);
716 result = RegQueryValueExW(key, L"Device Description", nullptr,
717 nullptr, (LPBYTE)value, &dwcbData);
718 if (result != ERROR_SUCCESS) {
719 dwcbData = sizeof(value);
720 result = RegQueryValueExW(key, L"DriverDesc", nullptr, nullptr,
721 (LPBYTE)value, &dwcbData);
723 RegCloseKey(key);
724 if (result == ERROR_SUCCESS) {
725 // If we didn't find a valid device with the original method
726 // take this one, and continue looking for the second GPU.
727 if (!foundValidDevice) {
728 foundValidDevice = true;
729 adapterVendorID[0] = adapterVendorID[1];
730 adapterDeviceID[0] = adapterDeviceID[1];
731 mDeviceString[0] = value;
732 mDeviceID[0] = deviceID2;
733 mDeviceKey[0] = driverKey2;
734 mDriverVersion[0] = driverVersion2;
735 mDriverDate[0] = driverDate2;
736 adapterSubsysID[0] =
737 ParseIDFromDeviceID(mDeviceID[0], "&SUBSYS_", 8);
738 continue;
741 mHasDualGPU = true;
742 mDeviceString[1] = value;
743 mDeviceID[1] = deviceID2;
744 mDeviceKey[1] = driverKey2;
745 mDriverVersion[1] = driverVersion2;
746 mDriverDate[1] = driverDate2;
747 adapterSubsysID[1] =
748 ParseIDFromDeviceID(mDeviceID[1], "&SUBSYS_", 8);
749 mAdapterVendorID[1].AppendPrintf("0x%04x", adapterVendorID[1]);
750 mAdapterDeviceID[1].AppendPrintf("0x%04x", adapterDeviceID[1]);
751 mAdapterSubsysID[1].AppendPrintf("%08x", adapterSubsysID[1]);
752 break;
758 SetupDiDestroyDeviceInfoList(devinfo);
762 mAdapterVendorID[0].AppendPrintf("0x%04x", adapterVendorID[0]);
763 mAdapterDeviceID[0].AppendPrintf("0x%04x", adapterDeviceID[0]);
764 mAdapterSubsysID[0].AppendPrintf("%08x", adapterSubsysID[0]);
766 // Sometimes, the enumeration is not quite right and the two adapters
767 // end up being swapped. Actually enumerate the adapters that come
768 // back from the DXGI factory to check, and tag the second as active
769 // if found.
770 if (mHasDualGPU) {
771 nsModuleHandle dxgiModule(LoadLibrarySystem32(L"dxgi.dll"));
772 decltype(CreateDXGIFactory)* createDXGIFactory =
773 (decltype(CreateDXGIFactory)*)GetProcAddress(dxgiModule,
774 "CreateDXGIFactory");
776 if (createDXGIFactory) {
777 RefPtr<IDXGIFactory> factory = nullptr;
778 createDXGIFactory(__uuidof(IDXGIFactory), (void**)(&factory));
779 if (factory) {
780 RefPtr<IDXGIAdapter> adapter;
781 if (SUCCEEDED(factory->EnumAdapters(0, getter_AddRefs(adapter)))) {
782 DXGI_ADAPTER_DESC desc;
783 PodZero(&desc);
784 if (SUCCEEDED(adapter->GetDesc(&desc))) {
785 if (desc.VendorId != adapterVendorID[0] &&
786 desc.DeviceId != adapterDeviceID[0] &&
787 desc.VendorId == adapterVendorID[1] &&
788 desc.DeviceId == adapterDeviceID[1]) {
789 mActiveGPUIndex = 1;
797 mHasDriverVersionMismatch = false;
798 if (mAdapterVendorID[mActiveGPUIndex] ==
799 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Intel)) {
800 // we've had big crashers (bugs 590373 and 595364) apparently correlated
801 // with bad Intel driver installations where the DriverVersion reported
802 // by the registry was not the version of the DLL.
804 // Note that these start without the .dll extension but eventually gain it.
805 bool is64bitApp = sizeof(void*) == 8;
806 nsAutoString dllFileName(is64bitApp ? u"igd10umd64" : u"igd10umd32");
807 nsAutoString dllFileName2(is64bitApp ? u"igd10iumd64" : u"igd10iumd32");
809 nsString dllVersion, dllVersion2;
810 uint64_t dllNumericVersion = 0, dllNumericVersion2 = 0,
811 driverNumericVersion = 0, knownSafeMismatchVersion = 0;
813 // Only parse the DLL version for those found in the driver list
814 nsAutoString eligibleDLLs;
815 if (NS_SUCCEEDED(GetAdapterDriver(eligibleDLLs))) {
816 if (FindInReadable(dllFileName, eligibleDLLs)) {
817 dllFileName += u".dll"_ns;
818 gfxWindowsPlatform::GetDLLVersion(dllFileName.get(), dllVersion);
819 ParseDriverVersion(dllVersion, &dllNumericVersion);
821 if (FindInReadable(dllFileName2, eligibleDLLs)) {
822 dllFileName2 += u".dll"_ns;
823 gfxWindowsPlatform::GetDLLVersion(dllFileName2.get(), dllVersion2);
824 ParseDriverVersion(dllVersion2, &dllNumericVersion2);
828 // Sometimes the DLL is not in the System32 nor SysWOW64 directories. But
829 // UserModeDriverName (or UserModeDriverNameWow, if available) might provide
830 // the full path to the DLL in some DriverStore FileRepository.
831 if (dllNumericVersion == 0 && dllNumericVersion2 == 0) {
832 nsTArray<nsString> eligibleDLLpaths;
833 const WCHAR* keyLocation = mDeviceKey[mActiveGPUIndex].get();
834 GetKeyValues(keyLocation, L"UserModeDriverName", eligibleDLLpaths);
835 GetKeyValues(keyLocation, L"UserModeDriverNameWow", eligibleDLLpaths);
836 size_t length = eligibleDLLpaths.Length();
837 for (size_t i = 0;
838 i < length && dllNumericVersion == 0 && dllNumericVersion2 == 0;
839 ++i) {
840 if (FindInReadable(dllFileName, eligibleDLLpaths[i])) {
841 gfxWindowsPlatform::GetDLLVersion(eligibleDLLpaths[i].get(),
842 dllVersion);
843 ParseDriverVersion(dllVersion, &dllNumericVersion);
844 } else if (FindInReadable(dllFileName2, eligibleDLLpaths[i])) {
845 gfxWindowsPlatform::GetDLLVersion(eligibleDLLpaths[i].get(),
846 dllVersion2);
847 ParseDriverVersion(dllVersion2, &dllNumericVersion2);
852 ParseDriverVersion(mDriverVersion[mActiveGPUIndex], &driverNumericVersion);
853 ParseDriverVersion(u"9.17.10.0"_ns, &knownSafeMismatchVersion);
855 // If there's a driver version mismatch, consider this harmful only when
856 // the driver version is less than knownSafeMismatchVersion. See the
857 // above comment about crashes with old mismatches. If the GetDllVersion
858 // call fails, we are not calling it a mismatch.
859 if ((dllNumericVersion != 0 && dllNumericVersion != driverNumericVersion) ||
860 (dllNumericVersion2 != 0 &&
861 dllNumericVersion2 != driverNumericVersion)) {
862 if (driverNumericVersion < knownSafeMismatchVersion ||
863 std::max(dllNumericVersion, dllNumericVersion2) <
864 knownSafeMismatchVersion) {
865 mHasDriverVersionMismatch = true;
866 gfxCriticalNoteOnce
867 << "Mismatched driver versions between the registry "
868 << NS_ConvertUTF16toUTF8(mDriverVersion[mActiveGPUIndex]).get()
869 << " and DLL(s) " << NS_ConvertUTF16toUTF8(dllVersion).get() << ", "
870 << NS_ConvertUTF16toUTF8(dllVersion2).get() << " reported.";
872 } else if (dllNumericVersion == 0 && dllNumericVersion2 == 0) {
873 // Leave it as an asserting error for now, to see if we can find
874 // a system that exhibits this kind of a problem internally.
875 gfxCriticalErrorOnce()
876 << "Potential driver version mismatch ignored due to missing DLLs "
877 << NS_ConvertUTF16toUTF8(dllFileName).get()
878 << " v=" << NS_ConvertUTF16toUTF8(dllVersion).get() << " and "
879 << NS_ConvertUTF16toUTF8(dllFileName2).get()
880 << " v=" << NS_ConvertUTF16toUTF8(dllVersion2).get();
884 // Get monitor information
885 RefreshMonitors();
887 const char* spoofedDriverVersionString =
888 PR_GetEnv("MOZ_GFX_SPOOF_DRIVER_VERSION");
889 if (spoofedDriverVersionString) {
890 mDriverVersion[mActiveGPUIndex].AssignASCII(spoofedDriverVersionString);
893 const char* spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_VENDOR_ID");
894 if (spoofedVendor) {
895 mAdapterVendorID[mActiveGPUIndex].AssignASCII(spoofedVendor);
898 const char* spoofedDevice = PR_GetEnv("MOZ_GFX_SPOOF_DEVICE_ID");
899 if (spoofedDevice) {
900 mAdapterDeviceID[mActiveGPUIndex].AssignASCII(spoofedDevice);
903 AddCrashReportAnnotations();
905 return rv;
908 NS_IMETHODIMP
909 GfxInfo::GetAdapterDescription(nsAString& aAdapterDescription) {
910 AssertNotWin32kLockdown();
912 aAdapterDescription = mDeviceString[mActiveGPUIndex];
913 return NS_OK;
916 NS_IMETHODIMP
917 GfxInfo::GetAdapterDescription2(nsAString& aAdapterDescription) {
918 AssertNotWin32kLockdown();
920 aAdapterDescription = mDeviceString[1 - mActiveGPUIndex];
921 return NS_OK;
924 NS_IMETHODIMP
925 GfxInfo::RefreshMonitors() {
926 AssertNotWin32kLockdown();
928 mDisplayInfo.Clear();
930 for (int deviceIndex = 0;; deviceIndex++) {
931 DISPLAY_DEVICEW device;
932 device.cb = sizeof(device);
933 if (!::EnumDisplayDevicesW(nullptr, deviceIndex, &device, 0)) {
934 break;
937 if (!(device.StateFlags & DISPLAY_DEVICE_ACTIVE)) {
938 continue;
941 DEVMODEW mode;
942 mode.dmSize = sizeof(mode);
943 mode.dmDriverExtra = 0;
944 if (!::EnumDisplaySettingsW(device.DeviceName, ENUM_CURRENT_SETTINGS,
945 &mode)) {
946 continue;
949 DisplayInfo displayInfo;
951 displayInfo.mScreenWidth = mode.dmPelsWidth;
952 displayInfo.mScreenHeight = mode.dmPelsHeight;
953 displayInfo.mRefreshRate = mode.dmDisplayFrequency;
954 displayInfo.mIsPseudoDisplay =
955 !!(device.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER);
956 displayInfo.mDeviceString = device.DeviceString;
958 mDisplayInfo.AppendElement(displayInfo);
960 return NS_OK;
963 NS_IMETHODIMP
964 GfxInfo::GetAdapterRAM(uint32_t* aAdapterRAM) {
965 AssertNotWin32kLockdown();
967 uint32_t result = 0;
968 if (NS_FAILED(GetKeyValue(mDeviceKey[mActiveGPUIndex].get(),
969 L"HardwareInformation.qwMemorySize", result,
970 REG_QWORD)) ||
971 result == 0) {
972 if (NS_FAILED(GetKeyValue(mDeviceKey[mActiveGPUIndex].get(),
973 L"HardwareInformation.MemorySize", result,
974 REG_DWORD))) {
975 result = 0;
978 *aAdapterRAM = result;
979 return NS_OK;
982 NS_IMETHODIMP
983 GfxInfo::GetAdapterRAM2(uint32_t* aAdapterRAM) {
984 AssertNotWin32kLockdown();
986 uint32_t result = 0;
987 if (mHasDualGPU) {
988 if (NS_FAILED(GetKeyValue(mDeviceKey[1 - mActiveGPUIndex].get(),
989 L"HardwareInformation.qwMemorySize", result,
990 REG_QWORD)) ||
991 result == 0) {
992 if (NS_FAILED(GetKeyValue(mDeviceKey[1 - mActiveGPUIndex].get(),
993 L"HardwareInformation.MemorySize", result,
994 REG_DWORD))) {
995 result = 0;
999 *aAdapterRAM = result;
1000 return NS_OK;
1003 NS_IMETHODIMP
1004 GfxInfo::GetAdapterDriver(nsAString& aAdapterDriver) {
1005 AssertNotWin32kLockdown();
1007 if (NS_FAILED(GetKeyValue(mDeviceKey[mActiveGPUIndex].get(),
1008 L"InstalledDisplayDrivers", aAdapterDriver,
1009 REG_MULTI_SZ)))
1010 aAdapterDriver = L"Unknown";
1011 return NS_OK;
1014 NS_IMETHODIMP
1015 GfxInfo::GetAdapterDriver2(nsAString& aAdapterDriver) {
1016 AssertNotWin32kLockdown();
1018 if (!mHasDualGPU) {
1019 aAdapterDriver.Truncate();
1020 } else if (NS_FAILED(GetKeyValue(mDeviceKey[1 - mActiveGPUIndex].get(),
1021 L"InstalledDisplayDrivers", aAdapterDriver,
1022 REG_MULTI_SZ))) {
1023 aAdapterDriver = L"Unknown";
1025 return NS_OK;
1028 NS_IMETHODIMP
1029 GfxInfo::GetAdapterDriverVendor(nsAString& aAdapterDriverVendor) {
1030 aAdapterDriverVendor.Truncate();
1031 return NS_OK;
1034 NS_IMETHODIMP
1035 GfxInfo::GetAdapterDriverVersion(nsAString& aAdapterDriverVersion) {
1036 AssertNotWin32kLockdown();
1038 aAdapterDriverVersion = mDriverVersion[mActiveGPUIndex];
1039 return NS_OK;
1042 NS_IMETHODIMP
1043 GfxInfo::GetAdapterDriverDate(nsAString& aAdapterDriverDate) {
1044 AssertNotWin32kLockdown();
1046 aAdapterDriverDate = mDriverDate[mActiveGPUIndex];
1047 return NS_OK;
1050 NS_IMETHODIMP
1051 GfxInfo::GetAdapterDriverVendor2(nsAString& aAdapterDriverVendor) {
1052 aAdapterDriverVendor.Truncate();
1053 return NS_OK;
1056 NS_IMETHODIMP
1057 GfxInfo::GetAdapterDriverVersion2(nsAString& aAdapterDriverVersion) {
1058 AssertNotWin32kLockdown();
1060 aAdapterDriverVersion = mDriverVersion[1 - mActiveGPUIndex];
1061 return NS_OK;
1064 NS_IMETHODIMP
1065 GfxInfo::GetAdapterDriverDate2(nsAString& aAdapterDriverDate) {
1066 AssertNotWin32kLockdown();
1068 aAdapterDriverDate = mDriverDate[1 - mActiveGPUIndex];
1069 return NS_OK;
1072 NS_IMETHODIMP
1073 GfxInfo::GetAdapterVendorID(nsAString& aAdapterVendorID) {
1074 AssertNotWin32kLockdown();
1076 aAdapterVendorID = mAdapterVendorID[mActiveGPUIndex];
1077 return NS_OK;
1080 NS_IMETHODIMP
1081 GfxInfo::GetAdapterVendorID2(nsAString& aAdapterVendorID) {
1082 AssertNotWin32kLockdown();
1084 aAdapterVendorID = mAdapterVendorID[1 - mActiveGPUIndex];
1085 return NS_OK;
1088 NS_IMETHODIMP
1089 GfxInfo::GetAdapterDeviceID(nsAString& aAdapterDeviceID) {
1090 AssertNotWin32kLockdown();
1092 aAdapterDeviceID = mAdapterDeviceID[mActiveGPUIndex];
1093 return NS_OK;
1096 NS_IMETHODIMP
1097 GfxInfo::GetAdapterDeviceID2(nsAString& aAdapterDeviceID) {
1098 AssertNotWin32kLockdown();
1100 aAdapterDeviceID = mAdapterDeviceID[1 - mActiveGPUIndex];
1101 return NS_OK;
1104 NS_IMETHODIMP
1105 GfxInfo::GetAdapterSubsysID(nsAString& aAdapterSubsysID) {
1106 AssertNotWin32kLockdown();
1108 aAdapterSubsysID = mAdapterSubsysID[mActiveGPUIndex];
1109 return NS_OK;
1112 NS_IMETHODIMP
1113 GfxInfo::GetAdapterSubsysID2(nsAString& aAdapterSubsysID) {
1114 AssertNotWin32kLockdown();
1116 aAdapterSubsysID = mAdapterSubsysID[1 - mActiveGPUIndex];
1117 return NS_OK;
1120 NS_IMETHODIMP
1121 GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) {
1122 // This is never the case, as the active GPU ends up being
1123 // the first one. It should probably be removed.
1124 *aIsGPU2Active = false;
1125 return NS_OK;
1128 NS_IMETHODIMP
1129 GfxInfo::GetDisplayInfo(nsTArray<nsString>& aDisplayInfo) {
1130 AssertNotWin32kLockdown();
1132 for (auto displayInfo : mDisplayInfo) {
1133 nsString value;
1134 value.AppendPrintf("%dx%d@%dHz %s %s", displayInfo.mScreenWidth,
1135 displayInfo.mScreenHeight, displayInfo.mRefreshRate,
1136 displayInfo.mIsPseudoDisplay ? "Pseudo Display :" : ":",
1137 NS_ConvertUTF16toUTF8(displayInfo.mDeviceString).get());
1139 aDisplayInfo.AppendElement(value);
1142 return NS_OK;
1145 NS_IMETHODIMP
1146 GfxInfo::GetDisplayWidth(nsTArray<uint32_t>& aDisplayWidth) {
1147 AssertNotWin32kLockdown();
1149 for (auto displayInfo : mDisplayInfo) {
1150 aDisplayWidth.AppendElement((uint32_t)displayInfo.mScreenWidth);
1152 return NS_OK;
1155 NS_IMETHODIMP
1156 GfxInfo::GetDisplayHeight(nsTArray<uint32_t>& aDisplayHeight) {
1157 AssertNotWin32kLockdown();
1159 for (auto displayInfo : mDisplayInfo) {
1160 aDisplayHeight.AppendElement((uint32_t)displayInfo.mScreenHeight);
1162 return NS_OK;
1165 NS_IMETHODIMP
1166 GfxInfo::GetDrmRenderDevice(nsACString& aDrmRenderDevice) {
1167 return NS_ERROR_NOT_IMPLEMENTED;
1170 /* Cisco's VPN software can cause corruption of the floating point state.
1171 * Make a note of this in our crash reports so that some weird crashes
1172 * make more sense */
1173 static void CheckForCiscoVPN() {
1174 LONG result;
1175 HKEY key;
1176 /* This will give false positives, but hopefully no false negatives */
1177 result =
1178 RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client",
1179 0, KEY_QUERY_VALUE, &key);
1180 if (result == ERROR_SUCCESS) {
1181 RegCloseKey(key);
1182 CrashReporter::AppendAppNotesToCrashReport("Cisco VPN\n"_ns);
1186 void GfxInfo::AddCrashReportAnnotations() {
1187 AssertNotWin32kLockdown();
1189 CheckForCiscoVPN();
1191 if (mHasDriverVersionMismatch) {
1192 CrashReporter::AppendAppNotesToCrashReport("DriverVersionMismatch\n"_ns);
1195 nsString deviceID, vendorID, driverVersion, subsysID;
1196 nsCString narrowDeviceID, narrowVendorID, narrowDriverVersion, narrowSubsysID;
1198 GetAdapterDeviceID(deviceID);
1199 CopyUTF16toUTF8(deviceID, narrowDeviceID);
1200 GetAdapterVendorID(vendorID);
1201 CopyUTF16toUTF8(vendorID, narrowVendorID);
1202 GetAdapterDriverVersion(driverVersion);
1203 CopyUTF16toUTF8(driverVersion, narrowDriverVersion);
1204 GetAdapterSubsysID(subsysID);
1205 CopyUTF16toUTF8(subsysID, narrowSubsysID);
1207 CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterVendorID,
1208 narrowVendorID);
1209 CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterDeviceID,
1210 narrowDeviceID);
1211 CrashReporter::AnnotateCrashReport(
1212 CrashReporter::Annotation::AdapterDriverVersion, narrowDriverVersion);
1213 CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterSubsysID,
1214 narrowSubsysID);
1216 /* Add an App Note, this contains extra information. */
1217 nsAutoCString note;
1219 // TODO: We should probably convert this into a proper annotation
1220 if (vendorID == GfxDriverInfo::GetDeviceVendor(DeviceVendor::All)) {
1221 /* if we didn't find a valid vendorID lets append the mDeviceID string to
1222 * try to find out why */
1223 LossyAppendUTF16toASCII(mDeviceID[mActiveGPUIndex], note);
1224 note.AppendLiteral(", ");
1225 LossyAppendUTF16toASCII(mDeviceKeyDebug, note);
1227 note.AppendLiteral("\n");
1229 if (mHasDualGPU) {
1230 nsString deviceID2, vendorID2, subsysID2;
1231 nsAutoString adapterDriverVersionString2;
1232 nsCString narrowDeviceID2, narrowVendorID2, narrowSubsysID2;
1234 // Make a slight difference between the two cases so that we
1235 // can see it in the crash reports. It may come in handy.
1236 if (mActiveGPUIndex == 1) {
1237 note.AppendLiteral("Has dual GPUs. GPU-#2: ");
1238 } else {
1239 note.AppendLiteral("Has dual GPUs. GPU #2: ");
1241 GetAdapterDeviceID2(deviceID2);
1242 CopyUTF16toUTF8(deviceID2, narrowDeviceID2);
1243 GetAdapterVendorID2(vendorID2);
1244 CopyUTF16toUTF8(vendorID2, narrowVendorID2);
1245 GetAdapterDriverVersion2(adapterDriverVersionString2);
1246 GetAdapterSubsysID(subsysID2);
1247 CopyUTF16toUTF8(subsysID2, narrowSubsysID2);
1248 note.AppendLiteral("AdapterVendorID2: ");
1249 note.Append(narrowVendorID2);
1250 note.AppendLiteral(", AdapterDeviceID2: ");
1251 note.Append(narrowDeviceID2);
1252 note.AppendLiteral(", AdapterSubsysID2: ");
1253 note.Append(narrowSubsysID2);
1254 note.AppendLiteral(", AdapterDriverVersion2: ");
1255 note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2));
1257 CrashReporter::AppendAppNotesToCrashReport(note);
1260 static OperatingSystem WindowsVersionToOperatingSystem(
1261 int32_t aWindowsVersion) {
1262 switch (aWindowsVersion) {
1263 case kWindows7:
1264 return OperatingSystem::Windows7;
1265 case kWindows8:
1266 return OperatingSystem::Windows8;
1267 case kWindows8_1:
1268 return OperatingSystem::Windows8_1;
1269 case kWindows10:
1270 return OperatingSystem::Windows10;
1271 case kWindowsUnknown:
1272 default:
1273 return OperatingSystem::Unknown;
1277 static bool OnlyAllowFeatureOnWhitelistedVendor(int32_t aFeature) {
1278 switch (aFeature) {
1279 // The GPU process doesn't need hardware acceleration and can run on
1280 // devices that we normally block from not being on our whitelist.
1281 case nsIGfxInfo::FEATURE_GPU_PROCESS:
1282 // We can mostly assume that ANGLE will work
1283 case nsIGfxInfo::FEATURE_DIRECT3D_11_ANGLE:
1284 // Remote WebGL is needed for Win32k Lockdown, so it should be enabled
1285 // regardless of HW support or not
1286 case nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS:
1287 return false;
1288 default:
1289 return true;
1293 // Return true if the CPU supports AVX, but the operating system does not.
1294 #if defined(_M_X64)
1295 static inline bool DetectBrokenAVX() {
1296 int regs[4];
1297 __cpuid(regs, 0);
1298 if (regs[0] == 0) {
1299 // Level not supported.
1300 return false;
1303 __cpuid(regs, 1);
1305 const unsigned AVX = 1u << 28;
1306 const unsigned XSAVE = 1u << 26;
1307 if ((regs[2] & (AVX | XSAVE)) != (AVX | XSAVE)) {
1308 // AVX is not supported on this CPU.
1309 return false;
1312 const unsigned OSXSAVE = 1u << 27;
1313 if ((regs[2] & OSXSAVE) != OSXSAVE) {
1314 // AVX is supported, but the OS didn't enable it.
1315 // This can be forced via bcdedit /set xsavedisable 1.
1316 return true;
1319 const unsigned AVX_CTRL_BITS = (1 << 1) | (1 << 2);
1320 return (xgetbv(0) & AVX_CTRL_BITS) != AVX_CTRL_BITS;
1322 #endif
1324 const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
1325 if (!sDriverInfo->Length()) {
1327 * It should be noted here that more specialized rules on certain features
1328 * should be inserted -before- more generalized restriction. As the first
1329 * match for feature/OS/device found in the list will be used for the final
1330 * blocklisting call.
1334 * NVIDIA entries
1337 * The last 5 digit of the NVIDIA driver version maps to the version that
1338 * NVIDIA uses. The minor version (15, 16, 17) corresponds roughtly to the
1339 * OS (Vista, Win7, Win7) but they show up in smaller numbers across all
1340 * OS versions (perhaps due to OS upgrades). So we want to support
1341 * October 2009+ drivers across all these minor versions.
1343 * 187.45 (late October 2009) and earlier contain a bug which can cause us
1344 * to crash on shutdown.
1346 APPEND_TO_DRIVER_BLOCKLIST(
1347 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1348 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1349 DRIVER_LESS_THAN_OR_EQUAL, V(8, 15, 11, 8745),
1350 "FEATURE_FAILURE_NV_W7_15", "nVidia driver > 187.45");
1351 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1352 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1353 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1354 DRIVER_BETWEEN_INCLUSIVE_START, V(8, 16, 10, 0000), V(8, 16, 11, 8745),
1355 "FEATURE_FAILURE_NV_W7_16", "nVidia driver > 187.45");
1356 // Telemetry doesn't show any driver in this range so it might not even be
1357 // required.
1358 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1359 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1360 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1361 DRIVER_BETWEEN_INCLUSIVE_START, V(8, 17, 10, 0000), V(8, 17, 11, 8745),
1362 "FEATURE_FAILURE_NV_W7_17", "nVidia driver > 187.45");
1365 * AMD/ATI entries. 8.56.1.15 is the driver that shipped with Windows 7 RTM
1367 APPEND_TO_DRIVER_BLOCKLIST(
1368 OperatingSystem::Windows, DeviceFamily::AtiAll,
1369 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1370 DRIVER_LESS_THAN, V(8, 56, 1, 15), "FEATURE_FAILURE_AMD1", "8.56.1.15");
1372 // Bug 1099252
1373 APPEND_TO_DRIVER_BLOCKLIST2(
1374 OperatingSystem::Windows7, DeviceFamily::AtiAll,
1375 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1376 DRIVER_EQUAL, V(8, 832, 0, 0), "FEATURE_FAILURE_BUG_1099252");
1378 // Bug 1118695
1379 APPEND_TO_DRIVER_BLOCKLIST2(
1380 OperatingSystem::Windows7, DeviceFamily::AtiAll,
1381 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1382 DRIVER_EQUAL, V(8, 783, 2, 2000), "FEATURE_FAILURE_BUG_1118695");
1384 // Bug 1587155
1386 // There are a several reports of strange rendering corruptions with this
1387 // driver version, with and without webrender. We weren't able to
1388 // reproduce these problems, but the users were able to update their
1389 // drivers and it went away. So just to be safe, let's blocklist all
1390 // gpu use with this particular (very old) driver, restricted
1391 // to Win10 since we only have reports from that platform.
1392 APPEND_TO_DRIVER_BLOCKLIST2(
1393 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1394 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1395 DRIVER_EQUAL, V(22, 19, 162, 4), "FEATURE_FAILURE_BUG_1587155");
1397 // Bug 1198815
1398 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1399 OperatingSystem::Windows, DeviceFamily::AtiAll,
1400 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1401 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1402 V(15, 200, 0, 0), V(15, 200, 1062, 1004), "FEATURE_FAILURE_BUG_1198815",
1403 "15.200.0.0-15.200.1062.1004");
1405 // Bug 1267970
1406 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1407 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1408 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1409 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1410 V(15, 200, 0, 0), V(15, 301, 2301, 1002), "FEATURE_FAILURE_BUG_1267970",
1411 "15.200.0.0-15.301.2301.1002");
1412 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1413 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1414 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1415 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1416 V(16, 100, 0, 0), V(16, 300, 2311, 0), "FEATURE_FAILURE_BUG_1267970",
1417 "16.100.0.0-16.300.2311.0");
1420 * Bug 783517 - crashes in AMD driver on Windows 8
1422 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1423 OperatingSystem::Windows8, DeviceFamily::AtiAll,
1424 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1425 DRIVER_BETWEEN_INCLUSIVE_START, V(8, 982, 0, 0), V(8, 983, 0, 0),
1426 "FEATURE_FAILURE_BUG_783517_AMD", "!= 8.982.*.*");
1429 * Bug 1599981 - crashes in AMD driver on Windows 10
1431 APPEND_TO_DRIVER_BLOCKLIST2(
1432 OperatingSystem::Windows10, DeviceFamily::RadeonCaicos,
1433 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1434 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1435 V(15, 301, 1901, 0), "FEATURE_FAILURE_BUG_1599981");
1437 /* OpenGL on any ATI/AMD hardware is discouraged
1438 * See:
1439 * bug 619773 - WebGL: Crash with blue screen : "NMI: Parity Check / Memory
1440 * Parity Error" bugs 584403, 584404, 620924 - crashes in atioglxx
1441 * + many complaints about incorrect rendering
1443 APPEND_TO_DRIVER_BLOCKLIST2(
1444 OperatingSystem::Windows, DeviceFamily::AtiAll,
1445 nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED,
1446 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1447 "FEATURE_FAILURE_OGL_ATI_DIS");
1450 * Intel entries
1453 /* The driver versions used here come from bug 594877. They might not
1454 * be particularly relevant anymore.
1456 #define IMPLEMENT_INTEL_DRIVER_BLOCKLIST(winVer, devFamily, driverVer, ruleId) \
1457 APPEND_TO_DRIVER_BLOCKLIST2(winVer, devFamily, GfxDriverInfo::allFeatures, \
1458 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \
1459 DRIVER_LESS_THAN, driverVer, ruleId)
1461 #define IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(winVer, devFamily, driverVer, \
1462 ruleId) \
1463 APPEND_TO_DRIVER_BLOCKLIST2(winVer, devFamily, nsIGfxInfo::FEATURE_DIRECT2D, \
1464 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, \
1465 DRIVER_BUILD_ID_LESS_THAN, driverVer, ruleId)
1467 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1468 DeviceFamily::IntelGMA500, 2026,
1469 "FEATURE_FAILURE_594877_7");
1470 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(
1471 OperatingSystem::Windows7, DeviceFamily::IntelGMA900,
1472 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_594877_8");
1473 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1474 DeviceFamily::IntelGMA950, 1930,
1475 "FEATURE_FAILURE_594877_9");
1476 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1477 DeviceFamily::IntelGMA3150, 2117,
1478 "FEATURE_FAILURE_594877_10");
1479 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(OperatingSystem::Windows7,
1480 DeviceFamily::IntelGMAX3000, 1930,
1481 "FEATURE_FAILURE_594877_11");
1482 IMPLEMENT_INTEL_DRIVER_BLOCKLIST_D2D(
1483 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1484 2202, "FEATURE_FAILURE_594877_12");
1486 /* Disable Direct2D on Intel GMAX4500 devices because of rendering
1487 * corruption discovered in bug 1180379. These seems to affect even the most
1488 * recent drivers. We're black listing all of the devices to be safe even
1489 * though we've only confirmed the issue on the G45
1491 APPEND_TO_DRIVER_BLOCKLIST2(
1492 OperatingSystem::Windows, DeviceFamily::IntelGMAX4500HD,
1493 nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1494 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1495 "FEATURE_FAILURE_1180379");
1497 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1498 OperatingSystem::Windows7, DeviceFamily::IntelGMA500, V(5, 0, 0, 2026),
1499 "FEATURE_FAILURE_INTEL_16");
1500 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1501 OperatingSystem::Windows7, DeviceFamily::IntelGMA900,
1502 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_INTEL_17");
1503 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1504 OperatingSystem::Windows7, DeviceFamily::IntelGMA950,
1505 V(8, 15, 10, 1930), "FEATURE_FAILURE_INTEL_18");
1506 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1507 OperatingSystem::Windows7, DeviceFamily::IntelGMA3150,
1508 V(8, 14, 10, 1972), "FEATURE_FAILURE_INTEL_19");
1509 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1510 OperatingSystem::Windows7, DeviceFamily::IntelGMAX3000,
1511 V(7, 15, 10, 1666), "FEATURE_FAILURE_INTEL_20");
1512 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1513 OperatingSystem::Windows7, DeviceFamily::IntelGMAX4500HD,
1514 V(7, 15, 10, 1666), "FEATURE_FAILURE_INTEL_21");
1515 IMPLEMENT_INTEL_DRIVER_BLOCKLIST(
1516 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1517 V(7, 15, 10, 1666), "FEATURE_FAILURE_INTEL_22");
1519 // Bug 1074378
1520 APPEND_TO_DRIVER_BLOCKLIST(
1521 OperatingSystem::Windows7, DeviceFamily::IntelGMAX4500HD,
1522 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1523 DRIVER_EQUAL, V(8, 15, 10, 1749), "FEATURE_FAILURE_BUG_1074378_1",
1524 "8.15.10.2342");
1525 APPEND_TO_DRIVER_BLOCKLIST(
1526 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1527 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1528 DRIVER_EQUAL, V(8, 15, 10, 1749), "FEATURE_FAILURE_BUG_1074378_2",
1529 "8.15.10.2342");
1531 /* OpenGL on any Intel hardware is discouraged */
1532 APPEND_TO_DRIVER_BLOCKLIST2(
1533 OperatingSystem::Windows, DeviceFamily::IntelAll,
1534 nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_DISCOURAGED,
1535 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1536 "FEATURE_FAILURE_INTEL_OGL_DIS");
1539 * Disable acceleration on Intel HD 3000 for graphics drivers
1540 * <= 8.15.10.2321. See bug 1018278 and bug 1060736.
1542 APPEND_TO_DRIVER_BLOCKLIST(
1543 OperatingSystem::Windows, DeviceFamily::IntelSandyBridge,
1544 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1545 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 2321, "FEATURE_FAILURE_BUG_1018278",
1546 "X.X.X.2342");
1549 * Disable D2D on Win7 on Intel Haswell for graphics drivers build id <=
1550 * 4578. See bug 1432610
1552 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows7,
1553 DeviceFamily::IntelHaswell,
1554 nsIGfxInfo::FEATURE_DIRECT2D,
1555 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1556 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 4578,
1557 "FEATURE_FAILURE_BUG_1432610");
1559 * Disable VP8 HW decoding on Windows 8.1 on Intel Haswel and a certain
1560 * driver version. See bug 1760464 comment 6 and bug 1761332.
1562 APPEND_TO_DRIVER_BLOCKLIST2(
1563 OperatingSystem::Windows8_1, DeviceFamily::IntelHaswell,
1564 nsIGfxInfo::FEATURE_VP8_HW_DECODE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1565 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1566 "FEATURE_FAILURE_BUG_1760464");
1568 APPEND_TO_DRIVER_BLOCKLIST2(
1569 OperatingSystem::Windows8_1, DeviceFamily::IntelAll,
1570 nsIGfxInfo::FEATURE_VP8_HW_DECODE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1571 DRIVER_EQUAL, V(10, 18, 14, 4264), "FEATURE_FAILURE_BUG_1761332");
1573 /* Disable D2D on Win7 on Intel HD Graphics on driver <= 8.15.10.2302
1574 * See bug 806786
1576 APPEND_TO_DRIVER_BLOCKLIST2(
1577 OperatingSystem::Windows7, DeviceFamily::IntelMobileHDGraphics,
1578 nsIGfxInfo::FEATURE_DIRECT2D,
1579 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1580 V(8, 15, 10, 2302), "FEATURE_FAILURE_BUG_806786");
1582 /* Disable D2D on Win8 on Intel HD Graphics on driver <= 8.15.10.2302
1583 * See bug 804144 and 863683
1585 APPEND_TO_DRIVER_BLOCKLIST2(
1586 OperatingSystem::Windows8, DeviceFamily::IntelMobileHDGraphics,
1587 nsIGfxInfo::FEATURE_DIRECT2D,
1588 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1589 V(8, 15, 10, 2302), "FEATURE_FAILURE_BUG_804144");
1591 /* Disable D2D on Win7 on Intel HD Graphics on driver == 8.15.10.2418
1592 * See bug 1433790
1594 APPEND_TO_DRIVER_BLOCKLIST2(
1595 OperatingSystem::Windows7, DeviceFamily::IntelHDGraphicsToSandyBridge,
1596 nsIGfxInfo::FEATURE_DIRECT2D,
1597 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1598 V(8, 15, 10, 2418), "FEATURE_FAILURE_BUG_1433790");
1600 /* Disable D3D11 layers on Intel G41 express graphics and Intel GM965, Intel
1601 * X3100, for causing device resets. See bug 1116812.
1603 APPEND_TO_DRIVER_BLOCKLIST2(
1604 OperatingSystem::Windows, DeviceFamily::Bug1116812,
1605 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1606 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1607 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1116812");
1609 /* Disable D3D11 layers on Intel GMA 3150 for failing to allocate a shared
1610 * handle for textures. See bug 1207665. Additionally block D2D so we don't
1611 * accidentally use WARP.
1613 APPEND_TO_DRIVER_BLOCKLIST2(
1614 OperatingSystem::Windows, DeviceFamily::Bug1207665,
1615 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1616 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1617 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1207665_1");
1618 APPEND_TO_DRIVER_BLOCKLIST2(
1619 OperatingSystem::Windows, DeviceFamily::Bug1207665,
1620 nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1621 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1622 "FEATURE_FAILURE_BUG_1207665_2");
1624 APPEND_TO_DRIVER_BLOCKLIST2(
1625 OperatingSystem::Windows10, DeviceFamily::QualcommAll,
1626 nsIGfxInfo::FEATURE_DIRECT2D,
1627 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1628 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_QUALCOMM");
1630 // Bug 1548410. Disable hardware accelerated video decoding on
1631 // Qualcomm drivers used on Windows on ARM64 which are known to
1632 // cause BSOD's and output suprious green frames while decoding video.
1633 // Bug 1592826 expands the blocklist.
1634 APPEND_TO_DRIVER_BLOCKLIST2(
1635 OperatingSystem::Windows10, DeviceFamily::QualcommAll,
1636 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1637 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN_OR_EQUAL,
1638 V(25, 18, 10440, 0), "FEATURE_FAILURE_BUG_1592826");
1640 /* Disable D2D on AMD Catalyst 14.4 until 14.6
1641 * See bug 984488
1643 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1644 OperatingSystem::Windows, DeviceFamily::AtiAll,
1645 nsIGfxInfo::FEATURE_DIRECT2D,
1646 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1647 DRIVER_BETWEEN_INCLUSIVE_START, V(14, 1, 0, 0), V(14, 2, 0, 0),
1648 "FEATURE_FAILURE_BUG_984488_1", "ATI Catalyst 14.6+");
1650 /* Disable D3D9 layers on NVIDIA 6100/6150/6200 series due to glitches
1651 * whilst scrolling. See bugs: 612007, 644787 & 645872.
1653 APPEND_TO_DRIVER_BLOCKLIST2(
1654 OperatingSystem::Windows, DeviceFamily::NvidiaBlockD3D9Layers,
1655 nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
1656 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1657 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_612007");
1659 /* Microsoft RemoteFX; blocked less than 6.2.0.0 */
1660 APPEND_TO_DRIVER_BLOCKLIST(
1661 OperatingSystem::Windows, DeviceFamily::MicrosoftAll,
1662 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1663 DRIVER_LESS_THAN, V(6, 2, 0, 0), "< 6.2.0.0",
1664 "FEATURE_FAILURE_REMOTE_FX");
1666 /* Bug 1008759: Optimus (NVidia) crash. Disable D2D on NV 310M. */
1667 APPEND_TO_DRIVER_BLOCKLIST2(
1668 OperatingSystem::Windows, DeviceFamily::Nvidia310M,
1669 nsIGfxInfo::FEATURE_DIRECT2D, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1670 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1671 "FEATURE_FAILURE_BUG_1008759");
1673 /* Bug 1139503: DXVA crashes with ATI cards on windows 10. */
1674 APPEND_TO_DRIVER_BLOCKLIST2(
1675 OperatingSystem::Windows10, DeviceFamily::AtiAll,
1676 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1677 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1678 V(15, 200, 1006, 0), "FEATURE_FAILURE_BUG_1139503");
1680 /* Bug 1213107: D3D9 crashes with ATI cards on Windows 7. */
1681 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1682 OperatingSystem::Windows7, DeviceFamily::AtiAll,
1683 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1684 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1685 V(8, 861, 0, 0), V(8, 862, 6, 5000), "FEATURE_FAILURE_BUG_1213107_1",
1686 "Radeon driver > 8.862.6.5000");
1687 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1688 OperatingSystem::Windows7, DeviceFamily::AtiAll,
1689 nsIGfxInfo::FEATURE_WEBGL_ANGLE,
1690 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1691 V(8, 861, 0, 0), V(8, 862, 6, 5000), "FEATURE_FAILURE_BUG_1213107_2",
1692 "Radeon driver > 8.862.6.5000");
1694 /* This may not be needed at all */
1695 APPEND_TO_DRIVER_BLOCKLIST2(
1696 OperatingSystem::Windows7, DeviceFamily::Bug1155608,
1697 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1698 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1699 V(8, 15, 10, 2869), "FEATURE_FAILURE_INTEL_W7_HW_DECODING");
1701 /* Bug 1203199/1092166: DXVA startup crashes on some intel drivers. */
1702 APPEND_TO_DRIVER_BLOCKLIST(OperatingSystem::Windows, DeviceFamily::IntelAll,
1703 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1704 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1705 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 2849,
1706 "FEATURE_FAILURE_BUG_1203199_1",
1707 "Intel driver > X.X.X.2849");
1709 APPEND_TO_DRIVER_BLOCKLIST2(
1710 OperatingSystem::Windows, DeviceFamily::Nvidia8800GTS,
1711 nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
1712 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_EQUAL,
1713 V(9, 18, 13, 4052), "FEATURE_FAILURE_BUG_1203199_2");
1715 /* Bug 1137716: XXX this should really check for the matching Intel piece as
1716 * well. Unfortunately, we don't have the infrastructure to do that */
1717 APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2(
1718 OperatingSystem::Windows7, DeviceFamily::Bug1137716,
1719 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1720 DRIVER_BETWEEN_INCLUSIVE, V(8, 17, 12, 5730), V(8, 17, 12, 6901),
1721 "FEATURE_FAILURE_BUG_1137716", "Nvidia driver > 8.17.12.6901");
1723 /* Bug 1336710: Crash in rx::Blit9::initialize. */
1724 APPEND_TO_DRIVER_BLOCKLIST2(
1725 OperatingSystem::WindowsXP, DeviceFamily::IntelGMAX4500HD,
1726 nsIGfxInfo::FEATURE_WEBGL_ANGLE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1727 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1728 "FEATURE_FAILURE_BUG_1336710");
1730 APPEND_TO_DRIVER_BLOCKLIST2(
1731 OperatingSystem::WindowsXP, DeviceFamily::IntelHDGraphicsToSandyBridge,
1732 nsIGfxInfo::FEATURE_WEBGL_ANGLE, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1733 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1734 "FEATURE_FAILURE_BUG_1336710");
1736 /* Bug 1304360: Graphical artifacts with D3D9 on Windows 7. */
1737 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows7,
1738 DeviceFamily::IntelGMAX3000,
1739 nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
1740 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1741 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 1749,
1742 "FEATURE_FAILURE_INTEL_W7_D3D9_LAYERS");
1744 /* Bug 1717519/1717911: Crashes while drawing with swgl.
1745 * Reproducible but not investigated yet.*/
1746 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1747 OperatingSystem::Windows, DeviceFamily::IntelAll,
1748 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1749 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1750 V(8, 15, 10, 2125), V(8, 15, 10, 2141), "FEATURE_FAILURE_BUG_1717911",
1751 "Intel driver > 8.15.10.2141");
1753 #if defined(_M_X64)
1754 if (DetectBrokenAVX()) {
1755 APPEND_TO_DRIVER_BLOCKLIST2(
1756 OperatingSystem::Windows7, DeviceFamily::IntelAll,
1757 nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
1758 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1759 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1403353");
1761 #endif
1763 ////////////////////////////////////
1764 // WebGL
1766 // Older than 5-15-2016
1767 APPEND_TO_DRIVER_BLOCKLIST2(
1768 OperatingSystem::Windows, DeviceFamily::AtiAll,
1769 nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED,
1770 DRIVER_LESS_THAN, V(16, 200, 1010, 1002), "WEBGL_NATIVE_GL_OLD_AMD");
1772 // Older than 11-18-2015
1773 APPEND_TO_DRIVER_BLOCKLIST2(
1774 OperatingSystem::Windows, DeviceFamily::IntelAll,
1775 nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED,
1776 DRIVER_BUILD_ID_LESS_THAN, 4331, "WEBGL_NATIVE_GL_OLD_INTEL");
1778 // Older than 2-23-2016
1779 APPEND_TO_DRIVER_BLOCKLIST2(
1780 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1781 nsIGfxInfo::FEATURE_WEBGL_OPENGL, nsIGfxInfo::FEATURE_DISCOURAGED,
1782 DRIVER_LESS_THAN, V(10, 18, 13, 6200), "WEBGL_NATIVE_GL_OLD_NVIDIA");
1784 ////////////////////////////////////
1785 // FEATURE_DX_INTEROP2
1787 // All AMD.
1788 APPEND_TO_DRIVER_BLOCKLIST2(
1789 OperatingSystem::Windows, DeviceFamily::AtiAll,
1790 nsIGfxInfo::FEATURE_DX_INTEROP2,
1791 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
1792 GfxDriverInfo::allDriverVersions, "DX_INTEROP2_AMD_CRASH");
1794 ////////////////////////////////////
1795 // FEATURE_D3D11_KEYED_MUTEX
1797 // bug 1359416
1798 APPEND_TO_DRIVER_BLOCKLIST2(
1799 OperatingSystem::Windows, DeviceFamily::IntelHDGraphicsToSandyBridge,
1800 nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX,
1801 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN,
1802 GfxDriverInfo::allDriverVersions, "FEATURE_FAILURE_BUG_1359416");
1804 // Bug 1447141, for causing device creation crashes.
1805 APPEND_TO_DRIVER_BLOCKLIST2(
1806 OperatingSystem::Windows7, DeviceFamily::Bug1447141,
1807 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1808 DRIVER_EQUAL, V(15, 201, 2201, 0), "FEATURE_FAILURE_BUG_1447141_1");
1809 APPEND_TO_DRIVER_BLOCKLIST2(
1810 OperatingSystem::Windows7, DeviceFamily::Bug1447141,
1811 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1812 DRIVER_EQUAL, V(15, 201, 1701, 0), "FEATURE_FAILURE_BUG_1447141_1");
1814 // bug 1457758
1815 APPEND_TO_DRIVER_BLOCKLIST2(
1816 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1817 GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1818 DRIVER_EQUAL, V(24, 21, 13, 9731), "FEATURE_FAILURE_BUG_1457758");
1820 ////////////////////////////////////
1821 // FEATURE_DX_NV12
1823 // Bug 1437334
1824 APPEND_TO_DRIVER_BLOCKLIST2(
1825 OperatingSystem::Windows, DeviceFamily::IntelHDGraphicsToSandyBridge,
1826 nsIGfxInfo::FEATURE_DX_NV12, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1827 DRIVER_BUILD_ID_LESS_THAN_OR_EQUAL, 4459,
1828 "FEATURE_BLOCKED_DRIVER_VERSION");
1830 ////////////////////////////////////
1831 // FEATURE_DX_P010
1833 APPEND_TO_DRIVER_BLOCKLIST2(
1834 OperatingSystem::Windows, DeviceFamily::NvidiaAll,
1835 nsIGfxInfo::FEATURE_DX_P010, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1836 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1837 "FEATURE_UNQUALIFIED_P010_NVIDIA");
1839 ////////////////////////////////////
1840 // FEATURE_VIDEO_OVERLAY - ALLOWLIST
1841 #ifdef NIGHTLY_BUILD
1842 APPEND_TO_DRIVER_BLOCKLIST2(
1843 OperatingSystem::Windows, DeviceFamily::All,
1844 nsIGfxInfo::FEATURE_VIDEO_OVERLAY, nsIGfxInfo::FEATURE_ALLOW_ALWAYS,
1845 DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0), "FEATURE_ROLLOUT_ALL");
1846 #else
1847 APPEND_TO_DRIVER_BLOCKLIST2(
1848 OperatingSystem::Windows, DeviceFamily::IntelAll,
1849 nsIGfxInfo::FEATURE_VIDEO_OVERLAY, nsIGfxInfo::FEATURE_ALLOW_ALWAYS,
1850 DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0), "FEATURE_ROLLOUT_INTEL");
1851 #endif
1853 ////////////////////////////////////
1854 // FEATURE_WEBRENDER
1855 // Block 8.56.1.15/16
1856 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows, DeviceFamily::AtiAll,
1857 nsIGfxInfo::FEATURE_WEBRENDER,
1858 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
1859 DRIVER_LESS_THAN_OR_EQUAL, V(8, 56, 1, 16),
1860 "CRASHY_DRIVERS_BUG_1678808");
1862 // Shader compilation startup crashes with WebRender on Windows 7.
1863 APPEND_TO_DRIVER_BLOCKLIST_RANGE(
1864 OperatingSystem::Windows7, DeviceFamily::NvidiaAll,
1865 nsIGfxInfo::FEATURE_WEBRENDER,
1866 nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_BETWEEN_INCLUSIVE,
1867 V(8, 17, 12, 8019), V(8, 17, 12, 8026), "FEATURE_FAILURE_BUG_1709629",
1868 "nVidia driver > 280.26");
1870 APPEND_TO_DRIVER_BLOCKLIST2(
1871 OperatingSystem::Windows, DeviceFamily::IntelWebRenderBlocked,
1872 nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1873 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions,
1874 "INTEL_DEVICE_GEN5_OR_OLDER");
1876 APPEND_TO_DRIVER_BLOCKLIST2(
1877 OperatingSystem::Windows, DeviceFamily::NvidiaWebRenderBlocked,
1878 nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1879 DRIVER_LESS_THAN, GfxDriverInfo::allDriverVersions, "EARLY_NVIDIA");
1881 ////////////////////////////////////
1882 // FEATURE_WEBRENDER - ALLOWLIST
1883 APPEND_TO_DRIVER_BLOCKLIST2_EXT(
1884 OperatingSystem::Windows, ScreenSizeStatus::All, BatteryStatus::All,
1885 DesktopEnvironment::All, WindowProtocol::All, DriverVendor::All,
1886 DeviceFamily::AtiAll, nsIGfxInfo::FEATURE_WEBRENDER,
1887 nsIGfxInfo::FEATURE_ALLOW_ALWAYS, DRIVER_COMPARISON_IGNORED,
1888 V(0, 0, 0, 0), "FEATURE_ROLLOUT_AMD");
1890 APPEND_TO_DRIVER_BLOCKLIST2_EXT(
1891 OperatingSystem::Windows, ScreenSizeStatus::All, BatteryStatus::All,
1892 DesktopEnvironment::All, WindowProtocol::All, DriverVendor::All,
1893 DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_WEBRENDER,
1894 nsIGfxInfo::FEATURE_ALLOW_ALWAYS, DRIVER_COMPARISON_IGNORED,
1895 V(0, 0, 0, 0), "FEATURE_ROLLOUT_NV");
1897 APPEND_TO_DRIVER_BLOCKLIST2_EXT(
1898 OperatingSystem::Windows, ScreenSizeStatus::All, BatteryStatus::All,
1899 DesktopEnvironment::All, WindowProtocol::All, DriverVendor::All,
1900 DeviceFamily::IntelAll, nsIGfxInfo::FEATURE_WEBRENDER,
1901 nsIGfxInfo::FEATURE_ALLOW_ALWAYS, DRIVER_COMPARISON_IGNORED,
1902 V(0, 0, 0, 0), "FEATURE_ROLLOUT_INTEL");
1904 APPEND_TO_DRIVER_BLOCKLIST2_EXT(
1905 OperatingSystem::Windows, ScreenSizeStatus::All, BatteryStatus::All,
1906 DesktopEnvironment::All, WindowProtocol::All, DriverVendor::All,
1907 DeviceFamily::QualcommAll, nsIGfxInfo::FEATURE_WEBRENDER,
1908 nsIGfxInfo::FEATURE_ALLOW_ALWAYS, DRIVER_COMPARISON_IGNORED,
1909 V(0, 0, 0, 0), "FEATURE_ROLLOUT_QUALCOMM");
1911 ////////////////////////////////////
1912 // FEATURE_WEBRENDER_COMPOSITOR
1914 #ifndef EARLY_BETA_OR_EARLIER
1915 // See also bug 1616874
1916 APPEND_TO_DRIVER_BLOCKLIST2(
1917 OperatingSystem::Windows, DeviceFamily::IntelAll,
1918 nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR,
1919 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_EQUAL, V(24, 20, 100, 6293),
1920 "FEATURE_FAILURE_BUG_1602511");
1922 APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Windows, DeviceFamily::AtiAll,
1923 nsIGfxInfo::FEATURE_WEBRENDER_COMPOSITOR,
1924 nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
1925 DRIVER_LESS_THAN_OR_EQUAL, V(8, 17, 10, 1129),
1926 "FEATURE_FAILURE_CHROME_BUG_800950");
1927 #endif
1929 // WebRender is unable to use scissored clears in some cases
1930 APPEND_TO_DRIVER_BLOCKLIST2(
1931 OperatingSystem::Windows, DeviceFamily::IntelAll,
1932 nsIGfxInfo::FEATURE_WEBRENDER_SCISSORED_CACHE_CLEARS,
1933 nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
1934 V(0, 0, 0, 0), "FEATURE_FAILURE_BUG_1603515");
1936 return *sDriverInfo;
1939 nsresult GfxInfo::GetFeatureStatusImpl(
1940 int32_t aFeature, int32_t* aStatus, nsAString& aSuggestedDriverVersion,
1941 const nsTArray<GfxDriverInfo>& aDriverInfo, nsACString& aFailureId,
1942 OperatingSystem* aOS /* = nullptr */) {
1943 AssertNotWin32kLockdown();
1945 NS_ENSURE_ARG_POINTER(aStatus);
1946 aSuggestedDriverVersion.SetIsVoid(true);
1947 OperatingSystem os = WindowsVersionToOperatingSystem(mWindowsVersion);
1948 *aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
1949 if (aOS) *aOS = os;
1951 if (sShutdownOccurred) {
1952 return NS_OK;
1955 // Don't evaluate special cases if we're checking the downloaded blocklist.
1956 if (!aDriverInfo.Length()) {
1957 nsAutoString adapterVendorID;
1958 nsAutoString adapterDeviceID;
1959 nsAutoString adapterDriverVersionString;
1960 if (NS_FAILED(GetAdapterVendorID(adapterVendorID)) ||
1961 NS_FAILED(GetAdapterDeviceID(adapterDeviceID)) ||
1962 NS_FAILED(GetAdapterDriverVersion(adapterDriverVersionString))) {
1963 aFailureId = "FEATURE_FAILURE_GET_ADAPTER";
1964 *aStatus = FEATURE_BLOCKED_DEVICE;
1965 return NS_OK;
1968 if (OnlyAllowFeatureOnWhitelistedVendor(aFeature) &&
1969 !adapterVendorID.Equals(
1970 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Intel),
1971 nsCaseInsensitiveStringComparator) &&
1972 !adapterVendorID.Equals(
1973 GfxDriverInfo::GetDeviceVendor(DeviceVendor::NVIDIA),
1974 nsCaseInsensitiveStringComparator) &&
1975 !adapterVendorID.Equals(
1976 GfxDriverInfo::GetDeviceVendor(DeviceVendor::ATI),
1977 nsCaseInsensitiveStringComparator) &&
1978 !adapterVendorID.Equals(
1979 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Microsoft),
1980 nsCaseInsensitiveStringComparator) &&
1981 !adapterVendorID.Equals(
1982 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Parallels),
1983 nsCaseInsensitiveStringComparator) &&
1984 !adapterVendorID.Equals(
1985 GfxDriverInfo::GetDeviceVendor(DeviceVendor::Qualcomm),
1986 nsCaseInsensitiveStringComparator) &&
1987 // FIXME - these special hex values are currently used in xpcshell tests
1988 // introduced by bug 625160 patch 8/8. Maybe these tests need to be
1989 // adjusted now that we're only whitelisting intel/ati/nvidia.
1990 !adapterVendorID.LowerCaseEqualsLiteral("0xabcd") &&
1991 !adapterVendorID.LowerCaseEqualsLiteral("0xdcba") &&
1992 !adapterVendorID.LowerCaseEqualsLiteral("0xabab") &&
1993 !adapterVendorID.LowerCaseEqualsLiteral("0xdcdc")) {
1994 if (adapterVendorID.Equals(
1995 GfxDriverInfo::GetDeviceVendor(DeviceVendor::MicrosoftHyperV),
1996 nsCaseInsensitiveStringComparator) ||
1997 adapterVendorID.Equals(
1998 GfxDriverInfo::GetDeviceVendor(DeviceVendor::VMWare),
1999 nsCaseInsensitiveStringComparator) ||
2000 adapterVendorID.Equals(
2001 GfxDriverInfo::GetDeviceVendor(DeviceVendor::VirtualBox),
2002 nsCaseInsensitiveStringComparator)) {
2003 aFailureId = "FEATURE_FAILURE_VM_VENDOR";
2004 } else if (adapterVendorID.Equals(GfxDriverInfo::GetDeviceVendor(
2005 DeviceVendor::MicrosoftBasic),
2006 nsCaseInsensitiveStringComparator)) {
2007 aFailureId = "FEATURE_FAILURE_MICROSOFT_BASIC_VENDOR";
2008 } else if (adapterVendorID.IsEmpty()) {
2009 aFailureId = "FEATURE_FAILURE_EMPTY_DEVICE_VENDOR";
2010 } else {
2011 aFailureId = "FEATURE_FAILURE_UNKNOWN_DEVICE_VENDOR";
2013 *aStatus = FEATURE_BLOCKED_DEVICE;
2014 return NS_OK;
2017 uint64_t driverVersion;
2018 if (!ParseDriverVersion(adapterDriverVersionString, &driverVersion)) {
2019 aFailureId = "FEATURE_FAILURE_PARSE_DRIVER";
2020 *aStatus = FEATURE_BLOCKED_DRIVER_VERSION;
2021 return NS_OK;
2024 if (mHasDriverVersionMismatch) {
2025 *aStatus = nsIGfxInfo::FEATURE_BLOCKED_MISMATCHED_VERSION;
2026 return NS_OK;
2030 return GfxInfoBase::GetFeatureStatusImpl(
2031 aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aFailureId, &os);
2034 nsresult GfxInfo::FindMonitors(JSContext* aCx, JS::HandleObject aOutArray) {
2035 AssertNotWin32kLockdown();
2037 int deviceCount = 0;
2038 for (auto displayInfo : mDisplayInfo) {
2039 JS::Rooted<JSObject*> obj(aCx, JS_NewPlainObject(aCx));
2041 JS::Rooted<JS::Value> screenWidth(aCx,
2042 JS::Int32Value(displayInfo.mScreenWidth));
2043 JS_SetProperty(aCx, obj, "screenWidth", screenWidth);
2045 JS::Rooted<JS::Value> screenHeight(
2046 aCx, JS::Int32Value(displayInfo.mScreenHeight));
2047 JS_SetProperty(aCx, obj, "screenHeight", screenHeight);
2049 JS::Rooted<JS::Value> refreshRate(aCx,
2050 JS::Int32Value(displayInfo.mRefreshRate));
2051 JS_SetProperty(aCx, obj, "refreshRate", refreshRate);
2053 JS::Rooted<JS::Value> pseudoDisplay(
2054 aCx, JS::BooleanValue(displayInfo.mIsPseudoDisplay));
2055 JS_SetProperty(aCx, obj, "pseudoDisplay", pseudoDisplay);
2057 JS::Rooted<JS::Value> element(aCx, JS::ObjectValue(*obj));
2058 JS_SetElement(aCx, aOutArray, deviceCount++, element);
2060 return NS_OK;
2063 void GfxInfo::DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> aObj) {
2064 // Add the platform neutral features
2065 GfxInfoBase::DescribeFeatures(aCx, aObj);
2067 JS::Rooted<JSObject*> obj(aCx);
2069 gfx::FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
2070 if (!InitFeatureObject(aCx, aObj, "d3d11", d3d11, &obj)) {
2071 return;
2073 if (d3d11.GetValue() == gfx::FeatureStatus::Available) {
2074 DeviceManagerDx* dm = DeviceManagerDx::Get();
2075 JS::Rooted<JS::Value> val(aCx,
2076 JS::Int32Value(dm->GetCompositorFeatureLevel()));
2077 JS_SetProperty(aCx, obj, "version", val);
2079 val = JS::BooleanValue(dm->IsWARP());
2080 JS_SetProperty(aCx, obj, "warp", val);
2082 val = JS::BooleanValue(dm->TextureSharingWorks());
2083 JS_SetProperty(aCx, obj, "textureSharing", val);
2085 bool blocklisted = false;
2086 if (nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service()) {
2087 int32_t status;
2088 nsCString discardFailureId;
2089 if (SUCCEEDED(
2090 gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
2091 discardFailureId, &status))) {
2092 blocklisted = (status != nsIGfxInfo::FEATURE_STATUS_OK);
2096 val = JS::BooleanValue(blocklisted);
2097 JS_SetProperty(aCx, obj, "blocklisted", val);
2100 gfx::FeatureState& d2d = gfxConfig::GetFeature(Feature::DIRECT2D);
2101 if (!InitFeatureObject(aCx, aObj, "d2d", d2d, &obj)) {
2102 return;
2105 const char* version = "1.1";
2106 JS::Rooted<JSString*> str(aCx, JS_NewStringCopyZ(aCx, version));
2107 JS::Rooted<JS::Value> val(aCx, JS::StringValue(str));
2108 JS_SetProperty(aCx, obj, "version", val);
2112 #ifdef DEBUG
2114 // Implement nsIGfxInfoDebug
2116 NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString& aVendorID) {
2117 mAdapterVendorID[mActiveGPUIndex] = aVendorID;
2118 return NS_OK;
2121 NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString& aDeviceID) {
2122 mAdapterDeviceID[mActiveGPUIndex] = aDeviceID;
2123 return NS_OK;
2126 NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString& aDriverVersion) {
2127 mDriverVersion[mActiveGPUIndex] = aDriverVersion;
2128 return NS_OK;
2131 NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion) {
2132 mWindowsVersion = aVersion;
2133 return NS_OK;
2136 NS_IMETHODIMP GfxInfo::FireTestProcess() { return NS_OK; }
2138 #endif