diff options
-rw-r--r-- | libs/rs/java/Fountain/res/raw/fountain.c | 6 | ||||
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/FountainView.java | 3 | ||||
-rw-r--r-- | libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java | 28 | ||||
-rw-r--r-- | libs/rs/jni/RenderScript_jni.cpp | 35 | ||||
-rw-r--r-- | libs/rs/rs.spec | 10 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 41 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 9 | ||||
-rw-r--r-- | libs/rs/rsObjectBase.cpp | 10 | ||||
-rw-r--r-- | libs/rs/rsObjectBase.h | 22 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 8 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.h | 2 | ||||
-rw-r--r-- | libs/rs/rsProgramFragmentStore.cpp | 13 | ||||
-rw-r--r-- | libs/rs/rsProgramFragmentStore.h | 2 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 1 | ||||
-rw-r--r-- | libs/rs/rsScript.h | 41 | ||||
-rw-r--r-- | libs/rs/rsScriptC.cpp | 106 | ||||
-rw-r--r-- | libs/rs/rsScriptC.h | 2 |
17 files changed, 202 insertions, 137 deletions
diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c index 5055c3959e2a..afb2fb33a9c7 100644 --- a/libs/rs/java/Fountain/res/raw/fountain.c +++ b/libs/rs/java/Fountain/res/raw/fountain.c @@ -3,8 +3,8 @@ #pragma version(1) #pragma stateVertex(orthoWindow) #pragma stateRaster(flat) -#pragma stateFragment(color) -#pragma stateStore(parent) +#pragma stateFragment(PgmFragBackground) +#pragma stateFragmentStore(MyBlend) int main(void* con, int ft, int launchID) { @@ -35,7 +35,7 @@ int main(void* con, int ft, int launchID) { } } - contextBindProgramFragment(con, loadI32(con, 0, 7)); + //contextBindProgramFragment(con, loadI32(con, 0, 7)); drawRect(con, 0, 256, 0, 512); contextBindProgramFragment(con, loadI32(con, 0, 6)); diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java index 338152598bd7..0a6f7c594792 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java @@ -82,6 +82,7 @@ public class FountainView extends RSSurfaceView { mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE); mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS); mPFS = mRS.programFragmentStoreCreate(); + mPFS.setName("MyBlend"); mRS.contextBindProgramFragmentStore(mPFS); mRS.samplerBegin(); @@ -92,6 +93,7 @@ public class FountainView extends RSSurfaceView { mRS.programFragmentBegin(null, null); mPF = mRS.programFragmentCreate(); + mPF.setName("PgmFragParts"); //mRS.contextBindProgramFragment(mPF); mRS.programFragmentBegin(null, null); @@ -100,6 +102,7 @@ public class FountainView extends RSSurfaceView { mRS.contextBindProgramFragment(mPF2); mPF2.bindTexture(mTexture, 0); mPF2.bindSampler(mSampler, 0); + mPF2.setName("PgmFragBackground"); mParams[0] = 0; mParams[1] = partCount; diff --git a/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java b/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java index 796fe3561587..fcfb82d77560 100644 --- a/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java +++ b/libs/rs/java/Fountain/src/com/android/fountain/RenderScript.java @@ -68,6 +68,8 @@ public class RenderScript { native private void nContextBindProgramFragmentStore(int pfs); native private void nContextBindProgramFragment(int pf); + native private void nAssignName(int obj, byte[] name); + native private void nElementBegin(); native private void nElementAddPredefined(int predef); native private void nElementAdd(int kind, int type, int norm, int bits); @@ -135,6 +137,7 @@ public class RenderScript { native private void nProgramFragmentStoreBlendFunc(int src, int dst); native private void nProgramFragmentStoreDither(boolean enable); native private int nProgramFragmentStoreCreate(); + native private void nProgramFragmentStoreDestroy(int pgm); native private void nProgramFragmentBegin(int in, int out); native private void nProgramFragmentBindTexture(int vpf, int slot, int a); @@ -143,6 +146,7 @@ public class RenderScript { native private void nProgramFragmentSetEnvMode(int slot, int env); native private void nProgramFragmentSetTexEnable(int slot, boolean enable); native private int nProgramFragmentCreate(); + native private void nProgramFragmentDestroy(int pgm); private int mDev; @@ -166,6 +170,26 @@ public class RenderScript { } int mID; + String mName; + + public void setName(String s) throws IllegalStateException, IllegalArgumentException + { + if(s.length() < 1) { + throw new IllegalArgumentException("setName does not accept a zero length string."); + } + if(mName != null) { + throw new IllegalArgumentException("setName object already has a name."); + } + + try { + byte[] bytes = s.getBytes("UTF-8"); + nAssignName(mID, bytes); + mName = s; + } catch (java.io.UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + protected void finalize() throws Throwable { if (mID != 0) { @@ -661,7 +685,7 @@ public class RenderScript { } public void destroy() { - nScriptDestroy(mID); + nProgramFragmentStoreDestroy(mID); mID = 0; } } @@ -712,7 +736,7 @@ public class RenderScript { } public void destroy() { - nScriptDestroy(mID); + nProgramFragmentDestroy(mID); mID = 0; } diff --git a/libs/rs/jni/RenderScript_jni.cpp b/libs/rs/jni/RenderScript_jni.cpp index 677ce0cbb68d..2dadf0718661 100644 --- a/libs/rs/jni/RenderScript_jni.cpp +++ b/libs/rs/jni/RenderScript_jni.cpp @@ -62,6 +62,21 @@ static void _nInit(JNIEnv *_env, jclass _this) // --------------------------------------------------------------------------- +static void +nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nAssignName, con(%p), obj(%p)", con, obj); + + jint len = _env->GetArrayLength(str); + jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0); + rsAssignName((void *)obj, (const char *)cptr); + _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT); +} + + +// --------------------------------------------------------------------------- + static jint nDeviceCreate(JNIEnv *_env, jobject _this) { @@ -662,9 +677,18 @@ nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); LOG_API("nProgramFragmentStoreCreate, con(%p)", con); + return (jint)rsProgramFragmentStoreCreate(); } +static void +nProgramFragmentStoreDestroy(JNIEnv *_env, jobject _this, jint pgm) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nProgramFragmentStoreDestroy, con(%p), pgm(%i)", con, pgm); + rsProgramFragmentStoreDestroy((RsProgramFragmentStore)pgm); +} + // --------------------------------------------------------------------------- static void @@ -723,6 +747,14 @@ nProgramFragmentCreate(JNIEnv *_env, jobject _this, jint slot, jboolean enable) return (jint)rsProgramFragmentCreate(); } +static void +nProgramFragmentDestroy(JNIEnv *_env, jobject _this, jint pgm) +{ + RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); + LOG_API("nProgramFragmentDestroy, con(%p), pgm(%i)", con, pgm); + rsProgramFragmentDestroy((RsProgramFragment)pgm); +} + // --------------------------------------------------------------------------- @@ -796,6 +828,7 @@ static JNINativeMethod methods[] = { {"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, {"nContextCreate", "(ILandroid/view/Surface;I)I", (void*)nContextCreate }, {"nContextDestroy", "(I)V", (void*)nContextDestroy }, +{"nAssignName", "(I[B)V", (void*)nAssignName }, {"nElementBegin", "()V", (void*)nElementBegin }, {"nElementAddPredefined", "(I)V", (void*)nElementAddPredefined }, @@ -858,6 +891,7 @@ static JNINativeMethod methods[] = { {"nProgramFragmentStoreBlendFunc", "(II)V", (void*)nProgramFragmentStoreBlendFunc }, {"nProgramFragmentStoreDither", "(Z)V", (void*)nProgramFragmentStoreDither }, {"nProgramFragmentStoreCreate", "()I", (void*)nProgramFragmentStoreCreate }, +{"nProgramFragmentStoreDestroy", "(I)V", (void*)nProgramFragmentStoreDestroy }, {"nProgramFragmentBegin", "(II)V", (void*)nProgramFragmentBegin }, {"nProgramFragmentBindTexture", "(III)V", (void*)nProgramFragmentBindTexture }, @@ -866,6 +900,7 @@ static JNINativeMethod methods[] = { {"nProgramFragmentSetEnvMode", "(II)V", (void*)nProgramFragmentSetEnvMode }, {"nProgramFragmentSetTexEnable", "(IZ)V", (void*)nProgramFragmentSetTexEnable }, {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, +{"nProgramFragmentDestroy", "(I)V", (void*)nProgramFragmentDestroy }, {"nContextBindRootScript", "(I)V", (void*)nContextBindRootScript }, {"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore }, diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 4ffdfce8431a..b7eaed1af9c5 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -16,6 +16,10 @@ ContextBindProgramVertex { param RsProgramVertex pgm } +AssignName { + param void *obj + param const char *name + } ElementBegin { } @@ -332,6 +336,9 @@ ProgramFragmentStoreCreate { ret RsProgramFragmentStore } +ProgramFragmentStoreDestroy { + param RsProgramFragmentStore pfs + } ProgramFragmentBegin { @@ -370,6 +377,9 @@ ProgramFragmentCreate { ret RsProgramFragment } +ProgramFragmentDestroy { + param RsProgramFragment pf + } ProgramVertexBegin { diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 82d64992efcd..ffd03d595d71 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -57,14 +57,17 @@ void Context::initEGL() eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &mHeight); } -bool Context::runScript(Script *s) +bool Context::runScript(Script *s, uint32_t launchID) { ObjectBaseRef<ProgramFragment> frag(mFragment); ObjectBaseRef<ProgramVertex> vtx(mVertex); ObjectBaseRef<ProgramFragmentStore> store(mFragmentStore); + bool ret = s->run(this, launchID); - + mFragment.set(frag); + mVertex.set(vtx); + mFragmentStore.set(store); return true; } @@ -107,7 +110,7 @@ bool Context::runRootScript() glClear(GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT); - return mRootScript->run(this, 0); + return runScript(mRootScript.get(), 0); } void Context::setupCheck() @@ -243,6 +246,33 @@ void Context::setVertex(ProgramVertex *pv) pv->setupGL(); } +void Context::assignName(ObjectBase *obj, const char *name) +{ + rsAssert(!obj->getName()); + obj->setName(name); + mNames.add(obj); +} + +void Context::removeName(ObjectBase *obj) +{ + for(size_t ct=0; ct < mNames.size(); ct++) { + if (obj == mNames[ct]) { + mNames.removeAt(ct); + return; + } + } +} + +ObjectBase * Context::lookupName(const char *name) const +{ + for(size_t ct=0; ct < mNames.size(); ct++) { + if (!strcmp(name, mNames[ct]->getName())) { + return mNames[ct]; + } + } + return NULL; +} + /////////////////////////////////////////////////////////////////////////////////////////// // @@ -286,6 +316,11 @@ void rsi_ContextBindProgramVertex(Context *rsc, RsProgramVertex vpv) rsc->setVertex(pv); } +void rsi_AssignName(Context *rsc, void * obj, const char *name) +{ + ObjectBase *ob = static_cast<ObjectBase *>(obj); + rsc->assignName(ob, name); +} } diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index 929c0f9b82f9..184740f29638 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -42,7 +42,6 @@ namespace android { namespace renderscript { - class Context { public: @@ -77,6 +76,10 @@ public: void setupCheck(); + void assignName(ObjectBase *obj, const char *name); + void removeName(ObjectBase *obj); + ObjectBase * lookupName(const char *name) const; + protected: Device *mDev; @@ -112,7 +115,7 @@ private: void initEGL(); - bool runScript(Script *s); + bool runScript(Script *s, uint32_t launchID); bool runRootScript(); static void * threadProc(void *); @@ -120,6 +123,8 @@ private: // todo: put in TLS static Context *gCon; Surface *mWndSurface; + + Vector<ObjectBase *> mNames; }; diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index f9cb9c82a0fd..8660818b3f57 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -23,6 +23,7 @@ using namespace android::renderscript; ObjectBase::ObjectBase() { mRefCount = 0; + mName = NULL; } ObjectBase::~ObjectBase() @@ -46,3 +47,12 @@ void ObjectBase::decRef() const } } +void ObjectBase::setName(const char *name) +{ + delete mName; + mName = NULL; + if (name) { + mName = new char[strlen(name) +1]; + strcpy(mName, name); + } +} diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h index ca7acda5a92d..4c52e9ccc4fe 100644 --- a/libs/rs/rsObjectBase.h +++ b/libs/rs/rsObjectBase.h @@ -33,7 +33,13 @@ public: void incRef() const; void decRef() const; + const char * getName() const { + return mName; + } + void setName(const char *); + private: + char * mName; mutable int32_t mRefCount; @@ -49,12 +55,16 @@ public: ObjectBaseRef(const ObjectBaseRef &ref) { mRef = ref.get(); - mRef->incRef(); + if (mRef) { + mRef->incRef(); + } } ObjectBaseRef(T *ref) { mRef = ref; - ref->incRef(); + if (mRef) { + ref->incRef(); + } } ~ObjectBaseRef() { @@ -65,10 +75,16 @@ public: if (mRef != ref) { clear(); mRef = ref; - ref->incRef(); + if (mRef) { + ref->incRef(); + } } } + void set(const ObjectBaseRef &ref) { + set(ref.mRef); + } + void clear() { if (mRef) { mRef->decRef(); diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 3d316ea1cbda..316e7916ff98 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -212,6 +212,14 @@ RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc) return pf; } +void rsi_ProgramFragmentDestroy(Context *rsc, RsProgramFragment vpf) +{ + ProgramFragment *pf = (ProgramFragment *)vpf; + if (pf->getName()) { + rsc->removeName(pf); + } + pf->decRef(); +} } diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h index cc08aea8f428..ed9c49beed82 100644 --- a/libs/rs/rsProgramFragment.h +++ b/libs/rs/rsProgramFragment.h @@ -85,7 +85,7 @@ public: ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; - + Vector<ProgramFragment *> mPrograms; }; diff --git a/libs/rs/rsProgramFragmentStore.cpp b/libs/rs/rsProgramFragmentStore.cpp index 7f5d5f49bb89..a1855a626b57 100644 --- a/libs/rs/rsProgramFragmentStore.cpp +++ b/libs/rs/rsProgramFragmentStore.cpp @@ -202,7 +202,6 @@ ProgramFragmentStoreState::~ProgramFragmentStoreState() } - namespace android { namespace renderscript { @@ -238,7 +237,6 @@ RsProgramFragmentStore rsi_ProgramFragmentStoreCreate(Context *rsc) ProgramFragmentStore *pfs = rsc->mStateFragmentStore.mPFS; pfs->incRef(); rsc->mStateFragmentStore.mPFS = 0; - return pfs; } @@ -247,6 +245,17 @@ void rsi_ProgramFragmentStoreDither(Context *rsc, bool enable) rsc->mStateFragmentStore.mPFS->setDitherEnable(enable); } +void rsi_ProgramFragmentStoreDestroy(Context *rsc, RsProgramFragmentStore vpfs) +{ + ProgramFragmentStore *pfs = (ProgramFragmentStore *)vpfs; + if (pfs->getName()) { + rsc->removeName(pfs); + } + pfs->decRef(); +} + + + } } diff --git a/libs/rs/rsProgramFragmentStore.h b/libs/rs/rsProgramFragmentStore.h index bbd0f385d986..d862775fe402 100644 --- a/libs/rs/rsProgramFragmentStore.h +++ b/libs/rs/rsProgramFragmentStore.h @@ -76,8 +76,6 @@ public: ~ProgramFragmentStoreState(); ProgramFragmentStore *mPFS; - - }; diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index 8e2b82d7fca4..a80e2f7ec309 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -97,7 +97,6 @@ RsProgramVertex rsi_ProgramVertexCreate(Context *rsc) ProgramVertex *pv = rsc->mStateVertex.mPV; pv->incRef(); rsc->mStateVertex.mPV = 0; - return pv; } diff --git a/libs/rs/rsScript.h b/libs/rs/rsScript.h index 25a21c1a19b6..d32f116a7f85 100644 --- a/libs/rs/rsScript.h +++ b/libs/rs/rsScript.h @@ -19,11 +19,15 @@ #include "rsAllocation.h" + // --------------------------------------------------------------------------- namespace android { namespace renderscript { - +class ProgramVertex; +class ProgramFragment; +class ProgramRaster; +class ProgramFragmentStore; class Script : public ObjectBase { @@ -40,37 +44,10 @@ public: float mClearDepth; uint32_t mClearStencil; - enum StateVertex { - VTX_ORTHO_WINDOW, - VTX_ORTHO_NORMALIZED, - VTX_PROJECTION, - VTX_PARENT - }; - StateVertex mStateVertex; - - enum StateRaster { - RASTER_FLAT, - RASTER_SMOOTH, - RASTER_PARENT - }; - StateRaster mStateRaster; - - enum StateFragment { - FRAGMENT_COLOR, - FRAGMENT_TEX_REPLACE, - FRAGMENT_TEX_MODULATE, - FRAGMENT_PARENT - }; - StateFragment mStateFragment; - - enum StateFragmentStore { - FRAGMENT_STORE_ALWAYS_REPLACE, - FRAGMENT_STORE_ALWAYS_BLEND, - FRAGMENT_STORE_DEPTH_LESS_REPLACE, - FRAGMENT_STORE_DEPTH_LESS_BLEND, - FRAGMENT_STORE_PARENT - }; - StateFragmentStore mStateFragmentStore; + ObjectBaseRef<ProgramVertex> mVertex; + ObjectBaseRef<ProgramFragment> mFragment; + //ObjectBaseRef<ProgramRaster> mRaster; + ObjectBaseRef<ProgramFragmentStore> mFragmentStore; }; Enviroment_t mEnviroment; diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 49d787297d1b..ae58e5f14b28 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -390,6 +390,14 @@ static rsc_FunctionTable scriptCPtrTable = { bool ScriptC::run(Context *rsc, uint32_t launchID) { Env e = {rsc, this}; + + if (mEnviroment.mFragmentStore.get()) { + rsc->setFragmentStore(mEnviroment.mFragmentStore.get()); + } + if (mEnviroment.mFragment.get()) { + rsc->setFragment(mEnviroment.mFragment.get()); + } + return mProgram.mScript(&e, &scriptCPtrTable, launchID) != 0; } @@ -425,7 +433,7 @@ void ScriptCState::clear() } -void ScriptCState::runCompiler() +void ScriptCState::runCompiler(Context *rsc) { mAccScript = accCreateScript(); @@ -442,16 +450,6 @@ void ScriptCState::runCompiler() ACCchar * str[pragmaMax]; accGetPragmas(mAccScript, &pragmaCount, pragmaMax, &str[0]); - // Start with defaults - mEnviroment.mStateVertex = - Script::Enviroment_t::VTX_ORTHO_WINDOW; - mEnviroment.mStateRaster = - Script::Enviroment_t::RASTER_FLAT; - mEnviroment.mStateFragment = - Script::Enviroment_t::FRAGMENT_COLOR; - mEnviroment.mStateFragmentStore = - Script::Enviroment_t::FRAGMENT_STORE_ALWAYS_REPLACE; - for (int ct=0; ct < pragmaCount; ct+=2) { LOGE("pragma %i %s %s", ct, str[ct], str[ct+1]); @@ -462,96 +460,34 @@ void ScriptCState::runCompiler() if (!strcmp(str[ct], "stateVertex")) { - if (!strcmp(str[ct+1], "orthoWindow")) { - mEnviroment.mStateVertex = - Script::Enviroment_t::VTX_ORTHO_WINDOW; - continue; - } - if (!strcmp(str[ct+1], "orthoNormalized")) { - mEnviroment.mStateVertex = - Script::Enviroment_t::VTX_ORTHO_NORMALIZED; - continue; - } - if (!strcmp(str[ct+1], "projection")) { - mEnviroment.mStateVertex = - Script::Enviroment_t::VTX_PROJECTION; - continue; - } - if (!strcmp(str[ct+1], "parent")) { - mEnviroment.mStateVertex = - Script::Enviroment_t::VTX_PARENT; - continue; - } LOGE("Unreconized value %s passed to stateVertex", str[ct+1]); } if (!strcmp(str[ct], "stateRaster")) { - if (!strcmp(str[ct+1], "flat")) { - mEnviroment.mStateRaster = - Script::Enviroment_t::RASTER_FLAT; - continue; - } - if (!strcmp(str[ct+1], "smooth")) { - mEnviroment.mStateRaster = - Script::Enviroment_t::RASTER_SMOOTH; - continue; - } - if (!strcmp(str[ct+1], "parent")) { - mEnviroment.mStateRaster = - Script::Enviroment_t::RASTER_PARENT; - continue; - } LOGE("Unreconized value %s passed to stateRaster", str[ct+1]); } if (!strcmp(str[ct], "stateFragment")) { - if (!strcmp(str[ct+1], "color")) { - mEnviroment.mStateFragment = - Script::Enviroment_t::FRAGMENT_COLOR; - continue; - } - if (!strcmp(str[ct+1], "texReplace")) { - mEnviroment.mStateFragment = - Script::Enviroment_t::FRAGMENT_TEX_REPLACE; - continue; - } - if (!strcmp(str[ct+1], "texModulate")) { - mEnviroment.mStateFragment = - Script::Enviroment_t::FRAGMENT_TEX_MODULATE; - continue; - } - if (!strcmp(str[ct+1], "parent")) { - mEnviroment.mStateFragment = - Script::Enviroment_t::FRAGMENT_PARENT; + ProgramFragment * pf = + (ProgramFragment *)rsc->lookupName(str[ct+1]); + if (pf != NULL) { + mEnviroment.mFragment.set(pf); continue; } LOGE("Unreconized value %s passed to stateFragment", str[ct+1]); } if (!strcmp(str[ct], "stateFragmentStore")) { - if (!strcmp(str[ct+1], "alwaysReplace")) { - mEnviroment.mStateFragmentStore = - Script::Enviroment_t::FRAGMENT_STORE_ALWAYS_REPLACE; - continue; - } - if (!strcmp(str[ct+1], "alwaysBlend")) { - mEnviroment.mStateFragmentStore = - Script::Enviroment_t::FRAGMENT_STORE_ALWAYS_BLEND; - continue; - } - if (!strcmp(str[ct+1], "depthLessReplace")) { - mEnviroment.mStateFragmentStore = - Script::Enviroment_t::FRAGMENT_STORE_DEPTH_LESS_REPLACE; - continue; - } - if (!strcmp(str[ct+1], "depthLessBlend")) { - mEnviroment.mStateFragmentStore = - Script::Enviroment_t::FRAGMENT_STORE_DEPTH_LESS_BLEND; + ProgramFragmentStore * pfs = + (ProgramFragmentStore *)rsc->lookupName(str[ct+1]); + if (pfs != NULL) { + mEnviroment.mFragmentStore.set(pfs); continue; } + if (!strcmp(str[ct+1], "parent")) { - mEnviroment.mStateFragmentStore = - Script::Enviroment_t::FRAGMENT_STORE_PARENT; + //mEnviroment.mStateFragmentStore = + //Script::Enviroment_t::FRAGMENT_STORE_PARENT; continue; } LOGE("Unreconized value %s passed to stateFragmentStore", str[ct+1]); @@ -632,7 +568,7 @@ RsScript rsi_ScriptCCreate(Context * rsc) { ScriptCState *ss = &rsc->mScriptC; - ss->runCompiler(); + ss->runCompiler(rsc); ScriptC *s = new ScriptC(); s->incRef(); diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h index d178c86ebd80..55a2cc63d36f 100644 --- a/libs/rs/rsScriptC.h +++ b/libs/rs/rsScriptC.h @@ -74,7 +74,7 @@ public: Vector<const Type *> mConstantBufferTypes; void clear(); - void runCompiler(); + void runCompiler(Context *rsc); }; |