From c39e71e314024a98f09eae452fd6bc0101978d6a Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Wed, 14 Apr 2021 15:57:04 -0700 Subject: [ProtonAOSP] blur: Invalidate newly-bound framebuffers before rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This signals to the GPU driver that the FBO contents do not need to be preserved. According to ARM, invalidating framebuffers after rendering and unbinding them won't do anything on Mali GPUs [1], but it improves performance with Qualcomm's Adreno GPU drivers. When tested with 2 layers of another 6-pass blur implementation, this saves ~100 µs of rendering time on an Adreno 640 GPU at 1440x3040 resolution. [1] https://community.arm.com/developer/tools-software/graphics/b/blog/posts/mali-performance-2-how-to-correctly-handle-framebuffers Change-Id: Ib26e904e66fbc95924d14bbe132cf8a0505d4f19 --- libs/renderengine/gl/filters/BlurFilter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/renderengine/gl/filters/BlurFilter.cpp b/libs/renderengine/gl/filters/BlurFilter.cpp index b139e4b3c5..2e80c62253 100644 --- a/libs/renderengine/gl/filters/BlurFilter.cpp +++ b/libs/renderengine/gl/filters/BlurFilter.cpp @@ -31,6 +31,9 @@ namespace android { namespace renderengine { namespace gl { +// This needs to be located in .rodata to get a pointer for the OpenGL API. +static const GLenum kInvalidateAttachment = GL_COLOR_ATTACHMENT0; + BlurFilter::BlurFilter(GLESRenderEngine& engine) : mEngine(engine), mCompositionFbo(engine), @@ -122,6 +125,7 @@ status_t BlurFilter::setAsDrawTarget(const DisplaySettings& display, uint32_t ra } mCompositionFbo.bind(); + glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &kInvalidateAttachment); glViewport(0, 0, mCompositionFbo.getBufferWidth(), mCompositionFbo.getBufferHeight()); return NO_ERROR; } @@ -151,6 +155,7 @@ status_t BlurFilter::prepare() { GLFramebuffer* draw = &mPingFbo; read->bindAsReadBuffer(); draw->bindAsDrawBuffer(); + glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &kInvalidateAttachment); glBlitFramebuffer(0, 0, read->getBufferWidth(), read->getBufferHeight(), 0, 0, @@ -161,6 +166,7 @@ status_t BlurFilter::prepare() { // And now we'll ping pong between our textures, to accumulate the result of various offsets. mBlurProgram.useProgram(); + glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &kInvalidateAttachment); glViewport(0, 0, draw->getBufferWidth(), draw->getBufferHeight()); for (auto i = 1; i < passes; i++) { ATRACE_NAME("BlurFilter::renderPass"); -- cgit v1.2.3