Bug 1616592 - Control the batching lookback count via a pref. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D63336

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Silva 2020-02-20 03:45:17 +00:00
parent 873d792d37
commit 8d2152543a
13 changed files with 77 additions and 0 deletions

View File

@ -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()) \

View File

@ -2022,6 +2022,8 @@ void CompositorBridgeParent::InitializeStatics() {
gfxVars::SetWebRenderDebugFlagsListener(&UpdateDebugFlags);
gfxVars::SetUseWebRenderMultithreadingListener(
&UpdateWebRenderMultithreading);
gfxVars::SetWebRenderBatchingLookbackListener(
&UpdateWebRenderBatchingParameters);
}
/*static*/
@ -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;

View File

@ -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.
*/

View File

@ -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) {

View File

@ -106,6 +106,7 @@ class WebRenderBridgeParent final
void UpdateQualitySettings();
void UpdateDebugFlags();
void UpdateMultithreading();
void UpdateBatchingParameters();
mozilla::ipc::IPCResult RecvEnsureConnected(
TextureFactoryIdentifier* aTextureFactoryIdentifier,

View File

@ -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.
@ -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();
}
}

View File

@ -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:

View File

@ -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();

View File

@ -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

View File

@ -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;

View File

@ -2886,6 +2886,7 @@ impl Renderer {
| DebugCommand::SimulateLongSceneBuild(_)
| DebugCommand::SimulateLongLowPrioritySceneBuild(_)
| DebugCommand::EnableNativeCompositor(_)
| DebugCommand::SetBatchingLookback(_)
| DebugCommand::EnableMultithreading(_) => {}
DebugCommand::InvalidateGpuCache => {
match self.gpu_cache_texture.bus {

View File

@ -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

View File

@ -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)