BlastBufferQueue: Fix acquire counts when holding buffers
Update the acquire count when ever we release a buffer otherwise
when going from 120hz to 60hz we may release multiple buffers
and only decrement the acquire count once. This will prevent the
adapter from acquiring all the possible buffers.
Also make sure we process the shadow queue every time we release
a buffer.
Bug: 188553729
Test: Run backpressure based game on 60Hz and 90hz and collect traces
Change-Id: I23517ee0fe840a9215f368bd85713ba19dbeb2a3
diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp
index 364c939..e15e11c 100644
--- a/libs/gui/BLASTBufferQueue.cpp
+++ b/libs/gui/BLASTBufferQueue.cpp
@@ -151,7 +151,7 @@
1, false);
static int32_t id = 0;
auto consumerName = mName + "(BLAST Consumer)" + std::to_string(id);
- mPendingBufferTrace = "PendingBuffer - " + mName + "BLAST#" + std::to_string(id);
+ mQueuedBufferTrace = "QueuedBuffer - " + mName + "BLAST#" + std::to_string(id);
id++;
mBufferItemConsumer->setName(String8(consumerName.c_str()));
mBufferItemConsumer->setFrameAvailableListener(this);
@@ -361,16 +361,15 @@
graphicBufferId);
return;
}
-
+ mNumAcquired--;
mBufferItemConsumer->releaseBuffer(it->second, releaseBuffer.releaseFence);
mSubmitted.erase(it);
+ processNextBufferLocked(false /* useNextTransaction */);
}
ATRACE_INT("PendingRelease", mPendingRelease.size());
-
- mNumAcquired--;
- ATRACE_INT(mPendingBufferTrace.c_str(), mNumFrameAvailable + mNumAcquired);
- processNextBufferLocked(false /* useNextTransaction */);
+ ATRACE_INT(mQueuedBufferTrace.c_str(),
+ mNumFrameAvailable + mNumAcquired - mPendingRelease.size());
mCallbackCV.notify_all();
}
@@ -538,7 +537,8 @@
}
// add to shadow queue
mNumFrameAvailable++;
- ATRACE_INT(mPendingBufferTrace.c_str(), mNumFrameAvailable + mNumAcquired);
+ ATRACE_INT(mQueuedBufferTrace.c_str(),
+ mNumFrameAvailable + mNumAcquired - mPendingRelease.size());
BQA_LOGV("onFrameAvailable framenumber=%" PRIu64 " nextTransactionSet=%s", item.mFrameNumber,
toString(nextTransactionSet));