зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1390840 - Add prefs to display the debugging view of webrender's texture cache and intermediate targets. r=jrmuizel
This commit is contained in:
Родитель
97ccdf1de8
Коммит
9f6f1a7d88
|
@ -36,6 +36,7 @@ class gfxVarReceiver;
|
|||
_(DXInterop2Blocked, bool, false) \
|
||||
_(UseWebRender, bool, false) \
|
||||
_(UseWebRenderANGLE, bool, false) \
|
||||
_(WebRenderDebugFlags, int32_t, 0) \
|
||||
_(ScreenDepth, int32_t, 0) \
|
||||
_(GREDirectory, nsCString, nsCString()) \
|
||||
_(UseOMTP, bool, false) \
|
||||
|
|
|
@ -260,11 +260,6 @@ CompositorBridgeParent::Setup()
|
|||
|
||||
MOZ_ASSERT(!sCompositorMap);
|
||||
sCompositorMap = new CompositorMap;
|
||||
|
||||
gfxPrefs::SetWebRenderProfilerEnabledChangeCallback(
|
||||
[](const GfxPrefValue& aValue) -> void {
|
||||
CompositorBridgeParent::SetWebRenderProfilerEnabled(aValue.get_bool());
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -273,7 +268,6 @@ CompositorBridgeParent::Shutdown()
|
|||
MOZ_ASSERT(sCompositorMap);
|
||||
MOZ_ASSERT(sCompositorMap->empty());
|
||||
sCompositorMap = nullptr;
|
||||
gfxPrefs::SetWebRenderProfilerEnabledChangeCallback(nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1701,8 +1695,7 @@ CompositorBridgeParent::AllocPWebRenderBridgeParent(const wr::PipelineId& aPipel
|
|||
|
||||
MOZ_ASSERT(mWidget);
|
||||
RefPtr<widget::CompositorWidget> widget = mWidget;
|
||||
RefPtr<wr::WebRenderAPI> api = wr::WebRenderAPI::Create(
|
||||
gfxPrefs::WebRenderProfilerEnabled(), this, Move(widget), aSize);
|
||||
RefPtr<wr::WebRenderAPI> api = wr::WebRenderAPI::Create(this, Move(widget), aSize);
|
||||
if (!api) {
|
||||
mWrBridge = WebRenderBridgeParent::CreateDestroyed();
|
||||
mWrBridge.get()->AddRef(); // IPDL reference
|
||||
|
@ -1759,18 +1752,6 @@ CompositorBridgeParent::GetTestingTimeStamp() const
|
|||
return mIsTesting ? Some(mTestTime) : Nothing();
|
||||
}
|
||||
|
||||
void
|
||||
CompositorBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled)
|
||||
{
|
||||
MonitorAutoLock lock(*sIndirectLayerTreesLock);
|
||||
for (auto it = sIndirectLayerTrees.begin(); it != sIndirectLayerTrees.end(); it++) {
|
||||
LayerTreeState* state = &it->second;
|
||||
if (state->mWrBridge) {
|
||||
state->mWrBridge->SetWebRenderProfilerEnabled(aEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EraseLayerState(uint64_t aId)
|
||||
{
|
||||
|
|
|
@ -450,8 +450,6 @@ public:
|
|||
RefPtr<WebRenderBridgeParent> GetWebRenderBridgeParent() const;
|
||||
Maybe<TimeStamp> GetTestingTimeStamp() const;
|
||||
|
||||
static void SetWebRenderProfilerEnabled(bool aEnabled);
|
||||
|
||||
static CompositorBridgeParent* GetCompositorBridgeParentFromLayersId(const uint64_t& aLayersId);
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
|
|
|
@ -1422,15 +1422,6 @@ WebRenderBridgeParent::RecvInitReadLocks(ReadLockArray&& aReadLocks)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
void
|
||||
WebRenderBridgeParent::SetWebRenderProfilerEnabled(bool aEnabled)
|
||||
{
|
||||
if (mWidget) {
|
||||
// Only set the flag to "root" WebRenderBridgeParent.
|
||||
mApi->SetProfilerEnabled(aEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
TextureFactoryIdentifier
|
||||
WebRenderBridgeParent::GetTextureFactoryIdentifier()
|
||||
{
|
||||
|
|
|
@ -152,7 +152,6 @@ public:
|
|||
mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* data) override;
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
void SetWebRenderProfilerEnabled(bool aEnabled);
|
||||
|
||||
void Pause();
|
||||
bool Resume();
|
||||
|
|
|
@ -598,6 +598,27 @@ void RecordingPrefChanged(const char *aPrefName, void *aClosure)
|
|||
}
|
||||
}
|
||||
|
||||
#define WR_DEBUG_PREF "gfx.webrender.debug"
|
||||
|
||||
void
|
||||
WebRenderDebugPrefChangeCallback(const char* aPrefName, void*)
|
||||
{
|
||||
int32_t flags = 0;
|
||||
// TODO: It would be nice to get the bit patterns directly from the rust code.
|
||||
if (Preferences::GetBool(WR_DEBUG_PREF".profiler", false)) {
|
||||
flags |= (1 << 0);
|
||||
}
|
||||
if (Preferences::GetBool(WR_DEBUG_PREF".texture-cache", false)) {
|
||||
flags |= (1 << 1);
|
||||
}
|
||||
if (Preferences::GetBool(WR_DEBUG_PREF".render-targets", false)) {
|
||||
flags |= (1 << 2);
|
||||
}
|
||||
|
||||
gfx::gfxVars::SetWebRenderDebugFlags(flags);
|
||||
}
|
||||
|
||||
|
||||
#if defined(USE_SKIA)
|
||||
static uint32_t GetSkiaGlyphCacheSize()
|
||||
{
|
||||
|
@ -1039,6 +1060,8 @@ gfxPlatform::ShutdownLayersIPC()
|
|||
layers::CompositorThreadHolder::Shutdown();
|
||||
if (gfxVars::UseWebRender()) {
|
||||
wr::RenderThread::ShutDown();
|
||||
|
||||
Preferences::UnregisterCallback(WebRenderDebugPrefChangeCallback, WR_DEBUG_PREF);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -2496,6 +2519,11 @@ gfxPlatform::InitWebRenderConfig()
|
|||
if (gfxConfig::IsEnabled(Feature::WEBRENDER)) {
|
||||
gfxVars::SetUseWebRender(true);
|
||||
reporter.SetSuccessful();
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
Preferences::RegisterPrefixCallbackAndCall(WebRenderDebugPrefChangeCallback,
|
||||
WR_DEBUG_PREF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -487,7 +487,6 @@ private:
|
|||
DECL_GFX_PREF(Live, "gfx.webrender.blob-images", WebRenderBlobImages, bool, false);
|
||||
DECL_GFX_PREF(Live, "gfx.webrender.highlight-painted-layers",WebRenderHighlightPaintedLayers, bool, false);
|
||||
DECL_GFX_PREF(Live, "gfx.webrender.layers-free", WebRenderLayersFree, bool, false);
|
||||
DECL_GFX_PREF(Live, "gfx.webrender.profiler.enabled", WebRenderProfilerEnabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "gfx.webrendest.enabled", WebRendestEnabled, bool, false);
|
||||
|
||||
// Use vsync events generated by hardware
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "GLContext.h"
|
||||
#include "GLContextProvider.h"
|
||||
#include "mozilla/gfx/Logging.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/LayersTypes.h"
|
||||
|
@ -65,6 +66,7 @@ RendererOGL::RendererOGL(RefPtr<RenderThread>&& aThread,
|
|||
, mRenderer(aRenderer)
|
||||
, mBridge(aBridge)
|
||||
, mWindowId(aWindowId)
|
||||
, mDebugFlags({ 0 })
|
||||
{
|
||||
MOZ_ASSERT(mThread);
|
||||
MOZ_ASSERT(mGL);
|
||||
|
@ -127,6 +129,13 @@ RendererOGL::Update()
|
|||
bool
|
||||
RendererOGL::Render()
|
||||
{
|
||||
uint32_t flags = gfx::gfxVars::WebRenderDebugFlags();
|
||||
|
||||
if (mDebugFlags.mBits != flags) {
|
||||
mDebugFlags.mBits = flags;
|
||||
wr_renderer_set_debug_flags(mRenderer, mDebugFlags);
|
||||
}
|
||||
|
||||
if (!mGL->MakeCurrent()) {
|
||||
gfxCriticalNote << "Failed to make render context current, can't draw.";
|
||||
// XXX This could cause oom in webrender since pending_texture_updates is not handled.
|
||||
|
@ -203,12 +212,6 @@ RendererOGL::Resume()
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
RendererOGL::SetProfilerEnabled(bool aEnabled)
|
||||
{
|
||||
wr_renderer_set_profiler_enabled(mRenderer, aEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
RendererOGL::SetFrameStartTime(const TimeStamp& aTime)
|
||||
{
|
||||
|
|
|
@ -99,6 +99,7 @@ protected:
|
|||
wr::WindowId mWindowId;
|
||||
TimeStamp mFrameStartTime;
|
||||
RefPtr<layers::SyncObjectHost> mSyncObject;
|
||||
wr::DebugFlags mDebugFlags;
|
||||
};
|
||||
|
||||
} // namespace wr
|
||||
|
|
|
@ -28,7 +28,6 @@ public:
|
|||
bool* aUseANGLE,
|
||||
RefPtr<widget::CompositorWidget>&& aWidget,
|
||||
layers::SynchronousTask* aTask,
|
||||
bool aEnableProfiler,
|
||||
LayoutDeviceIntSize aSize,
|
||||
layers::SyncHandle* aHandle)
|
||||
: mDocHandle(aDocHandle)
|
||||
|
@ -37,7 +36,6 @@ public:
|
|||
, mBridge(aBridge)
|
||||
, mCompositorWidget(Move(aWidget))
|
||||
, mTask(aTask)
|
||||
, mEnableProfiler(aEnableProfiler)
|
||||
, mSize(aSize)
|
||||
, mSyncHandle(aHandle)
|
||||
{
|
||||
|
@ -74,7 +72,7 @@ public:
|
|||
wr::Renderer* wrRenderer = nullptr;
|
||||
if (!wr_window_new(aWindowId, mSize.width, mSize.height, gl.get(),
|
||||
aRenderThread.ThreadPool().Raw(),
|
||||
this->mEnableProfiler, mDocHandle, &wrRenderer,
|
||||
mDocHandle, &wrRenderer,
|
||||
mMaxTextureSize)) {
|
||||
// wr_window_new puts a message into gfxCriticalNote if it returns false
|
||||
return;
|
||||
|
@ -110,7 +108,6 @@ private:
|
|||
layers::CompositorBridgeParentBase* mBridge;
|
||||
RefPtr<widget::CompositorWidget> mCompositorWidget;
|
||||
layers::SynchronousTask* mTask;
|
||||
bool mEnableProfiler;
|
||||
LayoutDeviceIntSize mSize;
|
||||
layers::SyncHandle* mSyncHandle;
|
||||
};
|
||||
|
@ -142,8 +139,7 @@ private:
|
|||
|
||||
//static
|
||||
already_AddRefed<WebRenderAPI>
|
||||
WebRenderAPI::Create(bool aEnableProfiler,
|
||||
layers::CompositorBridgeParentBase* aBridge,
|
||||
WebRenderAPI::Create(layers::CompositorBridgeParentBase* aBridge,
|
||||
RefPtr<widget::CompositorWidget>&& aWidget,
|
||||
LayoutDeviceIntSize aSize)
|
||||
{
|
||||
|
@ -163,7 +159,7 @@ WebRenderAPI::Create(bool aEnableProfiler,
|
|||
// the next time we need to access the DocumentHandle object.
|
||||
layers::SynchronousTask task("Create Renderer");
|
||||
auto event = MakeUnique<NewRenderer>(&docHandle, aBridge, &maxTextureSize, &useANGLE,
|
||||
Move(aWidget), &task, aEnableProfiler, aSize,
|
||||
Move(aWidget), &task, aSize,
|
||||
&syncHandle);
|
||||
RenderThread::Get()->RunEvent(id, Move(event));
|
||||
|
||||
|
@ -528,39 +524,6 @@ WebRenderAPI::DeleteFont(wr::FontKey aKey)
|
|||
wr_api_delete_font(mDocHandle, aKey);
|
||||
}
|
||||
|
||||
class EnableProfiler : public RendererEvent
|
||||
{
|
||||
public:
|
||||
explicit EnableProfiler(bool aEnabled)
|
||||
: mEnabled(aEnabled)
|
||||
{
|
||||
MOZ_COUNT_CTOR(EnableProfiler);
|
||||
}
|
||||
|
||||
~EnableProfiler()
|
||||
{
|
||||
MOZ_COUNT_DTOR(EnableProfiler);
|
||||
}
|
||||
|
||||
virtual void Run(RenderThread& aRenderThread, WindowId aWindowId) override
|
||||
{
|
||||
auto renderer = aRenderThread.GetRenderer(aWindowId);
|
||||
if (renderer) {
|
||||
renderer->SetProfilerEnabled(mEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool mEnabled;
|
||||
};
|
||||
|
||||
void
|
||||
WebRenderAPI::SetProfilerEnabled(bool aEnabled)
|
||||
{
|
||||
auto event = MakeUnique<EnableProfiler>(aEnabled);
|
||||
RunOnRenderThread(Move(event));
|
||||
}
|
||||
|
||||
class FrameStartTime : public RendererEvent
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -54,8 +54,7 @@ class WebRenderAPI
|
|||
|
||||
public:
|
||||
/// This can be called on the compositor thread only.
|
||||
static already_AddRefed<WebRenderAPI> Create(bool aEnableProfiler,
|
||||
layers::CompositorBridgeParentBase* aBridge,
|
||||
static already_AddRefed<WebRenderAPI> Create(layers::CompositorBridgeParentBase* aBridge,
|
||||
RefPtr<widget::CompositorWidget>&& aWidget,
|
||||
LayoutDeviceIntSize aSize);
|
||||
|
||||
|
@ -124,8 +123,6 @@ public:
|
|||
|
||||
void DeleteFont(wr::FontKey aKey);
|
||||
|
||||
void SetProfilerEnabled(bool aEnabled);
|
||||
|
||||
void SetFrameStartTime(const TimeStamp& aTime);
|
||||
|
||||
void RunOnRenderThread(UniquePtr<RendererEvent> aEvent);
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef wr::WrImageKey ImageKey;
|
|||
typedef wr::WrFontKey FontKey;
|
||||
typedef wr::WrEpoch Epoch;
|
||||
typedef wr::WrExternalImageId ExternalImageId;
|
||||
typedef wr::WrDebugFlags DebugFlags;
|
||||
|
||||
typedef mozilla::Maybe<mozilla::wr::WrImageMask> MaybeImageMask;
|
||||
typedef Maybe<ExternalImageId> MaybeExternalImageId;
|
||||
|
@ -45,6 +46,12 @@ inline Epoch NewEpoch(uint32_t aEpoch) {
|
|||
return e;
|
||||
}
|
||||
|
||||
inline DebugFlags NewDebugFlags(uint32_t aFlags) {
|
||||
DebugFlags flags;
|
||||
flags.mBits = aFlags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
inline Maybe<wr::ImageFormat>
|
||||
SurfaceFormatToImageFormat(gfx::SurfaceFormat aFormat) {
|
||||
switch (aFormat) {
|
||||
|
|
|
@ -9,7 +9,7 @@ use gleam::gl;
|
|||
use webrender_api::*;
|
||||
use webrender::renderer::{ReadPixelsFormat, Renderer, RendererOptions};
|
||||
use webrender::renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource};
|
||||
use webrender::renderer::{DebugFlags, PROFILER_DBG};
|
||||
use webrender::renderer::DebugFlags;
|
||||
use webrender::{ApiRecordingReceiver, BinaryRecorder};
|
||||
use thread_profiler::register_thread_with_profiler;
|
||||
use moz2d_renderer::Moz2dImageRenderer;
|
||||
|
@ -462,12 +462,22 @@ pub unsafe extern "C" fn wr_renderer_readback(renderer: &mut Renderer,
|
|||
&mut slice);
|
||||
}
|
||||
|
||||
/// cbindgen:field-names=[mBits]
|
||||
#[repr(C)]
|
||||
pub struct WrDebugFlags {
|
||||
bits: u32,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_renderer_set_profiler_enabled(renderer: &mut Renderer,
|
||||
enabled: bool) {
|
||||
let mut flags = renderer.get_debug_flags();
|
||||
flags.set(PROFILER_DBG, enabled);
|
||||
renderer.set_debug_flags(flags);
|
||||
pub extern "C" fn wr_renderer_get_debug_flags(renderer: &mut Renderer) -> WrDebugFlags {
|
||||
WrDebugFlags { bits: renderer.get_debug_flags().bits() }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wr_renderer_set_debug_flags(renderer: &mut Renderer, flags: WrDebugFlags) {
|
||||
if let Some(dbg_flags) = DebugFlags::from_bits(flags.bits) {
|
||||
renderer.set_debug_flags(dbg_flags);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -550,7 +560,6 @@ pub extern "C" fn wr_window_new(window_id: WrWindowId,
|
|||
window_height: u32,
|
||||
gl_context: *mut c_void,
|
||||
thread_pool: *mut WrThreadPool,
|
||||
enable_profiler: bool,
|
||||
out_handle: &mut *mut DocumentHandle,
|
||||
out_renderer: &mut *mut Renderer,
|
||||
out_max_texture_size: *mut u32)
|
||||
|
@ -580,12 +589,9 @@ pub extern "C" fn wr_window_new(window_id: WrWindowId,
|
|||
Arc::clone(&(*thread_pool).0)
|
||||
};
|
||||
|
||||
let mut debug_flags = DebugFlags::empty();
|
||||
debug_flags.set(PROFILER_DBG, enable_profiler);
|
||||
let opts = RendererOptions {
|
||||
enable_aa: true,
|
||||
enable_subpixel_aa: true,
|
||||
debug_flags: debug_flags,
|
||||
recorder: recorder,
|
||||
blob_image_renderer: Some(Box::new(Moz2dImageRenderer::new(workers.clone()))),
|
||||
workers: Some(workers.clone()),
|
||||
|
|
|
@ -611,6 +611,14 @@ struct WrWindowId {
|
|||
}
|
||||
};
|
||||
|
||||
struct WrDebugFlags {
|
||||
uint32_t mBits;
|
||||
|
||||
bool operator==(const WrDebugFlags& aOther) const {
|
||||
return mBits == aOther.mBits;
|
||||
}
|
||||
};
|
||||
|
||||
struct WrExternalImage {
|
||||
WrExternalImageType image_type;
|
||||
uint32_t handle;
|
||||
|
@ -1066,6 +1074,10 @@ WR_INLINE
|
|||
WrRenderedEpochs *wr_renderer_flush_rendered_epochs(Renderer *aRenderer)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
WrDebugFlags wr_renderer_get_debug_flags(Renderer *aRenderer)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_renderer_readback(Renderer *aRenderer,
|
||||
uint32_t aWidth,
|
||||
|
@ -1081,13 +1093,13 @@ void wr_renderer_render(Renderer *aRenderer,
|
|||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_renderer_set_external_image_handler(Renderer *aRenderer,
|
||||
WrExternalImageHandler *aExternalImageHandler)
|
||||
void wr_renderer_set_debug_flags(Renderer *aRenderer,
|
||||
WrDebugFlags aFlags)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_renderer_set_profiler_enabled(Renderer *aRenderer,
|
||||
bool aEnabled)
|
||||
void wr_renderer_set_external_image_handler(Renderer *aRenderer,
|
||||
WrExternalImageHandler *aExternalImageHandler)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
|
@ -1128,7 +1140,6 @@ bool wr_window_new(WrWindowId aWindowId,
|
|||
uint32_t aWindowHeight,
|
||||
void *aGlContext,
|
||||
WrThreadPool *aThreadPool,
|
||||
bool aEnableProfiler,
|
||||
DocumentHandle **aOutHandle,
|
||||
Renderer **aOutRenderer,
|
||||
uint32_t *aOutMaxTextureSize)
|
||||
|
|
|
@ -898,9 +898,13 @@ pref("gfx.webrender.force-angle", true);
|
|||
|
||||
pref("gfx.webrender.highlight-painted-layers", false);
|
||||
pref("gfx.webrender.layers-free", false);
|
||||
pref("gfx.webrender.profiler.enabled", false);
|
||||
pref("gfx.webrender.blob-images", false);
|
||||
|
||||
// WebRender debugging utilities.
|
||||
pref("gfx.webrender.debug.texture-cache", false);
|
||||
pref("gfx.webrender.debug.render-targets", false);
|
||||
pref("gfx.webrender.debug.profiler", false);
|
||||
|
||||
// Whether webrender should be used as much as possible.
|
||||
pref("gfx.webrendest.enabled", false);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче