Skip to content
Snippets Groups Projects
Unverified Commit c7decbd6 authored by Danny Lin's avatar Danny Lin Committed by Simão Gomes Viana
Browse files

blur: Invalidate newly-bound framebuffers before rendering

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
Signed-off-by: default avatarMohammad Hasan Keramat J <ikeramat@protonmail.com>
Signed-off-by: default avatarSimão Gomes Viana <devel@superboring.dev>
parent 6a18e4e5
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......@@ -152,6 +156,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,
......@@ -162,6 +167,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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment