diff options
author | Danny Lin <danny@kdrag0n.dev> | 2021-04-14 15:57:04 -0700 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2021-09-27 21:17:05 +0800 |
commit | c39e71e314024a98f09eae452fd6bc0101978d6a (patch) | |
tree | 1b0f092853fd9b9b3af808f93fb198aeabae0d1c | |
parent | 50a425a8f1388e7b309764963ce6ff0f16f93c11 (diff) |
[ProtonAOSP] blur: Invalidate newly-bound framebuffers before renderinglineage-18.1
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
-rw-r--r-- | libs/renderengine/gl/filters/BlurFilter.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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"); |