Skip to content

Commit

Permalink
Bug 1616592 - Control the batching lookback count via a pref. r=gw
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D63336

--HG--
extra : moz-landing-system : lando
  • Loading branch information
nical committed Feb 20, 2020
1 parent 873d792 commit 8d21525
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions gfx/config/gfxVars.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class gfxVarReceiver;
_(UseWebRenderMultithreading, bool, false) \
_(WebRenderMaxPartialPresentRects, int32_t, 0) \
_(WebRenderDebugFlags, int32_t, 0) \
_(WebRenderBatchingLookback, int32_t, 10) \
_(ScreenDepth, int32_t, 0) \
_(GREDirectory, nsString, nsString()) \
_(ProfDirectory, nsString, nsString()) \
Expand Down
20 changes: 20 additions & 0 deletions gfx/layers/ipc/CompositorBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,8 @@ void CompositorBridgeParent::InitializeStatics() {
gfxVars::SetWebRenderDebugFlagsListener(&UpdateDebugFlags);
gfxVars::SetUseWebRenderMultithreadingListener(
&UpdateWebRenderMultithreading);
gfxVars::SetWebRenderBatchingLookbackListener(
&UpdateWebRenderBatchingParameters);
}

/*static*/
Expand Down Expand Up @@ -2082,6 +2084,24 @@ void CompositorBridgeParent::UpdateWebRenderMultithreading() {
});
}

/*static*/
void CompositorBridgeParent::UpdateWebRenderBatchingParameters() {
if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) {
CompositorLoop()->PostTask(NewRunnableFunction(
"CompositorBridgeParent::UpdateWebRenderBatchingParameters",
&CompositorBridgeParent::UpdateWebRenderBatchingParameters));
}

return;
}

MonitorAutoLock lock(*sIndirectLayerTreesLock);
ForEachWebRenderBridgeParent([&](WebRenderBridgeParent* wrBridge) -> void {
wrBridge->UpdateBatchingParameters();
});
}

RefPtr<WebRenderBridgeParent> CompositorBridgeParent::GetWebRenderBridgeParent()
const {
return mWrBridge;
Expand Down
5 changes: 5 additions & 0 deletions gfx/layers/ipc/CompositorBridgeParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
*/
static void UpdateWebRenderMultithreading();

/**
* Notify the compositor webrender batching parameters have been updated.
*/
static void UpdateWebRenderBatchingParameters();

/**
* Wrap the data structure to be sent over IPC.
*/
Expand Down
10 changes: 10 additions & 0 deletions gfx/layers/wr/WebRenderBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,16 @@ void WebRenderBridgeParent::UpdateMultithreading() {
}
}

void WebRenderBridgeParent::UpdateBatchingParameters() {
uint32_t count = gfxVars::WebRenderBatchingLookback();
for (auto& api : mApis) {
if (!api) {
continue;
}
api->SetBatchingLookback(count);
}
}

#if defined(MOZ_WIDGET_ANDROID)
void WebRenderBridgeParent::RequestScreenPixels(
UiCompositorControllerParent* aController) {
Expand Down
1 change: 1 addition & 0 deletions gfx/layers/wr/WebRenderBridgeParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class WebRenderBridgeParent final
void UpdateQualitySettings();
void UpdateDebugFlags();
void UpdateMultithreading();
void UpdateBatchingParameters();

mozilla::ipc::IPCResult RecvEnsureConnected(
TextureFactoryIdentifier* aTextureFactoryIdentifier,
Expand Down
12 changes: 12 additions & 0 deletions gfx/thebes/gfxPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,13 @@ static void WebRenderMultithreadingPrefChangeCallback(const char* aPrefName,
gfx::gfxVars::SetUseWebRenderMultithreading(enable);
}

static void WebRenderBatchingPrefChangeCallback(const char* aPrefName, void*) {
uint32_t count = Preferences::GetUint(
StaticPrefs::GetPrefName_gfx_webrender_batching_lookback(), 10);

gfx::gfxVars::SetWebRenderBatchingLookback(count);
}

#if defined(USE_SKIA)
static uint32_t GetSkiaGlyphCacheSize() {
// Only increase font cache size on non-android to save memory.
Expand Down Expand Up @@ -2960,6 +2967,11 @@ void gfxPlatform::InitWebRenderConfig() {
nsDependentCString(
StaticPrefs::GetPrefName_gfx_webrender_enable_multithreading()));

Preferences::RegisterCallback(
WebRenderBatchingPrefChangeCallback,
nsDependentCString(
StaticPrefs::GetPrefName_gfx_webrender_batching_lookback()));

UpdateAllowSacrificingSubpixelAA();
}
}
Expand Down
4 changes: 4 additions & 0 deletions gfx/webrender_bindings/WebRenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@ void WebRenderAPI::EnableMultithreading(bool aEnable) {
wr_api_enable_multithreading(mDocHandle, aEnable);
}

void WebRenderAPI::SetBatchingLookback(uint32_t aCount) {
wr_api_set_batching_lookback(mDocHandle, aCount);
}

void WebRenderAPI::Pause() {
class PauseEvent : public RendererEvent {
public:
Expand Down
1 change: 1 addition & 0 deletions gfx/webrender_bindings/WebRenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class WebRenderAPI final {
void ClearAllCaches();
void EnableNativeCompositor(bool aEnable);
void EnableMultithreading(bool aEnable);
void SetBatchingLookback(uint32_t aCount);

void Pause();
bool Resume();
Expand Down
5 changes: 5 additions & 0 deletions gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,11 @@ pub unsafe extern "C" fn wr_api_enable_multithreading(dh: &mut DocumentHandle, e
dh.api.send_debug_cmd(DebugCommand::EnableMultithreading(enable));
}

#[no_mangle]
pub unsafe extern "C" fn wr_api_set_batching_lookback(dh: &mut DocumentHandle, count: u32) {
dh.api.send_debug_cmd(DebugCommand::SetBatchingLookback(count));
}

fn make_transaction(do_async: bool) -> Transaction {
let mut transaction = Transaction::new();
// Ensure that we either use async scene building or not based on the
Expand Down
10 changes: 10 additions & 0 deletions gfx/wr/webrender/src/render_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,16 @@ impl RenderBackend {
self.resource_cache.enable_multithreading(enable);
return RenderBackendStatus::Continue;
}
DebugCommand::SetBatchingLookback(count) => {
self.frame_config.batch_lookback_count = count as usize;
self.low_priority_scene_tx.send(SceneBuilderRequest::SetFrameBuilderConfig(
self.frame_config.clone()
)).unwrap();
for (_, doc) in &mut self.documents {
doc.scene.config.batch_lookback_count = count as usize;
}
return RenderBackendStatus::Continue;
}
DebugCommand::SimulateLongSceneBuild(time_ms) => {
self.scene_tx.send(SceneBuilderRequest::SimulateLongSceneBuild(time_ms)).unwrap();
return RenderBackendStatus::Continue;
Expand Down
1 change: 1 addition & 0 deletions gfx/wr/webrender/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2886,6 +2886,7 @@ impl Renderer {
| DebugCommand::SimulateLongSceneBuild(_)
| DebugCommand::SimulateLongLowPrioritySceneBuild(_)
| DebugCommand::EnableNativeCompositor(_)
| DebugCommand::SetBatchingLookback(_)
| DebugCommand::EnableMultithreading(_) => {}
DebugCommand::InvalidateGpuCache => {
match self.gpu_cache_texture.bus {
Expand Down
2 changes: 2 additions & 0 deletions gfx/wr/webrender_api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ pub enum DebugCommand {
EnableNativeCompositor(bool),
/// Enable/disable parallel job execution with rayon.
EnableMultithreading(bool),
/// Sets the maximum amount of existing batches to visit before creating a new one.
SetBatchingLookback(u32),
/// Invalidate GPU cache, forcing the update from the CPU mirror.
InvalidateGpuCache,
/// Causes the scene builder to pause for a given amount of milliseconds each time it
Expand Down
5 changes: 5 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3886,6 +3886,11 @@
value: true
mirror: always

- name: gfx.webrender.batching.lookback
type: uint32_t
value: 10
mirror: always

- name: gfx.webrender.compositor
type: bool
#if defined(XP_WIN)
Expand Down

0 comments on commit 8d21525

Please sign in to comment.