Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: content/gpu/gpu_info_collector_linux.cc

Issue 6803024: Collect driver vendor in linux through glXGetClientString. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/gpu/gpu_info_collector_linux.cc
===================================================================
--- content/gpu/gpu_info_collector_linux.cc (revision 80377)
+++ content/gpu/gpu_info_collector_linux.cc (working copy)
@@ -161,6 +161,29 @@
return "";
}
+// Use glXGetClientString to get driver vendor.
+// Return "" on failing.
+std::string CollectDriverVendorGlx() {
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationNone)
+ return "";
+ Display* display = XOpenDisplay(NULL);
+ if (display == NULL)
+ return "";
+ const char* vendor = glXGetClientString(display, GLX_VENDOR);
piman 2011/04/06 22:10:00 I suspect you'll want to copy that into the std::s
zmo 2011/04/06 23:14:34 Got it. Will fix.
piman 2011/04/06 23:18:01 Ah, ok, that should be fine then
+ XCloseDisplay(display);
+ return std::string(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.
piman 2011/04/06 22:10:00 The problem is that the client vendor string for I
zmo 2011/04/06 23:14:34 This is trying to collect vendor without creating
+ return 0;
+}
+
} // namespace anonymous
namespace gpu_info_collector {
@@ -197,6 +220,14 @@
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 +253,8 @@
(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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698