summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsScriptC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs/rsScriptC.cpp')
-rw-r--r--libs/rs/rsScriptC.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 072cc16..6587b51 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -104,16 +104,16 @@ Script * ScriptC::setTLS(Script *sc) {
void ScriptC::setupGLState(Context *rsc) {
if (mEnviroment.mFragmentStore.get()) {
- rsc->setFragmentStore(mEnviroment.mFragmentStore.get());
+ rsc->setProgramStore(mEnviroment.mFragmentStore.get());
}
if (mEnviroment.mFragment.get()) {
- rsc->setFragment(mEnviroment.mFragment.get());
+ rsc->setProgramFragment(mEnviroment.mFragment.get());
}
if (mEnviroment.mVertex.get()) {
- rsc->setVertex(mEnviroment.mVertex.get());
+ rsc->setProgramVertex(mEnviroment.mVertex.get());
}
if (mEnviroment.mRaster.get()) {
- rsc->setRaster(mEnviroment.mRaster.get());
+ rsc->setProgramRaster(mEnviroment.mRaster.get());
}
}
@@ -232,6 +232,7 @@ void ScriptC::runForEach(Context *rsc,
const RsScriptCall *sc) {
MTLaunchStruct mtls;
memset(&mtls, 0, sizeof(mtls));
+ Context::PushState ps(rsc);
if (ain) {
mtls.dimX = ain->getType()->getDimX();
@@ -395,15 +396,25 @@ static BCCvoid* symbolLookup(BCCvoid* pContext, const BCCchar* name) {
extern const char rs_runtime_lib_bc[];
extern unsigned rs_runtime_lib_bc_size;
-void ScriptCState::runCompiler(Context *rsc, ScriptC *s) {
+void ScriptCState::runCompiler(Context *rsc, ScriptC *s, const char *resName) {
{
- StopWatch compileTimer("RenderScript compile time");
s->mBccScript = bccCreateScript();
s->mEnviroment.mIsThreadable = true;
- bccScriptBitcode(s->mBccScript, s->mEnviroment.mScriptText, s->mEnviroment.mScriptTextLength);
- //bccLinkBitcode(s->mBccScript, rs_runtime_lib_bc, rs_runtime_lib_bc_size);
bccRegisterSymbolCallback(s->mBccScript, symbolLookup, s);
- bccCompileScript(s->mBccScript);
+ // bccReadBC() reads in the BitCode, if no cache file corresponding to
+ // the resName is found. Otherwise, bccReadBC() returns a negative value
+ // and the "else" branch will be taken.
+ if (bccReadBC(s->mBccScript,
+ s->mEnviroment.mScriptText,
+ s->mEnviroment.mScriptTextLength,
+ resName) >= 0) {
+ //bccLinkBC(s->mBccScript, rs_runtime_lib_bc, rs_runtime_lib_bc_size);
+ bccCompileBC(s->mBccScript);
+ } else {
+ // bccReadBC returns a neagative value: Didn't read any script,
+ // So, use cached binary instead
+ bccLoadBinary(s->mBccScript);
+ }
bccGetScriptLabel(s->mBccScript, "root", (BCCvoid**) &s->mProgram.mRoot);
bccGetScriptLabel(s->mBccScript, "init", (BCCvoid**) &s->mProgram.mInit);
}
@@ -517,14 +528,15 @@ void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) {
ss->mScript->mEnviroment.mScriptTextLength = len;
}
-RsScript rsi_ScriptCCreate(Context * rsc) {
+RsScript rsi_ScriptCCreate(Context * rsc, const char *resName)
+{
ScriptCState *ss = &rsc->mScriptC;
ObjectBaseRef<ScriptC> s(ss->mScript);
ss->mScript.clear();
s->incUserRef();
- ss->runCompiler(rsc, s.get());
+ ss->runCompiler(rsc, s.get(), resName);
ss->clear(rsc);
return s.get();
}