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

Commit c939411a authored by Brian C. Anderson's avatar Brian C. Anderson Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'latchAndLastRefresh'

* changes:
  EGL: Expose latch, last composite, and dequeue ready.
  Add a DequeueReady FrameEvent
parents b621c5f0 f7fd56a6
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ enum class FrameEvent {
    GL_COMPOSITION_DONE,
    DISPLAY_PRESENT,
    DISPLAY_RETIRE,
    DEQUEUE_READY,
    RELEASE,
    EVENT_COUNT, // Not an actual event.
};
@@ -61,6 +62,7 @@ struct FrameEvents {
    bool hasDisplayPresentInfo() const;
    bool hasDisplayRetireInfo() const;
    bool hasReleaseInfo() const;
    bool hasDequeueReadyInfo() const;

    void checkFencesForCompletion();
    void dump(String8& outString) const;
@@ -84,6 +86,7 @@ struct FrameEvents {
    nsecs_t latchTime{-1};
    nsecs_t firstRefreshStartTime{-1};
    nsecs_t lastRefreshStartTime{-1};
    nsecs_t dequeueReadyTime{-1};

    std::shared_ptr<FenceTime> acquireFence{FenceTime::NO_FENCE};
    std::shared_ptr<FenceTime> gpuCompositionDoneFence{FenceTime::NO_FENCE};
@@ -194,7 +197,7 @@ public:
            const std::shared_ptr<FenceTime>& displayPresent);
    void addRetire(uint64_t frameNumber,
            const std::shared_ptr<FenceTime>& displayRetire);
    void addRelease(uint64_t frameNumber,
    void addRelease(uint64_t frameNumber, nsecs_t dequeueReadyTime,
            std::shared_ptr<FenceTime>&& release);

    void getAndResetDelta(FrameEventHistoryDelta* delta);
@@ -255,6 +258,7 @@ private:
    nsecs_t mLatchTime{0};
    nsecs_t mFirstRefreshStartTime{0};
    nsecs_t mLastRefreshStartTime{0};
    nsecs_t mDequeueReadyTime{0};

    FenceTime::Snapshot mGpuCompositionDoneFence;
    FenceTime::Snapshot mDisplayPresentFence;
+3 −2
Original line number Diff line number Diff line
@@ -146,9 +146,10 @@ public:
    // See IGraphicBufferProducer::getFrameTimestamps
    status_t getFrameTimestamps(uint64_t frameNumber,
            nsecs_t* outRequestedPresentTime, nsecs_t* outAcquireTime,
            nsecs_t* outRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
            nsecs_t* outLatchTime, nsecs_t* outFirstRefreshStartTime,
            nsecs_t* outLastRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
            nsecs_t* outDisplayPresentTime, nsecs_t* outDisplayRetireTime,
            nsecs_t* outReleaseTime);
            nsecs_t* outDequeueReadyTime, nsecs_t* outReleaseTime);

    status_t getUniqueId(uint64_t* outId) const;

+22 −4
Original line number Diff line number Diff line
@@ -55,6 +55,10 @@ bool FrameEvents::hasLastRefreshStartInfo() const {
    return addRetireCalled || addReleaseCalled;
}

bool FrameEvents::hasDequeueReadyInfo() const {
    return Fence::isValidTimestamp(dequeueReadyTime);
}

bool FrameEvents::hasAcquireInfo() const {
    return acquireFence->isValid();
}
@@ -141,6 +145,14 @@ void FrameEvents::dump(String8& outString) const
            !addPostCompositeCalled, *displayPresentFence);
    dumpFenceTime(outString, "Display Retire    \t",
            !addRetireCalled, *displayRetireFence);

    outString.appendFormat("--- DequeueReady  \t");
    if (Fence::isValidTimestamp(dequeueReadyTime)) {
        outString.appendFormat("%" PRId64 "\n", dequeueReadyTime);
    } else {
        outString.appendFormat("Pending\n");
    }

    dumpFenceTime(outString, "Release           \t",
            true, *releaseFence);
}
@@ -262,6 +274,7 @@ void ProducerFrameEventHistory::applyDelta(
        frame.latchTime = d.mLatchTime;
        frame.firstRefreshStartTime = d.mFirstRefreshStartTime;
        frame.lastRefreshStartTime = d.mLastRefreshStartTime;
        frame.dequeueReadyTime = d.mDequeueReadyTime;

        if (frame.frameNumber != d.mFrameNumber) {
            // We got a new frame. Initialize some of the fields.
@@ -411,14 +424,15 @@ void ConsumerFrameEventHistory::addRetire(
    mFramesDirty[mRetireOffset].setDirty<FrameEvent::DISPLAY_RETIRE>();
}

void ConsumerFrameEventHistory::addRelease(
        uint64_t frameNumber, std::shared_ptr<FenceTime>&& release) {
void ConsumerFrameEventHistory::addRelease(uint64_t frameNumber,
        nsecs_t dequeueReadyTime, std::shared_ptr<FenceTime>&& release) {
    FrameEvents* frame = getFrame(frameNumber, &mReleaseOffset);
    if (frame == nullptr) {
        ALOGE("ConsumerFrameEventHistory::addRelease: Did not find frame.");
        return;
    }
    frame->addReleaseCalled = true;
    frame->dequeueReadyTime = dequeueReadyTime;
    frame->releaseFence = std::move(release);
    mFramesDirty[mReleaseOffset].setDirty<FrameEvent::RELEASE>();
}
@@ -467,7 +481,8 @@ FrameEventsDelta::FrameEventsDelta(
      mRequestedPresentTime(frameTimestamps.requestedPresentTime),
      mLatchTime(frameTimestamps.latchTime),
      mFirstRefreshStartTime(frameTimestamps.firstRefreshStartTime),
      mLastRefreshStartTime(frameTimestamps.lastRefreshStartTime) {
      mLastRefreshStartTime(frameTimestamps.lastRefreshStartTime),
      mDequeueReadyTime(frameTimestamps.dequeueReadyTime) {
    if (dirtyFields.isDirty<FrameEvent::GL_COMPOSITION_DONE>()) {
        mGpuCompositionDoneFence =
                frameTimestamps.gpuCompositionDoneFence->getSnapshot();
@@ -495,7 +510,8 @@ size_t FrameEventsDelta::minFlattenedSize() {
            sizeof(FrameEventsDelta::mRequestedPresentTime) +
            sizeof(FrameEventsDelta::mLatchTime) +
            sizeof(FrameEventsDelta::mFirstRefreshStartTime) +
            sizeof(FrameEventsDelta::mLastRefreshStartTime);
            sizeof(FrameEventsDelta::mLastRefreshStartTime) +
            sizeof(FrameEventsDelta::mDequeueReadyTime);
    return min;
}

@@ -544,6 +560,7 @@ status_t FrameEventsDelta::flatten(void*& buffer, size_t& size, int*& fds,
    FlattenableUtils::write(buffer, size, mLatchTime);
    FlattenableUtils::write(buffer, size, mFirstRefreshStartTime);
    FlattenableUtils::write(buffer, size, mLastRefreshStartTime);
    FlattenableUtils::write(buffer, size, mDequeueReadyTime);

    // Fences
    for (auto fence : allFences(this)) {
@@ -582,6 +599,7 @@ status_t FrameEventsDelta::unflatten(void const*& buffer, size_t& size,
    FlattenableUtils::read(buffer, size, mLatchTime);
    FlattenableUtils::read(buffer, size, mFirstRefreshStartTime);
    FlattenableUtils::read(buffer, size, mLastRefreshStartTime);
    FlattenableUtils::read(buffer, size, mDequeueReadyTime);

    // Fences
    for (auto fence : allFences(this)) {
+34 −13
Original line number Diff line number Diff line
@@ -150,27 +150,39 @@ void Surface::enableFrameTimestamps(bool enable) {

static bool checkConsumerForUpdates(
        const FrameEvents* e, const uint64_t lastFrameNumber,
        const nsecs_t* outRefreshStartTime,
        const nsecs_t* outLatchTime,
        const nsecs_t* outFirstRefreshStartTime,
        const nsecs_t* outLastRefreshStartTime,
        const nsecs_t* outGlCompositionDoneTime,
        const nsecs_t* outDisplayPresentTime,
        const nsecs_t* outDisplayRetireTime,
        const nsecs_t* outDequeueReadyTime,
        const nsecs_t* outReleaseTime) {
    bool checkForRefreshStart = (outRefreshStartTime != nullptr) &&
    bool checkForLatch = (outLatchTime != nullptr) && !e->hasLatchInfo();
    bool checkForFirstRefreshStart = (outFirstRefreshStartTime != nullptr) &&
            !e->hasFirstRefreshStartInfo();
    bool checkForGlCompositionDone = (outGlCompositionDoneTime != nullptr) &&
            !e->hasGpuCompositionDoneInfo();
    bool checkForDisplayPresent = (outDisplayPresentTime != nullptr) &&
            !e->hasDisplayPresentInfo();

    // DisplayRetire and Release are never available for the last frame.
    // LastRefreshStart, DisplayRetire, DequeueReady, and Release are never
    // available for the last frame.
    bool checkForLastRefreshStart = (outLastRefreshStartTime != nullptr) &&
            !e->hasLastRefreshStartInfo() &&
            (e->frameNumber != lastFrameNumber);
    bool checkForDisplayRetire = (outDisplayRetireTime != nullptr) &&
            !e->hasDisplayRetireInfo() && (e->frameNumber != lastFrameNumber);
    bool checkForDequeueReady = (outDequeueReadyTime != nullptr) &&
            !e->hasDequeueReadyInfo() && (e->frameNumber != lastFrameNumber);
    bool checkForRelease = (outReleaseTime != nullptr) &&
            !e->hasReleaseInfo() && (e->frameNumber != lastFrameNumber);

    // RequestedPresent and Acquire info are always available producer-side.
    return checkForRefreshStart || checkForGlCompositionDone ||
            checkForDisplayPresent || checkForDisplayRetire || checkForRelease;
    return checkForLatch || checkForFirstRefreshStart ||
            checkForLastRefreshStart || checkForGlCompositionDone ||
            checkForDisplayPresent || checkForDisplayRetire ||
            checkForDequeueReady || checkForRelease;
}

static void getFrameTimestamp(nsecs_t *dst, const nsecs_t& src) {
@@ -188,9 +200,10 @@ static void getFrameTimestampFence(nsecs_t *dst, const std::shared_ptr<FenceTime

status_t Surface::getFrameTimestamps(uint64_t frameNumber,
        nsecs_t* outRequestedPresentTime, nsecs_t* outAcquireTime,
        nsecs_t* outRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
        nsecs_t* outLatchTime, nsecs_t* outFirstRefreshStartTime,
        nsecs_t* outLastRefreshStartTime, nsecs_t* outGlCompositionDoneTime,
        nsecs_t* outDisplayPresentTime, nsecs_t* outDisplayRetireTime,
        nsecs_t* outReleaseTime) {
        nsecs_t* outDequeueReadyTime, nsecs_t* outReleaseTime) {
    ATRACE_CALL();

    Mutex::Autolock lock(mMutex);
@@ -217,8 +230,9 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber,

    // Update our cache of events if the requested events are not available.
    if (checkConsumerForUpdates(events, mLastFrameNumber,
            outRefreshStartTime, outGlCompositionDoneTime,
            outDisplayPresentTime, outDisplayRetireTime, outReleaseTime)) {
            outLatchTime, outFirstRefreshStartTime, outLastRefreshStartTime,
            outGlCompositionDoneTime, outDisplayPresentTime,
            outDisplayRetireTime, outDequeueReadyTime, outReleaseTime)) {
        FrameEventHistoryDelta delta;
        mGraphicBufferProducer->getFrameTimestamps(&delta);
        mFrameEventHistory->applyDelta(delta);
@@ -232,7 +246,10 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber,
    }

    getFrameTimestamp(outRequestedPresentTime, events->requestedPresentTime);
    getFrameTimestamp(outRefreshStartTime, events->firstRefreshStartTime);
    getFrameTimestamp(outLatchTime, events->latchTime);
    getFrameTimestamp(outFirstRefreshStartTime, events->firstRefreshStartTime);
    getFrameTimestamp(outLastRefreshStartTime, events->lastRefreshStartTime);
    getFrameTimestamp(outDequeueReadyTime, events->dequeueReadyTime);

    getFrameTimestampFence(outAcquireTime, events->acquireFence);
    getFrameTimestampFence(
@@ -941,15 +958,19 @@ int Surface::dispatchGetFrameTimestamps(va_list args) {
    uint32_t framesAgo = va_arg(args, uint32_t);
    nsecs_t* outRequestedPresentTime = va_arg(args, int64_t*);
    nsecs_t* outAcquireTime = va_arg(args, int64_t*);
    nsecs_t* outRefreshStartTime = va_arg(args, int64_t*);
    nsecs_t* outLatchTime = va_arg(args, int64_t*);
    nsecs_t* outFirstRefreshStartTime = va_arg(args, int64_t*);
    nsecs_t* outLastRefreshStartTime = va_arg(args, int64_t*);
    nsecs_t* outGlCompositionDoneTime = va_arg(args, int64_t*);
    nsecs_t* outDisplayPresentTime = va_arg(args, int64_t*);
    nsecs_t* outDisplayRetireTime = va_arg(args, int64_t*);
    nsecs_t* outDequeueReadyTime = va_arg(args, int64_t*);
    nsecs_t* outReleaseTime = va_arg(args, int64_t*);
    return getFrameTimestamps(getNextFrameNumber() - 1 - framesAgo,
            outRequestedPresentTime, outAcquireTime, outRefreshStartTime,
            outRequestedPresentTime, outAcquireTime, outLatchTime,
            outFirstRefreshStartTime, outLastRefreshStartTime,
            outGlCompositionDoneTime, outDisplayPresentTime,
            outDisplayRetireTime, outReleaseTime);
            outDisplayRetireTime, outDequeueReadyTime, outReleaseTime);
}

int Surface::connect(int api) {
+99 −76

File changed.

Preview size limit exceeded, changes collapsed.

Loading