Commit 07bb169a authored by Jonah Ryan-Davis's avatar Jonah Ryan-Davis Committed by Chromium LUCI CQ

Populate secondary GPU info after GPU switch on Mac.

The secondary GPU was not populated with information taken from GL
strings after a GPU switch. This CL addresses this by re-querying
this information each time the GPU is switched.
The active GPU in dual-GPU systems is now computed in the GPU
process and communicated back to the browser process. The
heuristic GpuDataManagerImpl::UpdateActiveGpu has been removed.

Bug: chromium:1152212
Change-Id: Ie54dd5dc06c3d0a1c5f0445cc0f313adc8fa24cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560552Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Cr-Commit-Position: refs/heads/master@{#832610}
parent 72c52cf1
...@@ -507,6 +507,10 @@ void GpuHostImpl::DisableGpuCompositing() { ...@@ -507,6 +507,10 @@ void GpuHostImpl::DisableGpuCompositing() {
delegate_->DisableGpuCompositing(); delegate_->DisableGpuCompositing();
} }
void GpuHostImpl::DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) {
delegate_->DidUpdateGPUInfo(gpu_info);
}
#if defined(OS_WIN) #if defined(OS_WIN)
void GpuHostImpl::DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) { void GpuHostImpl::DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) {
delegate_->DidUpdateOverlayInfo(overlay_info); delegate_->DidUpdateOverlayInfo(overlay_info);
......
...@@ -71,6 +71,7 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost { ...@@ -71,6 +71,7 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost {
virtual void DidFailInitialize() = 0; virtual void DidFailInitialize() = 0;
virtual void DidCreateContextSuccessfully() = 0; virtual void DidCreateContextSuccessfully() = 0;
virtual void MaybeShutdownGpuProcess() = 0; virtual void MaybeShutdownGpuProcess() = 0;
virtual void DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) = 0;
#if defined(OS_WIN) #if defined(OS_WIN)
virtual void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) = 0; virtual void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) = 0;
virtual void DidUpdateHDRStatus(bool hdr_enabled) = 0; virtual void DidUpdateHDRStatus(bool hdr_enabled) = 0;
...@@ -225,6 +226,7 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost { ...@@ -225,6 +226,7 @@ class VIZ_HOST_EXPORT GpuHostImpl : public mojom::GpuHost {
gpu::error::ContextLostReason reason, gpu::error::ContextLostReason reason,
const GURL& active_url) override; const GURL& active_url) override;
void DisableGpuCompositing() override; void DisableGpuCompositing() override;
void DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) override;
#if defined(OS_WIN) #if defined(OS_WIN)
void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) override; void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) override;
void DidUpdateHDRStatus(bool hdr_enabled) override; void DidUpdateHDRStatus(bool hdr_enabled) override;
......
...@@ -968,9 +968,12 @@ void GpuServiceImpl::WakeUpGpu() { ...@@ -968,9 +968,12 @@ void GpuServiceImpl::WakeUpGpu() {
void GpuServiceImpl::GpuSwitched(gl::GpuPreference active_gpu_heuristic) { void GpuServiceImpl::GpuSwitched(gl::GpuPreference active_gpu_heuristic) {
DVLOG(1) << "GPU: GPU has switched"; DVLOG(1) << "GPU: GPU has switched";
if (!in_host_process()) if (!in_host_process()) {
ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched( ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(
active_gpu_heuristic); active_gpu_heuristic);
gpu::CollectGraphicsInfoGL(&gpu_info_);
gpu_host_->DidUpdateGPUInfo(gpu_info_);
}
} }
void GpuServiceImpl::DisplayAdded() { void GpuServiceImpl::DisplayAdded() {
......
...@@ -328,12 +328,6 @@ void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() { ...@@ -328,12 +328,6 @@ void GpuDataManagerImpl::DisableDomainBlockingFor3DAPIsForTesting() {
private_->DisableDomainBlockingFor3DAPIsForTesting(); private_->DisableDomainBlockingFor3DAPIsForTesting();
} }
bool GpuDataManagerImpl::UpdateActiveGpu(uint32_t vendor_id,
uint32_t device_id) {
base::AutoLock auto_lock(lock_);
return private_->UpdateActiveGpu(vendor_id, device_id);
}
gpu::GpuMode GpuDataManagerImpl::GetGpuMode() const { gpu::GpuMode GpuDataManagerImpl::GetGpuMode() const {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
return private_->GetGpuMode(); return private_->GetGpuMode();
......
...@@ -151,10 +151,6 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager, ...@@ -151,10 +151,6 @@ class CONTENT_EXPORT GpuDataManagerImpl : public GpuDataManager,
// Disables domain blocking for 3D APIs. For use only in tests. // Disables domain blocking for 3D APIs. For use only in tests.
void DisableDomainBlockingFor3DAPIsForTesting(); void DisableDomainBlockingFor3DAPIsForTesting();
// Set the active gpu.
// Return true if it's a different GPU from the previous active one.
bool UpdateActiveGpu(uint32_t vendor_id, uint32_t device_id);
// Return mode describing what the GPU process will be launched to run. // Return mode describing what the GPU process will be launched to run.
gpu::GpuMode GetGpuMode() const; gpu::GpuMode GetGpuMode() const;
......
...@@ -330,17 +330,7 @@ void DisplayReconfigCallback(CGDirectDisplayID display, ...@@ -330,17 +330,7 @@ void DisplayReconfigCallback(CGDirectDisplayID display,
reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager); reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager);
DCHECK(manager); DCHECK(manager);
bool gpu_changed = false; manager->HandleGpuSwitch();
if (flags & kCGDisplayAddFlag) {
gpu::GPUInfo gpu_info;
if (gpu::CollectBasicGraphicsInfo(&gpu_info)) {
gpu_changed = manager->UpdateActiveGpu(gpu_info.active_gpu().vendor_id,
gpu_info.active_gpu().device_id);
}
}
if (gpu_changed)
manager->HandleGpuSwitch();
} }
#endif // OS_MAC #endif // OS_MAC
...@@ -1374,70 +1364,6 @@ void GpuDataManagerImplPrivate::OnDisplayMetricsChanged( ...@@ -1374,70 +1364,6 @@ void GpuDataManagerImplPrivate::OnDisplayMetricsChanged(
})); }));
} }
bool GpuDataManagerImplPrivate::UpdateActiveGpu(uint32_t vendor_id,
uint32_t device_id) {
// Heuristics for dual-GPU detection.
#if defined(OS_WIN)
// On Windows, "Microsoft Basic Render Driver" now shows up as a
// secondary GPU.
bool is_dual_gpu = gpu_info_.secondary_gpus.size() == 2;
#else
bool is_dual_gpu = gpu_info_.secondary_gpus.size() == 1;
#endif
// TODO(kbr/zmo): on Windows, at least, it's now possible to have a
// system with both low-power and high-performance GPUs from AMD.
const uint32_t kIntelID = 0x8086;
bool saw_intel_gpu = false;
bool saw_non_intel_gpu = false;
if (gpu_info_.gpu.vendor_id == vendor_id &&
gpu_info_.gpu.device_id == device_id) {
// The primary GPU is active.
if (gpu_info_.gpu.active)
return false;
gpu_info_.gpu.active = true;
for (size_t ii = 0; ii < gpu_info_.secondary_gpus.size(); ++ii) {
gpu_info_.secondary_gpus[ii].active = false;
}
} else {
// A secondary GPU is active.
for (size_t ii = 0; ii < gpu_info_.secondary_gpus.size(); ++ii) {
if (gpu_info_.secondary_gpus[ii].vendor_id == vendor_id &&
gpu_info_.secondary_gpus[ii].device_id == device_id) {
if (gpu_info_.secondary_gpus[ii].active)
return false;
gpu_info_.secondary_gpus[ii].active = true;
} else {
gpu_info_.secondary_gpus[ii].active = false;
}
}
gpu_info_.gpu.active = false;
}
active_gpu_heuristic_ = gl::GpuPreference::kDefault;
if (is_dual_gpu) {
if (gpu_info_.gpu.vendor_id == kIntelID) {
saw_intel_gpu = true;
} else {
saw_non_intel_gpu = true;
}
if (gpu_info_.secondary_gpus[0].vendor_id == kIntelID) {
saw_intel_gpu = true;
} else {
saw_non_intel_gpu = true;
}
if (saw_intel_gpu && saw_non_intel_gpu) {
if (vendor_id == kIntelID) {
active_gpu_heuristic_ = gl::GpuPreference::kLowPower;
} else {
active_gpu_heuristic_ = gl::GpuPreference::kHighPerformance;
}
}
}
GetContentClient()->SetGpuInfo(gpu_info_);
NotifyGpuInfoUpdate();
return true;
}
void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs(const GURL& url, void GpuDataManagerImplPrivate::BlockDomainFrom3DAPIs(const GURL& url,
gpu::DomainGuilt guilt) { gpu::DomainGuilt guilt) {
BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now()); BlockDomainFrom3DAPIsAtTime(url, guilt, base::Time::Now());
......
...@@ -116,8 +116,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate { ...@@ -116,8 +116,6 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
int render_frame_id, int render_frame_id,
ThreeDAPIType requester); ThreeDAPIType requester);
bool UpdateActiveGpu(uint32_t vendor_id, uint32_t device_id);
gpu::GpuMode GetGpuMode() const; gpu::GpuMode GetGpuMode() const;
void FallBackToNextGpuMode(); void FallBackToNextGpuMode();
......
...@@ -51,15 +51,6 @@ ...@@ -51,15 +51,6 @@
"features": [ "features": [
"all" "all"
] ]
},
{
"id": 7,
"description": "GpuDataManagerImplPrivateTest.UpdateActiveGpu",
"vendor_id": "0x8086",
"multi_gpu_category": "active",
"features": [
"accelerated_webgl"
]
} }
] ]
} }
...@@ -204,29 +204,6 @@ const GpuControlList::More kMoreForEntry6_572251052 = { ...@@ -204,29 +204,6 @@ const GpuControlList::More kMoreForEntry6_572251052 = {
GpuControlList::kDontCare, // subpixel_font_rendering GpuControlList::kDontCare, // subpixel_font_rendering
}; };
const int kFeatureListForGpuManagerTestingEntry7[1] = {
GPU_FEATURE_TYPE_ACCELERATED_WEBGL,
};
const GpuControlList::More kMoreForEntry7_572251052 = {
GpuControlList::kGLTypeNone, // gl_type
{GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical,
GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // gl_version
{GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical,
GpuControlList::kVersionSchemaCommon, nullptr,
nullptr}, // pixel_shader_version
false, // in_process_gpu
0, // gl_reset_notification_strategy
{GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical,
GpuControlList::kVersionSchemaCommon, nullptr,
nullptr}, // direct_rendering_version
{GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical,
GpuControlList::kVersionSchemaCommon, nullptr, nullptr}, // gpu_count
GpuControlList::kDontCare, // hardware_overlay
0, // test_group
GpuControlList::kDontCare, // subpixel_font_rendering
};
} // namespace gpu } // namespace gpu
#endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_TESTING_ARRAYS_AND_STRUCTS_AUTOGEN_H_ #endif // CONTENT_BROWSER_GPU_GPU_DATA_MANAGER_TESTING_ARRAYS_AND_STRUCTS_AUTOGEN_H_
...@@ -220,40 +220,6 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = { ...@@ -220,40 +220,6 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
0, // exceptions count 0, // exceptions count
nullptr, // exceptions nullptr, // exceptions
}, },
{
7, // id
"GpuDataManagerImplPrivateTest.UpdateActiveGpu",
base::size(kFeatureListForGpuManagerTestingEntry7), // features size
kFeatureListForGpuManagerTestingEntry7, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size
nullptr, // DisabledWebGLExtensions
0, // CrBugs size
nullptr, // CrBugs
{
GpuControlList::kOsAny, // os_type
{GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical,
GpuControlList::kVersionSchemaCommon, nullptr,
nullptr}, // os_version
0x8086, // vendor_id
0, // Devices size
nullptr, // Devices
GpuControlList::kMultiGpuCategoryActive, // multi_gpu_category
GpuControlList::kMultiGpuStyleNone, // multi_gpu_style
nullptr, // driver info
nullptr, // GL strings
nullptr, // machine model info
0, // intel_gpu_series size
nullptr, // intel_gpu_series
{GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical,
GpuControlList::kVersionSchemaCommon, nullptr,
nullptr}, // intel_gpu_generation
&kMoreForEntry7_572251052, // more data
},
0, // exceptions count
nullptr, // exceptions
},
}; };
const size_t kGpuDataManagerTestingEntryCount = 7; const size_t kGpuDataManagerTestingEntryCount = 6;
} // namespace gpu } // namespace gpu
...@@ -19,7 +19,6 @@ enum GpuDataManagerTestingEntryEnum { ...@@ -19,7 +19,6 @@ enum GpuDataManagerTestingEntryEnum {
kGpuDataManagerImplPrivateTest_GpuSideBlocklistingWebGL_1 = 3, kGpuDataManagerImplPrivateTest_GpuSideBlocklistingWebGL_1 = 3,
kGpuDataManagerImplPrivateTest_GpuSideException = 4, kGpuDataManagerImplPrivateTest_GpuSideException = 4,
kGpuDataManagerImplPrivateTest_BlocklistAllFeatures = 5, kGpuDataManagerImplPrivateTest_BlocklistAllFeatures = 5,
kGpuDataManagerImplPrivateTest_UpdateActiveGpu = 6,
}; };
} // namespace gpu } // namespace gpu
......
...@@ -1044,6 +1044,10 @@ void GpuProcessHost::MaybeShutdownGpuProcess() { ...@@ -1044,6 +1044,10 @@ void GpuProcessHost::MaybeShutdownGpuProcess() {
} }
} }
void GpuProcessHost::DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) {
GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info, base::nullopt);
}
#if defined(OS_WIN) #if defined(OS_WIN)
void GpuProcessHost::DidUpdateOverlayInfo( void GpuProcessHost::DidUpdateOverlayInfo(
const gpu::OverlayInfo& overlay_info) { const gpu::OverlayInfo& overlay_info) {
......
...@@ -163,6 +163,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -163,6 +163,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
void DidFailInitialize() override; void DidFailInitialize() override;
void DidCreateContextSuccessfully() override; void DidCreateContextSuccessfully() override;
void MaybeShutdownGpuProcess() override; void MaybeShutdownGpuProcess() override;
void DidUpdateGPUInfo(const gpu::GPUInfo& gpu_info) override;
#if defined(OS_WIN) #if defined(OS_WIN)
void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) override; void DidUpdateOverlayInfo(const gpu::OverlayInfo& overlay_info) override;
void DidUpdateHDRStatus(bool hdr_enabled) override; void DidUpdateHDRStatus(bool hdr_enabled) override;
......
...@@ -36,6 +36,10 @@ interface GpuHost { ...@@ -36,6 +36,10 @@ interface GpuHost {
ContextLostReason reason, ContextLostReason reason,
url.mojom.Url active_url); url.mojom.Url active_url);
// Tells the GPU host that the GPUInfo has been updated in the GPU
// process.
DidUpdateGPUInfo(gpu.mojom.GpuInfo gpu_info);
// Tells the GPU host that the overlay info has been updated in the GPU // Tells the GPU host that the overlay info has been updated in the GPU
// process. // process.
[EnableIf=is_win] [EnableIf=is_win]
......
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