From 0bde6b5a9837ab96484c988bb3f148d0b9b3ab4e Mon Sep 17 00:00:00 2001 From: Ady Abraham Date: Tue, 18 May 2021 13:57:02 -0700 Subject: SF: increase the number of buffers for SurfaceView 3 buffers are not sufficient for most apps to render at high refresh rates. This change increases the maxAcquiredBufferCount on the buffer queue for all surfaces, and removes the hwui-specific extra buffer allocations. All Surfaces connected to SurfaceFlinger will have now enough buffers to account for configured 'debug.sf.late.app.duration' value. Test: Run backpressure based game on 60Hz and 120Hz and collect traces Bug: 188553729 Change-Id: Ib8fda5db3f48c3bfc6fbf07167b4313674512cee --- libs/gui/BLASTBufferQueue.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libs/gui/BLASTBufferQueue.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index b9a293f4c3..8024482531 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -29,9 +29,10 @@ #include #include #include - #include +#include + #include using namespace std::chrono_literals; @@ -158,6 +159,11 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, const spsetDefaultBufferFormat(convertBufferFormat(format)); mBufferItemConsumer->setBlastBufferQueue(this); + int extraBufferCount = 0; + ComposerService::getComposerService()->getExtraBufferCount(&extraBufferCount); + mMaxAcquiredBuffers = 1 + extraBufferCount; + mBufferItemConsumer->setMaxAcquiredBufferCount(mMaxAcquiredBuffers); + mTransformHint = mSurfaceControl->getTransformHint(); mBufferItemConsumer->setTransformHint(mTransformHint); SurfaceComposerClient::Transaction() @@ -567,7 +573,7 @@ void BLASTBufferQueue::setTransactionCompleteCallback( // includeExtraAcquire is true to include this buffer to the count. Since this depends on the state // of the buffer, the next acquire may return with NO_BUFFER_AVAILABLE. bool BLASTBufferQueue::maxBuffersAcquired(bool includeExtraAcquire) const { - int maxAcquiredBuffers = MAX_ACQUIRED_BUFFERS + (includeExtraAcquire ? 2 : 1); + int maxAcquiredBuffers = mMaxAcquiredBuffers + (includeExtraAcquire ? 2 : 1); return mNumAcquired == maxAcquiredBuffers; } -- cgit v1.2.3-59-g8ed1b