Loading services/surfaceflinger/BufferLayer.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -425,7 +425,8 @@ bool BufferLayer::onPostComposition(const DisplayDevice* display, mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate)); mDrawingState.frameRate), getGameMode()); mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber, presentFence, FrameTracer::FrameEvent::PRESENT_FENCE); mFrameTracker.setActualPresentFence(std::shared_ptr<FenceTime>(presentFence)); Loading @@ -439,7 +440,8 @@ bool BufferLayer::onPostComposition(const DisplayDevice* display, mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate)); mDrawingState.frameRate), getGameMode()); mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber, actualPresentTime, FrameTracer::FrameEvent::PRESENT_FENCE); Loading services/surfaceflinger/BufferStateLayer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -444,7 +444,7 @@ bool BufferStateLayer::setBuffer(const std::shared_ptr<renderengine::ExternalTex const int32_t layerId = getSequence(); mFlinger->mTimeStats->setPostTime(layerId, mCurrentState.frameNumber, getName().c_str(), mOwnerUid, postTime); mOwnerUid, postTime, getGameMode()); mCurrentState.desiredPresentTime = desiredPresentTime; mCurrentState.isAutoTimestamp = isAutoTimestamp; Loading services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -304,7 +304,7 @@ SurfaceFrame::SurfaceFrame(const FrameTimelineInfo& frameTimelineInfo, pid_t own frametimeline::TimelineItem&& predictions, std::shared_ptr<TimeStats> timeStats, JankClassificationThresholds thresholds, TraceCookieCounter* traceCookieCounter, bool isBuffer) TraceCookieCounter* traceCookieCounter, bool isBuffer, int32_t gameMode) : mToken(frameTimelineInfo.vsyncId), mInputEventId(frameTimelineInfo.inputEventId), mOwnerPid(ownerPid), Loading @@ -319,7 +319,8 @@ SurfaceFrame::SurfaceFrame(const FrameTimelineInfo& frameTimelineInfo, pid_t own mTimeStats(timeStats), mJankClassificationThresholds(thresholds), mTraceCookieCounter(*traceCookieCounter), mIsBuffer(isBuffer) {} mIsBuffer(isBuffer), mGameMode(gameMode) {} void SurfaceFrame::setActualStartTime(nsecs_t actualStartTime) { std::scoped_lock lock(mMutex); Loading Loading @@ -607,8 +608,8 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, if (mPredictionState != PredictionState::None) { // Only update janky frames if the app used vsync predictions mTimeStats->incrementJankyFrames({refreshRate, mRenderRate, mOwnerUid, mLayerName, mJankType, displayDeadlineDelta, displayPresentDelta, deadlineDelta}); mGameMode, mJankType, displayDeadlineDelta, displayPresentDelta, deadlineDelta}); } } Loading Loading @@ -776,14 +777,14 @@ void FrameTimeline::registerDataSource() { std::shared_ptr<SurfaceFrame> FrameTimeline::createSurfaceFrameForToken( const FrameTimelineInfo& frameTimelineInfo, pid_t ownerPid, uid_t ownerUid, int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) { std::string layerName, std::string debugName, bool isBuffer, int32_t gameMode) { ATRACE_CALL(); if (frameTimelineInfo.vsyncId == FrameTimelineInfo::INVALID_VSYNC_ID) { return std::make_shared<SurfaceFrame>(frameTimelineInfo, ownerPid, ownerUid, layerId, std::move(layerName), std::move(debugName), PredictionState::None, TimelineItem(), mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter, isBuffer); isBuffer, gameMode); } std::optional<TimelineItem> predictions = mTokenManager.getPredictionsForToken(frameTimelineInfo.vsyncId); Loading @@ -792,13 +793,13 @@ std::shared_ptr<SurfaceFrame> FrameTimeline::createSurfaceFrameForToken( std::move(layerName), std::move(debugName), PredictionState::Valid, std::move(*predictions), mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter, isBuffer); &mTraceCookieCounter, isBuffer, gameMode); } return std::make_shared<SurfaceFrame>(frameTimelineInfo, ownerPid, ownerUid, layerId, std::move(layerName), std::move(debugName), PredictionState::Expired, TimelineItem(), mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter, isBuffer); isBuffer, gameMode); } FrameTimeline::DisplayFrame::DisplayFrame(std::shared_ptr<TimeStats> timeStats, Loading services/surfaceflinger/FrameTimeline/FrameTimeline.h +7 −3 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ public: int32_t layerId, std::string layerName, std::string debugName, PredictionState predictionState, TimelineItem&& predictions, std::shared_ptr<TimeStats> timeStats, JankClassificationThresholds thresholds, TraceCookieCounter* traceCookieCounter, bool isBuffer); TraceCookieCounter* traceCookieCounter, bool isBuffer, int32_t gameMode); ~SurfaceFrame() = default; // Returns std::nullopt if the frame hasn't been classified yet. Loading Loading @@ -259,6 +259,8 @@ private: // Tells if the SurfaceFrame is representing a buffer or a transaction without a // buffer(animations) bool mIsBuffer; // GameMode from the layer. Used in metrics. int32_t mGameMode = 0; }; /* Loading @@ -278,7 +280,8 @@ public: // Debug name is the human-readable debugging string for dumpsys. virtual std::shared_ptr<SurfaceFrame> createSurfaceFrameForToken( const FrameTimelineInfo& frameTimelineInfo, pid_t ownerPid, uid_t ownerUid, int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) = 0; int32_t layerId, std::string layerName, std::string debugName, bool isBuffer, int32_t gameMode) = 0; // Adds a new SurfaceFrame to the current DisplayFrame. Frames from multiple layers can be // composited into one display frame. Loading Loading @@ -437,7 +440,8 @@ public: frametimeline::TokenManager* getTokenManager() override { return &mTokenManager; } std::shared_ptr<SurfaceFrame> createSurfaceFrameForToken( const FrameTimelineInfo& frameTimelineInfo, pid_t ownerPid, uid_t ownerUid, int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) override; int32_t layerId, std::string layerName, std::string debugName, bool isBuffer, int32_t gameMode) 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, Loading services/surfaceflinger/Layer.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -1357,7 +1357,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransac mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, mTransactionName, /*isBuffer*/ false); /*isBuffer*/ false, getGameMode()); // For Transactions, the post time is considered to be both queue and acquire fence time. surfaceFrame->setActualQueueTime(postTime); surfaceFrame->setAcquireFenceTime(postTime); Loading @@ -1374,7 +1374,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer( auto surfaceFrame = mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, debugName, /*isBuffer*/ true); /*isBuffer*/ true, getGameMode()); // For buffers, acquire fence time will set during latch. surfaceFrame->setActualQueueTime(queueTime); const auto fps = mFlinger->mScheduler->getFrameRateOverride(getOwnerUid()); Loading Loading @@ -1635,7 +1635,8 @@ void Layer::addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps, FrameEventHistoryDelta* outDelta) { if (newTimestamps) { mFlinger->mTimeStats->setPostTime(getSequence(), newTimestamps->frameNumber, getName().c_str(), mOwnerUid, newTimestamps->postedTime); getName().c_str(), mOwnerUid, newTimestamps->postedTime, getGameMode()); mFlinger->mTimeStats->setAcquireFence(getSequence(), newTimestamps->frameNumber, newTimestamps->acquireFence); } Loading Loading
services/surfaceflinger/BufferLayer.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -425,7 +425,8 @@ bool BufferLayer::onPostComposition(const DisplayDevice* display, mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate)); mDrawingState.frameRate), getGameMode()); mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber, presentFence, FrameTracer::FrameEvent::PRESENT_FENCE); mFrameTracker.setActualPresentFence(std::shared_ptr<FenceTime>(presentFence)); Loading @@ -439,7 +440,8 @@ bool BufferLayer::onPostComposition(const DisplayDevice* display, mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime, refreshRate, renderRate, frameRateToSetFrameRateVotePayload( mDrawingState.frameRate)); mDrawingState.frameRate), getGameMode()); mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber, actualPresentTime, FrameTracer::FrameEvent::PRESENT_FENCE); Loading
services/surfaceflinger/BufferStateLayer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -444,7 +444,7 @@ bool BufferStateLayer::setBuffer(const std::shared_ptr<renderengine::ExternalTex const int32_t layerId = getSequence(); mFlinger->mTimeStats->setPostTime(layerId, mCurrentState.frameNumber, getName().c_str(), mOwnerUid, postTime); mOwnerUid, postTime, getGameMode()); mCurrentState.desiredPresentTime = desiredPresentTime; mCurrentState.isAutoTimestamp = isAutoTimestamp; Loading
services/surfaceflinger/FrameTimeline/FrameTimeline.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -304,7 +304,7 @@ SurfaceFrame::SurfaceFrame(const FrameTimelineInfo& frameTimelineInfo, pid_t own frametimeline::TimelineItem&& predictions, std::shared_ptr<TimeStats> timeStats, JankClassificationThresholds thresholds, TraceCookieCounter* traceCookieCounter, bool isBuffer) TraceCookieCounter* traceCookieCounter, bool isBuffer, int32_t gameMode) : mToken(frameTimelineInfo.vsyncId), mInputEventId(frameTimelineInfo.inputEventId), mOwnerPid(ownerPid), Loading @@ -319,7 +319,8 @@ SurfaceFrame::SurfaceFrame(const FrameTimelineInfo& frameTimelineInfo, pid_t own mTimeStats(timeStats), mJankClassificationThresholds(thresholds), mTraceCookieCounter(*traceCookieCounter), mIsBuffer(isBuffer) {} mIsBuffer(isBuffer), mGameMode(gameMode) {} void SurfaceFrame::setActualStartTime(nsecs_t actualStartTime) { std::scoped_lock lock(mMutex); Loading Loading @@ -607,8 +608,8 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType, if (mPredictionState != PredictionState::None) { // Only update janky frames if the app used vsync predictions mTimeStats->incrementJankyFrames({refreshRate, mRenderRate, mOwnerUid, mLayerName, mJankType, displayDeadlineDelta, displayPresentDelta, deadlineDelta}); mGameMode, mJankType, displayDeadlineDelta, displayPresentDelta, deadlineDelta}); } } Loading Loading @@ -776,14 +777,14 @@ void FrameTimeline::registerDataSource() { std::shared_ptr<SurfaceFrame> FrameTimeline::createSurfaceFrameForToken( const FrameTimelineInfo& frameTimelineInfo, pid_t ownerPid, uid_t ownerUid, int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) { std::string layerName, std::string debugName, bool isBuffer, int32_t gameMode) { ATRACE_CALL(); if (frameTimelineInfo.vsyncId == FrameTimelineInfo::INVALID_VSYNC_ID) { return std::make_shared<SurfaceFrame>(frameTimelineInfo, ownerPid, ownerUid, layerId, std::move(layerName), std::move(debugName), PredictionState::None, TimelineItem(), mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter, isBuffer); isBuffer, gameMode); } std::optional<TimelineItem> predictions = mTokenManager.getPredictionsForToken(frameTimelineInfo.vsyncId); Loading @@ -792,13 +793,13 @@ std::shared_ptr<SurfaceFrame> FrameTimeline::createSurfaceFrameForToken( std::move(layerName), std::move(debugName), PredictionState::Valid, std::move(*predictions), mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter, isBuffer); &mTraceCookieCounter, isBuffer, gameMode); } return std::make_shared<SurfaceFrame>(frameTimelineInfo, ownerPid, ownerUid, layerId, std::move(layerName), std::move(debugName), PredictionState::Expired, TimelineItem(), mTimeStats, mJankClassificationThresholds, &mTraceCookieCounter, isBuffer); isBuffer, gameMode); } FrameTimeline::DisplayFrame::DisplayFrame(std::shared_ptr<TimeStats> timeStats, Loading
services/surfaceflinger/FrameTimeline/FrameTimeline.h +7 −3 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ public: int32_t layerId, std::string layerName, std::string debugName, PredictionState predictionState, TimelineItem&& predictions, std::shared_ptr<TimeStats> timeStats, JankClassificationThresholds thresholds, TraceCookieCounter* traceCookieCounter, bool isBuffer); TraceCookieCounter* traceCookieCounter, bool isBuffer, int32_t gameMode); ~SurfaceFrame() = default; // Returns std::nullopt if the frame hasn't been classified yet. Loading Loading @@ -259,6 +259,8 @@ private: // Tells if the SurfaceFrame is representing a buffer or a transaction without a // buffer(animations) bool mIsBuffer; // GameMode from the layer. Used in metrics. int32_t mGameMode = 0; }; /* Loading @@ -278,7 +280,8 @@ public: // Debug name is the human-readable debugging string for dumpsys. virtual std::shared_ptr<SurfaceFrame> createSurfaceFrameForToken( const FrameTimelineInfo& frameTimelineInfo, pid_t ownerPid, uid_t ownerUid, int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) = 0; int32_t layerId, std::string layerName, std::string debugName, bool isBuffer, int32_t gameMode) = 0; // Adds a new SurfaceFrame to the current DisplayFrame. Frames from multiple layers can be // composited into one display frame. Loading Loading @@ -437,7 +440,8 @@ public: frametimeline::TokenManager* getTokenManager() override { return &mTokenManager; } std::shared_ptr<SurfaceFrame> createSurfaceFrameForToken( const FrameTimelineInfo& frameTimelineInfo, pid_t ownerPid, uid_t ownerUid, int32_t layerId, std::string layerName, std::string debugName, bool isBuffer) override; int32_t layerId, std::string layerName, std::string debugName, bool isBuffer, int32_t gameMode) 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, Loading
services/surfaceflinger/Layer.cpp +4 −3 Original line number Diff line number Diff line Loading @@ -1357,7 +1357,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransac mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, mTransactionName, /*isBuffer*/ false); /*isBuffer*/ false, getGameMode()); // For Transactions, the post time is considered to be both queue and acquire fence time. surfaceFrame->setActualQueueTime(postTime); surfaceFrame->setAcquireFenceTime(postTime); Loading @@ -1374,7 +1374,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer( auto surfaceFrame = mFlinger->mFrameTimeline->createSurfaceFrameForToken(info, mOwnerPid, mOwnerUid, getSequence(), mName, debugName, /*isBuffer*/ true); /*isBuffer*/ true, getGameMode()); // For buffers, acquire fence time will set during latch. surfaceFrame->setActualQueueTime(queueTime); const auto fps = mFlinger->mScheduler->getFrameRateOverride(getOwnerUid()); Loading Loading @@ -1635,7 +1635,8 @@ void Layer::addAndGetFrameTimestamps(const NewFrameEventsEntry* newTimestamps, FrameEventHistoryDelta* outDelta) { if (newTimestamps) { mFlinger->mTimeStats->setPostTime(getSequence(), newTimestamps->frameNumber, getName().c_str(), mOwnerUid, newTimestamps->postedTime); getName().c_str(), mOwnerUid, newTimestamps->postedTime, getGameMode()); mFlinger->mTimeStats->setAcquireFence(getSequence(), newTimestamps->frameNumber, newTimestamps->acquireFence); } Loading