| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/gpu/gpu_info_collector.h" | 5 #include "content/gpu/gpu_info_collector.h" |
| 6 | 6 |
| 7 // This has to be included before windows.h. | 7 // This has to be included before windows.h. |
| 8 #include "third_party/re2/re2/re2.h" | 8 #include "third_party/re2/re2/re2.h" |
| 9 | 9 |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <d3d9.h> | 11 #include <d3d9.h> |
| 12 #include <d3d11.h> | 12 #include <d3d11.h> |
| 13 #include <dxgi.h> | 13 #include <dxgi.h> |
| 14 #include <setupapi.h> | 14 #include <setupapi.h> |
| 15 | 15 |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/debug/trace_event.h" | 17 #include "base/debug/trace_event.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 23 #include "base/scoped_native_library.h" | 23 #include "base/scoped_native_library.h" |
| 24 #include "base/string_number_conversions.h" | 24 #include "base/string_number_conversions.h" |
| 25 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 26 #include "base/stringprintf.h" | 26 #include "base/stringprintf.h" |
| 27 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
| 28 #include "base/threading/worker_pool.h" | 28 #include "base/threading/worker_pool.h" |
| 29 #include "base/win/registry.h" |
| 29 #include "base/win/scoped_com_initializer.h" | 30 #include "base/win/scoped_com_initializer.h" |
| 30 #include "base/win/scoped_comptr.h" | 31 #include "base/win/scoped_comptr.h" |
| 31 #include "base/win/windows_version.h" | 32 #include "base/win/windows_version.h" |
| 32 #include "third_party/libxml/chromium/libxml_utils.h" | 33 #include "third_party/libxml/chromium/libxml_utils.h" |
| 33 #include "ui/gl/gl_implementation.h" | 34 #include "ui/gl/gl_implementation.h" |
| 34 #include "ui/gl/gl_surface_egl.h" | 35 #include "ui/gl/gl_surface_egl.h" |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 39 // This must be kept in sync with histograms.xml. |
| 40 enum DisplayLinkInstallationStatus { |
| 41 DISPLAY_LINK_NOT_INSTALLED, |
| 42 DISPLAY_LINK_7_1_OR_EARLIER, |
| 43 DISPLAY_LINK_7_2_OR_LATER, |
| 44 DISPLAY_LINK_INSTALLATION_STATUS_MAX |
| 45 }; |
| 46 |
| 38 float ReadXMLFloatValue(XmlReader* reader) { | 47 float ReadXMLFloatValue(XmlReader* reader) { |
| 39 std::string score_string; | 48 std::string score_string; |
| 40 if (!reader->ReadElementContent(&score_string)) | 49 if (!reader->ReadElementContent(&score_string)) |
| 41 return 0.0; | 50 return 0.0; |
| 42 | 51 |
| 43 double score; | 52 double score; |
| 44 if (!base::StringToDouble(score_string, &score)) | 53 if (!base::StringToDouble(score_string, &score)) |
| 45 return 0.0; | 54 return 0.0; |
| 46 | 55 |
| 47 return static_cast<float>(score); | 56 return static_cast<float>(score); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 stats.graphics * 10, 10, 200, 50); | 156 stats.graphics * 10, 10, 200, 50); |
| 148 UMA_HISTOGRAM_CUSTOM_COUNTS("GPU.WinSAT.GamingScore2", | 157 UMA_HISTOGRAM_CUSTOM_COUNTS("GPU.WinSAT.GamingScore2", |
| 149 stats.gaming * 10, 10, 200, 50); | 158 stats.gaming * 10, 10, 200, 50); |
| 150 UMA_HISTOGRAM_BOOLEAN( | 159 UMA_HISTOGRAM_BOOLEAN( |
| 151 "GPU.WinSAT.HasResults", | 160 "GPU.WinSAT.HasResults", |
| 152 stats.overall != 0.0 && stats.graphics != 0.0 && stats.gaming != 0.0); | 161 stats.overall != 0.0 && stats.graphics != 0.0 && stats.gaming != 0.0); |
| 153 | 162 |
| 154 return stats; | 163 return stats; |
| 155 } | 164 } |
| 156 | 165 |
| 166 // Returns the display link driver version or an invalid version if it is |
| 167 // not installed. |
| 168 Version DisplayLinkVersion() { |
| 169 base::win::RegKey key; |
| 170 |
| 171 if (FAILED(key.Open( |
| 172 HKEY_LOCAL_MACHINE, L"SOFTWARE", KEY_READ | KEY_WOW64_64KEY))) { |
| 173 return Version(); |
| 174 } |
| 175 |
| 176 if (FAILED(key.OpenKey(L"DisplayLink", KEY_READ | KEY_WOW64_64KEY))) |
| 177 return Version(); |
| 178 |
| 179 if (FAILED(key.OpenKey(L"Core", KEY_READ | KEY_WOW64_64KEY))) |
| 180 return Version(); |
| 181 |
| 182 string16 version; |
| 183 if (FAILED(key.ReadValue(L"Version", &version))) |
| 184 return Version(); |
| 185 |
| 186 return Version(WideToASCII(version)); |
| 187 } |
| 157 } // namespace anonymous | 188 } // namespace anonymous |
| 158 | 189 |
| 159 namespace gpu_info_collector { | 190 namespace gpu_info_collector { |
| 160 | 191 |
| 161 #if !defined(GOOGLE_CHROME_BUILD) | 192 #if !defined(GOOGLE_CHROME_BUILD) |
| 162 AMDVideoCardType GetAMDVideocardType() { | 193 AMDVideoCardType GetAMDVideocardType() { |
| 163 return UNKNOWN; | 194 return UNKNOWN; |
| 164 } | 195 } |
| 165 #else | 196 #else |
| 166 // This function has a real implementation for official builds that can | 197 // This function has a real implementation for official builds that can |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo"); | 508 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo"); |
| 478 | 509 |
| 479 DCHECK(gpu_info); | 510 DCHECK(gpu_info); |
| 480 | 511 |
| 481 gpu_info->performance_stats = RetrieveGpuPerformanceStatsWithHistograms(); | 512 gpu_info->performance_stats = RetrieveGpuPerformanceStatsWithHistograms(); |
| 482 | 513 |
| 483 // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled. | 514 // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled. |
| 484 HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll"); | 515 HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll"); |
| 485 gpu_info->optimus = nvd3d9wrap != NULL; | 516 gpu_info->optimus = nvd3d9wrap != NULL; |
| 486 | 517 |
| 518 gpu_info->display_link_version = DisplayLinkVersion(); |
| 519 |
| 520 if (!gpu_info->display_link_version .IsValid()) { |
| 521 UMA_HISTOGRAM_ENUMERATION("GPU.DisplayLinkInstallationStatus", |
| 522 DISPLAY_LINK_NOT_INSTALLED, |
| 523 DISPLAY_LINK_INSTALLATION_STATUS_MAX); |
| 524 } else if (gpu_info->display_link_version.IsOlderThan("7.2")) { |
| 525 UMA_HISTOGRAM_ENUMERATION("GPU.DisplayLinkInstallationStatus", |
| 526 DISPLAY_LINK_7_1_OR_EARLIER, |
| 527 DISPLAY_LINK_INSTALLATION_STATUS_MAX); |
| 528 } else { |
| 529 UMA_HISTOGRAM_ENUMERATION("GPU.DisplayLinkInstallationStatus", |
| 530 DISPLAY_LINK_7_2_OR_LATER, |
| 531 DISPLAY_LINK_INSTALLATION_STATUS_MAX); |
| 532 } |
| 533 |
| 487 // Taken from http://developer.nvidia.com/object/device_ids.html | 534 // Taken from http://developer.nvidia.com/object/device_ids.html |
| 488 DISPLAY_DEVICE dd; | 535 DISPLAY_DEVICE dd; |
| 489 dd.cb = sizeof(DISPLAY_DEVICE); | 536 dd.cb = sizeof(DISPLAY_DEVICE); |
| 490 std::wstring id; | 537 std::wstring id; |
| 491 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { | 538 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { |
| 492 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { | 539 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { |
| 493 id = dd.DeviceID; | 540 id = dd.DeviceID; |
| 494 break; | 541 break; |
| 495 } | 542 } |
| 496 } | 543 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 basic_gpu_info->software_rendering = true; | 577 basic_gpu_info->software_rendering = true; |
| 531 return; | 578 return; |
| 532 } | 579 } |
| 533 | 580 |
| 534 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 581 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
| 535 | 582 |
| 536 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; | 583 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; |
| 537 } | 584 } |
| 538 | 585 |
| 539 } // namespace gpu_info_collector | 586 } // namespace gpu_info_collector |
| OLD | NEW |