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

Commit bdeec118 authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "Implement RS VSync on new vsync infrastructure."

parents c92e6f14 4c2e4c80
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -623,7 +623,7 @@ nAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con,
                        jint srcAlloc, jint srcXoff, jint srcYoff,
                        jint srcMip, jint srcFace)
{
    LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff, dstYoff,"
    LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i),"
            " dstMip(%i), dstFace(%i), width(%i), height(%i),"
            " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)",
            con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace,
+1 −3
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ LOCAL_SRC_FILES:= \
	rsFifoSocket.cpp \
	rsFileA3D.cpp \
	rsFont.cpp \
	rsLocklessFifo.cpp \
	rsObjectBase.cpp \
	rsMatrix2x2.cpp \
	rsMatrix3x3.cpp \
@@ -128,7 +127,7 @@ LOCAL_SRC_FILES:= \
	driver/rsdShaderCache.cpp \
	driver/rsdVertexArray.cpp

LOCAL_SHARED_LIBRARIES += libz libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libbcc libbcinfo
LOCAL_SHARED_LIBRARIES += libz libcutils libutils libEGL libGLESv1_CM libGLESv2 libui libbcc libbcinfo libgui

LOCAL_STATIC_LIBRARIES := libdex libft2

@@ -196,7 +195,6 @@ LOCAL_SRC_FILES:= \
	rsFifoSocket.cpp \
	rsFileA3D.cpp \
	rsFont.cpp \
	rsLocklessFifo.cpp \
	rsObjectBase.cpp \
	rsMatrix2x2.cpp \
	rsMatrix3x3.cpp \
+2 −0
Original line number Diff line number Diff line
@@ -215,6 +215,8 @@ bool rsdGLInit(const Context *rsc) {
    ret = eglChooseConfig(dc->gl.egl.display, configAttribs, 0, 0, &numConfigs);
    checkEglError("eglGetConfigs", ret);

    eglSwapInterval(dc->gl.egl.display, 0);

    if (numConfigs) {
        EGLConfig* const configs = new EGLConfig[numConfigs];

+1 −0
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ ContextSetPriority {
	}

ContextDestroyWorker {
        sync
}

AssignName {
+48 −36
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "rsContext.h"
#include "rsThreadIO.h"
#include <ui/FramebufferNativeWindow.h>
#include <gui/DisplayEventReceiver.h>

#include <sys/types.h>
#include <sys/resource.h>
@@ -245,42 +246,55 @@ void * Context::threadProc(void *vrsc) {
    }

    rsc->mRunning = true;
    bool mDraw = true;
    bool doWait = true;
    if (!rsc->mIsGraphicsContext) {
        while (!rsc->mExit) {
            rsc->mIO.playCoreCommands(rsc, true, -1);
        }
    } else {
#ifndef ANDROID_RS_SERIALIZE
        DisplayEventReceiver displayEvent;
        DisplayEventReceiver::Event eventBuffer[1];
#endif
        int vsyncRate = 0;
        int targetRate = 0;

    uint64_t targetTime = rsc->getTime();
        bool drawOnce = false;
        while (!rsc->mExit) {
        uint64_t waitTime = 0;
        uint64_t now = rsc->getTime();
        if (!doWait) {
            if (now < targetTime) {
                waitTime = targetTime - now;
                doWait = true;
            rsc->timerSet(RS_TIMER_IDLE);

#ifndef ANDROID_RS_SERIALIZE
            if (vsyncRate != targetRate) {
                displayEvent.setVsyncRate(targetRate);
                vsyncRate = targetRate;
            }
            if (targetRate) {
                drawOnce |= rsc->mIO.playCoreCommands(rsc, true, displayEvent.getFd());
                while (displayEvent.getEvents(eventBuffer, 1) != 0) {
                    //ALOGE("vs2 time past %lld", (rsc->getTime() - eventBuffer[0].header.timestamp) / 1000000);
                }
            } else
#endif
            {
                drawOnce |= rsc->mIO.playCoreCommands(rsc, true, -1);
            }

        mDraw |= rsc->mIO.playCoreCommands(rsc, doWait, waitTime);
        mDraw &= (rsc->mRootScript.get() != NULL);
        mDraw &= rsc->mHasSurface;
            if ((rsc->mRootScript.get() != NULL) && rsc->mHasSurface &&
                (targetRate || drawOnce) && !rsc->mPaused) {

        if (mDraw && rsc->mIsGraphicsContext) {
            uint64_t delay = rsc->runRootScript() * 1000000;
            targetTime = rsc->getTime() + delay;
            doWait = (delay == 0);
                drawOnce = false;
                targetRate = ((rsc->runRootScript() + 15) / 16);

                if (rsc->props.mLogVisual) {
                    rsc->displayDebugStats();
                }

            mDraw = !rsc->mPaused;
                rsc->timerSet(RS_TIMER_CLEAR_SWAP);
                rsc->mHal.funcs.swap(rsc);
                rsc->timerFrame();
                rsc->timerSet(RS_TIMER_INTERNAL);
                rsc->timerPrint();
                rsc->timerReset();
        } else {
            doWait = true;
            }
        }
    }

@@ -315,8 +329,8 @@ void Context::destroyWorkerThreadResources() {
         mFBOCache.deinit(this);
    }
    ObjectBase::freeAllChildren(this);
    //ALOGV("destroyWorkerThreadResources 2");
    mExit = true;
    //ALOGV("destroyWorkerThreadResources 2");
}

void Context::printWatchdogInfo(void *ctx) {
@@ -382,7 +396,7 @@ bool Context::initContext(Device *dev, const RsSurfaceConfig *sc) {
    pthread_mutex_lock(&gInitMutex);

    mIO.init();
    mIO.setTimoutCallback(printWatchdogInfo, this, 2e9);
    mIO.setTimeoutCallback(printWatchdogInfo, this, 2e9);

    dev->addContext(this);
    mDev = dev;
@@ -434,14 +448,12 @@ Context::~Context() {
    ALOGV("%p Context::~Context", this);

    if (!mIsContextLite) {
        mIO.coreFlush();
        rsAssert(mExit);
        mExit = true;
        mPaused = false;
        void *res;

        mIO.shutdown();
        int status = pthread_join(mThreadId, &res);
        rsAssert(mExit);

        if (mHal.funcs.shutdownDriver) {
            mHal.funcs.shutdownDriver(this);
Loading