diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 00:27:53 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-21 00:27:53 +0000 |
commit | 7004d7ebec6cd4de175d8f894c2a0c58fb6f41c8 (patch) | |
tree | 5efa0e86cd64c61420909af28d43211d609ebf0f /chrome/common | |
parent | c7a827e9d91099bae12379f92467e29a8d7ffaab (diff) | |
download | chromium_src-7004d7ebec6cd4de175d8f894c2a0c58fb6f41c8.zip chromium_src-7004d7ebec6cd4de175d8f894c2a0c58fb6f41c8.tar.gz chromium_src-7004d7ebec6cd4de175d8f894c2a0c58fb6f41c8.tar.bz2 |
Refactor and improve gpu_info_collector: collect information on linux;
collect extra information (driver_vendor, gl_renderer, etc.) on Mac/linux.
Note that this CL takes some code from rlp's long outstandingCL (with her
permission).
BUG=49579
TEST=unittest
Review URL: http://codereview.chromium.org/6346007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72055 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/child_process_logging_mac.mm | 2 | ||||
-rw-r--r-- | chrome/common/child_process_logging_win.cc | 2 | ||||
-rw-r--r-- | chrome/common/gpu_info.cc | 64 | ||||
-rw-r--r-- | chrome/common/gpu_info.h | 62 | ||||
-rw-r--r-- | chrome/common/gpu_info_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/common/gpu_messages.cc | 37 | ||||
-rw-r--r-- | chrome/common/gpu_messages_unittest.cc | 22 |
7 files changed, 152 insertions, 47 deletions
diff --git a/chrome/common/child_process_logging_mac.mm b/chrome/common/child_process_logging_mac.mm index ca12d1c..e14aa36 100644 --- a/chrome/common/child_process_logging_mac.mm +++ b/chrome/common/child_process_logging_mac.mm @@ -151,7 +151,7 @@ void SetGpuInfoImpl(const GPUInfo& gpu_info, base::UintToString(gpu_info.device_id()), set_key_func); SetGpuKeyValue(kGPUDriverVersionParamName, - WideToUTF8(gpu_info.driver_version()), + gpu_info.driver_version(), set_key_func); SetGpuKeyValue(kGPUPixelShaderVersionParamName, base::UintToString(gpu_info.pixel_shader_version()), diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc index 1be4921..0753f44 100644 --- a/chrome/common/child_process_logging_win.cc +++ b/chrome/common/child_process_logging_win.cc @@ -139,7 +139,7 @@ void SetGpuInfo(const GPUInfo& gpu_info) { (set_gpu_info)( base::UintToString16(gpu_info.vendor_id()).c_str(), base::UintToString16(gpu_info.device_id()).c_str(), - gpu_info.driver_version().c_str(), + UTF8ToUTF16(gpu_info.driver_version()).c_str(), base::UintToString16(gpu_info.pixel_shader_version()).c_str(), base::UintToString16(gpu_info.vertex_shader_version()).c_str()); } diff --git a/chrome/common/gpu_info.cc b/chrome/common/gpu_info.cc index 744fdfc..a89bf82 100644 --- a/chrome/common/gpu_info.cc +++ b/chrome/common/gpu_info.cc @@ -8,10 +8,14 @@ GPUInfo::GPUInfo() : progress_(kUninitialized), vendor_id_(0), device_id_(0), - driver_version_(L""), + driver_vendor_(""), + driver_version_(""), pixel_shader_version_(0), vertex_shader_version_(0), gl_version_(0), + gl_version_string_(""), + gl_vendor_(""), + gl_renderer_(""), can_lose_context_(false) { } @@ -31,7 +35,11 @@ uint32 GPUInfo::device_id() const { return device_id_; } -std::wstring GPUInfo::driver_version() const { +std::string GPUInfo::driver_vendor() const { + return driver_vendor_; +} + +std::string GPUInfo::driver_version() const { return driver_version_; } @@ -47,34 +55,66 @@ uint32 GPUInfo::gl_version() const { return gl_version_; } +std::string GPUInfo::gl_version_string() const { + return gl_version_string_; +} + +std::string GPUInfo::gl_vendor() const { + return gl_vendor_; +} + +std::string GPUInfo::gl_renderer() const { + return gl_renderer_; +} bool GPUInfo::can_lose_context() const { return can_lose_context_; } +void GPUInfo::SetProgress(Progress progress) { + progress_ = progress; +} + void GPUInfo::SetInitializationTime( const base::TimeDelta& initialization_time) { initialization_time_ = initialization_time; } - -void GPUInfo::SetGraphicsInfo(uint32 vendor_id, uint32 device_id, - const std::wstring& driver_version, - uint32 pixel_shader_version, - uint32 vertex_shader_version, - uint32 gl_version, - bool can_lose_context) { +void GPUInfo::SetVideoCardInfo(uint32 vendor_id, uint32 device_id) { vendor_id_ = vendor_id; device_id_ = device_id; +} + +void GPUInfo::SetDriverInfo(const std::string& driver_vendor, + const std::string& driver_version) { + driver_vendor_ = driver_vendor; driver_version_ = driver_version; +} + +void GPUInfo::SetShaderVersion(uint32 pixel_shader_version, + uint32 vertex_shader_version) { pixel_shader_version_ = pixel_shader_version; vertex_shader_version_ = vertex_shader_version; +} + +void GPUInfo::SetGLVersion(uint32 gl_version) { gl_version_ = gl_version; - can_lose_context_ = can_lose_context; } -void GPUInfo::SetProgress(Progress progress) { - progress_ = progress; +void GPUInfo::SetGLVersionString(const std::string& gl_version_string) { + gl_version_string_ = gl_version_string; +} + +void GPUInfo::SetGLVendor(const std::string& gl_vendor) { + gl_vendor_ = gl_vendor; +} + +void GPUInfo::SetGLRenderer(const std::string& gl_renderer) { + gl_renderer_ = gl_renderer; +} + +void GPUInfo::SetCanLoseContext(bool can_lose_context) { + can_lose_context_ = can_lose_context; } #if defined(OS_WIN) diff --git a/chrome/common/gpu_info.h b/chrome/common/gpu_info.h index b8f7cc6..206ade1 100644 --- a/chrome/common/gpu_info.h +++ b/chrome/common/gpu_info.h @@ -12,6 +12,7 @@ #include <string> #include "base/basictypes.h" +#include "base/scoped_ptr.h" #include "base/time.h" #include "build/build_config.h" #include "chrome/common/dx_diag_node.h" @@ -42,27 +43,42 @@ class GPUInfo { // Device ids are unique to vendor, not to one another. uint32 device_id() const; + // Return the vendor of the graphics driver currently installed. + std::string driver_vendor() const; + // Return the version of the graphics driver currently installed. - // This will typically be something - std::wstring driver_version() const; + std::string driver_version() const; // Return the version of the pixel/fragment shader used by the gpu. - // This will typically be a number less than 10 so storing as a float - // should be okay. + // Major version in the second lowest 8 bits, minor in the lowest 8 bits, + // eg version 2.5 would be 0x00000205. uint32 pixel_shader_version() const; // Return the version of the vertex shader used by the gpu. - // This will typically be a number less than 10 so storing as a float - // should be okay. + // Major version in the second lowest 8 bits, minor in the lowest 8 bits, + // eg version 2.5 would be 0x00000205. uint32 vertex_shader_version() const; // Return the version of OpenGL we are using. - // Major version in the high word, minor in the low word, eg version 2.5 - // would be 0x00020005. + // Major version in the second lowest 8 bits, minor in the lowest 8 bits, + // eg version 2.5 would be 0x00000205. // Returns 0 if we're not using OpenGL, say because we're going through // D3D instead. + // TODO(zmo): should be able to tell if it's GL or GLES. uint32 gl_version() const; + // Return the GL_VERSION string. + // Return "" if we are not using OpenGL. + std::string gl_version_string() const; + + // Return the GL_VENDOR string. + // Return "" if we are not using OpenGL. + std::string gl_vendor() const; + + // Return the GL_RENDERER string. + // Return "" if we are not using OpenGL. + std::string gl_renderer() const; + // Return the device semantics, i.e. whether the Vista and Windows 7 specific // semantics are available. bool can_lose_context() const; @@ -71,13 +87,23 @@ class GPUInfo { void SetInitializationTime(const base::TimeDelta& initialization_time); - // Populate variables with passed in values - void SetGraphicsInfo(uint32 vendor_id, uint32 device_id, - const std::wstring& driver_version, - uint32 pixel_shader_version, - uint32 vertex_shader_version, - uint32 gl_version, - bool can_lose_context); + void SetVideoCardInfo(uint32 vendor_id, uint32 device_id); + + void SetDriverInfo(const std::string& driver_vendor, + const std::string& driver_version); + + void SetShaderVersion(uint32 pixel_shader_version, + uint32 vertex_shader_version); + + void SetGLVersion(uint32 gl_version); + + void SetGLVersionString(const std::string& gl_vendor_string); + + void SetGLVendor(const std::string& gl_vendor); + + void SetGLRenderer(const std::string& gl_renderer); + + void SetCanLoseContext(bool can_lose_context); #if defined(OS_WIN) // The information returned by the DirectX Diagnostics Tool. @@ -91,10 +117,14 @@ class GPUInfo { base::TimeDelta initialization_time_; uint32 vendor_id_; uint32 device_id_; - std::wstring driver_version_; + std::string driver_vendor_; + std::string driver_version_; uint32 pixel_shader_version_; uint32 vertex_shader_version_; uint32 gl_version_; + std::string gl_version_string_; + std::string gl_vendor_; + std::string gl_renderer_; bool can_lose_context_; #if defined(OS_WIN) diff --git a/chrome/common/gpu_info_unittest.cc b/chrome/common/gpu_info_unittest.cc index a209aa9..2dc2de7 100644 --- a/chrome/common/gpu_info_unittest.cc +++ b/chrome/common/gpu_info_unittest.cc @@ -8,9 +8,17 @@ // Test that an empty GPUInfo has valid members TEST(GPUInfoBasicTest, EmptyGPUInfo) { GPUInfo gpu_info; + EXPECT_EQ(gpu_info.progress(), GPUInfo::kUninitialized); + EXPECT_EQ(gpu_info.initialization_time().ToInternalValue(), 0); EXPECT_EQ(gpu_info.vendor_id(), 0u); EXPECT_EQ(gpu_info.device_id(), 0u); - EXPECT_EQ(gpu_info.driver_version(), L""); + EXPECT_EQ(gpu_info.driver_vendor(), ""); + EXPECT_EQ(gpu_info.driver_version(), ""); EXPECT_EQ(gpu_info.pixel_shader_version(), 0u); EXPECT_EQ(gpu_info.vertex_shader_version(), 0u); + EXPECT_EQ(gpu_info.gl_version(), 0u); + EXPECT_EQ(gpu_info.gl_version_string(), ""); + EXPECT_EQ(gpu_info.gl_vendor(), ""); + EXPECT_EQ(gpu_info.gl_renderer(), ""); + EXPECT_EQ(gpu_info.can_lose_context(), false); } diff --git a/chrome/common/gpu_messages.cc b/chrome/common/gpu_messages.cc index 9d5c32e..6114cd5 100644 --- a/chrome/common/gpu_messages.cc +++ b/chrome/common/gpu_messages.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/string_piece.h" +#include "base/sys_string_conversions.h" #include "chrome/common/gpu_create_command_buffer_config.h" #include "chrome/common/gpu_info.h" #include "chrome/common/dx_diag_node.h" @@ -130,10 +132,14 @@ void ParamTraits<GPUInfo> ::Write(Message* m, const param_type& p) { WriteParam(m, p.initialization_time()); WriteParam(m, p.vendor_id()); WriteParam(m, p.device_id()); + WriteParam(m, p.driver_vendor()); WriteParam(m, p.driver_version()); WriteParam(m, p.pixel_shader_version()); WriteParam(m, p.vertex_shader_version()); WriteParam(m, p.gl_version()); + WriteParam(m, p.gl_version_string()); + WriteParam(m, p.gl_vendor()); + WriteParam(m, p.gl_renderer()); WriteParam(m, p.can_lose_context()); #if defined(OS_WIN) @@ -146,32 +152,41 @@ bool ParamTraits<GPUInfo> ::Read(const Message* m, void** iter, param_type* p) { base::TimeDelta initialization_time; uint32 vendor_id; uint32 device_id; - std::wstring driver_version; + std::string driver_vendor; + std::string driver_version; uint32 pixel_shader_version; uint32 vertex_shader_version; uint32 gl_version; + std::string gl_version_string; + std::string gl_vendor; + std::string gl_renderer; bool can_lose_context; bool ret = ReadParam(m, iter, &progress); ret = ret && ReadParam(m, iter, &initialization_time); ret = ret && ReadParam(m, iter, &vendor_id); ret = ret && ReadParam(m, iter, &device_id); + ret = ret && ReadParam(m, iter, &driver_vendor); ret = ret && ReadParam(m, iter, &driver_version); ret = ret && ReadParam(m, iter, &pixel_shader_version); ret = ret && ReadParam(m, iter, &vertex_shader_version); ret = ret && ReadParam(m, iter, &gl_version); + ret = ret && ReadParam(m, iter, &gl_version_string); + ret = ret && ReadParam(m, iter, &gl_vendor); + ret = ret && ReadParam(m, iter, &gl_renderer); ret = ret && ReadParam(m, iter, &can_lose_context); p->SetProgress(static_cast<GPUInfo::Progress>(progress)); if (!ret) return false; p->SetInitializationTime(initialization_time); - p->SetGraphicsInfo(vendor_id, - device_id, - driver_version, - pixel_shader_version, - vertex_shader_version, - gl_version, - can_lose_context); + p->SetVideoCardInfo(vendor_id, device_id); + p->SetDriverInfo(driver_vendor, driver_version); + p->SetShaderVersion(pixel_shader_version, vertex_shader_version); + p->SetGLVersion(gl_version); + p->SetGLVersionString(gl_version_string); + p->SetGLVendor(gl_vendor); + p->SetGLRenderer(gl_renderer); + p->SetCanLoseContext(can_lose_context); #if defined(OS_WIN) DxDiagNode dx_diagnostics; @@ -185,13 +200,17 @@ bool ParamTraits<GPUInfo> ::Read(const Message* m, void** iter, param_type* p) { } void ParamTraits<GPUInfo> ::Log(const param_type& p, std::string* l) { - l->append(base::StringPrintf("<GPUInfo> %d %d %x %x %ls %d", + l->append(base::StringPrintf("<GPUInfo> %d %d %x %x %s %s %x %x %x %d", p.progress(), static_cast<int32>( p.initialization_time().InMilliseconds()), p.vendor_id(), p.device_id(), + p.driver_vendor().c_str(), p.driver_version().c_str(), + p.pixel_shader_version(), + p.vertex_shader_version(), + p.gl_version(), p.can_lose_context())); } diff --git a/chrome/common/gpu_messages_unittest.cc b/chrome/common/gpu_messages_unittest.cc index 904d9da..9be8162 100644 --- a/chrome/common/gpu_messages_unittest.cc +++ b/chrome/common/gpu_messages_unittest.cc @@ -12,14 +12,17 @@ // Test GPUInfo serialization TEST(GPUIPCMessageTest, GPUInfo) { GPUInfo input; - // Test variables taken from Lenovo T61 + // Test variables taken from HP Z600 Workstation input.SetProgress(GPUInfo::kPartial); input.SetInitializationTime(base::TimeDelta::FromMilliseconds(100)); - input.SetGraphicsInfo(0x10de, 0x429, L"6.14.11.7715", - 0xffff0300, - 0xfffe0300, - 0x00010005, - true); + input.SetVideoCardInfo(0x10de, 0x0658); + input.SetDriverInfo("NVIDIA", "195.36.24"); + input.SetShaderVersion(0x0162, 0x0162); + input.SetGLVersion(0x0302); + input.SetGLVersionString("3.2.0 NVIDIA 195.36.24"); + input.SetGLVendor("NVIDIA Corporation"); + input.SetGLRenderer("Quadro FX 380/PCI/SSE2"); + input.SetCanLoseContext(false); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); IPC::WriteParam(&msg, input); @@ -32,13 +35,18 @@ TEST(GPUIPCMessageTest, GPUInfo) { output.initialization_time().InMilliseconds()); EXPECT_EQ(input.vendor_id(), output.vendor_id()); EXPECT_EQ(input.device_id(), output.device_id()); + EXPECT_EQ(input.driver_vendor(), output.driver_vendor()); EXPECT_EQ(input.driver_version(), output.driver_version()); EXPECT_EQ(input.pixel_shader_version(), output.pixel_shader_version()); EXPECT_EQ(input.vertex_shader_version(), output.vertex_shader_version()); EXPECT_EQ(input.gl_version(), output.gl_version()); + EXPECT_EQ(input.gl_version_string(), output.gl_version_string()); + EXPECT_EQ(input.gl_vendor(), output.gl_vendor()); + EXPECT_EQ(input.gl_renderer(), output.gl_renderer()); EXPECT_EQ(input.can_lose_context(), output.can_lose_context()); std::string log_message; IPC::LogParam(output, &log_message); - EXPECT_STREQ("<GPUInfo> 1 100 10de 429 6.14.11.7715 1", log_message.c_str()); + EXPECT_STREQ("<GPUInfo> 1 100 10de 658 NVIDIA 195.36.24 162 162 302 0", + log_message.c_str()); } |