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