Commit 7c8bfedb authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

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

This reverts commit 4f0531b4.

Reason for revert:Another change was speculatively reverted at the
same time, when the webgl_conformance_tests began passing again.
This change does not change behavior except on Windows, so shouldn't
be the cause of the webgl_conformance_tests failure/passing on 
chromeos.

Original change's description:
> 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/+/2359663
> Reviewed-by: Fergus Dall <sidereal@google.com>
> Commit-Queue: Fergus Dall <sidereal@google.com>
> Cr-Commit-Position: refs/heads/master@{#798984}

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

# Not skipping CQ checks because this is a reland.

Bug: 1090951
Change-Id: Id5cf2e4c949b2d5b727047bdadb7fe021a535e1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363288Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarPatrick To <patrto@microsoft.com>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799742}
parent 29d124ed
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/trace_event/common/trace_event_common.h" #include "base/trace_event/common/trace_event_common.h"
#include "build/build_config.h"
#include "content/browser/xr/xr_utils.h" #include "content/browser/xr/xr_utils.h"
#include "content/public/browser/device_service.h" #include "content/public/browser/device_service.h"
#include "content/public/browser/gpu_data_manager.h" #include "content/public/browser/gpu_data_manager.h"
...@@ -340,12 +339,24 @@ void XRRuntimeManagerImpl::MakeXrCompatible() { ...@@ -340,12 +339,24 @@ void XRRuntimeManagerImpl::MakeXrCompatible() {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kUseAdapterLuid, luid_string); 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 // Get notified when the new GPU process sends back its GPUInfo. This
// indicates that the GPU process has finished initializing and the GPUInfo // indicates that the GPU process has finished initializing and the GPUInfo
// contains the LUID of the active adapter. // contains the LUID of the active adapter.
content::GpuDataManager::GetInstance()->AddObserver(this); content::GpuDataManager::GetInstance()->AddObserver(this);
content::KillGpuProcess(); content::KillGpuProcess();
return; return;
#else #else
// MakeXrCompatible is not yet supported on other platforms so // MakeXrCompatible is not yet supported on other platforms so
...@@ -408,6 +419,27 @@ XRRuntimeManagerImpl::~XRRuntimeManagerImpl() { ...@@ -408,6 +419,27 @@ XRRuntimeManagerImpl::~XRRuntimeManagerImpl() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
CHECK_EQ(g_xr_runtime_manager, this); CHECK_EQ(g_xr_runtime_manager, this);
g_xr_runtime_manager = nullptr; 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( scoped_refptr<XRRuntimeManagerImpl> XRRuntimeManagerImpl::CreateInstance(
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "base/timer/timer.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/browser_xr_runtime_impl.h"
#include "content/browser/xr/service/vr_service_impl.h" #include "content/browser/xr/service/vr_service_impl.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
...@@ -130,6 +131,11 @@ class CONTENT_EXPORT XRRuntimeManagerImpl ...@@ -130,6 +131,11 @@ class CONTENT_EXPORT XRRuntimeManagerImpl
bool providers_initialized_ = false; bool providers_initialized_ = false;
size_t num_initialized_providers_ = 0; 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_; std::set<VRServiceImpl*> services_;
THREAD_CHECKER(thread_checker_); 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