Commit 4f0531b4 authored by Fergus Dall's avatar Fergus Dall Committed by Commit Bot

Revert "Revert back to the default GPU when no renderers are using WebXR"

This reverts commit 0fb7ef15.

Reason for revert: Speculative revert
May have broken webgl_conformance_tests on chromeos-amd64-generic-rel:
https://ci.chromium.org/p/chromium/builders/ci/chromeos-amd64-generic-rel/45665

Original change's description:
> Revert back to the default GPU when no renderers are using WebXR
> 
> The GPU process may have been restarted and initialized on a different
> GPU than the default if the VR headset is not plugged into the default
> GPU. Staying on this XR compatible GPU can drain battery a lot quicker.
> When there are no longer any renderers using WebXR, this change reverts
> reverts the GPU process back to the default GPU.
> 
> Bug: 1090951
> Change-Id: Ibc5e7f709d2c82d5a6e8cbda08766d1d654951a3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321771
> Commit-Queue: Patrick To <patrto@microsoft.com>
> Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#798950}

TBR=patrto@microsoft.com,alcooper@chromium.org

Change-Id: I14e44c4fe60cdde138ea281b8766ac113887aa99
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1090951
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359663Reviewed-by: default avatarFergus Dall <sidereal@google.com>
Commit-Queue: Fergus Dall <sidereal@google.com>
Cr-Commit-Position: refs/heads/master@{#798984}
parent 19572659
......@@ -15,6 +15,7 @@
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/common/trace_event_common.h"
#include "build/build_config.h"
#include "content/browser/xr/xr_utils.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/gpu_data_manager.h"
......@@ -339,24 +340,12 @@ void XRRuntimeManagerImpl::MakeXrCompatible() {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kUseAdapterLuid, luid_string);
// Store the current GPU so we can revert back once XR is no longer needed.
// If default_gpu_ is nonzero, we have already previously stored the
// default GPU and should not overwrite it.
if (default_gpu_.LowPart == 0 && default_gpu_.HighPart == 0) {
default_gpu_ = content::GpuDataManager::GetInstance()
->GetGPUInfo()
.active_gpu()
.luid;
}
xr_compatible_restarted_gpu_ = true;
// Get notified when the new GPU process sends back its GPUInfo. This
// indicates that the GPU process has finished initializing and the GPUInfo
// contains the LUID of the active adapter.
content::GpuDataManager::GetInstance()->AddObserver(this);
content::KillGpuProcess();
return;
#else
// MakeXrCompatible is not yet supported on other platforms so
......@@ -419,27 +408,6 @@ XRRuntimeManagerImpl::~XRRuntimeManagerImpl() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
CHECK_EQ(g_xr_runtime_manager, this);
g_xr_runtime_manager = nullptr;
// If a GPU adapter LUID was added to the command line to pass to the GPU
// process, remove the switch so subsequent GPU processes initialize on the
// default GPU.
if (xr_compatible_restarted_gpu_) {
base::CommandLine::ForCurrentProcess()->RemoveSwitch(
switches::kUseAdapterLuid);
#if defined(OS_WIN)
// If we changed the GPU, revert it back to the default GPU. This is
// separate from xr_compatible_restarted_gpu_ because the GPU process may
// not have been successfully initialized using the specified GPU and is
// still on the default adapter.
LUID active_gpu =
content::GpuDataManager::GetInstance()->GetGPUInfo().active_gpu().luid;
if (active_gpu.LowPart != default_gpu_.LowPart ||
active_gpu.HighPart != default_gpu_.HighPart) {
content::KillGpuProcess();
}
#endif
}
}
scoped_refptr<XRRuntimeManagerImpl> XRRuntimeManagerImpl::CreateInstance(
......
......@@ -18,7 +18,6 @@
#include "base/optional.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "content/browser/xr/service/browser_xr_runtime_impl.h"
#include "content/browser/xr/service/vr_service_impl.h"
#include "content/common/content_export.h"
......@@ -131,11 +130,6 @@ class CONTENT_EXPORT XRRuntimeManagerImpl
bool providers_initialized_ = false;
size_t num_initialized_providers_ = 0;
bool xr_compatible_restarted_gpu_ = false;
#if defined(OS_WIN)
LUID default_gpu_ = {0, 0};
#endif
std::set<VRServiceImpl*> services_;
THREAD_CHECKER(thread_checker_);
......
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