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 "gpu/config/gpu_info_collector.h" | 5 #include "gpu/config/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 <cfgmgr32.h> | 11 #include <cfgmgr32.h> |
12 #include <d3d9.h> | 12 #include <d3d9.h> |
13 #include <d3d11.h> | 13 #include <d3d11.h> |
14 #include <dxgi.h> | 14 #include <dxgi.h> |
15 #include <setupapi.h> | 15 #include <setupapi.h> |
| 16 #include <stddef.h> |
| 17 #include <stdint.h> |
16 | 18 |
17 #include "base/command_line.h" | 19 #include "base/command_line.h" |
18 #include "base/files/file_enumerator.h" | 20 #include "base/files/file_enumerator.h" |
19 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
20 #include "base/files/file_util.h" | 22 #include "base/files/file_util.h" |
21 #include "base/logging.h" | 23 #include "base/logging.h" |
22 #include "base/message_loop/message_loop.h" | 24 #include "base/message_loop/message_loop.h" |
23 #include "base/metrics/field_trial.h" | 25 #include "base/metrics/field_trial.h" |
24 #include "base/metrics/histogram.h" | 26 #include "base/metrics/histogram.h" |
25 #include "base/scoped_native_library.h" | 27 #include "base/scoped_native_library.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 if (key.OpenKey(L"Lenovo", KEY_READ | KEY_WOW64_64KEY)) | 84 if (key.OpenKey(L"Lenovo", KEY_READ | KEY_WOW64_64KEY)) |
83 return false; | 85 return false; |
84 | 86 |
85 if (key.OpenKey(L"Lenovo dCute", KEY_READ | KEY_WOW64_64KEY)) | 87 if (key.OpenKey(L"Lenovo dCute", KEY_READ | KEY_WOW64_64KEY)) |
86 return false; | 88 return false; |
87 | 89 |
88 return true; | 90 return true; |
89 } | 91 } |
90 | 92 |
91 void DeviceIDToVendorAndDevice(const std::wstring& id, | 93 void DeviceIDToVendorAndDevice(const std::wstring& id, |
92 uint32* vendor_id, | 94 uint32_t* vendor_id, |
93 uint32* device_id) { | 95 uint32_t* device_id) { |
94 *vendor_id = 0; | 96 *vendor_id = 0; |
95 *device_id = 0; | 97 *device_id = 0; |
96 if (id.length() < 21) | 98 if (id.length() < 21) |
97 return; | 99 return; |
98 base::string16 vendor_id_string = id.substr(8, 4); | 100 base::string16 vendor_id_string = id.substr(8, 4); |
99 base::string16 device_id_string = id.substr(17, 4); | 101 base::string16 device_id_string = id.substr(17, 4); |
100 int vendor = 0; | 102 int vendor = 0; |
101 int device = 0; | 103 int device = 0; |
102 base::HexStringToInt(base::UTF16ToASCII(vendor_id_string), &vendor); | 104 base::HexStringToInt(base::UTF16ToASCII(vendor_id_string), &vendor); |
103 base::HexStringToInt(base::UTF16ToASCII(device_id_string), &device); | 105 base::HexStringToInt(base::UTF16ToASCII(device_id_string), &device); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 GPUDriver driver; | 212 GPUDriver driver; |
211 | 213 |
212 driver.driver_vendor = driver_vendor; | 214 driver.driver_vendor = driver_vendor; |
213 driver.driver_version = driver_version; | 215 driver.driver_version = driver_version; |
214 driver.driver_date = driver_date; | 216 driver.driver_date = driver_date; |
215 std::wstring id = new_device_id; | 217 std::wstring id = new_device_id; |
216 | 218 |
217 if (id.compare(0, device_id.size(), device_id) == 0) | 219 if (id.compare(0, device_id.size(), device_id) == 0) |
218 primary_device = drivers.size(); | 220 primary_device = drivers.size(); |
219 | 221 |
220 uint32 vendor_id = 0, device_id = 0; | 222 uint32_t vendor_id = 0, device_id = 0; |
221 DeviceIDToVendorAndDevice(id, &vendor_id, &device_id); | 223 DeviceIDToVendorAndDevice(id, &vendor_id, &device_id); |
222 driver.device.vendor_id = vendor_id; | 224 driver.device.vendor_id = vendor_id; |
223 driver.device.device_id = device_id; | 225 driver.device.device_id = device_id; |
224 drivers.push_back(driver); | 226 drivers.push_back(driver); |
225 | 227 |
226 if (vendor_id == 0x8086) | 228 if (vendor_id == 0x8086) |
227 found_intel = true; | 229 found_intel = true; |
228 if (vendor_id == 0x1002) | 230 if (vendor_id == 0x1002) |
229 found_amd = true; | 231 found_amd = true; |
230 } | 232 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // DirectX diagnostics are collected asynchronously because it takes a | 349 // DirectX diagnostics are collected asynchronously because it takes a |
348 // couple of seconds. | 350 // couple of seconds. |
349 } else { | 351 } else { |
350 gpu_info->dx_diagnostics_info_state = kCollectInfoNonFatalFailure; | 352 gpu_info->dx_diagnostics_info_state = kCollectInfoNonFatalFailure; |
351 } | 353 } |
352 | 354 |
353 gpu_info->context_info_state = kCollectInfoSuccess; | 355 gpu_info->context_info_state = kCollectInfoSuccess; |
354 return kCollectInfoSuccess; | 356 return kCollectInfoSuccess; |
355 } | 357 } |
356 | 358 |
357 CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) { | 359 CollectInfoResult CollectGpuID(uint32_t* vendor_id, uint32_t* device_id) { |
358 DCHECK(vendor_id && device_id); | 360 DCHECK(vendor_id && device_id); |
359 *vendor_id = 0; | 361 *vendor_id = 0; |
360 *device_id = 0; | 362 *device_id = 0; |
361 | 363 |
362 // Taken from http://developer.nvidia.com/object/device_ids.html | 364 // Taken from http://developer.nvidia.com/object/device_ids.html |
363 DISPLAY_DEVICE dd; | 365 DISPLAY_DEVICE dd; |
364 dd.cb = sizeof(DISPLAY_DEVICE); | 366 dd.cb = sizeof(DISPLAY_DEVICE); |
365 std::wstring id; | 367 std::wstring id; |
366 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { | 368 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { |
367 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { | 369 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 495 } |
494 | 496 |
495 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 497 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
496 | 498 |
497 basic_gpu_info->dx_diagnostics_info_state = | 499 basic_gpu_info->dx_diagnostics_info_state = |
498 context_gpu_info.dx_diagnostics_info_state; | 500 context_gpu_info.dx_diagnostics_info_state; |
499 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; | 501 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; |
500 } | 502 } |
501 | 503 |
502 } // namespace gpu | 504 } // namespace gpu |
OLD | NEW |