Commit 17f7b260 authored by Zhenyao Mo's avatar Zhenyao Mo Committed by Commit Bot

Collect a few rendering related perf metrics and display in about:gpu

BUG=1039792
TEST=bots
R=dcheng@chromium.org,sadrul@chromium.org,behdadb@chromium.org

Change-Id: I430437328cf391a67521f3b111389b4c7881ef30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2055353Reviewed-by: default avatarMaggie Chen <magchen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742916}
parent 1d97c60d
...@@ -114,10 +114,12 @@ void GpuDataManagerImpl::UpdateDxDiagNode( ...@@ -114,10 +114,12 @@ void GpuDataManagerImpl::UpdateDxDiagNode(
private_->UpdateDxDiagNode(dx_diagnostics); private_->UpdateDxDiagNode(dx_diagnostics);
} }
void GpuDataManagerImpl::UpdateDx12VulkanInfo( void GpuDataManagerImpl::UpdateDx12VulkanDevicePerfInfo(
const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info) { const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info,
const gpu::DevicePerfInfo& device_perf_info) {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
private_->UpdateDx12VulkanInfo(dx12_vulkan_version_info); private_->UpdateDx12VulkanDevicePerfInfo(dx12_vulkan_version_info,
device_perf_info);
} }
void GpuDataManagerImpl::UpdateOverlayInfo( void GpuDataManagerImpl::UpdateOverlayInfo(
...@@ -178,6 +180,12 @@ gpu::GpuExtraInfo GpuDataManagerImpl::GetGpuExtraInfo() const { ...@@ -178,6 +180,12 @@ gpu::GpuExtraInfo GpuDataManagerImpl::GetGpuExtraInfo() const {
return private_->GetGpuExtraInfo(); return private_->GetGpuExtraInfo();
} }
base::Optional<gpu::DevicePerfInfo> GpuDataManagerImpl::GetDevicePerfInfo()
const {
base::AutoLock auto_lock(lock_);
return private_->GetDevicePerfInfo();
}
bool GpuDataManagerImpl::IsGpuCompositingDisabled() const { bool GpuDataManagerImpl::IsGpuCompositingDisabled() const {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
return private_->IsGpuCompositingDisabled(); return private_->IsGpuCompositingDisabled();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/three_d_api_types.h" #include "content/public/common/three_d_api_types.h"
#include "gpu/config/device_perf_info.h"
#include "gpu/config/gpu_control_list.h" #include "gpu/config/gpu_control_list.h"
#include "gpu/config/gpu_domain_guilt.h" #include "gpu/config/gpu_domain_guilt.h"
#include "gpu/config/gpu_extra_info.h" #include "gpu/config/gpu_extra_info.h"
...@@ -79,8 +80,9 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager, ...@@ -79,8 +80,9 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager,
const base::Optional<gpu::GPUInfo>& gpu_info_for_hardware_gpu); const base::Optional<gpu::GPUInfo>& gpu_info_for_hardware_gpu);
#if defined(OS_WIN) #if defined(OS_WIN)
void UpdateDxDiagNode(const gpu::DxDiagNode& dx_diagnostics); void UpdateDxDiagNode(const gpu::DxDiagNode& dx_diagnostics);
void UpdateDx12VulkanInfo( void UpdateDx12VulkanDevicePerfInfo(
const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info); const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info,
const gpu::DevicePerfInfo& device_perf_info);
void UpdateOverlayInfo(const gpu::OverlayInfo& overlay_info); void UpdateOverlayInfo(const gpu::OverlayInfo& overlay_info);
void UpdateDxDiagNodeRequestStatus(bool request_continues); void UpdateDxDiagNodeRequestStatus(bool request_continues);
void UpdateDx12VulkanRequestStatus(bool request_continues); void UpdateDx12VulkanRequestStatus(bool request_continues);
...@@ -100,6 +102,8 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager, ...@@ -100,6 +102,8 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager,
gpu::GpuExtraInfo GetGpuExtraInfo() const; gpu::GpuExtraInfo GetGpuExtraInfo() const;
base::Optional<gpu::DevicePerfInfo> GetDevicePerfInfo() const;
bool IsGpuCompositingDisabled() const; bool IsGpuCompositingDisabled() const;
// This only handles the state of GPU compositing. Instead call // This only handles the state of GPU compositing. Instead call
......
...@@ -438,6 +438,20 @@ enum class CompositingMode { ...@@ -438,6 +438,20 @@ enum class CompositingMode {
NOINLINE void IntentionallyCrashBrowserForUnusableGpuProcess() { NOINLINE void IntentionallyCrashBrowserForUnusableGpuProcess() {
LOG(FATAL) << "GPU process isn't usable. Goodbye."; LOG(FATAL) << "GPU process isn't usable. Goodbye.";
} }
#if defined(OS_WIN)
void CollectExtraDevicePerfInfo(const gpu::GPUInfo& gpu_info,
gpu::DevicePerfInfo* device_perf_info) {
device_perf_info->intel_gpu_generation = gpu::GetIntelGpuGeneration(gpu_info);
const gpu::GPUInfo::GPUDevice& device = gpu_info.active_gpu();
if (device.vendor_id == 0xffff /* internal flag for software rendering */ ||
device.vendor_id == 0x15ad /* VMware */ ||
device.vendor_id == 0x1414 /* Microsoft software renderer */ ||
gpu_info.software_rendering /* SwiftShader */) {
device_perf_info->software_rendering = true;
}
}
#endif // OS_WIN
} // anonymous namespace } // anonymous namespace
GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner) GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(GpuDataManagerImpl* owner)
...@@ -560,6 +574,11 @@ gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfoForHardwareGpu() const { ...@@ -560,6 +574,11 @@ gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfoForHardwareGpu() const {
return gpu_info_for_hardware_gpu_; return gpu_info_for_hardware_gpu_;
} }
base::Optional<gpu::DevicePerfInfo>
GpuDataManagerImplPrivate::GetDevicePerfInfo() const {
return device_perf_info_;
}
bool GpuDataManagerImplPrivate::GpuAccessAllowed(std::string* reason) const { bool GpuDataManagerImplPrivate::GpuAccessAllowed(std::string* reason) const {
switch (gpu_mode_) { switch (gpu_mode_) {
case gpu::GpuMode::HARDWARE_GL: case gpu::GpuMode::HARDWARE_GL:
...@@ -675,11 +694,13 @@ void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion( ...@@ -675,11 +694,13 @@ void GpuDataManagerImplPrivate::RequestGpuSupportedRuntimeVersion(
manager->UpdateDx12VulkanRequestStatus(true); manager->UpdateDx12VulkanRequestStatus(true);
host->gpu_service()->GetGpuSupportedRuntimeVersionAndDevicePerfInfo( host->gpu_service()->GetGpuSupportedRuntimeVersionAndDevicePerfInfo(
base::BindOnce([](const gpu::Dx12VulkanVersionInfo& info, base::BindOnce(
const gpu::DevicePerfInfo& device_perf_info) { [](const gpu::Dx12VulkanVersionInfo& dx12_vulkan_info,
GpuDataManagerImpl::GetInstance()->UpdateDx12VulkanInfo(info); const gpu::DevicePerfInfo& device_perf_info) {
// TODO(zmo): Process collected DevicePerfInfo. GpuDataManagerImpl::GetInstance()
})); ->UpdateDx12VulkanDevicePerfInfo(dx12_vulkan_info,
device_perf_info);
}));
}, },
delayed); delayed);
...@@ -811,11 +832,13 @@ void GpuDataManagerImplPrivate::UpdateDxDiagNode( ...@@ -811,11 +832,13 @@ void GpuDataManagerImplPrivate::UpdateDxDiagNode(
NotifyGpuInfoUpdate(); NotifyGpuInfoUpdate();
} }
void GpuDataManagerImplPrivate::UpdateDx12VulkanInfo( void GpuDataManagerImplPrivate::UpdateDx12VulkanDevicePerfInfo(
const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info) { const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info,
const gpu::DevicePerfInfo& device_perf_info) {
gpu_info_.dx12_vulkan_version_info = dx12_vulkan_version_info; gpu_info_.dx12_vulkan_version_info = dx12_vulkan_version_info;
gpu_info_dx12_vulkan_valid_ = true; gpu_info_dx12_vulkan_valid_ = true;
device_perf_info_ = device_perf_info;
CollectExtraDevicePerfInfo(gpu_info_, &(device_perf_info_.value()));
// No need to call GetContentClient()->SetGpuInfo(). // No need to call GetContentClient()->SetGpuInfo().
NotifyGpuInfoUpdate(); NotifyGpuInfoUpdate();
} }
......
...@@ -31,10 +31,6 @@ namespace base { ...@@ -31,10 +31,6 @@ namespace base {
class CommandLine; class CommandLine;
} }
namespace gpu {
struct GpuPreferences;
}
namespace content { namespace content {
class CONTENT_EXPORT GpuDataManagerImplPrivate { class CONTENT_EXPORT GpuDataManagerImplPrivate {
...@@ -66,8 +62,9 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -66,8 +62,9 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
const base::Optional<gpu::GPUInfo>& optional_gpu_info_for_hardware_gpu); const base::Optional<gpu::GPUInfo>& optional_gpu_info_for_hardware_gpu);
#if defined(OS_WIN) #if defined(OS_WIN)
void UpdateDxDiagNode(const gpu::DxDiagNode& dx_diagnostics); void UpdateDxDiagNode(const gpu::DxDiagNode& dx_diagnostics);
void UpdateDx12VulkanInfo( void UpdateDx12VulkanDevicePerfInfo(
const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info); const gpu::Dx12VulkanVersionInfo& dx12_vulkan_version_info,
const gpu::DevicePerfInfo& device_perf_info);
void UpdateOverlayInfo(const gpu::OverlayInfo& overlay_info); void UpdateOverlayInfo(const gpu::OverlayInfo& overlay_info);
void UpdateDx12VulkanRequestStatus(bool request_continues); void UpdateDx12VulkanRequestStatus(bool request_continues);
void UpdateDxDiagNodeRequestStatus(bool request_continues); void UpdateDxDiagNodeRequestStatus(bool request_continues);
...@@ -81,6 +78,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -81,6 +78,7 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
gpu::GpuFeatureInfo GetGpuFeatureInfo() const; gpu::GpuFeatureInfo GetGpuFeatureInfo() const;
gpu::GpuFeatureInfo GetGpuFeatureInfoForHardwareGpu() const; gpu::GpuFeatureInfo GetGpuFeatureInfoForHardwareGpu() const;
gpu::GpuExtraInfo GetGpuExtraInfo() const; gpu::GpuExtraInfo GetGpuExtraInfo() const;
base::Optional<gpu::DevicePerfInfo> GetDevicePerfInfo() const;
bool IsGpuCompositingDisabled() const; bool IsGpuCompositingDisabled() const;
...@@ -218,6 +216,8 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -218,6 +216,8 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
gpu::GpuExtraInfo gpu_extra_info_; gpu::GpuExtraInfo gpu_extra_info_;
base::Optional<gpu::DevicePerfInfo> device_perf_info_;
const scoped_refptr<GpuDataManagerObserverList> observer_list_; const scoped_refptr<GpuDataManagerObserverList> observer_list_;
// Periodically calls RecordCompositingMode() for compositing mode UMA. // Periodically calls RecordCompositingMode() for compositing mode UMA.
......
...@@ -391,7 +391,7 @@ std::unique_ptr<base::ListValue> GpuMemoryBufferInfo( ...@@ -391,7 +391,7 @@ std::unique_ptr<base::ListValue> GpuMemoryBufferInfo(
return gpu_memory_buffer_info; return gpu_memory_buffer_info;
} }
std::unique_ptr<base::ListValue> getDisplayInfo() { std::unique_ptr<base::ListValue> GetDisplayInfo() {
auto display_info = std::make_unique<base::ListValue>(); auto display_info = std::make_unique<base::ListValue>();
const std::vector<display::Display> displays = const std::vector<display::Display> displays =
display::Screen::GetScreen()->GetAllDisplays(); display::Screen::GetScreen()->GetAllDisplays();
...@@ -428,6 +428,74 @@ std::unique_ptr<base::ListValue> getDisplayInfo() { ...@@ -428,6 +428,74 @@ std::unique_ptr<base::ListValue> getDisplayInfo() {
return display_info; return display_info;
} }
#if defined(OS_WIN)
const char* D3dFeatureLevelToString(D3D_FEATURE_LEVEL level) {
#define MAP_D3D_FEATURE_LEVEL_TO_STRING(LEVEL) \
case LEVEL: \
return #LEVEL;
switch (level) {
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_1_0_CORE)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_9_1)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_9_2)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_9_3)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_10_0)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_10_1)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_11_0)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_11_1)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_12_0)
MAP_D3D_FEATURE_LEVEL_TO_STRING(D3D_FEATURE_LEVEL_12_1)
}
#undef MAP_D3D_FEATURE_LEVEL_TO_STRING
}
#endif // OS_WIN
std::unique_ptr<base::ListValue> GetDevicePerfInfo() {
auto list = std::make_unique<base::ListValue>();
const base::Optional<gpu::DevicePerfInfo> device_perf_info =
GpuDataManagerImpl::GetInstance()->GetDevicePerfInfo();
if (device_perf_info.has_value()) {
list->Append(NewDescriptionValuePair(
"Total Physical Memory (Gb)",
base::NumberToString(device_perf_info->total_physical_memory_mb /
1024)));
list->Append(NewDescriptionValuePair(
"Total Disk Space (Gb)",
base::NumberToString(device_perf_info->total_disk_space_mb / 1024)));
list->Append(NewDescriptionValuePair(
"Hardware Concurrency",
base::NumberToString(device_perf_info->hardware_concurrency)));
#if defined(OS_WIN)
list->Append(NewDescriptionValuePair(
"System Commit Limit (Gb)",
base::NumberToString(device_perf_info->system_commit_limit_mb / 1024)));
list->Append(NewDescriptionValuePair(
"D3D11 Feature Level",
D3dFeatureLevelToString(device_perf_info->d3d11_feature_level)));
list->Append(NewDescriptionValuePair(
"Has Discrete GPU", device_perf_info->has_discrete_gpu ? "Yes" : "No"));
#endif // OS_WIN
if (device_perf_info->intel_gpu_generation !=
gpu::IntelGpuGeneration::kNonIntel) {
std::string intel_gpu_gen;
if (device_perf_info->intel_gpu_generation ==
gpu::IntelGpuGeneration::kUnknownIntel) {
intel_gpu_gen = "unknown";
} else {
intel_gpu_gen = base::NumberToString(
static_cast<int>(device_perf_info->intel_gpu_generation));
}
list->Append(
NewDescriptionValuePair("Intel GPU Generation", intel_gpu_gen));
}
list->Append(NewDescriptionValuePair(
"Software Rendering",
device_perf_info->software_rendering ? "Yes" : "No"));
}
return list;
}
const char* GetProfileName(gpu::VideoCodecProfile profile) { const char* GetProfileName(gpu::VideoCodecProfile profile) {
switch (profile) { switch (profile) {
case gpu::VIDEO_CODEC_PROFILE_UNKNOWN: case gpu::VIDEO_CODEC_PROFILE_UNKNOWN:
...@@ -743,9 +811,10 @@ void GpuMessageHandler::OnGpuInfoUpdate() { ...@@ -743,9 +811,10 @@ void GpuMessageHandler::OnGpuInfoUpdate() {
} }
gpu_info_val->Set("compositorInfo", CompositorInfo()); gpu_info_val->Set("compositorInfo", CompositorInfo());
gpu_info_val->Set("gpuMemoryBufferInfo", GpuMemoryBufferInfo(gpu_extra_info)); gpu_info_val->Set("gpuMemoryBufferInfo", GpuMemoryBufferInfo(gpu_extra_info));
gpu_info_val->Set("displayInfo", getDisplayInfo()); gpu_info_val->Set("displayInfo", GetDisplayInfo());
gpu_info_val->Set("videoAcceleratorsInfo", GetVideoAcceleratorsInfo()); gpu_info_val->Set("videoAcceleratorsInfo", GetVideoAcceleratorsInfo());
gpu_info_val->Set("ANGLEFeatures", GetANGLEFeatures()); gpu_info_val->Set("ANGLEFeatures", GetANGLEFeatures());
gpu_info_val->Set("devicePerfInfo", GetDevicePerfInfo());
// Send GPU Info to javascript. // Send GPU Info to javascript.
web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onGpuInfoUpdate", web_ui()->CallJavascriptFunctionUnsafe("browserBridge.onGpuInfoUpdate",
......
...@@ -66,6 +66,11 @@ found in the LICENSE file. ...@@ -66,6 +66,11 @@ found in the LICENSE file.
<div id="vulkan-info"></div> <div id="vulkan-info"></div>
</div> </div>
<div>
<h3>Device Performance Information</h3>
<div id="device-perf-info"></div>
</div>
<div class="diagnostics"> <div class="diagnostics">
<h3>Diagnostics</h3> <h3>Diagnostics</h3>
<div class="diagnostics-loading">... loading ...</div> <div class="diagnostics-loading">... loading ...</div>
......
...@@ -224,6 +224,11 @@ cr.define('gpu', function() { ...@@ -224,6 +224,11 @@ cr.define('gpu', function() {
this.setTable_('vulkan-info', []); this.setTable_('vulkan-info', []);
} }
if (gpuInfo.devicePerfInfo) {
this.setTable_('device-perf-info', gpuInfo.devicePerfInfo);
} else {
this.setTable_('device-perf-info', []);
}
} else { } else {
this.setText_('basic-info', '... loading ...'); this.setText_('basic-info', '... loading ...');
diagnosticsDiv.hidden = true; diagnosticsDiv.hidden = true;
......
...@@ -8,12 +8,49 @@ ...@@ -8,12 +8,49 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "build/build_config.h"
#include "gpu/gpu_export.h" #include "gpu/gpu_export.h"
#if defined(OS_WIN)
#include <d3dcommon.h>
#endif
namespace gpu { namespace gpu {
enum class IntelGpuGeneration {
kNonIntel = -1,
kUnknownIntel = 0, // Intel GPU, but not one of the following generations.
kGen1 = 1,
kGen2 = 2,
kGen3 = 3,
kGen4 = 4,
kGen5 = 5,
kGen6 = 6,
kGen7 = 7,
kGen8 = 8,
kGen9 = 9,
kGen10 = 10,
kGen11 = 11,
kGen12 = 12,
kMaxValue = kGen12,
};
struct GPU_EXPORT DevicePerfInfo { struct GPU_EXPORT DevicePerfInfo {
uint32_t score = 0; uint32_t total_physical_memory_mb = 0u;
uint32_t total_disk_space_mb = 0u;
uint32_t hardware_concurrency = 0u;
#if defined(OS_WIN)
// system commit limit (n pages) x page size.
uint32_t system_commit_limit_mb = 0u;
// If multiple GPUs are detected, this holds the highest feature level.
D3D_FEATURE_LEVEL d3d11_feature_level = D3D_FEATURE_LEVEL_1_0_CORE;
bool has_discrete_gpu = false;
#endif
// The following fields are only filled on the browser side. They don't
// need to be part of mojom.
IntelGpuGeneration intel_gpu_generation = IntelGpuGeneration::kNonIntel;
bool software_rendering = false;
}; };
} // namespace gpu } // namespace gpu
......
...@@ -4,16 +4,27 @@ ...@@ -4,16 +4,27 @@
#include "gpu/config/gpu_util.h" #include "gpu/config/gpu_util.h"
#if defined(OS_WIN)
#include <windows.h>
// Must be included after windows.h.
#include <psapi.h>
#endif // OS_WIN
#include <memory> #include <memory>
#include <set> #include <set>
#include <string> #include <string>
#include <thread>
#include <vector> #include <vector>
#include "base/base_paths.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "gpu/config/device_perf_info.h"
#include "gpu/config/gpu_blocklist.h" #include "gpu/config/gpu_blocklist.h"
#include "gpu/config/gpu_crash_keys.h" #include "gpu/config/gpu_crash_keys.h"
#include "gpu/config/gpu_driver_bug_list.h" #include "gpu/config/gpu_driver_bug_list.h"
...@@ -290,6 +301,55 @@ void AdjustGpuFeatureStatusToWorkarounds(GpuFeatureInfo* gpu_feature_info) { ...@@ -290,6 +301,55 @@ void AdjustGpuFeatureStatusToWorkarounds(GpuFeatureInfo* gpu_feature_info) {
} }
} }
// Estimates roughly user total disk space by counting in the drives where
// the exe is, where the temporary space is, where the user home is.
// If total space and free space are of the same size, they are considered
// the same drive. There could be corner cases this estimation is far from
// the actual total disk space, but for histogram purpose, limited numbers
// of outliers do not matter.
uint32_t EstimateAmountOfTotalDiskSpaceMB() {
const base::BasePathKey kPathKeys[] = {base::DIR_EXE, base::DIR_TEMP,
base::DIR_HOME};
std::vector<uint32_t> total_space_vector, free_space_vector;
uint32_t sum = 0;
for (const auto& path_key : kPathKeys) {
base::FilePath path;
if (base::PathService::Get(path_key, &path)) {
uint32_t total_space = static_cast<uint32_t>(
base::SysInfo::AmountOfTotalDiskSpace(path) / 1024 / 1024);
uint32_t free_space = static_cast<uint32_t>(
base::SysInfo::AmountOfFreeDiskSpace(path) / 1024 / 1024);
bool duplicated = false;
for (size_t ii = 0; ii < total_space_vector.size(); ++ii) {
if (total_space == total_space_vector[ii] &&
free_space == free_space_vector[ii]) {
duplicated = true;
break;
}
}
if (!duplicated) {
total_space_vector.push_back(total_space);
free_space_vector.push_back(free_space);
sum += total_space;
}
}
}
return sum;
}
#if defined(OS_WIN)
uint32_t GetSystemCommitLimitMb() {
PERFORMANCE_INFORMATION perf_info = {sizeof(perf_info)};
if (::GetPerformanceInfo(&perf_info, sizeof(perf_info))) {
uint64_t limit = perf_info.CommitLimit;
limit *= perf_info.PageSize;
limit /= 1024 * 1024;
return static_cast<uint32_t>(limit);
}
return 0u;
}
#endif // OS_WIN
GPUInfo* g_gpu_info_cache = nullptr; GPUInfo* g_gpu_info_cache = nullptr;
GpuFeatureInfo* g_gpu_feature_info_cache = nullptr; GpuFeatureInfo* g_gpu_feature_info_cache = nullptr;
...@@ -780,6 +840,46 @@ std::string GetIntelGpuGeneration(uint32_t vendor_id, uint32_t device_id) { ...@@ -780,6 +840,46 @@ std::string GetIntelGpuGeneration(uint32_t vendor_id, uint32_t device_id) {
return ""; return "";
} }
IntelGpuGeneration GetIntelGpuGeneration(const GPUInfo& gpu_info) {
const uint32_t kIntelVendorId = 0x8086;
IntelGpuGeneration latest = IntelGpuGeneration::kNonIntel;
std::vector<uint32_t> intel_device_ids;
if (gpu_info.gpu.vendor_id == kIntelVendorId)
intel_device_ids.push_back(gpu_info.gpu.device_id);
for (const auto& gpu : gpu_info.secondary_gpus) {
if (gpu.vendor_id == kIntelVendorId)
intel_device_ids.push_back(gpu.device_id);
}
if (intel_device_ids.empty())
return latest;
latest = IntelGpuGeneration::kUnknownIntel;
for (uint32_t device_id : intel_device_ids) {
std::string gen_str = gpu::GetIntelGpuGeneration(kIntelVendorId, device_id);
int gen_int = 0;
if (gen_str.empty() || !base::StringToInt(gen_str, &gen_int))
continue;
DCHECK_GE(gen_int, static_cast<int>(IntelGpuGeneration::kUnknownIntel));
DCHECK_LE(gen_int, static_cast<int>(IntelGpuGeneration::kMaxValue));
if (gen_int > static_cast<int>(latest))
latest = static_cast<IntelGpuGeneration>(gen_int);
}
return latest;
}
void CollectDevicePerfInfo(DevicePerfInfo* device_perf_info) {
DCHECK(device_perf_info);
device_perf_info->total_physical_memory_mb =
static_cast<uint32_t>(base::SysInfo::AmountOfPhysicalMemoryMB());
device_perf_info->total_disk_space_mb = EstimateAmountOfTotalDiskSpaceMB();
device_perf_info->hardware_concurrency =
static_cast<uint32_t>(std::thread::hardware_concurrency());
#if defined(OS_WIN)
device_perf_info->system_commit_limit_mb = GetSystemCommitLimitMb();
// TODO(zmo): Collect |d3d11_feature_level| and |has_discrete_gpu|.
#endif
}
#if defined(OS_WIN) #if defined(OS_WIN)
std::string D3DFeatureLevelToString(uint32_t d3d_feature_level) { std::string D3DFeatureLevelToString(uint32_t d3d_feature_level) {
if (d3d_feature_level == 0) { if (d3d_feature_level == 0) {
......
...@@ -15,9 +15,11 @@ class CommandLine; ...@@ -15,9 +15,11 @@ class CommandLine;
namespace gpu { namespace gpu {
struct DevicePerfInfo;
struct GPUInfo; struct GPUInfo;
struct GpuPreferences; struct GpuPreferences;
enum class GpuSeriesType; enum class GpuSeriesType;
enum class IntelGpuGeneration;
// Set GPU feature status if hardware acceleration is disabled. // Set GPU feature status if hardware acceleration is disabled.
GPU_EXPORT GpuFeatureInfo GPU_EXPORT GpuFeatureInfo
...@@ -80,6 +82,11 @@ GPU_EXPORT GpuSeriesType GetGpuSeriesType(uint32_t vendor_id, ...@@ -80,6 +82,11 @@ GPU_EXPORT GpuSeriesType GetGpuSeriesType(uint32_t vendor_id,
GPU_EXPORT std::string GetIntelGpuGeneration(uint32_t vendor_id, GPU_EXPORT std::string GetIntelGpuGeneration(uint32_t vendor_id,
uint32_t device_id); uint32_t device_id);
// If multiple Intel GPUs are detected, this returns the latest generation.
GPU_EXPORT IntelGpuGeneration GetIntelGpuGeneration(const GPUInfo& gpu_info);
GPU_EXPORT void CollectDevicePerfInfo(DevicePerfInfo* device_perf_info);
#if defined(OS_WIN) #if defined(OS_WIN)
GPU_EXPORT std::string D3DFeatureLevelToString(uint32_t d3d_feature_level); GPU_EXPORT std::string D3DFeatureLevelToString(uint32_t d3d_feature_level);
GPU_EXPORT std::string VulkanVersionToString(uint32_t vulkan_version); GPU_EXPORT std::string VulkanVersionToString(uint32_t vulkan_version);
......
...@@ -4,7 +4,30 @@ ...@@ -4,7 +4,30 @@
module gpu.mojom; module gpu.mojom;
// Corresponds to |gpu::DevicePerfInfo| in file gpu/config/device_perf_info.h // Corresponds to D3D_FEATURE_LEVEL in <d3dcommon.h>
enum Direct3DFeatureLevel {
k1_0_Core,
k9_1,
k9_2,
k9_3,
k10_0,
k10_1,
k11_0,
k11_1,
k12_0,
k12_1,
};
// Corresponds to |gpu::DevicePerfInfo| in "gpu/config/device_perf_info.h"
struct DevicePerfInfo { struct DevicePerfInfo {
uint32 score; uint32 total_physical_memory_mb;
uint32 total_disk_space_mb;
uint32 hardware_concurrency;
[EnableIf=is_win]
uint32 system_commit_limit_mb;
[EnableIf=is_win]
Direct3DFeatureLevel d3d11_feature_level;
[EnableIf=is_win]
bool has_discrete_gpu;
}; };
...@@ -6,4 +6,8 @@ mojom = "//gpu/ipc/common/device_perf_info.mojom" ...@@ -6,4 +6,8 @@ mojom = "//gpu/ipc/common/device_perf_info.mojom"
public_headers = [ "//gpu/config/device_perf_info.h" ] public_headers = [ "//gpu/config/device_perf_info.h" ]
traits_headers = [ "//gpu/ipc/common/device_perf_info_mojom_traits.h" ] traits_headers = [ "//gpu/ipc/common/device_perf_info_mojom_traits.h" ]
sources = [ "//gpu/ipc/common/device_perf_info_mojom_traits.cc" ] sources = [ "//gpu/ipc/common/device_perf_info_mojom_traits.cc" ]
type_mappings = [ "gpu.mojom.DevicePerfInfo=::gpu::DevicePerfInfo" ] type_mappings = [
"gpu.mojom.IntelGpuGeneration=::gpu::IntelGpuGeneration",
"gpu.mojom.D3D_FEATURE_LEVEL=::D3D_FEATURE_LEVEL",
"gpu.mojom.DevicePerfInfo=::gpu::DevicePerfInfo",
]
...@@ -6,11 +6,91 @@ ...@@ -6,11 +6,91 @@
namespace mojo { namespace mojo {
#if defined(OS_WIN)
// static
gpu::mojom::Direct3DFeatureLevel
EnumTraits<gpu::mojom::Direct3DFeatureLevel, D3D_FEATURE_LEVEL>::ToMojom(
D3D_FEATURE_LEVEL d3d_feature_level) {
switch (d3d_feature_level) {
case D3D_FEATURE_LEVEL_1_0_CORE:
return gpu::mojom::Direct3DFeatureLevel::k1_0_Core;
case D3D_FEATURE_LEVEL_9_1:
return gpu::mojom::Direct3DFeatureLevel::k9_1;
case D3D_FEATURE_LEVEL_9_2:
return gpu::mojom::Direct3DFeatureLevel::k9_2;
case D3D_FEATURE_LEVEL_9_3:
return gpu::mojom::Direct3DFeatureLevel::k9_3;
case D3D_FEATURE_LEVEL_10_0:
return gpu::mojom::Direct3DFeatureLevel::k10_0;
case D3D_FEATURE_LEVEL_10_1:
return gpu::mojom::Direct3DFeatureLevel::k10_1;
case D3D_FEATURE_LEVEL_11_0:
return gpu::mojom::Direct3DFeatureLevel::k11_0;
case D3D_FEATURE_LEVEL_11_1:
return gpu::mojom::Direct3DFeatureLevel::k11_1;
case D3D_FEATURE_LEVEL_12_0:
return gpu::mojom::Direct3DFeatureLevel::k12_0;
case D3D_FEATURE_LEVEL_12_1:
return gpu::mojom::Direct3DFeatureLevel::k12_1;
}
NOTREACHED() << "Invalid D3D_FEATURE_LEVEL:" << d3d_feature_level;
return gpu::mojom::Direct3DFeatureLevel::k1_0_Core;
}
// static
bool EnumTraits<gpu::mojom::Direct3DFeatureLevel, D3D_FEATURE_LEVEL>::FromMojom(
gpu::mojom::Direct3DFeatureLevel input,
D3D_FEATURE_LEVEL* out) {
switch (input) {
case gpu::mojom::Direct3DFeatureLevel::k1_0_Core:
*out = D3D_FEATURE_LEVEL_1_0_CORE;
return true;
case gpu::mojom::Direct3DFeatureLevel::k9_1:
*out = D3D_FEATURE_LEVEL_9_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k9_2:
*out = D3D_FEATURE_LEVEL_9_2;
return true;
case gpu::mojom::Direct3DFeatureLevel::k9_3:
*out = D3D_FEATURE_LEVEL_9_3;
return true;
case gpu::mojom::Direct3DFeatureLevel::k10_0:
*out = D3D_FEATURE_LEVEL_10_0;
return true;
case gpu::mojom::Direct3DFeatureLevel::k10_1:
*out = D3D_FEATURE_LEVEL_10_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k11_0:
*out = D3D_FEATURE_LEVEL_11_0;
return true;
case gpu::mojom::Direct3DFeatureLevel::k11_1:
*out = D3D_FEATURE_LEVEL_11_1;
return true;
case gpu::mojom::Direct3DFeatureLevel::k12_0:
*out = D3D_FEATURE_LEVEL_12_0;
return true;
case gpu::mojom::Direct3DFeatureLevel::k12_1:
*out = D3D_FEATURE_LEVEL_12_1;
return true;
}
NOTREACHED() << "Invalid D3D_FEATURE_LEVEL: " << input;
return false;
}
#endif // OS_WIN
// static // static
bool StructTraits<gpu::mojom::DevicePerfInfoDataView, gpu::DevicePerfInfo>:: bool StructTraits<gpu::mojom::DevicePerfInfoDataView, gpu::DevicePerfInfo>::
Read(gpu::mojom::DevicePerfInfoDataView data, gpu::DevicePerfInfo* out) { Read(gpu::mojom::DevicePerfInfoDataView data, gpu::DevicePerfInfo* out) {
out->score = data.score(); out->total_physical_memory_mb = data.total_physical_memory_mb();
return true; out->total_disk_space_mb = data.total_disk_space_mb();
out->hardware_concurrency = data.hardware_concurrency();
bool rt = true;
#if defined(OS_WIN)
out->system_commit_limit_mb = data.system_commit_limit_mb();
rt &= data.ReadD3d11FeatureLevel(&out->d3d11_feature_level);
out->has_discrete_gpu = data.has_discrete_gpu();
#endif // OS_WIN
return rt;
} }
} // namespace mojo } // namespace mojo
...@@ -7,14 +7,51 @@ ...@@ -7,14 +7,51 @@
#include "gpu/ipc/common/device_perf_info.mojom.h" #include "gpu/ipc/common/device_perf_info.mojom.h"
#include "build/build_config.h"
namespace mojo { namespace mojo {
#if defined(OS_WIN)
template <>
struct EnumTraits<gpu::mojom::Direct3DFeatureLevel, D3D_FEATURE_LEVEL> {
static gpu::mojom::Direct3DFeatureLevel ToMojom(
D3D_FEATURE_LEVEL d3d_feature_level);
static bool FromMojom(gpu::mojom::Direct3DFeatureLevel input,
D3D_FEATURE_LEVEL* out);
};
#endif // OS_WIN
template <> template <>
struct StructTraits<gpu::mojom::DevicePerfInfoDataView, gpu::DevicePerfInfo> { struct StructTraits<gpu::mojom::DevicePerfInfoDataView, gpu::DevicePerfInfo> {
static bool Read(gpu::mojom::DevicePerfInfoDataView data, static bool Read(gpu::mojom::DevicePerfInfoDataView data,
gpu::DevicePerfInfo* out); gpu::DevicePerfInfo* out);
static uint32_t score(const gpu::DevicePerfInfo& info) { return info.score; } static uint32_t total_physical_memory_mb(const gpu::DevicePerfInfo& info) {
return info.total_physical_memory_mb;
}
static uint32_t total_disk_space_mb(const gpu::DevicePerfInfo& info) {
return info.total_disk_space_mb;
}
static uint32_t hardware_concurrency(const gpu::DevicePerfInfo& info) {
return info.hardware_concurrency;
}
#if defined(OS_WIN)
static uint32_t system_commit_limit_mb(const gpu::DevicePerfInfo& info) {
return info.system_commit_limit_mb;
}
static D3D_FEATURE_LEVEL d3d11_feature_level(
const gpu::DevicePerfInfo& info) {
return info.d3d11_feature_level;
}
static bool has_discrete_gpu(const gpu::DevicePerfInfo& info) {
return info.has_discrete_gpu;
}
#endif
}; };
} // namespace mojo } // namespace mojo
......
...@@ -113,12 +113,6 @@ class GpuWatchdogInit { ...@@ -113,12 +113,6 @@ class GpuWatchdogInit {
private: private:
gpu::GpuWatchdogThread* watchdog_ptr_ = nullptr; gpu::GpuWatchdogThread* watchdog_ptr_ = nullptr;
}; };
DevicePerfInfo CollectDevicePerfInfo() {
// TODO(zmo): Collect perf info.
DevicePerfInfo info;
return info;
}
} // namespace } // namespace
GpuInit::GpuInit() = default; GpuInit::GpuInit() = default;
...@@ -133,7 +127,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -133,7 +127,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
if (gpu_preferences_.enable_perf_data_collection) { if (gpu_preferences_.enable_perf_data_collection) {
// This is only enabled on the info collection GPU process. // This is only enabled on the info collection GPU process.
device_perf_info_ = CollectDevicePerfInfo(); DevicePerfInfo device_perf_info;
CollectDevicePerfInfo(&device_perf_info);
device_perf_info_ = device_perf_info;
} }
// Blacklist decisions based on basic GPUInfo may not be final. It might // Blacklist decisions based on basic GPUInfo may not be final. It might
...@@ -172,6 +168,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, ...@@ -172,6 +168,7 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line,
gpu_info_, gpu_preferences_, command_line, &needs_more_info); gpu_info_, gpu_preferences_, command_line, &needs_more_info);
} }
#endif // !OS_ANDROID && !BUILDFLAG(IS_CHROMECAST) #endif // !OS_ANDROID && !BUILDFLAG(IS_CHROMECAST)
gpu_info_.in_process_gpu = false; gpu_info_.in_process_gpu = false;
bool use_swiftshader = false; bool use_swiftshader = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment