diff options
Diffstat (limited to 'libs/rs/driver/rsdBcc.cpp')
-rw-r--r-- | libs/rs/driver/rsdBcc.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp index 6c5a55b..8120864 100644 --- a/libs/rs/driver/rsdBcc.cpp +++ b/libs/rs/driver/rsdBcc.cpp @@ -17,6 +17,7 @@ #include "rsdCore.h" #include "rsdBcc.h" +#include "rsdRuntime.h" #include "rsContext.h" #include "rsScriptC.h" @@ -55,8 +56,9 @@ struct DrvScript { }; + static Script * setTLS(Script *sc) { - ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(Context::gThreadTLSKey); + ScriptTLSStruct * tls = (ScriptTLSStruct *)pthread_getspecific(rsdgThreadTLSKey); rsAssert(tls); Script *old = tls->mScript; tls->mScript = sc; @@ -129,16 +131,16 @@ bool rsdScriptInit(const Context *rsc, char const *cacheDir, uint8_t const *bitcode, size_t bitcodeSize, - uint32_t flags, - RsHalSymbolLookupFunc lookupFunc) { + uint32_t flags) { //LOGE("rsdScriptCreate %p %p %p %p %i %i %p", rsc, resName, cacheDir, bitcode, bitcodeSize, flags, lookupFunc); + pthread_mutex_lock(&rsdgInitMutex); char *cachePath = NULL; uint32_t objectSlotCount = 0; DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript)); if (drv == NULL) { - return false; + goto error; } script->mHal.drv = drv; @@ -149,7 +151,7 @@ bool rsdScriptInit(const Context *rsc, //LOGE("mBccScript %p", script->mBccScript); - if (bccRegisterSymbolCallback(drv->mBccScript, lookupFunc, script) != 0) { + if (bccRegisterSymbolCallback(drv->mBccScript, &rsdLookupRuntimeStub, script) != 0) { LOGE("bcc: FAILS to register symbol callback"); goto error; } @@ -159,20 +161,20 @@ bool rsdScriptInit(const Context *rsc, (char const *)drv->mScriptText, drv->mScriptTextLength, 0) != 0) { LOGE("bcc: FAILS to read bitcode"); - return NULL; + goto error; } #if 1 if (bccLinkFile(drv->mBccScript, "/system/lib/libclcore.bc", 0) != 0) { LOGE("bcc: FAILS to link bitcode"); - return NULL; + goto error; } #endif cachePath = genCacheFileName(cacheDir, resName, ".oBCC"); if (bccPrepareExecutable(drv->mBccScript, cachePath, 0) != 0) { LOGE("bcc: FAILS to prepare executable"); - return NULL; + goto error; } free(cachePath); @@ -234,10 +236,12 @@ bool rsdScriptInit(const Context *rsc, script->mHal.info.root = drv->mRoot; + pthread_mutex_unlock(&rsdgInitMutex); return true; error: + pthread_mutex_unlock(&rsdgInitMutex); free(drv); return false; @@ -334,7 +338,7 @@ void rsdScriptInvokeForEach(const Context *rsc, uint32_t usrLen, const RsScriptCall *sc) { - RsHal * dc = (RsHal *)rsc->mHal.drv; + RsdHal * dc = (RsdHal *)rsc->mHal.drv; MTLaunchStruct mtls; memset(&mtls, 0, sizeof(mtls)); @@ -381,7 +385,7 @@ void rsdScriptInvokeForEach(const Context *rsc, mtls.zEnd = rsMax((uint32_t)1, mtls.zEnd); mtls.arrayEnd = rsMax((uint32_t)1, mtls.arrayEnd); - rsAssert(ain->getType()->getDimZ() == 0); + rsAssert(!ain || (ain->getType()->getDimZ() == 0)); Context *mrsc = (Context *)rsc; Script * oldTLS = setTLS(s); @@ -513,7 +517,7 @@ void rsdScriptSetGlobalObj(const Context *dc, const Script *script, uint32_t slo return; } - rsiSetObject((ObjectBase **)destPtr, data); + rsrSetObject(dc, script, (ObjectBase **)destPtr, data); } void rsdScriptDestroy(const Context *dc, Script *script) { @@ -525,7 +529,7 @@ void rsdScriptDestroy(const Context *dc, Script *script) { // The field address can be NULL if the script-side has // optimized the corresponding global variable away. if (drv->mFieldAddress[ct]) { - rsiClearObject((ObjectBase **)drv->mFieldAddress[ct]); + rsrClearObject(dc, script, (ObjectBase **)drv->mFieldAddress[ct]); } } } |