diff options
Diffstat (limited to 'libs/rs')
-rw-r--r-- | libs/rs/rsAllocation.cpp | 33 | ||||
-rw-r--r-- | libs/rs/rsAllocation.h | 10 | ||||
-rw-r--r-- | libs/rs/rsContext.cpp | 8 | ||||
-rw-r--r-- | libs/rs/rsContext.h | 1 | ||||
-rw-r--r-- | libs/rs/rsProgram.cpp | 16 | ||||
-rw-r--r-- | libs/rs/rsProgram.h | 3 |
6 files changed, 44 insertions, 27 deletions
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 408d83f..bc62f92 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -139,6 +139,7 @@ void Allocation::data(const void *data, uint32_t sizeBytes) return; } memcpy(mPtr, data, size); + sendDirty(); } void Allocation::read(void *data) @@ -159,6 +160,7 @@ void Allocation::subData(uint32_t xoff, uint32_t count, const void *data, uint32 return; } memcpy(ptr, data, size); + sendDirty(); } void Allocation::subData(uint32_t xoff, uint32_t yoff, @@ -183,6 +185,7 @@ void Allocation::subData(uint32_t xoff, uint32_t yoff, src += lineSize; dst += destW * eSize; } + sendDirty(); } void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff, @@ -190,6 +193,22 @@ void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff, { } +void Allocation::addProgramToDirty(const Program *p) +{ + mToDirtyList.add(p); +} + +void Allocation::removeProgramToDirty(const Program *p) +{ + for (size_t ct=0; ct < mToDirtyList.size(); ct++) { + if (mToDirtyList[ct] == p) { + mToDirtyList.removeAt(ct); + return; + } + } + rsAssert(0); +} + void Allocation::dumpLOGV(const char *prefix) const { ObjectBase::dumpLOGV(prefix); @@ -206,9 +225,14 @@ void Allocation::dumpLOGV(const char *prefix) const LOGV("%s allocation mIsTexture=%i mIsTextureID=%i, mIsVertexBuffer=%i, mBufferID=%i", prefix, mIsTexture, mTextureID, mIsVertexBuffer, mBufferID); - } +void Allocation::sendDirty() const +{ + for (size_t ct=0; ct < mToDirtyList.size(); ct++) { + mToDirtyList[ct]->forceDirty(); + } +} ///////////////// // @@ -444,31 +468,24 @@ RsAllocation rsi_AllocationCreateFromBitmapBoxed(Context *rsc, uint32_t w, uint3 RsAllocation ret = rsi_AllocationCreateFromBitmap(rsc, w2, h2, _dst, _src, genMips, tmp); free(tmp); return ret; - - - - } void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); a->data(data, sizeBytes); - rsc->allocationCheck(a); } void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); a->subData(xoff, count, data, sizeBytes); - rsc->allocationCheck(a); } void rsi_Allocation2DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); a->subData(xoff, yoff, w, h, data, sizeBytes); - rsc->allocationCheck(a); } void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data) diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index 514b1c2..ac2edf8 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -23,7 +23,7 @@ namespace android { namespace renderscript { - +class Program; class Allocation : public ObjectBase { @@ -65,13 +65,19 @@ public: void enableGLVertexBuffers() const; void setupGLIndexBuffers() const; - virtual void dumpLOGV(const char *prefix) const; + void addProgramToDirty(const Program *); + void removeProgramToDirty(const Program *); + virtual void dumpLOGV(const char *prefix) const; protected: + void sendDirty() const; + ObjectBaseRef<const Type> mType; void * mPtr; + Vector<const Program *> mToDirtyList; + // Usage restrictions bool mCpuWrite; bool mCpuRead; diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index 08ed725..5cca60f 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -536,13 +536,6 @@ void Context::setRaster(ProgramRaster *pr) } } -void Context::allocationCheck(const Allocation *a) -{ - mVertex->checkUpdatedAllocation(a); - mFragment->checkUpdatedAllocation(a); - mFragmentStore->checkUpdatedAllocation(a); -} - void Context::setVertex(ProgramVertex *pv) { if (pv == NULL) { @@ -550,7 +543,6 @@ void Context::setVertex(ProgramVertex *pv) } else { mVertex.set(pv); } - mVertex->forceDirty(); } void Context::assignName(ObjectBase *obj, const char *name, uint32_t len) diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index fb878eb..07cb7ba 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -90,7 +90,6 @@ public: const ProgramVertex * getVertex() {return mVertex.get();} void setupCheck(); - void allocationCheck(const Allocation *); void pause(); void resume(); diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp index 5f2a609..ed5918b 100644 --- a/libs/rs/rsProgram.cpp +++ b/libs/rs/rsProgram.cpp @@ -32,19 +32,23 @@ Program::Program(Context *rsc, Element *in, Element *out) : ObjectBase(rsc) Program::~Program() { + bindAllocation(NULL); } void Program::bindAllocation(Allocation *alloc) { + if (mConstants.get() == alloc) { + return; + } + if (mConstants.get()) { + mConstants.get()->removeProgramToDirty(this); + } mConstants.set(alloc); + if (alloc) { + alloc->addProgramToDirty(this); + } mDirty = true; } -void Program::checkUpdatedAllocation(const Allocation *alloc) -{ - if (mConstants.get() == alloc) { - mDirty = true; - } -} diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h index 57c654f..86a46e2 100644 --- a/libs/rs/rsProgram.h +++ b/libs/rs/rsProgram.h @@ -33,7 +33,6 @@ public: virtual ~Program(); void bindAllocation(Allocation *); - void checkUpdatedAllocation(const Allocation *); protected: // Components not listed in "in" will be passed though @@ -47,7 +46,7 @@ protected: public: - void forceDirty() {mDirty = true;} + void forceDirty() const {mDirty = true;} }; |