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 #include <windows.h> | 7 #include <windows.h> |
8 #include <d3d9.h> | 8 #include <d3d9.h> |
9 #include <setupapi.h> | 9 #include <setupapi.h> |
10 #include <winsatcominterfacei.h> | 10 #include <winsatcominterfacei.h> |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 driver_version = WideToASCII(std::wstring(value)); | 281 driver_version = WideToASCII(std::wstring(value)); |
282 | 282 |
283 std::string driver_date; | 283 std::string driver_date; |
284 dwcb_data = sizeof(value); | 284 dwcb_data = sizeof(value); |
285 result = RegQueryValueExW( | 285 result = RegQueryValueExW( |
286 key, L"DriverDate", NULL, NULL, | 286 key, L"DriverDate", NULL, NULL, |
287 reinterpret_cast<LPBYTE>(value), &dwcb_data); | 287 reinterpret_cast<LPBYTE>(value), &dwcb_data); |
288 if (result == ERROR_SUCCESS) | 288 if (result == ERROR_SUCCESS) |
289 driver_date = WideToASCII(std::wstring(value)); | 289 driver_date = WideToASCII(std::wstring(value)); |
290 | 290 |
| 291 std::string driver_vendor; |
| 292 dwcb_data = sizeof(value); |
| 293 result = RegQueryValueExW( |
| 294 key, L"ProviderName", NULL, NULL, |
| 295 reinterpret_cast<LPBYTE>(value), &dwcb_data); |
| 296 if (result == ERROR_SUCCESS) { |
| 297 driver_vendor = WideToASCII(std::wstring(value)); |
| 298 // If it's an Intel GPU with a driver provided by AMD then it's |
| 299 // probably AMD's Dynamic Switchable Graphics. |
| 300 // TODO: detect only AMD switchable |
| 301 gpu_info->amd_switchable = |
| 302 driver_vendor == "Advanced Micro Devices, Inc." || |
| 303 driver_vendor == "ATI Technologies Inc."; |
| 304 } |
| 305 |
| 306 gpu_info->driver_vendor = driver_vendor; |
291 gpu_info->driver_version = driver_version; | 307 gpu_info->driver_version = driver_version; |
292 gpu_info->driver_date = driver_date; | 308 gpu_info->driver_date = driver_date; |
293 found = true; | 309 found = true; |
294 RegCloseKey(key); | 310 RegCloseKey(key); |
295 break; | 311 break; |
296 } | 312 } |
297 } | 313 } |
298 } | 314 } |
299 SetupDiDestroyDeviceInfoList(device_info); | 315 SetupDiDestroyDeviceInfoList(device_info); |
300 return found; | 316 return found; |
301 } | 317 } |
302 | 318 |
303 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { | 319 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { |
304 DCHECK(gpu_info); | 320 DCHECK(gpu_info); |
305 | 321 |
306 std::string gl_version_string = gpu_info->gl_version_string; | 322 std::string gl_version_string = gpu_info->gl_version_string; |
307 | 323 |
308 // TODO(zmo): We assume the driver version is in the end of GL_VERSION | 324 // TODO(zmo): We assume the driver version is in the end of GL_VERSION |
309 // string. Need to verify if it is true for majority drivers. | 325 // string. Need to verify if it is true for majority drivers. |
310 | 326 |
311 size_t pos = gl_version_string.find_last_not_of("0123456789."); | 327 size_t pos = gl_version_string.find_last_not_of("0123456789."); |
312 if (pos != std::string::npos && pos < gl_version_string.length() - 1) { | 328 if (pos != std::string::npos && pos < gl_version_string.length() - 1) { |
313 gpu_info->driver_version = gl_version_string.substr(pos + 1); | 329 gpu_info->driver_version = gl_version_string.substr(pos + 1); |
314 return true; | 330 return true; |
315 } | 331 } |
316 return false; | 332 return false; |
317 } | 333 } |
318 | 334 |
319 } // namespace gpu_info_collector | 335 } // namespace gpu_info_collector |
OLD | NEW |