Bug 1717857 - Detect more multi-GPU cases via PCI in GfxInfo,r=aosmond
authorRobert Mader <robert.mader@posteo.de>
Wed, 23 Jun 2021 21:25:23 +0000
changeset 584212 240cbdff5521cadcc818770a074db3c67a8324fe
parent 584211 3b2212d68b0849890b35d676bfb2cdba1e3df2ad
child 584213 9d21dce2fa37d04dfaa172ba7cd353980b4b410b
push id145522
push userrobert.mader@posteo.de
push dateWed, 23 Jun 2021 21:27:46 +0000
treeherderautoland@240cbdff5521 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1717857
milestone91.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1717857 - Detect more multi-GPU cases via PCI in GfxInfo,r=aosmond This improves handling of: - multiple GPUs of the same vendor - multiple GPUs with the same device ID - using mesa software drivers despite a GPU being detected via PCI Differential Revision: https://phabricator.services.mozilla.com/D118604
widget/gtk/GfxInfo.cpp
--- a/widget/gtk/GfxInfo.cpp
+++ b/widget/gtk/GfxInfo.cpp
@@ -308,16 +308,24 @@ void GfxInfo::GetData() {
 
     if (!mesaVendor.IsEmpty()) {
       mVendorId = mesaVendor;
     }
 
     if (!mesaDevice.IsEmpty()) {
       mDeviceId = mesaDevice;
     }
+
+    if (!mIsAccelerated && mVendorId.IsEmpty()) {
+      mVendorId.Assign(glVendor.get());
+    }
+
+    if (!mIsAccelerated && mDeviceId.IsEmpty()) {
+      mDeviceId.Assign(glRenderer.get());
+    }
   } else if (glVendor.EqualsLiteral("NVIDIA Corporation")) {
     CopyUTF16toUTF8(GfxDriverInfo::GetDeviceVendor(DeviceVendor::NVIDIA),
                     mVendorId);
     mDriverVendor.AssignLiteral("nvidia/unknown");
     // TODO: Use NV-CONTROL X11 extension to query Device ID and VRAM.
   } else if (glVendor.EqualsLiteral("ATI Technologies Inc.")) {
     CopyUTF16toUTF8(GfxDriverInfo::GetDeviceVendor(DeviceVendor::ATI),
                     mVendorId);
@@ -389,34 +397,40 @@ void GfxInfo::GetData() {
         CopyUTF16toUTF8(GfxDriverInfo::GetDeviceVendor(DeviceVendor::Qualcomm),
                         mVendorId);
       }
     }
   }
 
   // If we still don't have a vendor ID, we can try the PCI vendor list.
   if (mVendorId.IsEmpty()) {
-    if (pciVendors.Length() == 1) {
-      mVendorId = pciVendors[0];
-    } else if (pciVendors.IsEmpty()) {
+    if (pciVendors.IsEmpty()) {
       gfxCriticalNote << "No GPUs detected via PCI";
     } else {
-      gfxCriticalNote
-          << "More than 1 GPU detected via PCI, cannot deduce vendor";
+      for (size_t i = 0; i < pciVendors.Length(); ++i) {
+        if (mVendorId.IsEmpty()) {
+          mVendorId = pciVendors[i];
+        } else if (mVendorId != pciVendors[i]) {
+          gfxCriticalNote << "More than 1 GPU vendor detected via PCI, cannot "
+                             "deduce vendor";
+          mVendorId.Truncate();
+          break;
+        }
+      }
     }
   }
 
   // If we know the vendor ID, but didn't get a device ID, we can guess from the
   // PCI device list.
   if (mDeviceId.IsEmpty() && !mVendorId.IsEmpty()) {
     for (size_t i = 0; i < pciLen; ++i) {
       if (mVendorId.Equals(pciVendors[i])) {
         if (mDeviceId.IsEmpty()) {
           mDeviceId = pciDevices[i];
-        } else {
+        } else if (mDeviceId != pciDevices[i]) {
           gfxCriticalNote << "More than 1 GPU from same vendor detected via "
                              "PCI, cannot deduce device";
           mDeviceId.Truncate();
           break;
         }
       }
     }
   }