diff options
-rw-r--r-- | rsAdapter.cpp | 8 | ||||
-rw-r--r-- | rsAllocation.cpp | 2 | ||||
-rw-r--r-- | rsComponent.cpp | 4 | ||||
-rw-r--r-- | rsContext.cpp | 13 | ||||
-rw-r--r-- | rsElement.cpp | 4 | ||||
-rw-r--r-- | rsLight.cpp | 2 | ||||
-rw-r--r-- | rsMesh.cpp | 2 | ||||
-rw-r--r-- | rsObjectBase.cpp | 34 | ||||
-rw-r--r-- | rsObjectBase.h | 6 | ||||
-rw-r--r-- | rsProgram.cpp | 5 | ||||
-rw-r--r-- | rsProgramFragment.cpp | 8 | ||||
-rw-r--r-- | rsProgramFragment.h | 1 | ||||
-rw-r--r-- | rsProgramFragmentStore.cpp | 8 | ||||
-rw-r--r-- | rsProgramFragmentStore.h | 1 | ||||
-rw-r--r-- | rsProgramRaster.cpp | 8 | ||||
-rw-r--r-- | rsProgramRaster.h | 1 | ||||
-rw-r--r-- | rsProgramVertex.cpp | 16 | ||||
-rw-r--r-- | rsProgramVertex.h | 3 | ||||
-rw-r--r-- | rsSampler.cpp | 4 | ||||
-rw-r--r-- | rsScript.cpp | 2 | ||||
-rw-r--r-- | rsScriptC.cpp | 2 | ||||
-rw-r--r-- | rsSimpleMesh.cpp | 4 | ||||
-rw-r--r-- | rsType.cpp | 2 |
23 files changed, 123 insertions, 17 deletions
diff --git a/rsAdapter.cpp b/rsAdapter.cpp index 9a3bbb1f..0d31facb 100644 --- a/rsAdapter.cpp +++ b/rsAdapter.cpp @@ -23,11 +23,15 @@ using namespace android::renderscript; Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; reset(); } Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; reset(); setAllocation(a); } @@ -127,11 +131,15 @@ void rsi_Adapter1DData(Context *rsc, RsAdapter1D va, const void *data) Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; reset(); } Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; reset(); setAllocation(a); } diff --git a/rsAllocation.cpp b/rsAllocation.cpp index 96e128b6..8ee6e5a4 100644 --- a/rsAllocation.cpp +++ b/rsAllocation.cpp @@ -24,6 +24,8 @@ using namespace android::renderscript; Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mPtr = NULL; mCpuWrite = false; diff --git a/rsComponent.cpp b/rsComponent.cpp index 67184ffa..42e2e4fb 100644 --- a/rsComponent.cpp +++ b/rsComponent.cpp @@ -23,6 +23,8 @@ using namespace android::renderscript; Component::Component(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mType = FLOAT; mKind = USER; mIsNormalized = false; @@ -33,6 +35,8 @@ Component::Component(Context *rsc, DataKind dk, DataType dt, bool isNormalized, uint32_t bits, const char * name) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mType = dt; mKind = dk; mIsNormalized = isNormalized; diff --git a/rsContext.cpp b/rsContext.cpp index 653d4273..70add927 100644 --- a/rsContext.cpp +++ b/rsContext.cpp @@ -269,11 +269,16 @@ void * Context::threadProc(void *vrsc) } LOGV("RS Thread exiting"); + rsc->mRaster.clear(); + rsc->mFragment.clear(); + rsc->mVertex.clear(); + rsc->mFragmentStore.clear(); + rsc->mRootScript.clear(); + rsc->mStateRaster.deinit(rsc); + rsc->mStateVertex.deinit(rsc); + rsc->mStateFragment.deinit(rsc); + rsc->mStateFragmentStore.deinit(rsc); ObjectBase::zeroAllUserRef(rsc); - rsc->mRaster.set(NULL); - rsc->mFragment.set(NULL); - rsc->mVertex.set(NULL); - rsc->mFragmentStore.set(NULL); glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); diff --git a/rsElement.cpp b/rsElement.cpp index e7ae2474..a00fb521 100644 --- a/rsElement.cpp +++ b/rsElement.cpp @@ -24,12 +24,16 @@ using namespace android::renderscript; Element::Element(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mComponents = NULL; mComponentCount = 0; } Element::Element(Context *rsc, uint32_t count) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mComponents = new ObjectBaseRef<Component> [count]; mComponentCount = count; } diff --git a/rsLight.cpp b/rsLight.cpp index e9b8ef9b..6f2cf3e7 100644 --- a/rsLight.cpp +++ b/rsLight.cpp @@ -24,6 +24,8 @@ using namespace android::renderscript; Light::Light(Context *rsc, bool isLocal, bool isMono) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mIsLocal = isLocal; mIsMono = isMono; @@ -24,6 +24,8 @@ using namespace android::renderscript; Mesh::Mesh(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mVerticies = NULL; mVerticiesCount = 0; mPrimitives = NULL; diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp index 83fa482a..720e8fcc 100644 --- a/rsObjectBase.cpp +++ b/rsObjectBase.cpp @@ -28,6 +28,8 @@ ObjectBase::ObjectBase(Context *rsc) mRSC = NULL; mNext = NULL; mPrev = NULL; + mAllocFile = __FILE__; + mAllocLine = __LINE__; setContext(rsc); } @@ -39,6 +41,17 @@ ObjectBase::~ObjectBase() remove(); } +void ObjectBase::dumpObj(const char *op) const +{ + if (mName) { + LOGV("%s RSobj %p, name %s, refs %i,%i from %s,%i links %p,%p,%p", + op, this, mName, mUserRefCount, mSysRefCount, mAllocFile, mAllocLine, mNext, mPrev, mRSC); + } else { + LOGV("%s RSobj %p, no-name, refs %i,%i from %s,%i links %p,%p,%p", + op, this, mUserRefCount, mSysRefCount, mAllocFile, mAllocLine, mNext, mPrev, mRSC); + } +} + void ObjectBase::setContext(Context *rsc) { if (mRSC) { @@ -66,11 +79,7 @@ bool ObjectBase::checkDelete() const { if (!(mSysRefCount | mUserRefCount)) { if (mRSC && mRSC->props.mLogObjects) { - if (mName) { - LOGV("Deleting RS object %p, name %s", this, mName); - } else { - LOGV("Deleting RS object %p, no name", this); - } + dumpObj("checkDelete"); } delete this; return true; @@ -82,14 +91,14 @@ bool ObjectBase::decUserRef() const { rsAssert(mUserRefCount > 0); mUserRefCount --; - //LOGV("ObjectBase %p dec ref %i", this, mRefCount); + //dumpObj("decUserRef"); return checkDelete(); } bool ObjectBase::zeroUserRef() const { mUserRefCount = 0; - //LOGV("ObjectBase %p dec ref %i", this, mRefCount); + //dumpObj("zeroUserRef"); return checkDelete(); } @@ -97,7 +106,7 @@ bool ObjectBase::decSysRef() const { rsAssert(mSysRefCount > 0); mSysRefCount --; - //LOGV("ObjectBase %p dec ref %i", this, mRefCount); + //dumpObj("decSysRef"); return checkDelete(); } @@ -174,5 +183,14 @@ void ObjectBase::zeroAllUserRef(Context *rsc) //LOGE("o next %p", o); } } + + if (rsc->props.mLogObjects) { + LOGV("Objects remaining."); + o = rsc->mObjHead; + while (o) { + o->dumpObj(" "); + o = o->mNext; + } + } } diff --git a/rsObjectBase.h b/rsObjectBase.h index be400caa..ea5e37cc 100644 --- a/rsObjectBase.h +++ b/rsObjectBase.h @@ -50,6 +50,12 @@ public: static void zeroAllUserRef(Context *rsc); + void dumpObj(const char *op) const; + +protected: + const char *mAllocFile; + uint32_t mAllocLine; + private: void add() const; void remove() const; diff --git a/rsProgram.cpp b/rsProgram.cpp index 051483f4..5f2a6097 100644 --- a/rsProgram.cpp +++ b/rsProgram.cpp @@ -23,10 +23,11 @@ using namespace android::renderscript; Program::Program(Context *rsc, Element *in, Element *out) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; + mElementIn.set(in); mElementOut.set(out); - - } Program::~Program() diff --git a/rsProgramFragment.cpp b/rsProgramFragment.cpp index 5f685ff5..708a0e0f 100644 --- a/rsProgramFragment.cpp +++ b/rsProgramFragment.cpp @@ -27,6 +27,8 @@ using namespace android::renderscript; ProgramFragment::ProgramFragment(Context *rsc, Element *in, Element *out, bool pointSpriteEnable) : Program(rsc, in, out) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { mEnvModes[ct] = RS_TEX_ENV_MODE_REPLACE; mTextureDimensions[ct] = 2; @@ -190,6 +192,12 @@ void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) mDefault.set(pf); } +void ProgramFragmentState::deinit(Context *rsc) +{ + mDefault.clear(); + mLast.clear(); +} + namespace android { namespace renderscript { diff --git a/rsProgramFragment.h b/rsProgramFragment.h index d783c0df..e26c6e8a 100644 --- a/rsProgramFragment.h +++ b/rsProgramFragment.h @@ -75,6 +75,7 @@ public: ProgramFragment *mPF; void init(Context *rsc, int32_t w, int32_t h); + void deinit(Context *rsc); ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; ObjectBaseRef<ProgramFragment> mDefault; diff --git a/rsProgramFragmentStore.cpp b/rsProgramFragmentStore.cpp index 39802c7b..de33d9c5 100644 --- a/rsProgramFragmentStore.cpp +++ b/rsProgramFragmentStore.cpp @@ -27,6 +27,8 @@ using namespace android::renderscript; ProgramFragmentStore::ProgramFragmentStore(Context *rsc, Element *in, Element *out) : Program(rsc, in, out) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mDitherEnable = true; mBlendEnable = false; mColorRWriteEnable = true; @@ -217,6 +219,12 @@ void ProgramFragmentStoreState::init(Context *rsc, int32_t w, int32_t h) mDefault.set(pfs); } +void ProgramFragmentStoreState::deinit(Context *rsc) +{ + mDefault.clear(); + mLast.clear(); +} + namespace android { namespace renderscript { diff --git a/rsProgramFragmentStore.h b/rsProgramFragmentStore.h index b71e35f9..a3443873 100644 --- a/rsProgramFragmentStore.h +++ b/rsProgramFragmentStore.h @@ -65,6 +65,7 @@ public: ProgramFragmentStoreState(); ~ProgramFragmentStoreState(); void init(Context *rsc, int32_t w, int32_t h); + void deinit(Context *rsc); ObjectBaseRef<ProgramFragmentStore> mDefault; ObjectBaseRef<ProgramFragmentStore> mLast; diff --git a/rsProgramRaster.cpp b/rsProgramRaster.cpp index 2a9c4abd..fcf6824f 100644 --- a/rsProgramRaster.cpp +++ b/rsProgramRaster.cpp @@ -32,6 +32,8 @@ ProgramRaster::ProgramRaster(Context *rsc, bool pointSprite) : Program(rsc, in, out) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mPointSmooth = pointSmooth; mLineSmooth = lineSmooth; mPointSprite = pointSprite; @@ -100,6 +102,12 @@ void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h) mDefault.set(pr); } +void ProgramRasterState::deinit(Context *rsc) +{ + mDefault.clear(); + mLast.clear(); +} + namespace android { namespace renderscript { diff --git a/rsProgramRaster.h b/rsProgramRaster.h index da68f67d..a6d5ba8e 100644 --- a/rsProgramRaster.h +++ b/rsProgramRaster.h @@ -58,6 +58,7 @@ public: ProgramRasterState(); ~ProgramRasterState(); void init(Context *rsc, int32_t w, int32_t h); + void deinit(Context *rsc); ObjectBaseRef<ProgramRaster> mDefault; ObjectBaseRef<ProgramRaster> mLast; diff --git a/rsProgramVertex.cpp b/rsProgramVertex.cpp index 9eb32ff2..9bfa6022 100644 --- a/rsProgramVertex.cpp +++ b/rsProgramVertex.cpp @@ -27,6 +27,8 @@ using namespace android::renderscript; ProgramVertex::ProgramVertex(Context *rsc, Element *in, Element *out) : Program(rsc, in, out) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mTextureMatrixEnable = false; mLightCount = 0; } @@ -139,10 +141,10 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h) rsi_TypeBegin(rsc, e); rsi_TypeAdd(rsc, RS_DIMENSION_X, 48); - mAllocType = rsi_TypeCreate(rsc); + mAllocType.set((Type *)rsi_TypeCreate(rsc)); ProgramVertex *pv = new ProgramVertex(rsc, NULL, NULL); - Allocation *alloc = (Allocation *)rsi_AllocationCreateTyped(rsc, mAllocType); + Allocation *alloc = (Allocation *)rsi_AllocationCreateTyped(rsc, mAllocType.get()); mDefaultAlloc.set(alloc); mDefault.set(pv); @@ -156,6 +158,16 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h) alloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4); } +void ProgramVertexState::deinit(Context *rsc) +{ + mDefaultAlloc.clear(); + mDefault.clear(); + mAllocType.clear(); + mLast.clear(); + delete mPV; + mPV = NULL; +} + namespace android { namespace renderscript { diff --git a/rsProgramVertex.h b/rsProgramVertex.h index b3a8b8da..e198f238 100644 --- a/rsProgramVertex.h +++ b/rsProgramVertex.h @@ -59,12 +59,13 @@ public: ~ProgramVertexState(); void init(Context *rsc, int32_t w, int32_t h); + void deinit(Context *rsc); ObjectBaseRef<ProgramVertex> mDefault; ObjectBaseRef<ProgramVertex> mLast; ObjectBaseRef<Allocation> mDefaultAlloc; - RsType mAllocType; + ObjectBaseRef<Type> mAllocType; ProgramVertex *mPV; diff --git a/rsSampler.cpp b/rsSampler.cpp index 99091a91..b7937507 100644 --- a/rsSampler.cpp +++ b/rsSampler.cpp @@ -27,6 +27,8 @@ using namespace android::renderscript; Sampler::Sampler(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; // Should not get called. rsAssert(0); } @@ -38,6 +40,8 @@ Sampler::Sampler(Context *rsc, RsSamplerValue wrapT, RsSamplerValue wrapR) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mMagFilter = magFilter; mMinFilter = minFilter; mWrapS = wrapS; diff --git a/rsScript.cpp b/rsScript.cpp index f9526fe0..cb1436b0 100644 --- a/rsScript.cpp +++ b/rsScript.cpp @@ -21,6 +21,8 @@ using namespace android::renderscript; Script::Script(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; memset(&mEnviroment, 0, sizeof(mEnviroment)); mEnviroment.mClearColor[0] = 0; mEnviroment.mClearColor[1] = 0; diff --git a/rsScriptC.cpp b/rsScriptC.cpp index fb8180fc..e63ed246 100644 --- a/rsScriptC.cpp +++ b/rsScriptC.cpp @@ -35,6 +35,8 @@ using namespace android::renderscript; ScriptC::ScriptC(Context *rsc) : Script(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mAccScript = NULL; memset(&mProgram, 0, sizeof(mProgram)); } diff --git a/rsSimpleMesh.cpp b/rsSimpleMesh.cpp index fe06e0cc..b082fd7d 100644 --- a/rsSimpleMesh.cpp +++ b/rsSimpleMesh.cpp @@ -24,10 +24,14 @@ using namespace android::renderscript; SimpleMesh::SimpleMesh(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; } SimpleMesh::~SimpleMesh() { + delete[] mVertexTypes; + delete[] mVertexBuffers; } void SimpleMesh::render() const @@ -22,6 +22,8 @@ using namespace android::renderscript; Type::Type(Context *rsc) : ObjectBase(rsc) { + mAllocFile = __FILE__; + mAllocLine = __LINE__; mLODs = 0; mLODCount = 0; memset(&mGL, 0, sizeof(mGL)); |