Loading libs/rs/rsAllocation.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -58,19 +58,7 @@ void Allocation::updateCache() { } Allocation::~Allocation() { if (mHal.state.hasReferences && (mHal.state.hasFaces || mHal.state.hasMipmaps)) { LOGE("Cube/mip allocation with references unsupported, memory not cleaned up!"); } uint32_t elemCount = mHal.state.dimensionX; if (mHal.state.dimensionY > 1) { elemCount *= mHal.state.dimensionY; } if (mHal.state.dimensionZ > 1) { elemCount *= mHal.state.dimensionZ; } decRefs(getPtr(), elemCount, 0); freeChildrenUnlocked(); mRSC->mHal.funcs.allocation.destroy(mRSC, this); } Loading Loading @@ -299,6 +287,19 @@ void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const { } } void Allocation::freeChildrenUnlocked () { decRefs(getPtr(), mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0); } bool Allocation::freeChildren() { if (mHal.state.hasReferences) { incSysRef(); freeChildrenUnlocked(); return decSysRef(); } return false; } void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) { } Loading libs/rs/rsAllocation.h +2 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,7 @@ public: void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const; void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const; virtual bool freeChildren(); void sendDirty(const Context *rsc) const; bool getHasGraphicsMipmaps() const { Loading @@ -127,6 +128,7 @@ protected: Vector<const Program *> mToDirtyList; private: void freeChildrenUnlocked(); Allocation(Context *rsc, const Type *, uint32_t usages, RsAllocationMipmapControl mc); }; Loading libs/rs/rsContext.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -312,6 +312,7 @@ void Context::destroyWorkerThreadResources() { mStateSampler.deinit(this); mFBOCache.deinit(this); } ObjectBase::freeAllChildren(this); //LOGV("destroyWorkerThreadResources 2"); mExit = true; } Loading libs/rs/rsObjectBase.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,10 @@ void ObjectBase::incSysRef() const { void ObjectBase::preDestroy() const { } bool ObjectBase::freeChildren() { return false; } bool ObjectBase::checkDelete(const ObjectBase *ref) { if (!ref) { return false; Loading Loading @@ -217,6 +221,28 @@ void ObjectBase::zeroAllUserRef(Context *rsc) { } } void ObjectBase::freeAllChildren(Context *rsc) { if (rsc->props.mLogObjects) { LOGV("Forcing release of all child objects."); } // This operation can be slow, only to be called during context cleanup. ObjectBase * o = (ObjectBase *)rsc->mObjHead; while (o) { if (o->freeChildren()) { // deleted ref to self and possibly others, restart from head. o = (ObjectBase *)rsc->mObjHead; } else { o = (ObjectBase *)o->mNext; } } if (rsc->props.mLogObjects) { LOGV("Objects remaining."); dumpAll(rsc); } } void ObjectBase::dumpAll(Context *rsc) { asyncLock(); Loading libs/rs/rsObjectBase.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ public: void setName(const char *, uint32_t len); Context * getContext() const {return mRSC;} virtual bool freeChildren(); static void zeroAllUserRef(Context *rsc); static void freeAllChildren(Context *rsc); static void dumpAll(Context *rsc); virtual void dumpLOGV(const char *prefix) const; Loading Loading
libs/rs/rsAllocation.cpp +14 −13 Original line number Diff line number Diff line Loading @@ -58,19 +58,7 @@ void Allocation::updateCache() { } Allocation::~Allocation() { if (mHal.state.hasReferences && (mHal.state.hasFaces || mHal.state.hasMipmaps)) { LOGE("Cube/mip allocation with references unsupported, memory not cleaned up!"); } uint32_t elemCount = mHal.state.dimensionX; if (mHal.state.dimensionY > 1) { elemCount *= mHal.state.dimensionY; } if (mHal.state.dimensionZ > 1) { elemCount *= mHal.state.dimensionZ; } decRefs(getPtr(), elemCount, 0); freeChildrenUnlocked(); mRSC->mHal.funcs.allocation.destroy(mRSC, this); } Loading Loading @@ -299,6 +287,19 @@ void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const { } } void Allocation::freeChildrenUnlocked () { decRefs(getPtr(), mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0); } bool Allocation::freeChildren() { if (mHal.state.hasReferences) { incSysRef(); freeChildrenUnlocked(); return decSysRef(); } return false; } void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) { } Loading
libs/rs/rsAllocation.h +2 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,7 @@ public: void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const; void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const; virtual bool freeChildren(); void sendDirty(const Context *rsc) const; bool getHasGraphicsMipmaps() const { Loading @@ -127,6 +128,7 @@ protected: Vector<const Program *> mToDirtyList; private: void freeChildrenUnlocked(); Allocation(Context *rsc, const Type *, uint32_t usages, RsAllocationMipmapControl mc); }; Loading
libs/rs/rsContext.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -312,6 +312,7 @@ void Context::destroyWorkerThreadResources() { mStateSampler.deinit(this); mFBOCache.deinit(this); } ObjectBase::freeAllChildren(this); //LOGV("destroyWorkerThreadResources 2"); mExit = true; } Loading
libs/rs/rsObjectBase.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,10 @@ void ObjectBase::incSysRef() const { void ObjectBase::preDestroy() const { } bool ObjectBase::freeChildren() { return false; } bool ObjectBase::checkDelete(const ObjectBase *ref) { if (!ref) { return false; Loading Loading @@ -217,6 +221,28 @@ void ObjectBase::zeroAllUserRef(Context *rsc) { } } void ObjectBase::freeAllChildren(Context *rsc) { if (rsc->props.mLogObjects) { LOGV("Forcing release of all child objects."); } // This operation can be slow, only to be called during context cleanup. ObjectBase * o = (ObjectBase *)rsc->mObjHead; while (o) { if (o->freeChildren()) { // deleted ref to self and possibly others, restart from head. o = (ObjectBase *)rsc->mObjHead; } else { o = (ObjectBase *)o->mNext; } } if (rsc->props.mLogObjects) { LOGV("Objects remaining."); dumpAll(rsc); } } void ObjectBase::dumpAll(Context *rsc) { asyncLock(); Loading
libs/rs/rsObjectBase.h +2 −0 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ public: void setName(const char *, uint32_t len); Context * getContext() const {return mRSC;} virtual bool freeChildren(); static void zeroAllUserRef(Context *rsc); static void freeAllChildren(Context *rsc); static void dumpAll(Context *rsc); virtual void dumpLOGV(const char *prefix) const; Loading