diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/rs/rsContext.cpp | 25 | ||||
-rw-r--r-- | libs/rs/rsScriptC.cpp | 32 | ||||
-rw-r--r-- | libs/rs/rsScriptC.h | 7 |
3 files changed, 29 insertions, 35 deletions
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 3acb624..11d0bdc 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -201,9 +201,9 @@ bool Context::initGLThread() { mGL.mExtensions = glGetString(GL_EXTENSIONS); //LOGV("EGL Version %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion); - LOGV("GL Version %s", mGL.mVersion); + //LOGV("GL Version %s", mGL.mVersion); //LOGV("GL Vendor %s", mGL.mVendor); - LOGV("GL Renderer %s", mGL.mRenderer); + //LOGV("GL Renderer %s", mGL.mRenderer); //LOGV("GL Extensions %s", mGL.mExtensions); const char *verptr = NULL; @@ -468,7 +468,6 @@ void * Context::threadProc(void *vrsc) { return NULL; } - rsc->mScriptC.init(rsc); if (rsc->mIsGraphicsContext) { rsc->mStateRaster.init(rsc); rsc->setProgramRaster(NULL); @@ -528,7 +527,7 @@ void * Context::threadProc(void *vrsc) { } void Context::destroyWorkerThreadResources() { - LOGV("destroyWorkerThreadResources 1"); + //LOGV("destroyWorkerThreadResources 1"); if (mIsGraphicsContext) { mRaster.clear(); mFragment.clear(); @@ -544,7 +543,7 @@ void Context::destroyWorkerThreadResources() { mShaderCache.cleanupAll(); } ObjectBase::zeroAllUserRef(this); - LOGV("destroyWorkerThreadResources 2"); + //LOGV("destroyWorkerThreadResources 2"); mExit = true; } @@ -552,7 +551,7 @@ void * Context::helperThreadProc(void *vrsc) { Context *rsc = static_cast<Context *>(vrsc); uint32_t idx = (uint32_t)android_atomic_inc(&rsc->mWorkers.mLaunchCount); - LOGV("RS helperThread starting %p idx=%i", rsc, idx); + //LOGV("RS helperThread starting %p idx=%i", rsc, idx); rsc->mWorkers.mLaunchSignals[idx].init(); rsc->mWorkers.mNativeThreadId[idx] = gettid(); @@ -573,7 +572,7 @@ void * Context::helperThreadProc(void *vrsc) { LOGE("pthread_setspecific %i", status); } - while (rsc->mRunning) { + while (!rsc->mExit) { rsc->mWorkers.mLaunchSignals[idx].wait(); if (rsc->mWorkers.mLaunchCallback) { rsc->mWorkers.mLaunchCallback(rsc->mWorkers.mLaunchData, idx); @@ -582,7 +581,7 @@ void * Context::helperThreadProc(void *vrsc) { rsc->mWorkers.mCompleteSignal.set(); } - LOGV("RS helperThread exiting %p idx=%i", rsc, idx); + //LOGV("RS helperThread exited %p idx=%i", rsc, idx); return NULL; } @@ -730,6 +729,16 @@ Context::~Context() { mIO.shutdown(); int status = pthread_join(mThreadId, &res); + // Cleanup compute threads. + mWorkers.mLaunchData = NULL; + mWorkers.mLaunchCallback = NULL; + mWorkers.mRunningCount = (int)mWorkers.mCount; + for (uint32_t ct = 0; ct < mWorkers.mCount; ct++) { + mWorkers.mLaunchSignals[ct].set(); + int status = pthread_join(mWorkers.mThreadId[ct], &res); + } + rsAssert(!mWorkers.mRunningCount); + // Global structure cleanup. pthread_mutex_lock(&gInitMutex); if (mDev) { diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index eecfa16..3858e1c 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -421,21 +421,9 @@ void ScriptC::Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len } ScriptCState::ScriptCState() { - mScript.clear(); } ScriptCState::~ScriptCState() { - mScript.clear(); -} - -void ScriptCState::init(Context *rsc) { - clear(rsc); -} - -void ScriptCState::clear(Context *rsc) { - rsAssert(rsc); - mScript.clear(); - mScript.set(new ScriptC(rsc)); } static void* symbolLookup(void* pContext, char const* name) { @@ -608,8 +596,6 @@ namespace android { namespace renderscript { void rsi_ScriptCBegin(Context * rsc) { - ScriptCState *ss = &rsc->mScriptC; - ss->clear(rsc); } void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) { @@ -618,8 +604,8 @@ void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) { char *t = (char *)malloc(len + 1); memcpy(t, text, len); t[len] = 0; - ss->mScript->mEnviroment.mScriptText = t; - ss->mScript->mEnviroment.mScriptTextLength = len; + ss->mScriptText = t; + ss->mScriptLen = len; } @@ -630,17 +616,19 @@ RsScript rsi_ScriptCCreate(Context *rsc, { ScriptCState *ss = &rsc->mScriptC; - ObjectBaseRef<ScriptC> s(ss->mScript); - ss->mScript.clear(); + ScriptC *s = new ScriptC(rsc); + s->mEnviroment.mScriptText = ss->mScriptText; + s->mEnviroment.mScriptTextLength = ss->mScriptLen; + ss->mScriptText = NULL; + ss->mScriptLen = 0; s->incUserRef(); - if (!ss->runCompiler(rsc, s.get(), resName, cacheDir)) { + if (!ss->runCompiler(rsc, s, resName, cacheDir)) { // Error during compile, destroy s and return null. - s->zeroUserRef(); + delete s; return NULL; } - ss->clear(rsc); - return s.get(); + return s; } } diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h index 612e38a..7143c67 100644 --- a/libs/rs/rsScriptC.h +++ b/libs/rs/rsScriptC.h @@ -76,11 +76,9 @@ public: ScriptCState(); ~ScriptCState(); - ObjectBaseRef<ScriptC> mScript; + char * mScriptText; + size_t mScriptLen; - void init(Context *rsc); - - void clear(Context *rsc); bool runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir); struct SymbolTable_t { @@ -88,7 +86,6 @@ public: void * mPtr; bool threadable; }; - //static SymbolTable_t gSyms[]; static const SymbolTable_t * lookupSymbol(const char *); static const SymbolTable_t * lookupSymbolCL(const char *); static const SymbolTable_t * lookupSymbolGL(const char *); |