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

Commit f7fd56a6 authored by Brian Anderson's avatar Brian Anderson
Browse files

EGL: Expose latch, last composite, and dequeue ready.

Also fix discontinuous reserved token values.

Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*

Change-Id: I9d513b8784a7205dfe534c1c74b56c18cd49e74a
parent f6386862
Loading
Loading
Loading
Loading
+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;

+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) {
+94 −73

File changed.

Preview size limit exceeded, changes collapsed.

+8 −5
Original line number Diff line number Diff line
@@ -634,11 +634,14 @@ typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROID) (co
#define EGL_TIMESTAMPS_ANDROID 0x314D
#define EGL_REQUESTED_PRESENT_TIME_ANDROID 0x314E
#define EGL_RENDERING_COMPLETE_TIME_ANDROID 0x314F
#define EGL_COMPOSITION_START_TIME_ANDROID 0x3430
#define EGL_COMPOSITION_FINISHED_TIME_ANDROID 0x3431
#define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x3432
#define EGL_DISPLAY_RETIRE_TIME_ANDROID 0x3433
#define EGL_READS_DONE_TIME_ANDROID 0x3434
#define EGL_COMPOSITION_LATCH_TIME_ANDROID 0x3150
#define EGL_FIRST_COMPOSITION_START_TIME_ANDROID 0x3151
#define EGL_LAST_COMPOSITION_START_TIME_ANDROID 0x3152
#define EGL_FIRST_COMPOSITION_FINISHED_TIME_ANDROID 0x3153
#define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x3154
#define EGL_DISPLAY_RETIRE_TIME_ANDROID 0x3155
#define EGL_DEQUEUE_READY_TIME_ANDROID 0x3156
#define EGL_READS_DONE_TIME_ANDROID 0x3157
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLBoolean eglGetFrameTimestampsANDROID(EGLDisplay dpy, EGLSurface surface, EGLint framesAgo, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values);
EGLAPI EGLBoolean eglQueryTimestampSupportedANDROID(EGLDisplay dpy, EGLSurface surface, EGLint timestamp);
+24 −9
Original line number Diff line number Diff line
@@ -2041,10 +2041,13 @@ EGLBoolean eglGetFrameTimestampsANDROID(EGLDisplay dpy, EGLSurface surface,

    nsecs_t* requestedPresentTime = nullptr;
    nsecs_t* acquireTime = nullptr;
    nsecs_t* refreshStartTime = nullptr;
    nsecs_t* latchTime = nullptr;
    nsecs_t* firstRefreshStartTime = nullptr;
    nsecs_t* GLCompositionDoneTime = nullptr;
    nsecs_t* lastRefreshStartTime = nullptr;
    nsecs_t* displayPresentTime = nullptr;
    nsecs_t* displayRetireTime = nullptr;
    nsecs_t* dequeueReadyTime = nullptr;
    nsecs_t* releaseTime = nullptr;

    for (int i = 0; i < numTimestamps; i++) {
@@ -2055,10 +2058,16 @@ EGLBoolean eglGetFrameTimestampsANDROID(EGLDisplay dpy, EGLSurface surface,
            case EGL_RENDERING_COMPLETE_TIME_ANDROID:
                acquireTime = &values[i];
                break;
            case EGL_COMPOSITION_START_TIME_ANDROID:
                refreshStartTime = &values[i];
            case EGL_COMPOSITION_LATCH_TIME_ANDROID:
                latchTime = &values[i];
                break;
            case EGL_COMPOSITION_FINISHED_TIME_ANDROID:
            case EGL_FIRST_COMPOSITION_START_TIME_ANDROID:
                firstRefreshStartTime = &values[i];
                break;
            case EGL_LAST_COMPOSITION_START_TIME_ANDROID:
                lastRefreshStartTime = &values[i];
                break;
            case EGL_FIRST_COMPOSITION_FINISHED_TIME_ANDROID:
                GLCompositionDoneTime = &values[i];
                break;
            case EGL_DISPLAY_PRESENT_TIME_ANDROID:
@@ -2067,6 +2076,9 @@ EGLBoolean eglGetFrameTimestampsANDROID(EGLDisplay dpy, EGLSurface surface,
            case EGL_DISPLAY_RETIRE_TIME_ANDROID:
                displayRetireTime = &values[i];
                break;
            case EGL_DEQUEUE_READY_TIME_ANDROID:
                dequeueReadyTime = &values[i];
                break;
            case EGL_READS_DONE_TIME_ANDROID:
                releaseTime = &values[i];
                break;
@@ -2076,9 +2088,9 @@ EGLBoolean eglGetFrameTimestampsANDROID(EGLDisplay dpy, EGLSurface surface,
    }

    status_t ret = native_window_get_frame_timestamps(s->win.get(), framesAgo,
            requestedPresentTime, acquireTime, refreshStartTime,
            GLCompositionDoneTime, displayPresentTime, displayRetireTime,
            releaseTime);
            requestedPresentTime, acquireTime, latchTime, firstRefreshStartTime,
            lastRefreshStartTime, GLCompositionDoneTime, displayPresentTime,
            displayRetireTime, dequeueReadyTime, releaseTime);

    switch (ret) {
      case NO_ERROR:
@@ -2122,8 +2134,11 @@ EGLBoolean eglQueryTimestampSupportedANDROID(EGLDisplay dpy, EGLSurface surface,
#if ENABLE_EGL_ANDROID_GET_FRAME_TIMESTAMPS
        case EGL_REQUESTED_PRESENT_TIME_ANDROID:
        case EGL_RENDERING_COMPLETE_TIME_ANDROID:
        case EGL_COMPOSITION_START_TIME_ANDROID:
        case EGL_COMPOSITION_FINISHED_TIME_ANDROID:
        case EGL_COMPOSITION_LATCH_TIME_ANDROID:
        case EGL_FIRST_COMPOSITION_START_TIME_ANDROID:
        case EGL_LAST_COMPOSITION_START_TIME_ANDROID:
        case EGL_FIRST_COMPOSITION_FINISHED_TIME_ANDROID:
        case EGL_DEQUEUE_READY_TIME_ANDROID:
        case EGL_READS_DONE_TIME_ANDROID:
            return EGL_TRUE;
        case EGL_DISPLAY_PRESENT_TIME_ANDROID: {
Loading