Bug 1599887 - Update frame is when WR rendering is skipped r=nical

wr::WebRenderPipelineInfo needs to be handled even when WR rendering does not happen.

Differential Revision: https://phabricator.services.mozilla.com/D55899
This commit is contained in:
sotaro
2019-12-06 13:06:21 +00:00
parent 07cdb06bff
commit d0c54fc702
7 changed files with 39 additions and 27 deletions

View File

@@ -528,40 +528,29 @@ void AsyncImagePipelineManager::NotifyPipelinesUpdated(
wr::RenderedFrameId aLastCompletedFrameId) {
MOZ_ASSERT(wr::RenderThread::IsInRenderThread());
MOZ_ASSERT(mLastCompletedFrameId <= aLastCompletedFrameId.mId);
MOZ_ASSERT(aLatestFrameId.IsValid());
// This is called on the render thread, so we just stash the data into
// mPendingUpdates and process it later on the compositor thread.
mPendingUpdates.push_back(aInfo);
mLastCompletedFrameId = aLastCompletedFrameId.mId;
// If aLatestFrameId is valid then a render has been submitted.
if (aLatestFrameId.IsValid()) {
mLastCompletedFrameId = aLastCompletedFrameId.mId;
{
// We need to lock for mRenderSubmittedUpdates because it can be accessed
// on the compositor thread.
MutexAutoLock lock(mRenderSubmittedUpdatesLock);
{
// We need to lock for mRenderSubmittedUpdates because it can be accessed
// on the compositor thread.
MutexAutoLock lock(mRenderSubmittedUpdatesLock);
// Move the pending updates into the submitted ones. Note that this clears
// mPendingUpdates.
mRenderSubmittedUpdates.emplace_back(aLatestFrameId,
std::move(mPendingUpdates));
}
// Queue a runnable on the compositor thread to process the updates.
// This will also call CheckForTextureHostsNotUsedByGPU.
layers::CompositorThreadHolder::Loop()->PostTask(
NewRunnableMethod("ProcessPipelineUpdates", this,
&AsyncImagePipelineManager::ProcessPipelineUpdates));
} else if (mLastCompletedFrameId < aLastCompletedFrameId.mId) {
// We're not running ProcessPipelineUpdates but a later frame has completed,
// so queue a runnable on the compositor thread to check if any TextureHosts
// can be released.
mLastCompletedFrameId = aLastCompletedFrameId.mId;
layers::CompositorThreadHolder::Loop()->PostTask(NewRunnableMethod(
"CheckForTextureHostsNotUsedByGPU", this,
&AsyncImagePipelineManager::CheckForTextureHostsNotUsedByGPU));
// Move the pending updates into the submitted ones. Note that this clears
// mPendingUpdates.
mRenderSubmittedUpdates.emplace_back(aLatestFrameId,
std::move(mPendingUpdates));
}
// Queue a runnable on the compositor thread to process the updates.
// This will also call CheckForTextureHostsNotUsedByGPU.
layers::CompositorThreadHolder::Loop()->PostTask(
NewRunnableMethod("ProcessPipelineUpdates", this,
&AsyncImagePipelineManager::ProcessPipelineUpdates));
}
void AsyncImagePipelineManager::ProcessPipelineUpdates() {

View File

@@ -53,6 +53,9 @@ class RenderCompositor {
return mLatestRenderFrameId.Prev();
}
// Update FrameId when WR rendering does not happen.
virtual RenderedFrameId UpdateFrameId() { return GetNextRenderFrameId(); }
virtual void Pause() = 0;
virtual bool Resume() = 0;
// Called when WR rendering is skipped

View File

@@ -703,6 +703,12 @@ RenderedFrameId RenderCompositorANGLE::GetLastCompletedFrameId() {
return mLastCompletedFrameId;
}
RenderedFrameId RenderCompositorANGLE::UpdateFrameId() {
RenderedFrameId frameId = GetNextRenderFrameId();
InsertGraphicsCommandsFinishedWaitQuery(frameId);
return frameId;
}
bool RenderCompositorANGLE::IsContextLost() {
// XXX glGetGraphicsResetStatus sometimes did not work for detecting TDR.
// Then this function just uses GetDeviceRemovedReason().

View File

@@ -43,6 +43,7 @@ class RenderCompositorANGLE : public RenderCompositor {
RenderedFrameId EndFrame(const FfiVec<DeviceIntRect>& aDirtyRects) final;
bool WaitForGPU() override;
RenderedFrameId GetLastCompletedFrameId() final;
RenderedFrameId UpdateFrameId() final;
void Pause() override;
bool Resume() override;
void Update() override;

View File

@@ -503,6 +503,12 @@ void RenderThread::UpdateAndRender(
renderer->WaitForGPU();
}
if (!aRender) {
// Update frame id for NotifyPipelinesUpdated() when rendering does not
// happen.
latestFrameId = renderer->UpdateFrameId();
}
RenderedFrameId lastCompletedFrameId = renderer->GetLastCompletedFrameId();
RefPtr<layers::AsyncImagePipelineManager> pipelineMgr =

View File

@@ -220,6 +220,10 @@ RenderedFrameId RendererOGL::GetLastCompletedFrameId() {
return mCompositor->GetLastCompletedFrameId();
}
RenderedFrameId RendererOGL::UpdateFrameId() {
return mCompositor->UpdateFrameId();
}
void RendererOGL::Pause() { mCompositor->Pause(); }
bool RendererOGL::Resume() { return mCompositor->Resume(); }

View File

@@ -69,6 +69,9 @@ class RendererOGL {
/// This can be called on the render thread only.
RenderedFrameId GetLastCompletedFrameId();
/// This can be called on the render thread only.
RenderedFrameId UpdateFrameId();
/// This can be called on the render thread only.
void SetProfilerEnabled(bool aEnabled);