summaryrefslogtreecommitdiffstats
path: root/chromium/gpu/config/gpu_info_collector_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/gpu/config/gpu_info_collector_win.cc')
-rw-r--r--chromium/gpu/config/gpu_info_collector_win.cc81
1 files changed, 41 insertions, 40 deletions
diff --git a/chromium/gpu/config/gpu_info_collector_win.cc b/chromium/gpu/config/gpu_info_collector_win.cc
index 3b63296ff9e..65d75ec91a1 100644
--- a/chromium/gpu/config/gpu_info_collector_win.cc
+++ b/chromium/gpu/config/gpu_info_collector_win.cc
@@ -27,6 +27,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread.h"
#include "base/threading/worker_pool.h"
#include "base/win/registry.h"
@@ -186,7 +187,7 @@ Version DisplayLinkVersion() {
if (key.ReadValue(L"Version", &version))
return Version();
- return Version(WideToASCII(version));
+ return Version(base::UTF16ToASCII(version));
}
// Returns whether Lenovo dCute is installed.
@@ -210,8 +211,9 @@ bool IsLenovoDCuteInstalled() {
bool D3D11ShouldWork(const GPUInfo& gpu_info) {
// TODO(apatrick): This is a temporary change to see what impact disabling
// D3D11 stats collection has on Canary.
+#if 1
return false;
-
+#else
// Windows XP never supports D3D11. It seems to be less stable that D3D9 on
// Vista.
if (base::win::GetVersion() <= base::win::VERSION_VISTA)
@@ -222,6 +224,7 @@ bool D3D11ShouldWork(const GPUInfo& gpu_info) {
return false;
return true;
+#endif
}
// Collects information about the level of D3D11 support and records it in
@@ -360,13 +363,14 @@ void CollectD3D11Support() {
} // namespace anonymous
#if !defined(GOOGLE_CHROME_BUILD)
-AMDVideoCardType GetAMDVideocardType() {
- return STANDALONE;
+void GetAMDVideocardInfo(GPUInfo* gpu_info) {
+ DCHECK(gpu_info);
+ return;
}
#else
// This function has a real implementation for official builds that can
// be found in src/third_party/amd.
-AMDVideoCardType GetAMDVideocardType();
+void GetAMDVideocardInfo(GPUInfo* gpu_info);
#endif
bool CollectDriverInfoD3D(const std::wstring& device_id,
@@ -407,7 +411,7 @@ bool CollectDriverInfoD3D(const std::wstring& device_id,
key, L"DriverVersion", NULL, NULL,
reinterpret_cast<LPBYTE>(value), &dwcb_data);
if (result == ERROR_SUCCESS)
- driver_version = WideToASCII(std::wstring(value));
+ driver_version = base::UTF16ToASCII(std::wstring(value));
std::string driver_date;
dwcb_data = sizeof(value);
@@ -415,7 +419,7 @@ bool CollectDriverInfoD3D(const std::wstring& device_id,
key, L"DriverDate", NULL, NULL,
reinterpret_cast<LPBYTE>(value), &dwcb_data);
if (result == ERROR_SUCCESS)
- driver_date = WideToASCII(std::wstring(value));
+ driver_date = base::UTF16ToASCII(std::wstring(value));
std::string driver_vendor;
dwcb_data = sizeof(value);
@@ -423,16 +427,21 @@ bool CollectDriverInfoD3D(const std::wstring& device_id,
key, L"ProviderName", NULL, NULL,
reinterpret_cast<LPBYTE>(value), &dwcb_data);
if (result == ERROR_SUCCESS) {
- driver_vendor = WideToASCII(std::wstring(value));
+ driver_vendor = base::UTF16ToASCII(std::wstring(value));
if (driver_vendor == "Advanced Micro Devices, Inc." ||
driver_vendor == "ATI Technologies Inc.") {
// We are conservative and assume that in the absence of a clear
// signal the videocard is assumed to be switchable. Additionally,
// some switchable systems with Intel GPUs aren't correctly
// detected, so always count them.
- AMDVideoCardType amd_card_type = GetAMDVideocardType();
- gpu_info->amd_switchable = (gpu_info->gpu.vendor_id == 0x8086) ||
- (amd_card_type != STANDALONE);
+ GetAMDVideocardInfo(gpu_info);
+ if (!gpu_info->amd_switchable &&
+ gpu_info->gpu.vendor_id == 0x8086) {
+ gpu_info->amd_switchable = true;
+ gpu_info->secondary_gpus.push_back(gpu_info->gpu);
+ gpu_info->gpu.vendor_id = 0x1002;
+ gpu_info->gpu.device_id = 0; // Unknown discrete AMD GPU.
+ }
}
}
@@ -449,7 +458,7 @@ bool CollectDriverInfoD3D(const std::wstring& device_id,
return found;
}
-bool CollectContextGraphicsInfo(GPUInfo* gpu_info) {
+CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) {
TRACE_EVENT0("gpu", "CollectGraphicsInfo");
DCHECK(gpu_info);
@@ -459,12 +468,13 @@ bool CollectContextGraphicsInfo(GPUInfo* gpu_info) {
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL);
if (requested_implementation_name == "swiftshader") {
gpu_info->software_rendering = true;
- return false;
+ return kCollectInfoNonFatalFailure;
}
}
- if (!CollectGraphicsInfoGL(gpu_info))
- return false;
+ CollectInfoResult result = CollectGraphicsInfoGL(gpu_info);
+ if (result != kCollectInfoSuccess)
+ return result;
// ANGLE's renderer strings are of the form:
// ANGLE (<adapter_identifier> Direct3D<version> vs_x_x ps_x_x)
@@ -514,7 +524,7 @@ bool CollectContextGraphicsInfo(GPUInfo* gpu_info) {
gpu_info->finalized = true;
}
- return true;
+ return kCollectInfoSuccess;
}
GpuIDResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
@@ -537,16 +547,17 @@ GpuIDResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
int vendor = 0, device = 0;
std::wstring vendor_string = id.substr(8, 4);
std::wstring device_string = id.substr(17, 4);
- base::HexStringToInt(WideToASCII(vendor_string), &vendor);
- base::HexStringToInt(WideToASCII(device_string), &device);
+ base::HexStringToInt(base::UTF16ToASCII(vendor_string), &vendor);
+ base::HexStringToInt(base::UTF16ToASCII(device_string), &device);
*vendor_id = vendor;
*device_id = device;
- return kGpuIDSuccess;
+ if (*vendor_id != 0 && *device_id != 0)
+ return kGpuIDSuccess;
}
return kGpuIDFailure;
}
-bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
+CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
TRACE_EVENT0("gpu", "CollectPreliminaryGraphicsInfo");
DCHECK(gpu_info);
@@ -587,18 +598,18 @@ bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
}
if (id.length() <= 20)
- return false;
+ return kCollectInfoNonFatalFailure;
int vendor_id = 0, device_id = 0;
base::string16 vendor_id_string = id.substr(8, 4);
base::string16 device_id_string = id.substr(17, 4);
- base::HexStringToInt(WideToASCII(vendor_id_string), &vendor_id);
- base::HexStringToInt(WideToASCII(device_id_string), &device_id);
+ base::HexStringToInt(base::UTF16ToASCII(vendor_id_string), &vendor_id);
+ base::HexStringToInt(base::UTF16ToASCII(device_id_string), &device_id);
gpu_info->gpu.vendor_id = vendor_id;
gpu_info->gpu.device_id = device_id;
// TODO(zmo): we only need to call CollectDriverInfoD3D() if we use ANGLE.
if (!CollectDriverInfoD3D(id, gpu_info))
- return false;
+ return kCollectInfoNonFatalFailure;
// Collect basic information about supported D3D11 features. Delay for 45
// seconds so as not to regress performance tests.
@@ -620,20 +631,18 @@ bool CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
}
}
- return true;
+ return kCollectInfoSuccess;
}
-bool CollectDriverInfoGL(GPUInfo* gpu_info) {
+CollectInfoResult CollectDriverInfoGL(GPUInfo* gpu_info) {
TRACE_EVENT0("gpu", "CollectDriverInfoGL");
if (!gpu_info->driver_version.empty())
- return true;
+ return kCollectInfoSuccess;
- std::string gl_version_string = gpu_info->gl_version_string;
-
- return RE2::PartialMatch(gl_version_string,
- "([\\d\\.]+)$",
- &gpu_info->driver_version);
+ bool parsed = RE2::PartialMatch(
+ gpu_info->gl_version, "([\\d\\.]+)$", &gpu_info->driver_version);
+ return parsed ? kCollectInfoSuccess : kCollectInfoNonFatalFailure;
}
void MergeGPUInfo(GPUInfo* basic_gpu_info,
@@ -650,12 +659,4 @@ void MergeGPUInfo(GPUInfo* basic_gpu_info,
basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics;
}
-bool DetermineActiveGPU(GPUInfo* gpu_info) {
- DCHECK(gpu_info);
- if (gpu_info->secondary_gpus.size() == 0)
- return true;
- // TODO(zmo): implement this.
- return false;
-}
-
} // namespace gpu