Add Gpu composition info to FrameTimeline
Post composition, update the Display and SurfaceFrames that were
composited by the GPU.
Bug: 169876734
Test: None
Change-Id: Iad9c6e9714b28a56bfdcc32e514ab180850536b1
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
index b1dff8d..2784861 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.cpp
@@ -348,6 +348,11 @@
mRenderRate = renderRate;
}
+void SurfaceFrame::setGpuComposition() {
+ std::scoped_lock lock(mMutex);
+ mGpuComposition = true;
+}
+
std::optional<int32_t> SurfaceFrame::getJankType() const {
std::scoped_lock lock(mMutex);
if (mPresentState == PresentState::Dropped) {
@@ -828,10 +833,14 @@
}
void FrameTimeline::setSfPresent(nsecs_t sfPresentTime,
- const std::shared_ptr<FenceTime>& presentFence) {
+ const std::shared_ptr<FenceTime>& presentFence,
+ bool gpuComposition) {
ATRACE_CALL();
std::scoped_lock lock(mMutex);
mCurrentDisplayFrame->setActualEndTime(sfPresentTime);
+ if (gpuComposition) {
+ mCurrentDisplayFrame->setGpuComposition();
+ }
mPendingPresentFences.emplace_back(std::make_pair(presentFence, mCurrentDisplayFrame));
flushPendingPresentFences();
finalizeCurrentDisplayFrame();
@@ -869,6 +878,10 @@
mSurfaceFlingerActuals.endTime = actualEndTime;
}
+void FrameTimeline::DisplayFrame::setGpuComposition() {
+ mGpuComposition = true;
+}
+
void FrameTimeline::DisplayFrame::classifyJank(nsecs_t& deadlineDelta, nsecs_t& deltaToVsync) {
if (mPredictionState == PredictionState::Expired ||
mSurfaceFlingerActuals.presentTime == Fence::SIGNAL_TIME_INVALID) {
diff --git a/services/surfaceflinger/FrameTimeline/FrameTimeline.h b/services/surfaceflinger/FrameTimeline/FrameTimeline.h
index 3cf35f0..3f04592 100644
--- a/services/surfaceflinger/FrameTimeline/FrameTimeline.h
+++ b/services/surfaceflinger/FrameTimeline/FrameTimeline.h
@@ -180,6 +180,7 @@
void setDropTime(nsecs_t dropTime);
void setPresentState(PresentState presentState, nsecs_t lastLatchTime = 0);
void setRenderRate(Fps renderRate);
+ void setGpuComposition();
// When a bufferless SurfaceFrame is promoted to a buffer SurfaceFrame, we also have to update
// isBuffer.
@@ -292,11 +293,11 @@
// the token and sets the actualSfWakeTime for the current DisplayFrame.
virtual void setSfWakeUp(int64_t token, nsecs_t wakeupTime, Fps refreshRate) = 0;
- // Sets the sfPresentTime and finalizes the current DisplayFrame. Tracks the given present fence
- // until it's signaled, and updates the present timestamps of all presented SurfaceFrames in
- // that vsync.
- virtual void setSfPresent(nsecs_t sfPresentTime,
- const std::shared_ptr<FenceTime>& presentFence) = 0;
+ // Sets the sfPresentTime, gpuComposition and finalizes the current DisplayFrame. Tracks the
+ // given present fence until it's signaled, and updates the present timestamps of all presented
+ // SurfaceFrames in that vsync.
+ virtual void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
+ bool gpuComposition) = 0;
// Args:
// -jank : Dumps only the Display Frames that are either janky themselves
@@ -375,6 +376,7 @@
void setPredictions(PredictionState predictionState, TimelineItem predictions);
void setActualStartTime(nsecs_t actualStartTime);
void setActualEndTime(nsecs_t actualEndTime);
+ void setGpuComposition();
// BaseTime is the smallest timestamp in a DisplayFrame.
// Used for dumping all timestamps relative to the oldest, making it easy to read.
@@ -444,8 +446,8 @@
int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) override;
void addSurfaceFrame(std::shared_ptr<frametimeline::SurfaceFrame> surfaceFrame) override;
void setSfWakeUp(int64_t token, nsecs_t wakeupTime, Fps refreshRate) override;
- void setSfPresent(nsecs_t sfPresentTime,
- const std::shared_ptr<FenceTime>& presentFence) override;
+ void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
+ bool gpuComposition = false) override;
void parseArgs(const Vector<String16>& args, std::string& result) override;
void setMaxDisplayFrames(uint32_t size) override;
float computeFps(const std::unordered_set<int32_t>& layerIds) override;