From 482c419e4405959a950b2471441b9467097e6ca9 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Wed, 23 Jun 2021 21:25:23 +0000 Subject: [PATCH] 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 | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/widget/gtk/GfxInfo.cpp b/widget/gtk/GfxInfo.cpp index 69d9e8d97a6c..e68344adfd7d 100644 --- a/widget/gtk/GfxInfo.cpp +++ b/widget/gtk/GfxInfo.cpp @@ -313,6 +313,14 @@ void GfxInfo::GetData() { 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); @@ -394,13 +402,19 @@ void GfxInfo::GetData() { // 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; + } + } } } @@ -411,7 +425,7 @@ void GfxInfo::GetData() { 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();