From adf632ba3a3298b4e66edfc468cf3888d5f2eac4 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Thu, 7 Jan 2021 14:05:08 -0800 Subject: BlastBufferQueue: Pass client dequeue times to SurfaceFlinger SF keeps track of client dequeue, queue, acquire etc. timestamps to construct frame rendering timelines for developers. With BBQ, SF no longer has access to this data, so pass the dequeue time along with the buffers. Ideally this data should flow to the perfetto trace directly from the client but this is a temp solution while some perf issues with client logging is sorted out. Bug: 176931912 Test: manual tests Change-Id: Ic88170c1fb20850662cb99325ac42b7232a02817 --- libs/gui/BLASTBufferQueue.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libs/gui/BLASTBufferQueue.cpp') diff --git a/libs/gui/BLASTBufferQueue.cpp b/libs/gui/BLASTBufferQueue.cpp index eaa47f9680..f4b5a26033 100644 --- a/libs/gui/BLASTBufferQueue.cpp +++ b/libs/gui/BLASTBufferQueue.cpp @@ -354,6 +354,16 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) { t->setAutoRefresh(mSurfaceControl, bufferItem.mAutoRefresh); mAutoRefresh = bufferItem.mAutoRefresh; } + { + std::unique_lock _lock{mTimestampMutex}; + auto dequeueTime = mDequeueTimestamps.find(buffer->getId()); + if (dequeueTime != mDequeueTimestamps.end()) { + Parcel p; + p.writeInt64(dequeueTime->second); + t->setMetadata(mSurfaceControl, METADATA_DEQUEUE_TIME, p); + mDequeueTimestamps.erase(dequeueTime); + } + } auto mergeTransaction = [&t, currentFrameNumber = bufferItem.mFrameNumber]( @@ -412,6 +422,16 @@ void BLASTBufferQueue::onFrameReplaced(const BufferItem& item) { // Do nothing since we are not storing unacquired buffer items locally. } +void BLASTBufferQueue::onFrameDequeued(const uint64_t bufferId) { + std::unique_lock _lock{mTimestampMutex}; + mDequeueTimestamps[bufferId] = systemTime(); +}; + +void BLASTBufferQueue::onFrameCancelled(const uint64_t bufferId) { + std::unique_lock _lock{mTimestampMutex}; + mDequeueTimestamps.erase(bufferId); +}; + void BLASTBufferQueue::setNextTransaction(SurfaceComposerClient::Transaction* t) { std::lock_guard _lock{mMutex}; mNextTransaction = t; -- cgit v1.2.3-59-g8ed1b