Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b69e0768 authored by Adithya Srinivasan's avatar Adithya Srinivasan
Browse files

Add trace event for fallback composition

When the HWC rejects composition of any layer, it is returned to
surfaceflinger and queued to the GPU for doing client composition.
This event is important to track as it can show why the GPU is busy at
that time.

Test: Set fallback composition in the middle of a GAPID trace from the
commandline
Bug: 140236090

Change-Id: Id1cb71f301023743dc9fa6a1396f8a525b5de7bd
parent 871023e6
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) {
    return hasReadyFrame();
}

bool BufferLayer::onPostComposition(const std::optional<DisplayId>& displayId,
bool BufferLayer::onPostComposition(sp<const DisplayDevice> displayDevice,
                                    const std::shared_ptr<FenceTime>& glDoneFence,
                                    const std::shared_ptr<FenceTime>& presentFence,
                                    const CompositorTiming& compositorTiming) {
@@ -308,6 +308,14 @@ bool BufferLayer::onPostComposition(const std::optional<DisplayId>& displayId,
    const int32_t layerId = getSequence();
    mFlinger->mTimeStats->setDesiredTime(layerId, mCurrentFrameNumber, desiredPresentTime);

    const auto outputLayer = findOutputLayerForDisplay(displayDevice);
    if (outputLayer && outputLayer->requiresClientComposition()) {
        nsecs_t clientCompositionTimestamp = outputLayer->getState().clientCompositionTimestamp;
        mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber,
                                               clientCompositionTimestamp,
                                               FrameTracer::FrameEvent::FALLBACK_COMPOSITION);
    }

    std::shared_ptr<FenceTime> frameReadyFence = mBufferInfo.mFenceTime;
    if (frameReadyFence->isValid()) {
        mFrameTracker.setFrameReadyFence(std::move(frameReadyFence));
@@ -317,6 +325,7 @@ bool BufferLayer::onPostComposition(const std::optional<DisplayId>& displayId,
        mFrameTracker.setFrameReadyTime(desiredPresentTime);
    }

    const auto displayId = displayDevice->getId();
    if (presentFence->isValid()) {
        mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence);
        mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber,
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public:

    bool isHdrY410() const override;

    bool onPostComposition(const std::optional<DisplayId>& displayId,
    bool onPostComposition(sp<const DisplayDevice> displayDevice,
                           const std::shared_ptr<FenceTime>& glDoneFence,
                           const std::shared_ptr<FenceTime>& presentFence,
                           const CompositorTiming& compositorTiming) override;
+3 −0
Original line number Diff line number Diff line
@@ -98,6 +98,9 @@ struct OutputLayerCompositionState {

    // Debugging
    void dump(std::string& result) const;

    // Timestamp for when the layer is queued for client composition
    nsecs_t clientCompositionTimestamp;
};

} // namespace compositionengine::impl
+1 −0
Original line number Diff line number Diff line
@@ -904,6 +904,7 @@ std::vector<renderengine::LayerSettings> Output::generateClientCompositionReques
                    layerSettings.disableBlending = true;
                }

                layer->editState().clientCompositionTimestamp = systemTime();
                clientCompositionLayers.push_back(*result);
            }
        }
+5 −0
Original line number Diff line number Diff line
@@ -805,6 +805,7 @@ TEST_F(GenerateClientCompositionRequestsTest, worksForLandscapeModeSplitScreen)
    EXPECT_CALL(leftOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
    EXPECT_CALL(leftLayer, getFEState()).WillRepeatedly(ReturnRef(leftLayerFEState));
    EXPECT_CALL(leftLayerFE, prepareClientComposition(_)).WillOnce(Return(leftLayerRESettings));
    EXPECT_CALL(leftOutputLayer, editState()).WillRepeatedly(ReturnRef(leftOutputLayerState));

    EXPECT_CALL(rightOutputLayer, getState()).WillRepeatedly(ReturnRef(rightOutputLayerState));
    EXPECT_CALL(rightOutputLayer, getLayer()).WillRepeatedly(ReturnRef(rightLayer));
@@ -813,6 +814,7 @@ TEST_F(GenerateClientCompositionRequestsTest, worksForLandscapeModeSplitScreen)
    EXPECT_CALL(rightOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
    EXPECT_CALL(rightLayer, getFEState()).WillRepeatedly(ReturnRef(rightLayerFEState));
    EXPECT_CALL(rightLayerFE, prepareClientComposition(_)).WillOnce(Return(rightLayerRESettings));
    EXPECT_CALL(rightOutputLayer, editState()).WillRepeatedly(ReturnRef(rightOutputLayerState));

    EXPECT_CALL(mOutput, getOutputLayerCount()).WillRepeatedly(Return(2u));
    EXPECT_CALL(mOutput, getOutputLayerOrderedByZByIndex(0u))
@@ -865,6 +867,7 @@ TEST_F(GenerateClientCompositionRequestsTest, ignoresLayersThatDoNotIntersectWit
    EXPECT_CALL(outputLayer, needsFiltering()).WillRepeatedly(Return(false));
    EXPECT_CALL(layer, getFEState()).WillRepeatedly(ReturnRef(layerFEState));
    EXPECT_CALL(layerFE, prepareClientComposition(_)).Times(0);
    EXPECT_CALL(outputLayer, editState()).WillRepeatedly(ReturnRef(outputLayerState));

    EXPECT_CALL(mOutput, getOutputLayerCount()).WillRepeatedly(Return(1u));
    EXPECT_CALL(mOutput, getOutputLayerOrderedByZByIndex(0u)).WillRepeatedly(Return(&outputLayer));
@@ -930,6 +933,7 @@ TEST_F(GenerateClientCompositionRequestsTest, clearsDeviceLayesAfterFirst) {
    EXPECT_CALL(leftOutputLayer, requiresClientComposition()).WillRepeatedly(Return(false));
    EXPECT_CALL(leftOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
    EXPECT_CALL(leftLayer, getFEState()).WillRepeatedly(ReturnRef(leftLayerFEState));
    EXPECT_CALL(leftOutputLayer, editState()).WillRepeatedly(ReturnRef(leftOutputLayerState));

    EXPECT_CALL(rightOutputLayer, getState()).WillRepeatedly(ReturnRef(rightOutputLayerState));
    EXPECT_CALL(rightOutputLayer, getLayer()).WillRepeatedly(ReturnRef(rightLayer));
@@ -938,6 +942,7 @@ TEST_F(GenerateClientCompositionRequestsTest, clearsDeviceLayesAfterFirst) {
    EXPECT_CALL(rightOutputLayer, needsFiltering()).WillRepeatedly(Return(false));
    EXPECT_CALL(rightLayer, getFEState()).WillRepeatedly(ReturnRef(rightLayerFEState));
    EXPECT_CALL(rightLayerFE, prepareClientComposition(_)).WillOnce(Return(rightLayerRESettings));
    EXPECT_CALL(rightOutputLayer, editState()).WillRepeatedly(ReturnRef(rightOutputLayerState));

    EXPECT_CALL(mOutput, getOutputLayerCount()).WillRepeatedly(Return(2u));
    EXPECT_CALL(mOutput, getOutputLayerOrderedByZByIndex(0u))
Loading