| 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> |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 found = true; | 445 found = true; |
| 446 RegCloseKey(key); | 446 RegCloseKey(key); |
| 447 break; | 447 break; |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 } | 450 } |
| 451 SetupDiDestroyDeviceInfoList(device_info); | 451 SetupDiDestroyDeviceInfoList(device_info); |
| 452 return found; | 452 return found; |
| 453 } | 453 } |
| 454 | 454 |
| 455 bool CollectContextGraphicsInfo(GPUInfo* gpu_info) { | 455 CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) { |
| 456 TRACE_EVENT0("gpu", "CollectGraphicsInfo"); | 456 TRACE_EVENT0("gpu", "CollectGraphicsInfo"); |
| 457 | 457 |
| 458 DCHECK(gpu_info); | 458 DCHECK(gpu_info); |
| 459 | 459 |
| 460 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) { | 460 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) { |
| 461 std::string requested_implementation_name = | 461 std::string requested_implementation_name = |
| 462 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); | 462 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); |
| 463 if (requested_implementation_name == "swiftshader") { | 463 if (requested_implementation_name == "swiftshader") { |
| 464 gpu_info->software_rendering = true; | 464 gpu_info->software_rendering = true; |
| 465 return false; | 465 return kCollectInfoNonFatalFailure; |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 if (!CollectGraphicsInfoGL(gpu_info)) | 469 CollectInfoResult result = CollectGraphicsInfoGL(gpu_info); |
| 470 return false; | 470 if (result != kCollectInfoSuccess) |
| 471 return result; |
| 471 | 472 |
| 472 // ANGLE's renderer strings are of the form: | 473 // ANGLE's renderer strings are of the form: |
| 473 // ANGLE (<adapter_identifier> Direct3D<version> vs_x_x ps_x_x) | 474 // ANGLE (<adapter_identifier> Direct3D<version> vs_x_x ps_x_x) |
| 474 std::string direct3d_version; | 475 std::string direct3d_version; |
| 475 int vertex_shader_major_version = 0; | 476 int vertex_shader_major_version = 0; |
| 476 int vertex_shader_minor_version = 0; | 477 int vertex_shader_minor_version = 0; |
| 477 int pixel_shader_major_version = 0; | 478 int pixel_shader_major_version = 0; |
| 478 int pixel_shader_minor_version = 0; | 479 int pixel_shader_minor_version = 0; |
| 479 gpu_info->adapter_luid = 0; | 480 gpu_info->adapter_luid = 0; |
| 480 if (RE2::FullMatch(gpu_info->gl_renderer, | 481 if (RE2::FullMatch(gpu_info->gl_renderer, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 510 " \\(adapter LUID: ([0-9A-Fa-f]{16})\\)", | 511 " \\(adapter LUID: ([0-9A-Fa-f]{16})\\)", |
| 511 RE2::Hex(&gpu_info->adapter_luid)); | 512 RE2::Hex(&gpu_info->adapter_luid)); |
| 512 | 513 |
| 513 // DirectX diagnostics are collected asynchronously because it takes a | 514 // DirectX diagnostics are collected asynchronously because it takes a |
| 514 // couple of seconds. Do not mark gpu_info as complete until that is done. | 515 // couple of seconds. Do not mark gpu_info as complete until that is done. |
| 515 gpu_info->finalized = false; | 516 gpu_info->finalized = false; |
| 516 } else { | 517 } else { |
| 517 gpu_info->finalized = true; | 518 gpu_info->finalized = true; |
| 518 } | 519 } |
| 519 | 520 |
| 520 return true; | 521 return kCollectInfoSuccess; |
| 521 } | 522 } |
| 522 | 523 |
| 523 GpuIDResult CollectGpuID(uint32* vendor_id, uint32* device_id) { | 524 GpuIDResult CollectGpuID(uint32* vendor_id, uint32* device_id) { |
| 524 DCHECK(vendor_id && device_id); | 525 DCHECK(vendor_id && device_id); |
| 525 *vendor_id = 0; | 526 *vendor_id = 0; |
| 526 *device_id = 0; | 527 *device_id = 0; |
| 527 | 528 |
| 528 // Taken from http://developer.nvidia.com/object/device_ids.html | 529 // Taken from http://developer.nvidia.com/object/device_ids.html |
| 529 DISPLAY_DEVICE dd; | 530 DISPLAY_DEVICE dd; |
| 530 dd.cb = sizeof(DISPLAY_DEVICE); | 531 dd.cb = sizeof(DISPLAY_DEVICE); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 542 std::wstring device_string = id.substr(17, 4); | 543 std::wstring device_string = id.substr(17, 4); |
| 543 base::HexStringToInt(base::UTF16ToASCII(vendor_string), &vendor); | 544 base::HexStringToInt(base::UTF16ToASCII(vendor_string), &vendor); |
| 544 base::HexStringToInt(base::UTF16ToASCII(device_string), &device); | 545 base::HexStringToInt(base::UTF16ToASCII(device_string), &device); |
| 545 *vendor_id = vendor; | 546 *vendor_id = vendor; |
| 546 *device_id = device; | 547 *device_id = device; |
| 547 return kGpuIDSuccess; | 548 return kGpuIDSuccess; |
| 548 } | 549 } |
| 549 return kGpuIDFailure; | 550 return kGpuIDFailure; |
| 550 } | 551 } |
| 551 | 552 |
| 552 bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) { | 553 CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) { |
| 553 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo"); | 554 TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo"); |
| 554 | 555 |
| 555 DCHECK(gpu_info); | 556 DCHECK(gpu_info); |
| 556 | 557 |
| 557 gpu_info->performance_stats = RetrieveGpuPerformanceStatsWithHistograms(); | 558 gpu_info->performance_stats = RetrieveGpuPerformanceStatsWithHistograms(); |
| 558 | 559 |
| 559 // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled. | 560 // nvd3d9wrap.dll is loaded into all processes when Optimus is enabled. |
| 560 HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll"); | 561 HMODULE nvd3d9wrap = GetModuleHandleW(L"nvd3d9wrap.dll"); |
| 561 gpu_info->optimus = nvd3d9wrap != NULL; | 562 gpu_info->optimus = nvd3d9wrap != NULL; |
| 562 | 563 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 583 dd.cb = sizeof(DISPLAY_DEVICE); | 584 dd.cb = sizeof(DISPLAY_DEVICE); |
| 584 std::wstring id; | 585 std::wstring id; |
| 585 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { | 586 for (int i = 0; EnumDisplayDevices(NULL, i, &dd, 0); ++i) { |
| 586 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { | 587 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { |
| 587 id = dd.DeviceID; | 588 id = dd.DeviceID; |
| 588 break; | 589 break; |
| 589 } | 590 } |
| 590 } | 591 } |
| 591 | 592 |
| 592 if (id.length() <= 20) | 593 if (id.length() <= 20) |
| 593 return false; | 594 return kCollectInfoNonFatalFailure; |
| 594 | 595 |
| 595 int vendor_id = 0, device_id = 0; | 596 int vendor_id = 0, device_id = 0; |
| 596 base::string16 vendor_id_string = id.substr(8, 4); | 597 base::string16 vendor_id_string = id.substr(8, 4); |
| 597 base::string16 device_id_string = id.substr(17, 4); | 598 base::string16 device_id_string = id.substr(17, 4); |
| 598 base::HexStringToInt(base::UTF16ToASCII(vendor_id_string), &vendor_id); | 599 base::HexStringToInt(base::UTF16ToASCII(vendor_id_string), &vendor_id); |
| 599 base::HexStringToInt(base::UTF16ToASCII(device_id_string), &device_id); | 600 base::HexStringToInt(base::UTF16ToASCII(device_id_string), &device_id); |
| 600 gpu_info->gpu.vendor_id = vendor_id; | 601 gpu_info->gpu.vendor_id = vendor_id; |
| 601 gpu_info->gpu.device_id = device_id; | 602 gpu_info->gpu.device_id = device_id; |
| 602 // TODO(zmo): we only need to call CollectDriverInfoD3D() if we use ANGLE. | 603 // TODO(zmo): we only need to call CollectDriverInfoD3D() if we use ANGLE. |
| 603 if (!CollectDriverInfoD3D(id, gpu_info)) | 604 if (!CollectDriverInfoD3D(id, gpu_info)) |
| 604 return false; | 605 return kCollectInfoNonFatalFailure; |
| 605 | 606 |
| 606 // Collect basic information about supported D3D11 features. Delay for 45 | 607 // Collect basic information about supported D3D11 features. Delay for 45 |
| 607 // seconds so as not to regress performance tests. | 608 // seconds so as not to regress performance tests. |
| 608 if (D3D11ShouldWork(*gpu_info)) { | 609 if (D3D11ShouldWork(*gpu_info)) { |
| 609 // This is on a field trial so we can turn it off easily if it blows up | 610 // This is on a field trial so we can turn it off easily if it blows up |
| 610 // again in stable channel. | 611 // again in stable channel. |
| 611 scoped_refptr<base::FieldTrial> trial( | 612 scoped_refptr<base::FieldTrial> trial( |
| 612 base::FieldTrialList::FactoryGetFieldTrial( | 613 base::FieldTrialList::FactoryGetFieldTrial( |
| 613 "D3D11Experiment", 100, "Disabled", 2015, 7, 8, | 614 "D3D11Experiment", 100, "Disabled", 2015, 7, 8, |
| 614 base::FieldTrial::SESSION_RANDOMIZED, NULL)); | 615 base::FieldTrial::SESSION_RANDOMIZED, NULL)); |
| 615 const int enabled_group = | 616 const int enabled_group = |
| 616 trial->AppendGroup("Enabled", 0); | 617 trial->AppendGroup("Enabled", 0); |
| 617 | 618 |
| 618 if (trial->group() == enabled_group) { | 619 if (trial->group() == enabled_group) { |
| 619 base::MessageLoop::current()->PostDelayedTask( | 620 base::MessageLoop::current()->PostDelayedTask( |
| 620 FROM_HERE, | 621 FROM_HERE, |
| 621 base::Bind(&CollectD3D11Support), | 622 base::Bind(&CollectD3D11Support), |
| 622 base::TimeDelta::FromSeconds(45)); | 623 base::TimeDelta::FromSeconds(45)); |
| 623 } | 624 } |
| 624 } | 625 } |
| 625 | 626 |
| 626 return true; | 627 return kCollectInfoSuccess; |
| 627 } | 628 } |
| 628 | 629 |
| 629 bool CollectDriverInfoGL(GPUInfo* gpu_info) { | 630 CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) { |
| 630 TRACE_EVENT0("gpu", "CollectDriverInfoGL"); | 631 TRACE_EVENT0("gpu", "CollectDriverInfoGL"); |
| 631 | 632 |
| 632 if (!gpu_info->driver_version.empty()) | 633 if (!gpu_info->driver_version.empty()) |
| 633 return true; | 634 return kCollectInfoSuccess; |
| 634 | 635 |
| 635 std::string gl_version_string = gpu_info->gl_version_string; | 636 std::string gl_version_string = gpu_info->gl_version_string; |
| 636 | 637 |
| 637 return RE2::PartialMatch(gl_version_string, | 638 bool parsed = RE2::PartialMatch( |
| 638 "([\\d\\.]+)$", | 639 gl_version_string, "([\\d\\.]+)$", &gpu_info->driver_version); |
| 639 &gpu_info->driver_version); | 640 return parsed ? kCollectInfoSuccess : kCollectInfoNonFatalFailure; |
| 640 } | 641 } |
| 641 | 642 |
| 642 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 643 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
| 643 const GPUInfo& context_gpu_info) { | 644 const GPUInfo& context_gpu_info) { |
| 644 DCHECK(basic_gpu_info); | 645 DCHECK(basic_gpu_info); |
| 645 | 646 |
| 646 if (context_gpu_info.software_rendering) { | 647 if (context_gpu_info.software_rendering) { |
| 647 basic_gpu_info->software_rendering = true; | 648 basic_gpu_info->software_rendering = true; |
| 648 return; | 649 return; |
| 649 } | 650 } |
| 650 | 651 |
| 651 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 652 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
| 652 | 653 |
| 653 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; | 654 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; |
| 654 } | 655 } |
| 655 | 656 |
| 656 } // namespace gpu | 657 } // namespace gpu |
| OLD | NEW |