diff options
author | Vishnu Nair <vishnun@google.com> | 2021-06-21 21:18:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-06-21 21:18:33 +0000 |
commit | 769add28779ff4f9aec5aec9a61334c1af7bd0f6 (patch) | |
tree | 9c0e9c86138c86d3ce9fa0aea7680e843c20a3c1 | |
parent | 831288d496135c75d50467facd69064e0d8fa7bc (diff) | |
parent | 9a69a04e3dc0765a8c97cd837873be99234360ce (diff) | |
download | native-769add28779ff4f9aec5aec9a61334c1af7bd0f6.tar.gz |
Merge "Blast: Populate compositor timings" into sc-dev
-rw-r--r-- | libs/gui/include/gui/FrameTimestamps.h | 1 | ||||
-rw-r--r-- | libs/gui/tests/BLASTBufferQueue_test.cpp | 27 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 17 |
3 files changed, 36 insertions, 9 deletions
diff --git a/libs/gui/include/gui/FrameTimestamps.h b/libs/gui/include/gui/FrameTimestamps.h index 0750080e1c..dd3de58844 100644 --- a/libs/gui/include/gui/FrameTimestamps.h +++ b/libs/gui/include/gui/FrameTimestamps.h @@ -131,6 +131,7 @@ public: // Public for testing. static nsecs_t snapToNextTick( nsecs_t timestamp, nsecs_t tickPhase, nsecs_t tickInterval); + nsecs_t getReportedCompositeDeadline() const { return mCompositorTiming.deadline; }; nsecs_t getNextCompositeDeadline(const nsecs_t now) const; nsecs_t getCompositeInterval() const { return mCompositorTiming.interval; } diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp index d69aac505b..6ff67aa7cb 100644 --- a/libs/gui/tests/BLASTBufferQueue_test.cpp +++ b/libs/gui/tests/BLASTBufferQueue_test.cpp @@ -1109,4 +1109,31 @@ TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_DroppedFrame) { adapter.waitForCallbacks(); } +TEST_F(BLASTFrameEventHistoryTest, FrameEventHistory_CompositorTimings) { + BLASTBufferQueueHelper adapter(mSurfaceControl, mDisplayWidth, mDisplayHeight); + sp<IGraphicBufferProducer> igbProducer; + ProducerFrameEventHistory history; + setUpProducer(adapter, igbProducer); + + IGraphicBufferProducer::QueueBufferOutput qbOutput; + nsecs_t requestedPresentTimeA = 0; + nsecs_t postedTimeA = 0; + adapter.setTransactionCompleteCallback(1); + setUpAndQueueBuffer(igbProducer, &requestedPresentTimeA, &postedTimeA, &qbOutput, true); + history.applyDelta(qbOutput.frameTimestamps); + adapter.waitForCallback(1); + + // queue another buffer so we query for frame event deltas + nsecs_t requestedPresentTimeB = 0; + nsecs_t postedTimeB = 0; + setUpAndQueueBuffer(igbProducer, &requestedPresentTimeB, &postedTimeB, &qbOutput, true); + history.applyDelta(qbOutput.frameTimestamps); + + // check for a valid compositor deadline + ASSERT_NE(0, history.getReportedCompositeDeadline()); + + // wait for any callbacks that have not been received + adapter.waitForCallbacks(); +} + } // namespace android diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 26581a07ea..e01ea5c027 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2231,18 +2231,15 @@ void SurfaceFlinger::postComposition() { getBE().mDisplayTimeline.push(mPreviousPresentFences[0].fenceTime); + nsecs_t now = systemTime(); + // Set presentation information before calling Layer::releasePendingBuffer, such that jank // information from previous' frame classification is already available when sending jank info // to clients, so they get jank classification as early as possible. - mFrameTimeline->setSfPresent(systemTime(), mPreviousPresentFences[0].fenceTime, + mFrameTimeline->setSfPresent(/* sfPresentTime */ now, mPreviousPresentFences[0].fenceTime, glCompositionDoneFenceTime); - nsecs_t dequeueReadyTime = systemTime(); - for (const auto& layer : mLayersWithQueuedFrames) { - layer->releasePendingBuffer(dequeueReadyTime); - } - - const DisplayStatInfo stats = mScheduler->getDisplayStatInfo(systemTime()); + const DisplayStatInfo stats = mScheduler->getDisplayStatInfo(now); // We use the CompositionEngine::getLastFrameRefreshTimestamp() which might // be sampled a little later than when we started doing work for this frame, @@ -2259,6 +2256,7 @@ void SurfaceFlinger::postComposition() { const bool frameLatched = layer->onPostComposition(display, glCompositionDoneFenceTime, mPreviousPresentFences[0].fenceTime, compositorTiming); + layer->releasePendingBuffer(/*dequeueReadyTime*/ now); if (frameLatched) { recordBufferingStats(layer->getName(), layer->getOccupancyHistory(false)); } @@ -4473,10 +4471,11 @@ void SurfaceFlinger::onInitializeDisplays() { d.height = 0; displays.add(d); + nsecs_t now = systemTime(); // It should be on the main thread, apply it directly. applyTransactionState(FrameTimelineInfo{}, state, displays, 0, mInputWindowCommands, - systemTime(), true, {}, systemTime(), true, false, {}, getpid(), getuid(), - 0 /* Undefined transactionId */); + /* desiredPresentTime */ now, true, {}, /* postTime */ now, true, false, + {}, getpid(), getuid(), 0 /* Undefined transactionId */); setPowerModeInternal(display, hal::PowerMode::ON); const nsecs_t vsyncPeriod = mRefreshRateConfigs->getCurrentRefreshRate().getVsyncPeriod(); |