diff options
Diffstat (limited to 'content/gpu')
-rw-r--r-- | content/gpu/gpu_info_collector.cc | 17 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector_linux.cc | 4 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector_mac.mm | 4 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector_unittest.cc | 49 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector_win.cc | 26 | ||||
-rw-r--r-- | content/gpu/gpu_info_unittest_win.cc | 6 | ||||
-rw-r--r-- | content/gpu/gpu_thread.cc | 21 | ||||
-rw-r--r-- | content/gpu/gpu_thread.h | 5 |
8 files changed, 67 insertions, 65 deletions
diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc index 5211e9d..13b293e 100644 --- a/content/gpu/gpu_info_collector.cc +++ b/content/gpu/gpu_info_collector.cc @@ -55,8 +55,8 @@ std::string GetGLString(unsigned int pname) { return ""; } -uint32 GetVersionNumberFromString(const std::string& version_string) { - int major = 0, minor = 0; +// Return a version string in the format of "major.minor". +std::string GetVersionFromString(const std::string& version_string) { size_t begin = version_string.find_first_of("0123456789"); if (begin != std::string::npos) { size_t end = version_string.find_first_not_of("01234567890.", begin); @@ -67,12 +67,10 @@ uint32 GetVersionNumberFromString(const std::string& version_string) { sub_string = version_string.substr(begin); std::vector<std::string> pieces; base::SplitString(sub_string, '.', &pieces); - if (pieces.size() >= 2) { - base::StringToInt(pieces[0], &major); - base::StringToInt(pieces[1], &minor); - } + if (pieces.size() >= 2) + return pieces[0] + "." + pieces[1]; } - return ((major << 8) + minor); + return ""; } } // namespace anonymous @@ -107,10 +105,9 @@ bool CollectGLVersionInfo(GPUInfo* gpu_info) { std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION); - uint32 gl_version = GetVersionNumberFromString(gl_version_string); - gpu_info->gl_version = gl_version; + gpu_info->gl_version = GetVersionFromString(gl_version_string); - uint32 glsl_version = GetVersionNumberFromString(glsl_version_string); + std::string glsl_version = GetVersionFromString(glsl_version_string); gpu_info->pixel_shader_version = glsl_version; gpu_info->vertex_shader_version = glsl_version; diff --git a/content/gpu/gpu_info_collector_linux.cc b/content/gpu/gpu_info_collector_linux.cc index 08b1f9c..6ee7c97 100644 --- a/content/gpu/gpu_info_collector_linux.cc +++ b/content/gpu/gpu_info_collector_linux.cc @@ -143,15 +143,13 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { // desktop GL and GL_ARB_robustness extension is available. gpu_info->can_lose_context = (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); - gpu_info->level = GPUInfo::kComplete; + gpu_info->finalized = true; return CollectGraphicsInfoGL(gpu_info); } bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { DCHECK(gpu_info); - gpu_info->level = GPUInfo::kPartial; - bool rt = true; if (!CollectVideoCardInfo(gpu_info)) rt = false; diff --git a/content/gpu/gpu_info_collector_mac.mm b/content/gpu/gpu_info_collector_mac.mm index e1b625d..c524fa7 100644 --- a/content/gpu/gpu_info_collector_mac.mm +++ b/content/gpu/gpu_info_collector_mac.mm @@ -49,15 +49,13 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { gpu_info->can_lose_context = (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2); - gpu_info-> level = GPUInfo::kComplete; + gpu_info->finalized = true; return CollectGraphicsInfoGL(gpu_info); } bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { DCHECK(gpu_info); - gpu_info->level = GPUInfo::kPartial; - bool rt = true; if (!CollectVideoCardInfo(gpu_info)) rt = false; diff --git a/content/gpu/gpu_info_collector_unittest.cc b/content/gpu/gpu_info_collector_unittest.cc index a441484..1cc4b64 100644 --- a/content/gpu/gpu_info_collector_unittest.cc +++ b/content/gpu/gpu_info_collector_unittest.cc @@ -27,8 +27,8 @@ class GPUInfoCollectorTest : public testing::Test { const uint32 device_id = 0x0658; const char* driver_vendor = ""; // not implemented const char* driver_version = ""; - const uint32 shader_version = 0x00000128; - const uint32 gl_version = 0x00000301; + const char* shader_version = "1.40"; + const char* gl_version = "3.1"; const char* gl_renderer = "Quadro FX 380/PCI/SSE2"; const char* gl_vendor = "NVIDIA Corporation"; const char* gl_version_string = "3.1.0"; @@ -41,8 +41,8 @@ class GPUInfoCollectorTest : public testing::Test { const uint32 device_id = 0x0640; const char* driver_vendor = ""; // not implemented const char* driver_version = "1.6.18"; - const uint32 shader_version = 0x00000114; - const uint32 gl_version = 0x00000201; + const char* shader_version = "1.20"; + const char* gl_version = "2.1"; const char* gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; const char* gl_vendor = "NVIDIA Corporation"; const char* gl_version_string = "2.1 NVIDIA-1.6.18"; @@ -55,8 +55,8 @@ class GPUInfoCollectorTest : public testing::Test { const uint32 device_id = 0x0658; const char* driver_vendor = "NVIDIA"; const char* driver_version = "195.36.24"; - const uint32 shader_version = 0x00000132; - const uint32 gl_version = 0x00000302; + const char* shader_version = "1.50"; + const char* gl_version = "3.2"; const char* gl_renderer = "Quadro FX 380/PCI/SSE2"; const char* gl_vendor = "NVIDIA Corporation"; const char* gl_version_string = "3.2.0 NVIDIA 195.36.24"; @@ -69,7 +69,6 @@ class GPUInfoCollectorTest : public testing::Test { test_values_.device_id = device_id; test_values_.driver_vendor = driver_vendor; test_values_.driver_version =driver_version; - test_values_.driver_date = ""; test_values_.pixel_shader_version = shader_version; test_values_.vertex_shader_version = shader_version; test_values_.gl_version = gl_version; @@ -113,8 +112,8 @@ class GPUInfoCollectorTest : public testing::Test { TEST_F(GPUInfoCollectorTest, DriverVendorGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - std::string driver_vendor = gpu_info.driver_vendor; - EXPECT_EQ(test_values_.driver_vendor, driver_vendor); + EXPECT_EQ(test_values_.driver_vendor, + gpu_info.driver_vendor); } // Skip Windows because the driver version is obtained from bot registry. @@ -122,56 +121,56 @@ TEST_F(GPUInfoCollectorTest, DriverVendorGL) { TEST_F(GPUInfoCollectorTest, DriverVersionGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - std::string driver_version = gpu_info.driver_version; - EXPECT_EQ(test_values_.driver_version, driver_version); + EXPECT_EQ(test_values_.driver_version, + gpu_info.driver_version); } #endif TEST_F(GPUInfoCollectorTest, PixelShaderVersionGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - uint32 ps_version = gpu_info.pixel_shader_version; - EXPECT_EQ(test_values_.pixel_shader_version, ps_version); + EXPECT_EQ(test_values_.pixel_shader_version, + gpu_info.pixel_shader_version); } TEST_F(GPUInfoCollectorTest, VertexShaderVersionGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - uint32 vs_version = gpu_info.vertex_shader_version; - EXPECT_EQ(test_values_.vertex_shader_version, vs_version); + EXPECT_EQ(test_values_.vertex_shader_version, + gpu_info.vertex_shader_version); } TEST_F(GPUInfoCollectorTest, GLVersionGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - uint32 gl_version = gpu_info.gl_version; - EXPECT_EQ(test_values_.gl_version, gl_version); + EXPECT_EQ(test_values_.gl_version, + gpu_info.gl_version); } TEST_F(GPUInfoCollectorTest, GLVersionStringGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - std::string gl_version_string = gpu_info.gl_version_string; - EXPECT_EQ(test_values_.gl_version_string, gl_version_string); + EXPECT_EQ(test_values_.gl_version_string, + gpu_info.gl_version_string); } TEST_F(GPUInfoCollectorTest, GLRendererGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - std::string gl_renderer = gpu_info.gl_renderer; - EXPECT_EQ(test_values_.gl_renderer, gl_renderer); + EXPECT_EQ(test_values_.gl_renderer, + gpu_info.gl_renderer); } TEST_F(GPUInfoCollectorTest, GLVendorGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - std::string gl_vendor = gpu_info.gl_vendor; - EXPECT_EQ(test_values_.gl_vendor, gl_vendor); + EXPECT_EQ(test_values_.gl_vendor, + gpu_info.gl_vendor); } TEST_F(GPUInfoCollectorTest, GLExtensionsGL) { GPUInfo gpu_info; gpu_info_collector::CollectGraphicsInfoGL(&gpu_info); - std::string gl_extensions = gpu_info.gl_extensions; - EXPECT_EQ(test_values_.gl_extensions, gl_extensions); + EXPECT_EQ(test_values_.gl_extensions, + gpu_info.gl_extensions); } diff --git a/content/gpu/gpu_info_collector_win.cc b/content/gpu/gpu_info_collector_win.cc index 35ab7c0..75302d0 100644 --- a/content/gpu/gpu_info_collector_win.cc +++ b/content/gpu/gpu_info_collector_win.cc @@ -20,6 +20,19 @@ #include "libEGL/main.h" #include "libEGL/Display.h" +namespace { + +// The version number stores the major and minor version in the least 16 bits; +// for example, 2.5 is 0x00000205. +// Returned string is in the format of "major.minor". +std::string VersionNumberToString(uint32 version_number) { + int hi = (version_number >> 8) & 0xff; + int low = version_number & 0xff; + return base::IntToString(hi) + "." + base::IntToString(low); +} + +} // namespace anonymous + // Setup API functions typedef HDEVINFO (WINAPI*SetupDiGetClassDevsWFunc)( CONST GUID *ClassGuid, @@ -51,13 +64,10 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { DCHECK(gpu_info); if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { - gpu_info->level = GPUInfo::kComplete; + gpu_info->finalized = true; return CollectGraphicsInfoGL(gpu_info); } - // Set to partial now in case this function returns false below. - gpu_info->level = GPUInfo::kPartial; - // TODO(zmo): the following code only works if running on top of ANGLE. // Need to handle the case when running on top of real EGL/GLES2 drivers. @@ -91,8 +101,6 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { DCHECK(gpu_info); - gpu_info->level = GPUInfo::kPreliminary; - bool rt = true; if (!CollectVideoCardInfo(gpu_info)) rt = false; @@ -111,8 +119,10 @@ bool CollectGraphicsInfoD3D(IDirect3D9* d3d, GPUInfo* gpu_info) { if (d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3d_caps) == D3D_OK) { - gpu_info->pixel_shader_version = d3d_caps.PixelShaderVersion; - gpu_info->vertex_shader_version = d3d_caps.VertexShaderVersion; + gpu_info->pixel_shader_version = + VersionNumberToString(d3d_caps.PixelShaderVersion); + gpu_info->vertex_shader_version = + VersionNumberToString(d3d_caps.VertexShaderVersion); } else { LOG(ERROR) << "d3d->GetDeviceCaps() failed"; succeed = false; diff --git a/content/gpu/gpu_info_unittest_win.cc b/content/gpu/gpu_info_unittest_win.cc index d468a48..182f2d3 100644 --- a/content/gpu/gpu_info_unittest_win.cc +++ b/content/gpu/gpu_info_unittest_win.cc @@ -47,13 +47,11 @@ class GPUInfoTest : public testing::Test { TEST_F(GPUInfoTest, PixelShaderVersionD3D) { GPUInfo gpu_info; ASSERT_TRUE(gpu_info_collector::CollectGraphicsInfoD3D(&d3d_, &gpu_info)); - uint32 ps_version = gpu_info.pixel_shader_version; - EXPECT_EQ(ps_version, D3DPS_VERSION(3, 0)); + EXPECT_EQ(gpu_info.pixel_shader_version, "3.0"); } TEST_F(GPUInfoTest, VertexShaderVersionD3D) { GPUInfo gpu_info; ASSERT_TRUE(gpu_info_collector::CollectGraphicsInfoD3D(&d3d_, &gpu_info)); - uint32 vs_version = gpu_info.vertex_shader_version; - EXPECT_EQ(vs_version, D3DVS_VERSION(3, 0)); + EXPECT_EQ(gpu_info.vertex_shader_version, "3.0"); } diff --git a/content/gpu/gpu_thread.cc b/content/gpu/gpu_thread.cc index 7eaf7fd..3dc960e 100644 --- a/content/gpu/gpu_thread.cc +++ b/content/gpu/gpu_thread.cc @@ -48,7 +48,8 @@ bool InitializeGpuSandbox() { #if defined(OS_WIN) GpuThread::GpuThread(sandbox::TargetServices* target_services) - : target_services_(target_services) { + : target_services_(target_services), + collecting_dx_diagnostics_(false) { } #else GpuThread::GpuThread() { @@ -129,11 +130,7 @@ void GpuThread::OnInitialize() { MessageLoop::current()->Quit(); return; } - bool gpu_info_result = gpu_info_collector::CollectGraphicsInfo(&gpu_info_); - if (!gpu_info_result) { - gpu_info_.collection_error = true; - LOG(ERROR) << "gpu_info_collector::CollectGraphicsInfo() failed"; - } + gpu_info_collector::CollectGraphicsInfo(&gpu_info_); content::GetContentClient()->SetGpuInfo(gpu_info_); LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete"; @@ -247,11 +244,11 @@ void GpuThread::OnSynchronize() { Send(new GpuHostMsg_SynchronizeReply()); } -void GpuThread::OnCollectGraphicsInfo(GPUInfo::Level level) { +void GpuThread::OnCollectGraphicsInfo() { #if defined(OS_WIN) - if (level == GPUInfo::kComplete && gpu_info_.level <= GPUInfo::kPartial) { + if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { // Prevent concurrent collection of DirectX diagnostics. - gpu_info_.level = GPUInfo::kCompleting; + collecting_dx_diagnostics_ = true; // Asynchronously collect the DirectX diagnostics because this can take a // couple of seconds. @@ -262,7 +259,8 @@ void GpuThread::OnCollectGraphicsInfo(GPUInfo::Level level) { // Flag GPU info as complete if the DirectX diagnostics cannot be // collected. - gpu_info_.level = GPUInfo::kComplete; + collecting_dx_diagnostics_ = false; + gpu_info_.finalized = true; } else { // Do not send response if we are still completing the GPUInfo struct return; @@ -340,7 +338,8 @@ void GpuThread::CollectDxDiagnostics(GpuThread* thread) { // Runs on the GPU thread. void GpuThread::SetDxDiagnostics(GpuThread* thread, const DxDiagNode& node) { thread->gpu_info_.dx_diagnostics = node; - thread->gpu_info_.level = GPUInfo::kComplete; + thread->gpu_info_.finalized = true; + thread->collecting_dx_diagnostics_ = false; thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); } diff --git a/content/gpu/gpu_thread.h b/content/gpu/gpu_thread.h index 21ad923..4a0c348 100644 --- a/content/gpu/gpu_thread.h +++ b/content/gpu/gpu_thread.h @@ -58,7 +58,7 @@ class GpuThread : public ChildThread { void OnEstablishChannel(int renderer_id); void OnCloseChannel(const IPC::ChannelHandle& channel_handle); void OnSynchronize(); - void OnCollectGraphicsInfo(GPUInfo::Level level); + void OnCollectGraphicsInfo(); void OnCreateViewCommandBuffer( gfx::PluginWindowHandle window, int32 render_view_id, @@ -89,6 +89,9 @@ class GpuThread : public ChildThread { #if defined(OS_WIN) // Windows specific client sandbox interface. sandbox::TargetServices* target_services_; + + // Indicates whether DirectX Diagnostics collection is ongoing. + bool collecting_dx_diagnostics_; #endif DISALLOW_COPY_AND_ASSIGN(GpuThread); |