Bug 1670014 - Delay querying buffer age until it is actually needed. r=sotaro

Currently we query the backbuffer age in
RenderCompositor::BeginFrame(). Querying the age on android requires
the driver to dequeue a new backbuffer. By doing this right at the
start of the frame, we may cause the driver to block until a buffer is
ready.

We don't actually need the buffer age until part way through
rendering, in Renderer::composite_simple(), by which point there is a
better chance the buffer is available. So move the query to there instead.

Differential Revision: https://phabricator.services.mozilla.com/D92950
This commit is contained in:
Jamie Nicol 2020-10-09 08:25:43 +00:00
parent bac7ca64e9
commit 788a554a66
4 changed files with 8 additions and 21 deletions

View File

@ -59,9 +59,7 @@ EGLSurface RenderCompositorEGL::CreateEGLSurface() {
RenderCompositorEGL::RenderCompositorEGL(
RefPtr<widget::CompositorWidget> aWidget)
: RenderCompositor(std::move(aWidget)),
mEGLSurface(EGL_NO_SURFACE),
mBufferAge(0) {}
: RenderCompositor(std::move(aWidget)), mEGLSurface(EGL_NO_SURFACE) {}
RenderCompositorEGL::~RenderCompositorEGL() {
#ifdef MOZ_WIDGET_ANDROID
@ -91,9 +89,6 @@ bool RenderCompositorEGL::BeginFrame() {
gl()->MakeCurrent(); // DestroyUnused can change the current context!
#endif
// sets 0 if buffer_age is not supported
mBufferAge = gl::GLContextEGL::Cast(gl())->GetBufferAge();
return true;
}
@ -238,7 +233,7 @@ bool RenderCompositorEGL::UsePartialPresent() {
return gfx::gfxVars::WebRenderMaxPartialPresentRects() > 0;
}
bool RenderCompositorEGL::RequestFullRender() { return mBufferAge == 0; }
bool RenderCompositorEGL::RequestFullRender() { return false; }
uint32_t RenderCompositorEGL::GetMaxPartialPresentRects() {
return gfx::gfxVars::WebRenderMaxPartialPresentRects();
@ -248,7 +243,9 @@ bool RenderCompositorEGL::ShouldDrawPreviousPartialPresentRegions() {
return true;
}
size_t RenderCompositorEGL::GetBufferAge() const { return mBufferAge; }
size_t RenderCompositorEGL::GetBufferAge() const {
return gl::GLContextEGL::Cast(gl())->GetBufferAge();
}
void RenderCompositorEGL::SetBufferDamageRegion(const wr::DeviceIntRect* aRects,
size_t aNumRects) {

View File

@ -59,8 +59,6 @@ class RenderCompositorEGL : public RenderCompositor {
LayoutDeviceIntSize mEGLSurfaceSize;
#endif
EGLint mBufferAge;
// FileDescriptor of release fence.
// Release fence is a fence that is used for waiting until usage/composite of
// AHardwareBuffer is ended. The fence is delivered to client side via

View File

@ -34,7 +34,7 @@ UniquePtr<RenderCompositor> RenderCompositorOGL::Create(
RenderCompositorOGL::RenderCompositorOGL(
RefPtr<gl::GLContext>&& aGL, RefPtr<widget::CompositorWidget>&& aWidget)
: RenderCompositor(std::move(aWidget)), mGL(aGL), mBufferAge(0) {
: RenderCompositor(std::move(aWidget)), mGL(aGL) {
MOZ_ASSERT(mGL);
mIsEGL = aGL->GetContextType() == mozilla::gl::GLContextType::EGL;
@ -57,11 +57,6 @@ bool RenderCompositorOGL::BeginFrame() {
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mGL->GetDefaultFramebuffer());
if (mIsEGL) {
// sets 0 if buffer_age is not supported
mBufferAge = gl::GLContextEGL::Cast(gl())->GetBufferAge();
}
return true;
}
@ -112,9 +107,7 @@ uint32_t RenderCompositorOGL::GetMaxPartialPresentRects() {
return mIsEGL ? gfx::gfxVars::WebRenderMaxPartialPresentRects() : 0;
}
bool RenderCompositorOGL::RequestFullRender() {
return mIsEGL && (mBufferAge == 0);
}
bool RenderCompositorOGL::RequestFullRender() { return false; }
bool RenderCompositorOGL::UsePartialPresent() {
return mIsEGL && gfx::gfxVars::WebRenderMaxPartialPresentRects() > 0;
@ -126,7 +119,7 @@ bool RenderCompositorOGL::ShouldDrawPreviousPartialPresentRegions() {
size_t RenderCompositorOGL::GetBufferAge() const {
if (mIsEGL) {
return mBufferAge;
return gl::GLContextEGL::Cast(gl())->GetBufferAge();
}
return 0;
}

View File

@ -44,7 +44,6 @@ class RenderCompositorOGL : public RenderCompositor {
protected:
RefPtr<gl::GLContext> mGL;
bool mIsEGL;
EGLint mBufferAge;
};
} // namespace wr