summaryrefslogtreecommitdiffstats
path: root/content/gpu/gpu_info_collector_linux.cc
diff options
context:
space:
mode:
authorzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-08 00:47:22 +0000
committerzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-08 00:47:22 +0000
commitc1e7064d462adadf1e18e1584d38f5cbce693b7c (patch)
tree88d614f78815c58ccf084cb482bd8a582b56f12c /content/gpu/gpu_info_collector_linux.cc
parent6c2fe63cfe26053dfd166a9291333e6236c25589 (diff)
downloadchromium_src-c1e7064d462adadf1e18e1584d38f5cbce693b7c.zip
chromium_src-c1e7064d462adadf1e18e1584d38f5cbce693b7c.tar.gz
chromium_src-c1e7064d462adadf1e18e1584d38f5cbce693b7c.tar.bz2
Collect driver vendor in linux through glXGetClientString.
This helps in the situation where libpci is unavailable: at least we can identify a few vendors. Unfortunately we can not run this in preliminary GPU info collection because gl binding hasn't been initialized yet. BUG=78526 TEST=bots green Review URL: http://codereview.chromium.org/6803024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/gpu/gpu_info_collector_linux.cc')
-rw-r--r--content/gpu/gpu_info_collector_linux.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/content/gpu/gpu_info_collector_linux.cc b/content/gpu/gpu_info_collector_linux.cc
index 64087d2..c8115bf3 100644
--- a/content/gpu/gpu_info_collector_linux.cc
+++ b/content/gpu/gpu_info_collector_linux.cc
@@ -161,6 +161,30 @@ std::string CollectDriverVersionATI() {
return "";
}
+// Use glXGetClientString to get driver vendor.
+// Return "" on failing.
+std::string CollectDriverVendorGlx() {
+ // TODO(zmo): handle the EGL/GLES2 case.
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
+ return "";
+ Display* display = XOpenDisplay(NULL);
+ if (display == NULL)
+ return "";
+ std::string vendor = glXGetClientString(display, GLX_VENDOR);
+ XCloseDisplay(display);
+ return vendor;
+}
+
+// Return 0 on unrecognized vendor.
+uint32 VendorStringToID(const std::string& vendor_string) {
+ if (StartsWithASCII(vendor_string, "NVIDIA", true))
+ return 0x10de;
+ if (StartsWithASCII(vendor_string, "ATI", true))
+ return 0x1002;
+ // TODO(zmo): find a way to identify Intel cards.
+ return 0;
+}
+
} // namespace anonymous
namespace gpu_info_collector {
@@ -197,6 +221,14 @@ bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) {
bool CollectVideoCardInfo(GPUInfo* gpu_info) {
DCHECK(gpu_info);
+ std::string driver_vendor = CollectDriverVendorGlx();
+ if (!driver_vendor.empty()) {
+ gpu_info->driver_vendor = driver_vendor;
+ uint32 vendor_id = VendorStringToID(driver_vendor);
+ if (vendor_id != 0)
+ gpu_info->vendor_id = vendor_id;
+ }
+
if (IsPciSupported() == false) {
VLOG(1) << "PCI bus scanning is not supported";
return false;
@@ -222,7 +254,8 @@ bool CollectVideoCardInfo(GPUInfo* gpu_info) {
(interface->pci_fill_info)(device, 33); // Fill the IDs and class fields.
// TODO(zmo): there might be other classes that qualify as display devices.
if (device->device_class == 0x0300) { // Device class is DISPLAY_VGA.
- gpu_list.push_back(device);
+ if (gpu_info->vendor_id == 0 || gpu_info->vendor_id == device->vendor_id)
+ gpu_list.push_back(device);
}
}
if (gpu_list.size() == 1) {