mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1851736 - Enable NVIDIA RTX Video Super Resolution for video overlay on Windows only during power charge r=gfx-reviewers,ahale
Super Resolution consumes more power. Then it is better to enable it only during power charging. Differential Revision: https://phabricator.services.mozilla.com/D202781
This commit is contained in:
parent
1443ad5c50
commit
b41ff7d6db
@ -578,6 +578,12 @@ mozilla::ipc::IPCResult GPUParent::RecvScreenInformationChanged() {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult GPUParent::RecvNotifyBatteryInfo(
|
||||
const BatteryInformation& aBatteryInfo) {
|
||||
wr::RenderThread::Get()->SetBatteryInfo(aBatteryInfo);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
static void CopyFeatureChange(Feature aFeature, Maybe<FeatureFailure>* aOut) {
|
||||
FeatureState& feature = gfxConfig::GetFeature(aFeature);
|
||||
if (feature.DisabledByDefault() || feature.IsEnabled()) {
|
||||
|
@ -75,6 +75,8 @@ class GPUParent final : public PGPUParent {
|
||||
mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref);
|
||||
mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref);
|
||||
mozilla::ipc::IPCResult RecvScreenInformationChanged();
|
||||
mozilla::ipc::IPCResult RecvNotifyBatteryInfo(
|
||||
const BatteryInformation& aBatteryInfo);
|
||||
mozilla::ipc::IPCResult RecvNewContentCompositorManager(
|
||||
Endpoint<PCompositorManagerParent>&& aEndpoint,
|
||||
const ContentParentId& aChildId, uint32_t aNamespace);
|
||||
|
@ -142,6 +142,22 @@ GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
GPUProcessManager::BatteryObserver::BatteryObserver(GPUProcessManager* aManager)
|
||||
: mManager(aManager) {
|
||||
hal::RegisterBatteryObserver(this);
|
||||
}
|
||||
|
||||
void GPUProcessManager::BatteryObserver::Notify(
|
||||
const hal::BatteryInformation& aBatteryInfo) {
|
||||
mManager->NotifyBatteryInfo(aBatteryInfo);
|
||||
}
|
||||
|
||||
void GPUProcessManager::BatteryObserver::ShutDown() {
|
||||
hal::UnregisterBatteryObserver(this);
|
||||
}
|
||||
|
||||
GPUProcessManager::BatteryObserver::~BatteryObserver() {}
|
||||
|
||||
void GPUProcessManager::OnXPCOMShutdown() {
|
||||
if (mObserver) {
|
||||
nsContentUtils::UnregisterShutdownObserver(mObserver);
|
||||
@ -183,6 +199,13 @@ void GPUProcessManager::ScreenInformationChanged() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void GPUProcessManager::NotifyBatteryInfo(
|
||||
const hal::BatteryInformation& aBatteryInfo) {
|
||||
if (mGPUChild) {
|
||||
mGPUChild->SendNotifyBatteryInfo(aBatteryInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void GPUProcessManager::ResetProcessStable() {
|
||||
mTotalProcessAttempts++;
|
||||
mProcessStable = false;
|
||||
@ -578,6 +601,9 @@ void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) {
|
||||
std::move(vsyncChild));
|
||||
mGPUChild->SendInitVsyncBridge(std::move(vsyncParent));
|
||||
|
||||
MOZ_ASSERT(!mBatteryObserver);
|
||||
mBatteryObserver = new BatteryObserver(this);
|
||||
|
||||
// Flush any pref updates that happened during launch and weren't
|
||||
// included in the blobs set up in LaunchGPUProcess.
|
||||
for (const mozilla::dom::Pref& pref : mQueuedPrefs) {
|
||||
@ -1074,6 +1100,10 @@ void GPUProcessManager::DestroyProcess(bool aUnexpectedShutdown) {
|
||||
mVsyncBridge->Close();
|
||||
mVsyncBridge = nullptr;
|
||||
}
|
||||
if (mBatteryObserver) {
|
||||
mBatteryObserver->ShutDown();
|
||||
mBatteryObserver = nullptr;
|
||||
}
|
||||
|
||||
CrashReporter::AnnotateCrashReport(
|
||||
CrashReporter::Annotation::GPUProcessStatus, "Destroyed"_ns);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/gfx/GPUProcessHost.h"
|
||||
#include "mozilla/gfx/PGPUChild.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/ipc/TaskFactory.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
@ -310,6 +311,8 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(GPUProcessManager);
|
||||
|
||||
void NotifyBatteryInfo(const hal::BatteryInformation& aBatteryInfo);
|
||||
|
||||
class Observer final : public nsIObserver {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -323,10 +326,25 @@ class GPUProcessManager final : public GPUProcessHost::Listener {
|
||||
};
|
||||
friend class Observer;
|
||||
|
||||
class BatteryObserver final : public hal::BatteryObserver {
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(BatteryObserver)
|
||||
explicit BatteryObserver(GPUProcessManager* aManager);
|
||||
|
||||
void Notify(const hal::BatteryInformation& aBatteryInfo) override;
|
||||
void ShutDown();
|
||||
|
||||
protected:
|
||||
virtual ~BatteryObserver();
|
||||
|
||||
GPUProcessManager* mManager;
|
||||
};
|
||||
|
||||
private:
|
||||
bool mDecodeVideoOnGpuProcess = true;
|
||||
|
||||
RefPtr<Observer> mObserver;
|
||||
RefPtr<BatteryObserver> mBatteryObserver;
|
||||
mozilla::ipc::TaskFactory<GPUProcessManager> mTaskFactory;
|
||||
RefPtr<VsyncIOThreadHolder> mVsyncIOThread;
|
||||
uint32_t mNextNamespace;
|
||||
|
@ -41,6 +41,7 @@ using mozilla::layers::OverlayInfo from "mozilla/layers/OverlayInfo.h";
|
||||
using mozilla::layers::SwapChainInfo from "mozilla/layers/OverlayInfo.h";
|
||||
using mozilla::media::MediaCodecsSupported from "MediaCodecsSupport.h";
|
||||
using mozilla::layers::VideoBridgeSource from "mozilla/layers/VideoBridgeUtils.h";
|
||||
using mozilla::hal::BatteryInformation from "mozilla/hal_sandbox/PHal.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -80,6 +81,7 @@ parent:
|
||||
|
||||
async PreferenceUpdate(Pref pref);
|
||||
async ScreenInformationChanged();
|
||||
async NotifyBatteryInfo(BatteryInformation aBatteryInfo);
|
||||
|
||||
// Create a new content-process compositor bridge.
|
||||
async NewContentCompositorManager(Endpoint<PCompositorManagerParent> endpoint, ContentParentId childId, uint32_t aNamespace);
|
||||
|
@ -1781,8 +1781,10 @@ bool DCSurfaceVideo::CallVideoProcessorBlt() {
|
||||
}
|
||||
|
||||
const UINT vendorId = GetVendorId(videoDevice);
|
||||
const auto powerIsCharging = RenderThread::Get()->GetPowerIsCharging();
|
||||
if (vendorId == 0x10DE &&
|
||||
StaticPrefs::gfx_webrender_super_resolution_nvidia_AtStartup()) {
|
||||
StaticPrefs::gfx_webrender_super_resolution_nvidia_AtStartup() &&
|
||||
powerIsCharging) {
|
||||
SetNvidiaVideoSuperRes(videoContext, videoProcessor, true);
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ RenderThread::RenderThread(RefPtr<nsIThread> aThread)
|
||||
mThreadPool(false),
|
||||
mThreadPoolLP(true),
|
||||
mSingletonGLIsForHardwareWebRender(true),
|
||||
mBatteryInfo("RenderThread.mBatteryInfo"),
|
||||
mWindowInfos("RenderThread.mWindowInfos"),
|
||||
mRenderTextureMapLock("RenderThread.mRenderTextureMapLock"),
|
||||
mHasShutdown(false),
|
||||
@ -291,6 +292,26 @@ RefPtr<MemoryReportPromise> RenderThread::AccumulateMemoryReport(
|
||||
return p;
|
||||
}
|
||||
|
||||
void RenderThread::SetBatteryInfo(const hal::BatteryInformation& aBatteryInfo) {
|
||||
MOZ_ASSERT(XRE_IsGPUProcess());
|
||||
|
||||
auto batteryInfo = mBatteryInfo.Lock();
|
||||
batteryInfo.ref() = Some(aBatteryInfo);
|
||||
}
|
||||
|
||||
bool RenderThread::GetPowerIsCharging() {
|
||||
MOZ_ASSERT(XRE_IsGPUProcess());
|
||||
|
||||
auto batteryInfo = mBatteryInfo.Lock();
|
||||
if (batteryInfo.ref().isSome()) {
|
||||
return batteryInfo.ref().ref().charging();
|
||||
}
|
||||
|
||||
gfxCriticalNoteOnce << "BatteryInfo is not set";
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
|
||||
return false;
|
||||
}
|
||||
|
||||
void RenderThread::AddRenderer(wr::WindowId aWindowId,
|
||||
UniquePtr<RendererOGL> aRenderer) {
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "GLTypes.h" // for GLenum
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
#include "mozilla/DataMutex.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
@ -302,6 +303,9 @@ class RenderThread final {
|
||||
|
||||
static void MaybeEnableGLDebugMessage(gl::GLContext* aGLContext);
|
||||
|
||||
void SetBatteryInfo(const hal::BatteryInformation& aBatteryInfo);
|
||||
bool GetPowerIsCharging();
|
||||
|
||||
private:
|
||||
enum class RenderTextureOp {
|
||||
PrepareForUse,
|
||||
@ -434,6 +438,8 @@ class RenderThread final {
|
||||
|
||||
std::map<wr::WindowId, UniquePtr<RendererOGL>> mRenderers;
|
||||
|
||||
DataMutex<Maybe<hal::BatteryInformation>> mBatteryInfo;
|
||||
|
||||
struct PendingFrameInfo {
|
||||
TimeStamp mStartTime;
|
||||
VsyncId mStartId;
|
||||
|
Loading…
Reference in New Issue
Block a user