diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 01:08:17 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 01:08:17 +0000 |
commit | 9615798e2784ff141856e7611582f9a674ce4e3d (patch) | |
tree | 6fd1705a11fe5437331bd514017afcf9cf4583aa /content | |
parent | 51d50f093404db2e755e738f2bd90b8cc96f617f (diff) | |
download | chromium_src-9615798e2784ff141856e7611582f9a674ce4e3d.zip chromium_src-9615798e2784ff141856e7611582f9a674ce4e3d.tar.gz chromium_src-9615798e2784ff141856e7611582f9a674ce4e3d.tar.bz2 |
Use nv contrl x extension to query nvidia driver version.
So we can do it in browser process, not wait until gpu process launches and a gl context is created.
This is tested on my linux box with NVIDIA driver.
We need to put more code to tell chrome (Linux/NVIDIA) that we have enough information for blacklisting, so at GPU launch time we don't need to collect GPUInfo.
Will do it in a followup CL.
BUG=122912
TEST=tree green
TBR=jam
Review URL: https://chromiumcodereview.appspot.com/10536232
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/content_gpu.gypi | 5 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector_linux.cc | 55 |
2 files changed, 54 insertions, 6 deletions
diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi index b98d991..6d9d587 100644 --- a/content/content_gpu.gypi +++ b/content/content_gpu.gypi @@ -90,5 +90,10 @@ }, ], }], + ['OS=="linux"', { + 'dependencies': [ + '../third_party/libXNVCtrl/libXNVCtrl.gyp:libXNVCtrl', + ], + }], ], } diff --git a/content/gpu/gpu_info_collector_linux.cc b/content/gpu/gpu_info_collector_linux.cc index 0c53478..2916414 100644 --- a/content/gpu/gpu_info_collector_linux.cc +++ b/content/gpu/gpu_info_collector_linux.cc @@ -5,6 +5,7 @@ #include "content/gpu/gpu_info_collector.h" #include <dlfcn.h> +#include <X11/Xlib.h> #include <vector> #include "base/command_line.h" @@ -12,10 +13,14 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop.h" #include "base/string_piece.h" #include "base/string_split.h" #include "base/string_tokenizer.h" #include "base/string_util.h" +#include "content/public/browser/browser_thread.h" +#include "third_party/libXNVCtrl/NVCtrl.h" +#include "third_party/libXNVCtrl/NVCtrlLib.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" @@ -165,6 +170,33 @@ std::string CollectDriverVersionATI() { return ""; } +// Use NVCtrl extention to query NV driver version. +std::string CollectDriverVersionNVidia() { + Display* display = base::MessagePumpForUI::GetDefaultXDisplay(); + if (!display) { + LOG(ERROR) << "XOpenDisplay failed."; + return ""; + } + int event_base = 0, error_base = 0; + if (!XNVCTRLQueryExtension(display, &event_base, &error_base)) { + LOG(INFO) << "NVCtrl extension does not exits."; + return ""; + } + int screen_count = ScreenCount(display); + for (int screen = 0; screen < screen_count; ++screen) { + char* buffer = NULL; + if (XNVCTRLIsNvScreen(display, screen) && + XNVCTRLQueryStringAttribute(display, screen, 0, + NV_CTRL_STRING_NVIDIA_DRIVER_VERSION, + &buffer)) { + std::string driver_version(buffer); + XFree(buffer); + return driver_version; + } + } + return ""; +} + const uint32 kVendorIDIntel = 0x8086; const uint32 kVendorIDNVidia = 0x10de; const uint32 kVendorIDAMD = 0x1002; @@ -196,15 +228,26 @@ bool CollectGraphicsInfo(content::GPUInfo* gpu_info) { bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) { DCHECK(gpu_info); + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); bool rt = CollectVideoCardInfo(gpu_info); - if (gpu_info->gpu.vendor_id == kVendorIDAMD) { - std::string ati_driver_version = CollectDriverVersionATI(); - if (!ati_driver_version.empty()) { - gpu_info->driver_vendor = "ATI / AMD"; - gpu_info->driver_version = ati_driver_version; - } + std::string driver_version; + switch (gpu_info->gpu.vendor_id) { + case kVendorIDAMD: + driver_version = CollectDriverVersionATI(); + if (!driver_version.empty()) { + gpu_info->driver_vendor = "ATI / AMD"; + gpu_info->driver_version = driver_version; + } + break; + case kVendorIDNVidia: + driver_version = CollectDriverVersionNVidia(); + if (!driver_version.empty()) { + gpu_info->driver_vendor = "NVIDIA"; + gpu_info->driver_version = driver_version; + } + break; } return rt; |