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

Commit 156cce69 authored by Jason Sams's avatar Jason Sams
Browse files

Improve RS error handling. On errors RS will now store the error and a...

Improve RS error handling.  On errors RS will now store the error and a message that can be read from the app.  RS will then not continue rendering frames while an unchecked error is present until new state is received.
parent a034cd3e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -202,6 +202,12 @@ enum RsPrimitive {
    RS_PRIMITIVE_TRIANGLE_FAN
};

enum RsError {
    RS_ERROR_NONE,
    RS_ERROR_BAD_SHADER,
    RS_ERROR_BAD_SCRIPT
};

#ifndef NO_RS_FUNCS
#include "rsgApiFuncDecl.h"
#endif
+5 −0
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@ ContextDump {
	param int32_t bits
}

ContextGetError {
	param RsError *err
	ret const char *
	}

ContextSetPriority {
	param int32_t priority
	}
+40 −2
Original line number Diff line number Diff line
@@ -178,6 +178,11 @@ uint32_t Context::runRootScript()
    uint32_t ret = runScript(mRootScript.get(), 0);

    checkError("runRootScript");
    if (mError != RS_ERROR_NONE) {
        // If we have an error condition we stop rendering until
        // somthing changes that might fix it.
        ret = 0;
    }
    return ret;
}

@@ -240,10 +245,13 @@ void Context::timerPrint()
    }
}

void Context::setupCheck()
bool Context::setupCheck()
{
    if (checkVersion2_0()) {
        mShaderCache.lookup(this, mVertex.get(), mFragment.get());
        if (!mShaderCache.lookup(this, mVertex.get(), mFragment.get())) {
            LOGE("Context::setupCheck() 1 fail");
            return false;
        }

        mFragmentStore->setupGL2(this, &mStateFragmentStore);
        mFragment->setupGL2(this, &mStateFragment, &mShaderCache);
@@ -256,6 +264,7 @@ void Context::setupCheck()
        mRaster->setupGL(this, &mStateRaster);
        mVertex->setupGL(this, &mStateVertex);
    }
    return true;
}

static bool getProp(const char *str)
@@ -389,6 +398,9 @@ Context::Context(Device *dev, bool isGraphics, bool useDepth)
    mUseDepth = useDepth;
    mPaused = false;
    mObjHead = NULL;
    mError = RS_ERROR_NONE;
    mErrorMsg = NULL;

    memset(&mEGL, 0, sizeof(mEGL));
    memset(&mGL, 0, sizeof(mGL));
    mIsGraphicsContext = isGraphics;
@@ -764,6 +776,23 @@ void Context::deinitToClient()
    mIO.mToClient.shutdown();
}

const char * Context::getError(RsError *err)
{
    *err = mError;
    mError = RS_ERROR_NONE;
    if (*err != RS_ERROR_NONE) {
        return mErrorMsg;
    }
    return NULL;
}

void Context::setError(RsError e, const char *msg)
{
    mError = e;
    mErrorMsg = msg;
}


void Context::dumpDebug() const
{
    LOGE("RS Context debug %p", this);
@@ -874,6 +903,15 @@ void rsi_ContextDump(Context *rsc, int32_t bits)
    ObjectBase::dumpAll(rsc);
}

const char * rsi_ContextGetError(Context *rsc, RsError *e)
{
    const char *msg = rsc->getError(e);
    if (*e != RS_ERROR_NONE) {
        LOGE("RS Error %i %s", *e, msg);
    }
    return msg;
}

}
}

+5 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public:
    const ProgramRaster * getRaster() {return mRaster.get();}
    const ProgramVertex * getVertex() {return mVertex.get();}

    void setupCheck();
    bool setupCheck();
    bool checkDriver() const {return mEGL.mSurface != 0;}

    void pause();
@@ -160,6 +160,8 @@ public:

    void dumpDebug() const;
    void checkError(const char *) const;
    const char * getError(RsError *);
    void setError(RsError e, const char *msg);

    mutable const ObjectBase * mObjHead;

@@ -211,6 +213,8 @@ protected:
    bool mExit;
    bool mUseDepth;
    bool mPaused;
    RsError mError;
    const char *mErrorMsg;

    pthread_t mThreadId;
    pid_t mNativeThreadId;
+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ Program::Program(Context *rsc) : ObjectBase(rsc)
    mInputCount = 0;
    mOutputCount = 0;
    mConstantCount = 0;
    mIsValid = false;
}

Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength,
@@ -216,6 +217,7 @@ bool Program::loadShader(Context *rsc, uint32_t type)
                }
                glDeleteShader(mShaderID);
                mShaderID = 0;
                rsc->setError(RS_ERROR_BAD_SHADER, "Error returned from GL driver loading shader text,");
                return false;
            }
        }
@@ -224,6 +226,7 @@ bool Program::loadShader(Context *rsc, uint32_t type)
    if (rsc->props.mLogShaders) {
        LOGV("--Shader load result %x ", glGetError());
    }
    mIsValid = true;
    return true;
}

Loading