Bug 1321907 - Hook up the GPU process to the profiler. r=dvander

MozReview-Commit-ID: 8Xq3FPprAF8

--HG--
extra : rebase_source : 5fc143275081bd736574051e90b3dfa821a4be9a
This commit is contained in:
Markus Stange 2017-03-21 19:39:13 -04:00
Родитель c1e6abcc0a
Коммит f1e72b72af
5 изменённых файлов: 131 добавлений и 2 удалений

Просмотреть файл

@ -18,6 +18,10 @@
# include "mozilla/gfx/DeviceManagerDx.h"
#endif
#include "mozilla/ipc/CrashReporterHost.h"
#include "mozilla/Unused.h"
#ifdef MOZ_GECKO_PROFILER
#include "CrossProcessProfilerController.h"
#endif
namespace mozilla {
namespace gfx {
@ -64,6 +68,10 @@ GPUChild::Init()
SendInit(prefs, updates, devicePrefs);
gfxVars::AddReceiver(this);
#ifdef MOZ_ENABLE_PROFILER_SPS
mProfilerController = CrossProcessProfilerController::ForProtocol(this);
#endif
}
void
@ -185,6 +193,17 @@ GPUChild::RecvNotifyDeviceReset()
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUChild::RecvProfile(const nsCString& aProfile)
{
#ifdef MOZ_GECKO_PROFILER
if (mProfilerController) {
mProfilerController->RecvProfile(aProfile);
}
#endif
return IPC_OK();
}
bool
GPUChild::SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
@ -219,6 +238,30 @@ GPUChild::RecvFinishMemoryReport(const uint32_t& aGeneration)
return IPC_OK();
}
void
GPUChild::SendStartProfiler(const ProfilerInitParams& aParams)
{
Unused << PGPUChild::SendStartProfiler(aParams);
}
void
GPUChild::SendStopProfiler()
{
Unused << PGPUChild::SendStopProfiler();
}
void
GPUChild::SendPauseProfiler(const bool& aPause)
{
Unused << PGPUChild::SendPauseProfiler(aPause);
}
void
GPUChild::SendGatherProfile()
{
Unused << PGPUChild::SendGatherProfile();
}
void
GPUChild::ActorDestroy(ActorDestroyReason aWhy)
{
@ -240,6 +283,10 @@ GPUChild::ActorDestroy(ActorDestroyReason aWhy)
}
#ifdef MOZ_ENABLE_PROFILER_SPS
mProfilerController = nullptr;
#endif
gfxVars::RemoveReceiver(this);
mHost->OnChannelClosed();
}

Просмотреть файл

@ -10,8 +10,14 @@
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/PGPUChild.h"
#include "mozilla/gfx/gfxVarReceiver.h"
#include "ProfilerControllingProcess.h"
namespace mozilla {
#ifdef MOZ_GECKO_PROFILER
class CrossProcessProfilerController;
#endif
namespace ipc {
class CrashReporterHost;
} // namespace ipc
@ -23,8 +29,9 @@ namespace gfx {
class GPUProcessHost;
class GPUChild final
: public PGPUChild,
public gfxVarReceiver
: public PGPUChild
, public gfxVarReceiver
, public ProfilerControllingProcess
{
typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
@ -54,9 +61,15 @@ public:
mozilla::ipc::IPCResult RecvGraphicsError(const nsCString& aError) override;
mozilla::ipc::IPCResult RecvNotifyUiObservers(const nsCString& aTopic) override;
mozilla::ipc::IPCResult RecvNotifyDeviceReset() override;
mozilla::ipc::IPCResult RecvProfile(const nsCString& aProfile) override;
mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport) override;
mozilla::ipc::IPCResult RecvFinishMemoryReport(const uint32_t& aGeneration) override;
void SendStartProfiler(const ProfilerInitParams& aParams) override;
void SendStopProfiler() override;
void SendPauseProfiler(const bool& aPause) override;
void SendGatherProfile() override;
bool SendRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,
const bool& aMinimizeMemoryUsage,
@ -69,6 +82,9 @@ private:
UniquePtr<ipc::CrashReporterHost> mCrashReporter;
UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;
bool mGPUReady;
#ifdef MOZ_GECKO_PROFILER
UniquePtr<CrossProcessProfilerController> mProfilerController;
#endif
};
} // namespace gfx

Просмотреть файл

@ -7,6 +7,7 @@
#include "WMF.h"
#endif
#include "GPUParent.h"
#include "GeckoProfiler.h"
#include "gfxConfig.h"
#include "gfxPlatform.h"
#include "gfxPrefs.h"
@ -376,6 +377,58 @@ GPUParent::RecvNotifyGpuObservers(const nsCString& aTopic)
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUParent::RecvStartProfiler(const ProfilerInitParams& params)
{
nsTArray<const char*> featureArray;
for (size_t i = 0; i < params.features().Length(); ++i) {
featureArray.AppendElement(params.features()[i].get());
}
nsTArray<const char*> threadNameFilterArray;
for (size_t i = 0; i < params.threadFilters().Length(); ++i) {
threadNameFilterArray.AppendElement(params.threadFilters()[i].get());
}
profiler_start(params.entries(), params.interval(),
featureArray.Elements(), featureArray.Length(),
threadNameFilterArray.Elements(),
threadNameFilterArray.Length());
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUParent::RecvStopProfiler()
{
profiler_stop();
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUParent::RecvPauseProfiler(const bool& aPause)
{
if (aPause) {
profiler_pause();
} else {
profiler_resume();
}
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUParent::RecvGatherProfile()
{
nsCString profileCString;
UniquePtr<char[]> profile = profiler_get_profile();
if (profile) {
profileCString = nsDependentCString(profile.get());
}
Unused << SendProfile(profileCString);
return IPC_OK();
}
mozilla::ipc::IPCResult
GPUParent::RecvRequestMemoryReport(const uint32_t& aGeneration,
const bool& aAnonymize,

Просмотреть файл

@ -54,6 +54,10 @@ public:
mozilla::ipc::IPCResult RecvAddLayerTreeIdMapping(nsTArray<LayerTreeIdMapping>&& aMappings) override;
mozilla::ipc::IPCResult RecvRemoveLayerTreeIdMapping(const LayerTreeIdMapping& aMapping) override;
mozilla::ipc::IPCResult RecvNotifyGpuObservers(const nsCString& aTopic) override;
mozilla::ipc::IPCResult RecvStartProfiler(const ProfilerInitParams& params) override;
mozilla::ipc::IPCResult RecvPauseProfiler(const bool& aPause) override;
mozilla::ipc::IPCResult RecvStopProfiler() override;
mozilla::ipc::IPCResult RecvGatherProfile() override;
mozilla::ipc::IPCResult RecvRequestMemoryReport(
const uint32_t& generation,
const bool& anonymize,

Просмотреть файл

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include GraphicsMessages;
include ProfilerTypes;
include MemoryReportTypes;
include protocol PCompositorBridge;
include protocol PImageBridge;
@ -88,6 +89,12 @@ parent:
// observer service.
async NotifyGpuObservers(nsCString aTopic);
// Control the Gecko Profiler in the GPU process.
async StartProfiler(ProfilerInitParams params);
async StopProfiler();
async PauseProfiler(bool aPause);
async GatherProfile();
async RequestMemoryReport(uint32_t generation,
bool anonymize,
bool minimizeMemoryUsage,
@ -119,6 +126,8 @@ child:
async NotifyDeviceReset();
// Called in response to GatherProfile.
async Profile(nsCString aProfile);
async AddMemoryReport(MemoryReport aReport);
async FinishMemoryReport(uint32_t aGeneration);
};