Loading libs/rs/rsScript.cpp +28 −10 Original line number Diff line number Diff line Loading @@ -24,10 +24,37 @@ Script::Script(Context *rsc) : ObjectBase(rsc) mAllocFile = __FILE__; mAllocLine = __LINE__; memset(&mEnviroment, 0, sizeof(mEnviroment)); mSlots = NULL; mTypes = NULL; } Script::~Script() { if(mSlots) { delete [] mSlots; mSlots = NULL; } if(mTypes) { delete [] mTypes; mTypes = NULL; } } void Script::initSlots() { if(mEnviroment.mFieldCount > 0) { mSlots = new ObjectBaseRef<Allocation>[mEnviroment.mFieldCount]; mTypes = new ObjectBaseRef<const Type>[mEnviroment.mFieldCount]; } } void Script::setSlot(uint32_t slot, Allocation *a) { if(slot >= mEnviroment.mFieldCount) { LOGE("Script::setSlot unable to set allocation, invalid slot index"); return; } mSlots[slot].set(a); } void Script::setVar(uint32_t slot, const void *val, uint32_t len) Loading @@ -51,7 +78,7 @@ void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint3 { Script *s = static_cast<Script *>(vs); Allocation *a = static_cast<Allocation *>(va); s->mSlots[slot].set(a); s->setSlot(slot, a); //LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr()); } Loading @@ -61,15 +88,6 @@ void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, ui s->mEnviroment.mTimeZone = timeZone; } void rsi_ScriptSetType(Context * rsc, RsType vt, uint32_t slot, bool writable, const char *name) { ScriptCState *ss = &rsc->mScriptC; const Type *t = static_cast<const Type *>(vt); ss->mConstantBufferTypes[slot].set(t); ss->mSlotWritable[slot] = writable; LOGE("rsi_ScriptSetType"); } void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot) { Script *s = static_cast<Script *>(vs); Loading libs/rs/rsScript.h +6 −6 Original line number Diff line number Diff line Loading @@ -29,8 +29,6 @@ class ProgramFragment; class ProgramRaster; class ProgramStore; #define MAX_SCRIPT_BANKS 32 class Script : public ObjectBase { public: Loading Loading @@ -61,10 +59,8 @@ public: }; Enviroment_t mEnviroment; ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS]; ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS]; bool mSlotWritable[MAX_SCRIPT_BANKS]; void initSlots(); void setSlot(uint32_t slot, Allocation *a); void setVar(uint32_t slot, const void *val, uint32_t len); virtual void runForEach(Context *rsc, Loading @@ -76,6 +72,10 @@ public: virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0; virtual void setupScript(Context *rsc) = 0; virtual uint32_t run(Context *) = 0; protected: ObjectBaseRef<Allocation> *mSlots; ObjectBaseRef<const Type> *mTypes; }; Loading libs/rs/rsScriptC.cpp +1 −9 Original line number Diff line number Diff line Loading @@ -365,11 +365,6 @@ void ScriptCState::init(Context *rsc) void ScriptCState::clear(Context *rsc) { rsAssert(rsc); for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) { mConstantBufferTypes[ct].clear(); mSlotWritable[ct] = false; } mScript.clear(); mScript.set(new ScriptC(rsc)); } Loading Loading @@ -428,6 +423,7 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s) else { s->mEnviroment.mFieldAddress = (void **) calloc(s->mEnviroment.mFieldCount, sizeof(void *)); bccGetExportVars(s->mBccScript, NULL, s->mEnviroment.mFieldCount, (BCCvoid **) s->mEnviroment.mFieldAddress); s->initSlots(); } s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment()); Loading Loading @@ -532,10 +528,6 @@ RsScript rsi_ScriptCCreate(Context * rsc) ss->runCompiler(rsc, s.get()); s->incUserRef(); s->setContext(rsc); for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) { s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get()); s->mSlotWritable[ct] = ss->mSlotWritable[ct]; } ss->clear(rsc); return s.get(); Loading libs/rs/rsScriptC.h +0 −5 Original line number Diff line number Diff line Loading @@ -81,11 +81,6 @@ public: ObjectBaseRef<ScriptC> mScript; ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS]; //String8 mSlotNames[MAX_SCRIPT_BANKS]; bool mSlotWritable[MAX_SCRIPT_BANKS]; //String8 mInvokableNames[MAX_SCRIPT_BANKS]; void init(Context *rsc); void clear(Context *rsc); Loading libs/rs/rsType.cpp +30 −5 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ Type::Type(Context *rsc) : ObjectBase(rsc) mAllocLine = __LINE__; mLODs = 0; mLODCount = 0; mAttribs = NULL; mAttribsSize = 0; clear(); } Loading @@ -44,6 +46,11 @@ Type::~Type() } if (mLODs) { delete [] mLODs; mLODs = NULL; } if(mAttribs) { delete [] mAttribs; mAttribs = NULL; } } Loading Loading @@ -145,6 +152,21 @@ uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) co void Type::makeGLComponents() { // Count the number of gl attrs to initialize mAttribsSize = 0; for (uint32_t ct=0; ct < getElement()->getFieldCount(); ct++) { if(getElement()->getFieldName(ct)[0] != '#') { mAttribsSize ++; } } if(mAttribs) { delete [] mAttribs; mAttribs = NULL; } if(mAttribsSize) { mAttribs = new VertexArray::Attrib[mAttribsSize]; } uint32_t userNum = 0; for (uint32_t ct=0; ct < getElement()->getFieldCount(); ct++) { const Component &c = getElement()->getField(ct)->getComponent(); Loading @@ -160,11 +182,8 @@ void Type::makeGLComponents() String8 tmp(RS_SHADER_ATTR); tmp.append(getElement()->getFieldName(ct)); mAttribs[userNum].name.setTo(tmp.string()); userNum ++; if(userNum == RS_MAX_ATTRIBS) { return; } userNum ++; } } Loading @@ -172,7 +191,13 @@ void Type::makeGLComponents() void Type::enableGLVertexBuffer(VertexArray *va) const { uint32_t stride = mElement->getSizeBytes(); for (uint32_t ct=0; ct < RS_MAX_ATTRIBS; ct++) { for (uint32_t ct=0; ct < mAttribsSize; ct++) { // Load up to RS_MAX_ATTRIBS inputs // TODO: grow vertexarray dynamically if(ct >= RS_MAX_ATTRIBS) { LOGE("More GL attributes than we can handle"); break; } if (mAttribs[ct].size) { va->add(mAttribs[ct], stride); } Loading Loading
libs/rs/rsScript.cpp +28 −10 Original line number Diff line number Diff line Loading @@ -24,10 +24,37 @@ Script::Script(Context *rsc) : ObjectBase(rsc) mAllocFile = __FILE__; mAllocLine = __LINE__; memset(&mEnviroment, 0, sizeof(mEnviroment)); mSlots = NULL; mTypes = NULL; } Script::~Script() { if(mSlots) { delete [] mSlots; mSlots = NULL; } if(mTypes) { delete [] mTypes; mTypes = NULL; } } void Script::initSlots() { if(mEnviroment.mFieldCount > 0) { mSlots = new ObjectBaseRef<Allocation>[mEnviroment.mFieldCount]; mTypes = new ObjectBaseRef<const Type>[mEnviroment.mFieldCount]; } } void Script::setSlot(uint32_t slot, Allocation *a) { if(slot >= mEnviroment.mFieldCount) { LOGE("Script::setSlot unable to set allocation, invalid slot index"); return; } mSlots[slot].set(a); } void Script::setVar(uint32_t slot, const void *val, uint32_t len) Loading @@ -51,7 +78,7 @@ void rsi_ScriptBindAllocation(Context * rsc, RsScript vs, RsAllocation va, uint3 { Script *s = static_cast<Script *>(vs); Allocation *a = static_cast<Allocation *>(va); s->mSlots[slot].set(a); s->setSlot(slot, a); //LOGE("rsi_ScriptBindAllocation %i %p %p", slot, a, a->getPtr()); } Loading @@ -61,15 +88,6 @@ void rsi_ScriptSetTimeZone(Context * rsc, RsScript vs, const char * timeZone, ui s->mEnviroment.mTimeZone = timeZone; } void rsi_ScriptSetType(Context * rsc, RsType vt, uint32_t slot, bool writable, const char *name) { ScriptCState *ss = &rsc->mScriptC; const Type *t = static_cast<const Type *>(vt); ss->mConstantBufferTypes[slot].set(t); ss->mSlotWritable[slot] = writable; LOGE("rsi_ScriptSetType"); } void rsi_ScriptInvoke(Context *rsc, RsScript vs, uint32_t slot) { Script *s = static_cast<Script *>(vs); Loading
libs/rs/rsScript.h +6 −6 Original line number Diff line number Diff line Loading @@ -29,8 +29,6 @@ class ProgramFragment; class ProgramRaster; class ProgramStore; #define MAX_SCRIPT_BANKS 32 class Script : public ObjectBase { public: Loading Loading @@ -61,10 +59,8 @@ public: }; Enviroment_t mEnviroment; ObjectBaseRef<Allocation> mSlots[MAX_SCRIPT_BANKS]; ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS]; bool mSlotWritable[MAX_SCRIPT_BANKS]; void initSlots(); void setSlot(uint32_t slot, Allocation *a); void setVar(uint32_t slot, const void *val, uint32_t len); virtual void runForEach(Context *rsc, Loading @@ -76,6 +72,10 @@ public: virtual void Invoke(Context *rsc, uint32_t slot, const void *data, uint32_t len) = 0; virtual void setupScript(Context *rsc) = 0; virtual uint32_t run(Context *) = 0; protected: ObjectBaseRef<Allocation> *mSlots; ObjectBaseRef<const Type> *mTypes; }; Loading
libs/rs/rsScriptC.cpp +1 −9 Original line number Diff line number Diff line Loading @@ -365,11 +365,6 @@ void ScriptCState::init(Context *rsc) void ScriptCState::clear(Context *rsc) { rsAssert(rsc); for (uint32_t ct=0; ct < MAX_SCRIPT_BANKS; ct++) { mConstantBufferTypes[ct].clear(); mSlotWritable[ct] = false; } mScript.clear(); mScript.set(new ScriptC(rsc)); } Loading Loading @@ -428,6 +423,7 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s) else { s->mEnviroment.mFieldAddress = (void **) calloc(s->mEnviroment.mFieldCount, sizeof(void *)); bccGetExportVars(s->mBccScript, NULL, s->mEnviroment.mFieldCount, (BCCvoid **) s->mEnviroment.mFieldAddress); s->initSlots(); } s->mEnviroment.mFragment.set(rsc->getDefaultProgramFragment()); Loading Loading @@ -532,10 +528,6 @@ RsScript rsi_ScriptCCreate(Context * rsc) ss->runCompiler(rsc, s.get()); s->incUserRef(); s->setContext(rsc); for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) { s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get()); s->mSlotWritable[ct] = ss->mSlotWritable[ct]; } ss->clear(rsc); return s.get(); Loading
libs/rs/rsScriptC.h +0 −5 Original line number Diff line number Diff line Loading @@ -81,11 +81,6 @@ public: ObjectBaseRef<ScriptC> mScript; ObjectBaseRef<const Type> mConstantBufferTypes[MAX_SCRIPT_BANKS]; //String8 mSlotNames[MAX_SCRIPT_BANKS]; bool mSlotWritable[MAX_SCRIPT_BANKS]; //String8 mInvokableNames[MAX_SCRIPT_BANKS]; void init(Context *rsc); void clear(Context *rsc); Loading
libs/rs/rsType.cpp +30 −5 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ Type::Type(Context *rsc) : ObjectBase(rsc) mAllocLine = __LINE__; mLODs = 0; mLODCount = 0; mAttribs = NULL; mAttribsSize = 0; clear(); } Loading @@ -44,6 +46,11 @@ Type::~Type() } if (mLODs) { delete [] mLODs; mLODs = NULL; } if(mAttribs) { delete [] mAttribs; mAttribs = NULL; } } Loading Loading @@ -145,6 +152,21 @@ uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) co void Type::makeGLComponents() { // Count the number of gl attrs to initialize mAttribsSize = 0; for (uint32_t ct=0; ct < getElement()->getFieldCount(); ct++) { if(getElement()->getFieldName(ct)[0] != '#') { mAttribsSize ++; } } if(mAttribs) { delete [] mAttribs; mAttribs = NULL; } if(mAttribsSize) { mAttribs = new VertexArray::Attrib[mAttribsSize]; } uint32_t userNum = 0; for (uint32_t ct=0; ct < getElement()->getFieldCount(); ct++) { const Component &c = getElement()->getField(ct)->getComponent(); Loading @@ -160,11 +182,8 @@ void Type::makeGLComponents() String8 tmp(RS_SHADER_ATTR); tmp.append(getElement()->getFieldName(ct)); mAttribs[userNum].name.setTo(tmp.string()); userNum ++; if(userNum == RS_MAX_ATTRIBS) { return; } userNum ++; } } Loading @@ -172,7 +191,13 @@ void Type::makeGLComponents() void Type::enableGLVertexBuffer(VertexArray *va) const { uint32_t stride = mElement->getSizeBytes(); for (uint32_t ct=0; ct < RS_MAX_ATTRIBS; ct++) { for (uint32_t ct=0; ct < mAttribsSize; ct++) { // Load up to RS_MAX_ATTRIBS inputs // TODO: grow vertexarray dynamically if(ct >= RS_MAX_ATTRIBS) { LOGE("More GL attributes than we can handle"); break; } if (mAttribs[ct].size) { va->add(mAttribs[ct], stride); } Loading