Merge change 27137 into eclair
* changes: Improve renderscript context teardown. Track object in the system and then force their cleanup by releasing all user references once destroy context is called. Java layer will no longer send destroy notifications for objects garbage collected once a context is destroyed.
This commit is contained in:
@@ -60,9 +60,10 @@ class BaseObj {
|
|||||||
protected void finalize() throws Throwable
|
protected void finalize() throws Throwable
|
||||||
{
|
{
|
||||||
if (!mDestroyed) {
|
if (!mDestroyed) {
|
||||||
if(mID != 0) {
|
if(mID != 0 && mRS.isAlive()) {
|
||||||
mRS.nObjDestroyOOB(mID);
|
mRS.nObjDestroyOOB(mID);
|
||||||
}
|
}
|
||||||
|
mRS = null;
|
||||||
mID = 0;
|
mID = 0;
|
||||||
mDestroyed = true;
|
mDestroyed = true;
|
||||||
Log.v(RenderScript.LOG_TAG,
|
Log.v(RenderScript.LOG_TAG,
|
||||||
|
|||||||
@@ -219,6 +219,10 @@ public class RenderScript {
|
|||||||
mDev = 0;
|
mDev = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isAlive() {
|
||||||
|
return mContext != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void pause() {
|
void pause() {
|
||||||
nContextPause();
|
nContextPause();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public class Fountain extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
|
Log.e("rs", "onResume");
|
||||||
|
|
||||||
// Ideally a game should implement onResume() and onPause()
|
// Ideally a game should implement onResume() and onPause()
|
||||||
// to take appropriate action when the activity looses focus
|
// to take appropriate action when the activity looses focus
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -70,12 +72,16 @@ public class Fountain extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
Log.e("rs", "onPause");
|
||||||
|
|
||||||
// Ideally a game should implement onResume() and onPause()
|
// Ideally a game should implement onResume() and onPause()
|
||||||
// to take appropriate action when the activity looses focus
|
// to take appropriate action when the activity looses focus
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mView.onPause();
|
mView.onPause();
|
||||||
|
|
||||||
Runtime.getRuntime().exit(0);
|
|
||||||
|
|
||||||
|
//Runtime.getRuntime().exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,14 +49,40 @@ public class FountainView extends RSSurfaceView {
|
|||||||
private RenderScript mRS;
|
private RenderScript mRS;
|
||||||
private FountainRS mRender;
|
private FountainRS mRender;
|
||||||
|
|
||||||
|
private void destroyRS() {
|
||||||
|
if(mRS != null) {
|
||||||
|
mRS = null;
|
||||||
|
destroyRenderScript();
|
||||||
|
}
|
||||||
|
java.lang.System.gc();
|
||||||
|
}
|
||||||
|
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
|
||||||
super.surfaceChanged(holder, format, w, h);
|
super.surfaceChanged(holder, format, w, h);
|
||||||
|
|
||||||
|
Log.e("rs", "surfaceChanged");
|
||||||
|
destroyRS();
|
||||||
|
|
||||||
|
|
||||||
mRS = createRenderScript(false, true);
|
mRS = createRenderScript(false, true);
|
||||||
mRender = new FountainRS();
|
mRender = new FountainRS();
|
||||||
mRender.init(mRS, getResources(), w, h);
|
mRender.init(mRS, getResources(), w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
// Surface will be destroyed when we return
|
||||||
|
Log.v("rs", "surfaceDestroyed");
|
||||||
|
destroyRS();
|
||||||
|
|
||||||
|
try {
|
||||||
|
java.lang.Thread.sleep(5000);
|
||||||
|
} catch(InterruptedException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
Runtime.getRuntime().exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent ev)
|
public boolean onTouchEvent(MotionEvent ev)
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
Adapter1D::Adapter1D()
|
Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Adapter1D::Adapter1D(Allocation *a)
|
Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
setAllocation(a);
|
setAllocation(a);
|
||||||
@@ -71,7 +71,7 @@ namespace renderscript {
|
|||||||
|
|
||||||
RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
|
RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
Adapter1D *a = new Adapter1D();
|
Adapter1D *a = new Adapter1D(rsc);
|
||||||
a->incUserRef();
|
a->incUserRef();
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -125,12 +125,12 @@ void rsi_Adapter1DData(Context *rsc, RsAdapter1D va, const void *data)
|
|||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
Adapter2D::Adapter2D()
|
Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Adapter2D::Adapter2D(Allocation *a)
|
Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
setAllocation(a);
|
setAllocation(a);
|
||||||
@@ -184,7 +184,7 @@ namespace renderscript {
|
|||||||
|
|
||||||
RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
|
RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
Adapter2D *a = new Adapter2D();
|
Adapter2D *a = new Adapter2D(rsc);
|
||||||
a->incUserRef();
|
a->incUserRef();
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,15 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
namespace renderscript {
|
namespace renderscript {
|
||||||
|
|
||||||
|
|
||||||
class Adapter1D : public ObjectBase
|
class Adapter1D : public ObjectBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// By policy this allocation will hold a pointer to the type
|
// By policy this allocation will hold a pointer to the type
|
||||||
// but will not destroy it on destruction.
|
// but will not destroy it on destruction.
|
||||||
Adapter1D();
|
Adapter1D(Context *);
|
||||||
Adapter1D(Allocation *);
|
Adapter1D(Context *, Allocation *);
|
||||||
void reset();
|
void reset();
|
||||||
void * getElement(uint32_t x);
|
void * getElement(uint32_t x);
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ class Adapter2D : public ObjectBase
|
|||||||
public:
|
public:
|
||||||
// By policy this allocation will hold a pointer to the type
|
// By policy this allocation will hold a pointer to the type
|
||||||
// but will not destroy it on destruction.
|
// but will not destroy it on destruction.
|
||||||
Adapter2D();
|
Adapter2D(Context *);
|
||||||
Adapter2D(Allocation *);
|
Adapter2D(Context *, Allocation *);
|
||||||
void reset();
|
void reset();
|
||||||
void * getElement(uint32_t x, uint32_t y) const;
|
void * getElement(uint32_t x, uint32_t y) const;
|
||||||
|
|
||||||
@@ -79,8 +79,8 @@ public:
|
|||||||
inline void setFace(uint32_t face) {mFace = face;}
|
inline void setFace(uint32_t face) {mFace = face;}
|
||||||
//void setArray(uint32_t num, uint32_t value);
|
//void setArray(uint32_t num, uint32_t value);
|
||||||
|
|
||||||
void data(const void *data);
|
void data(const void *data);
|
||||||
void subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data);
|
void subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ObjectBaseRef<Allocation> mAllocation;
|
ObjectBaseRef<Allocation> mAllocation;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
Allocation::Allocation(const Type *type)
|
Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mPtr = NULL;
|
mPtr = NULL;
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ void Allocation::uploadToTexture(uint32_t lodOffset)
|
|||||||
}
|
}
|
||||||
glBindTexture(GL_TEXTURE_2D, mTextureID);
|
glBindTexture(GL_TEXTURE_2D, mTextureID);
|
||||||
|
|
||||||
Adapter2D adapt(this);
|
Adapter2D adapt(getContext(), this);
|
||||||
for(uint32_t lod = 0; (lod + lodOffset) < mType->getLODCount(); lod++) {
|
for(uint32_t lod = 0; (lod + lodOffset) < mType->getLODCount(); lod++) {
|
||||||
adapt.setLOD(lod+lodOffset);
|
adapt.setLOD(lod+lodOffset);
|
||||||
|
|
||||||
@@ -186,14 +186,14 @@ RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype)
|
|||||||
{
|
{
|
||||||
const Type * type = static_cast<const Type *>(vtype);
|
const Type * type = static_cast<const Type *>(vtype);
|
||||||
|
|
||||||
Allocation * alloc = new Allocation(type);
|
Allocation * alloc = new Allocation(rsc, type);
|
||||||
alloc->incUserRef();
|
alloc->incUserRef();
|
||||||
return alloc;
|
return alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsAllocation rsi_AllocationCreateSized(Context *rsc, RsElement e, size_t count)
|
RsAllocation rsi_AllocationCreateSized(Context *rsc, RsElement e, size_t count)
|
||||||
{
|
{
|
||||||
Type * type = new Type();
|
Type * type = new Type(rsc);
|
||||||
type->setDimX(count);
|
type->setDimX(count);
|
||||||
type->setElement(static_cast<Element *>(e));
|
type->setElement(static_cast<Element *>(e));
|
||||||
type->compute();
|
type->compute();
|
||||||
@@ -371,8 +371,8 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h
|
|||||||
cvt(texAlloc->getPtr(), data, w * h);
|
cvt(texAlloc->getPtr(), data, w * h);
|
||||||
|
|
||||||
if (genMips) {
|
if (genMips) {
|
||||||
Adapter2D adapt(texAlloc);
|
Adapter2D adapt(rsc, texAlloc);
|
||||||
Adapter2D adapt2(texAlloc);
|
Adapter2D adapt2(rsc, texAlloc);
|
||||||
for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
|
for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
|
||||||
adapt.setLOD(lod);
|
adapt.setLOD(lod);
|
||||||
adapt2.setLOD(lod + 1);
|
adapt2.setLOD(lod + 1);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class Allocation : public ObjectBase
|
|||||||
public:
|
public:
|
||||||
// By policy this allocation will hold a pointer to the type
|
// By policy this allocation will hold a pointer to the type
|
||||||
// but will not destroy it on destruction.
|
// but will not destroy it on destruction.
|
||||||
Allocation(const Type *);
|
Allocation(Context *rsc, const Type *);
|
||||||
virtual ~Allocation();
|
virtual ~Allocation();
|
||||||
|
|
||||||
void setCpuWritable(bool);
|
void setCpuWritable(bool);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
Component::Component()
|
Component::Component(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mType = FLOAT;
|
mType = FLOAT;
|
||||||
mKind = USER;
|
mKind = USER;
|
||||||
@@ -29,9 +29,9 @@ Component::Component()
|
|||||||
mBits = 0;
|
mBits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component::Component(
|
Component::Component(Context *rsc,
|
||||||
DataKind dk, DataType dt,
|
DataKind dk, DataType dt,
|
||||||
bool isNormalized, uint32_t bits, const char * name)
|
bool isNormalized, uint32_t bits, const char * name) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mType = dt;
|
mType = dt;
|
||||||
mKind = dk;
|
mKind = dk;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Component(DataKind dk, DataType dt, bool isNorm, uint32_t bits, const char *);
|
Component(Context *rsc, DataKind dk, DataType dt, bool isNorm, uint32_t bits, const char *);
|
||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
|
|
||||||
DataType getType() const {return mType;}
|
DataType getType() const {return mType;}
|
||||||
@@ -66,7 +66,7 @@ protected:
|
|||||||
String8 mName;
|
String8 mName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Component();
|
Component(Context *rsc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -269,6 +269,12 @@ void * Context::threadProc(void *vrsc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOGV("RS Thread exiting");
|
LOGV("RS Thread exiting");
|
||||||
|
ObjectBase::zeroAllUserRef(rsc);
|
||||||
|
rsc->mRaster.set(NULL);
|
||||||
|
rsc->mFragment.set(NULL);
|
||||||
|
rsc->mVertex.set(NULL);
|
||||||
|
rsc->mFragmentStore.set(NULL);
|
||||||
|
|
||||||
glClearColor(0,0,0,0);
|
glClearColor(0,0,0,0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
|
eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
|
||||||
@@ -286,6 +292,7 @@ Context::Context(Device *dev, Surface *sur, bool useDepth)
|
|||||||
mExit = false;
|
mExit = false;
|
||||||
mUseDepth = useDepth;
|
mUseDepth = useDepth;
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
|
mObjHead = NULL;
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
pthread_attr_t threadAttr;
|
pthread_attr_t threadAttr;
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ public:
|
|||||||
|
|
||||||
bool logTimes;
|
bool logTimes;
|
||||||
|
|
||||||
|
mutable const ObjectBase * mObjHead;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Device *mDev;
|
Device *mDev;
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
Element::Element()
|
Element::Element(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mComponents = NULL;
|
mComponents = NULL;
|
||||||
mComponentCount = 0;
|
mComponentCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element::Element(uint32_t count)
|
Element::Element(Context *rsc, uint32_t count) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mComponents = new ObjectBaseRef<Component> [count];
|
mComponents = new ObjectBaseRef<Component> [count];
|
||||||
mComponentCount = count;
|
mComponentCount = count;
|
||||||
@@ -197,7 +197,8 @@ void rsi_ElementBegin(Context *rsc)
|
|||||||
void rsi_ElementAdd(Context *rsc, RsDataKind dk, RsDataType dt, bool isNormalized, size_t bits, const char *name)
|
void rsi_ElementAdd(Context *rsc, RsDataKind dk, RsDataType dt, bool isNormalized, size_t bits, const char *name)
|
||||||
{
|
{
|
||||||
ElementState * sec = &rsc->mStateElement;
|
ElementState * sec = &rsc->mStateElement;
|
||||||
Component *c = new Component(static_cast<Component::DataKind>(dk),
|
Component *c = new Component(rsc,
|
||||||
|
static_cast<Component::DataKind>(dk),
|
||||||
static_cast<Component::DataType>(dt),
|
static_cast<Component::DataType>(dt),
|
||||||
isNormalized,
|
isNormalized,
|
||||||
bits,
|
bits,
|
||||||
@@ -208,7 +209,7 @@ void rsi_ElementAdd(Context *rsc, RsDataKind dk, RsDataType dt, bool isNormalize
|
|||||||
RsElement rsi_ElementCreate(Context *rsc)
|
RsElement rsi_ElementCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
ElementState * sec = &rsc->mStateElement;
|
ElementState * sec = &rsc->mStateElement;
|
||||||
Element *se = new Element(sec->mComponentBuildList.size());
|
Element *se = new Element(rsc, sec->mComponentBuildList.size());
|
||||||
|
|
||||||
for (size_t ct = 0; ct < se->getComponentCount(); ct++) {
|
for (size_t ct = 0; ct < se->getComponentCount(); ct++) {
|
||||||
se->setComponent(ct, sec->mComponentBuildList[ct]);
|
se->setComponent(ct, sec->mComponentBuildList[ct]);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace renderscript {
|
|||||||
class Element : public ObjectBase
|
class Element : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Element(uint32_t count);
|
Element(Context *, uint32_t count);
|
||||||
~Element();
|
~Element();
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ protected:
|
|||||||
ObjectBaseRef<Component> * mComponents;
|
ObjectBaseRef<Component> * mComponents;
|
||||||
//uint32_t *mOffsetTable;
|
//uint32_t *mOffsetTable;
|
||||||
|
|
||||||
Element();
|
Element(Context *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ void FileA3D::IO::loadString(String8 *s)
|
|||||||
|
|
||||||
void FileA3D::processChunk_Mesh(Context *rsc, IO *io, A3DIndexEntry *ie)
|
void FileA3D::processChunk_Mesh(Context *rsc, IO *io, A3DIndexEntry *ie)
|
||||||
{
|
{
|
||||||
Mesh * m = new Mesh;
|
Mesh * m = new Mesh(rsc);
|
||||||
|
|
||||||
m->mPrimitivesCount = io->loadU32();
|
m->mPrimitivesCount = io->loadU32();
|
||||||
m->mPrimitives = new Mesh::Primitive_t *[m->mPrimitivesCount];
|
m->mPrimitives = new Mesh::Primitive_t *[m->mPrimitivesCount];
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
Light::Light(bool isLocal, bool isMono)
|
Light::Light(Context *rsc, bool isLocal, bool isMono) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mIsLocal = isLocal;
|
mIsLocal = isLocal;
|
||||||
mIsMono = isMono;
|
mIsMono = isMono;
|
||||||
@@ -104,7 +104,7 @@ void rsi_LightSetMonochromatic(Context *rsc, bool isMono)
|
|||||||
|
|
||||||
RsLight rsi_LightCreate(Context *rsc)
|
RsLight rsi_LightCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
Light *l = new Light(rsc->mStateLight.mIsLocal,
|
Light *l = new Light(rsc, rsc->mStateLight.mIsLocal,
|
||||||
rsc->mStateLight.mIsMono);
|
rsc->mStateLight.mIsMono);
|
||||||
l->incUserRef();
|
l->incUserRef();
|
||||||
return l;
|
return l;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace renderscript {
|
|||||||
class Light : public ObjectBase
|
class Light : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Light(bool isLocal, bool isMono);
|
Light(Context *, bool isLocal, bool isMono);
|
||||||
virtual ~Light();
|
virtual ~Light();
|
||||||
|
|
||||||
// Values, mutable after creation.
|
// Values, mutable after creation.
|
||||||
|
|||||||
@@ -131,6 +131,12 @@ const void * LocklessCommandFifo::get(uint32_t *command, uint32_t *bytesData)
|
|||||||
mSignalToWorker.wait();
|
mSignalToWorker.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mInShutdown) {
|
||||||
|
*command = 0;
|
||||||
|
*bytesData = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
*command = reinterpret_cast<const uint16_t *>(mGet)[0];
|
*command = reinterpret_cast<const uint16_t *>(mGet)[0];
|
||||||
*bytesData = reinterpret_cast<const uint16_t *>(mGet)[1];
|
*bytesData = reinterpret_cast<const uint16_t *>(mGet)[1];
|
||||||
if (*command) {
|
if (*command) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ using namespace android::renderscript;
|
|||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
|
|
||||||
Mesh::Mesh()
|
Mesh::Mesh(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mVerticies = NULL;
|
mVerticies = NULL;
|
||||||
mVerticiesCount = 0;
|
mVerticiesCount = 0;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace renderscript {
|
|||||||
class Mesh : public ObjectBase
|
class Mesh : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Mesh();
|
Mesh(Context *);
|
||||||
~Mesh();
|
~Mesh();
|
||||||
|
|
||||||
struct Verticies_t
|
struct Verticies_t
|
||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
size_t mOffsetCoord;
|
size_t mOffsetCoord;
|
||||||
size_t mOffsetTex;
|
size_t mOffsetTex;
|
||||||
size_t mOffsetNorm;
|
size_t mOffsetNorm;
|
||||||
|
|
||||||
size_t mSizeCoord;
|
size_t mSizeCoord;
|
||||||
size_t mSizeTex;
|
size_t mSizeTex;
|
||||||
size_t mSizeNorm;
|
size_t mSizeNorm;
|
||||||
|
|||||||
@@ -15,22 +15,39 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rsObjectBase.h"
|
#include "rsObjectBase.h"
|
||||||
|
#include "rsContext.h"
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
ObjectBase::ObjectBase()
|
ObjectBase::ObjectBase(Context *rsc)
|
||||||
{
|
{
|
||||||
mUserRefCount = 0;
|
mUserRefCount = 0;
|
||||||
mSysRefCount = 0;
|
mSysRefCount = 0;
|
||||||
mName = NULL;
|
mName = NULL;
|
||||||
|
mRSC = NULL;
|
||||||
|
mNext = NULL;
|
||||||
|
mPrev = NULL;
|
||||||
|
setContext(rsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectBase::~ObjectBase()
|
ObjectBase::~ObjectBase()
|
||||||
{
|
{
|
||||||
//LOGV("~ObjectBase %p ref %i", this, mRefCount);
|
//LOGV("~ObjectBase %p ref %i,%i", this, mUserRefCount, mSysRefCount);
|
||||||
rsAssert(!mUserRefCount);
|
rsAssert(!mUserRefCount);
|
||||||
rsAssert(!mSysRefCount);
|
rsAssert(!mSysRefCount);
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectBase::setContext(Context *rsc)
|
||||||
|
{
|
||||||
|
if (mRSC) {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
mRSC = rsc;
|
||||||
|
if (rsc) {
|
||||||
|
add();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectBase::incUserRef() const
|
void ObjectBase::incUserRef() const
|
||||||
@@ -45,34 +62,41 @@ void ObjectBase::incSysRef() const
|
|||||||
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
|
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectBase::decUserRef() const
|
bool ObjectBase::checkDelete() const
|
||||||
|
{
|
||||||
|
if (!(mSysRefCount | mUserRefCount)) {
|
||||||
|
if (mName) {
|
||||||
|
LOGV("Deleting RS object %p, name %s", this, mName);
|
||||||
|
} else {
|
||||||
|
LOGV("Deleting RS object %p, no name", this);
|
||||||
|
}
|
||||||
|
delete this;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjectBase::decUserRef() const
|
||||||
{
|
{
|
||||||
rsAssert(mUserRefCount > 0);
|
rsAssert(mUserRefCount > 0);
|
||||||
mUserRefCount --;
|
mUserRefCount --;
|
||||||
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||||
if (!(mSysRefCount | mUserRefCount)) {
|
return checkDelete();
|
||||||
if (mName) {
|
|
||||||
LOGV("Deleting RS object %p, name %s", this, mName);
|
|
||||||
} else {
|
|
||||||
LOGV("Deleting RS object %p, no name", this);
|
|
||||||
}
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectBase::decSysRef() const
|
bool ObjectBase::zeroUserRef() const
|
||||||
|
{
|
||||||
|
mUserRefCount = 0;
|
||||||
|
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||||
|
return checkDelete();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ObjectBase::decSysRef() const
|
||||||
{
|
{
|
||||||
rsAssert(mSysRefCount > 0);
|
rsAssert(mSysRefCount > 0);
|
||||||
mSysRefCount --;
|
mSysRefCount --;
|
||||||
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||||
if (!(mSysRefCount | mUserRefCount)) {
|
return checkDelete();
|
||||||
if (mName) {
|
|
||||||
LOGV("Deleting RS object %p, name %s", this, mName);
|
|
||||||
} else {
|
|
||||||
LOGV("Deleting RS object %p, no name", this);
|
|
||||||
}
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectBase::setName(const char *name)
|
void ObjectBase::setName(const char *name)
|
||||||
@@ -96,3 +120,55 @@ void ObjectBase::setName(const char *name, uint32_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectBase::add() const
|
||||||
|
{
|
||||||
|
rsAssert(!mNext);
|
||||||
|
rsAssert(!mPrev);
|
||||||
|
//LOGV("calling add rsc %p", mRSC);
|
||||||
|
mNext = mRSC->mObjHead;
|
||||||
|
if (mRSC->mObjHead) {
|
||||||
|
mRSC->mObjHead->mPrev = this;
|
||||||
|
}
|
||||||
|
mRSC->mObjHead = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectBase::remove() const
|
||||||
|
{
|
||||||
|
//LOGV("calling remove rsc %p", mRSC);
|
||||||
|
if (!mRSC) {
|
||||||
|
rsAssert(!mPrev);
|
||||||
|
rsAssert(!mNext);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mRSC->mObjHead == this) {
|
||||||
|
mRSC->mObjHead = mNext;
|
||||||
|
}
|
||||||
|
if (mPrev) {
|
||||||
|
mPrev->mNext = mNext;
|
||||||
|
}
|
||||||
|
if (mNext) {
|
||||||
|
mNext->mPrev = mPrev;
|
||||||
|
}
|
||||||
|
mPrev = NULL;
|
||||||
|
mNext = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectBase::zeroAllUserRef(Context *rsc)
|
||||||
|
{
|
||||||
|
LOGV("Forcing release of all outstanding user refs.");
|
||||||
|
|
||||||
|
// This operation can be slow, only to be called during context cleanup.
|
||||||
|
const ObjectBase * o = rsc->mObjHead;
|
||||||
|
while (o) {
|
||||||
|
//LOGE("o %p", o);
|
||||||
|
if (o->zeroUserRef()) {
|
||||||
|
// deleted the object and possibly others, restart from head.
|
||||||
|
o = rsc->mObjHead;
|
||||||
|
//LOGE("o head %p", o);
|
||||||
|
} else {
|
||||||
|
o = o->mNext;
|
||||||
|
//LOGE("o next %p", o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,21 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
namespace renderscript {
|
namespace renderscript {
|
||||||
|
|
||||||
|
class Context;
|
||||||
|
|
||||||
// An element is a group of Components that occupies one cell in a structure.
|
// An element is a group of Components that occupies one cell in a structure.
|
||||||
class ObjectBase
|
class ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObjectBase();
|
ObjectBase(Context *rsc);
|
||||||
virtual ~ObjectBase();
|
virtual ~ObjectBase();
|
||||||
|
|
||||||
void incSysRef() const;
|
void incSysRef() const;
|
||||||
void decSysRef() const;
|
bool decSysRef() const;
|
||||||
|
|
||||||
void incUserRef() const;
|
void incUserRef() const;
|
||||||
void decUserRef() const;
|
bool decUserRef() const;
|
||||||
|
bool zeroUserRef() const;
|
||||||
|
|
||||||
const char * getName() const {
|
const char * getName() const {
|
||||||
return mName;
|
return mName;
|
||||||
@@ -42,12 +45,24 @@ public:
|
|||||||
void setName(const char *);
|
void setName(const char *);
|
||||||
void setName(const char *, uint32_t len);
|
void setName(const char *, uint32_t len);
|
||||||
|
|
||||||
|
Context * getContext() const {return mRSC;}
|
||||||
|
void setContext(Context *);
|
||||||
|
|
||||||
|
static void zeroAllUserRef(Context *rsc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void add() const;
|
||||||
|
void remove() const;
|
||||||
|
|
||||||
|
bool checkDelete() const;
|
||||||
|
|
||||||
char * mName;
|
char * mName;
|
||||||
|
Context *mRSC;
|
||||||
mutable int32_t mSysRefCount;
|
mutable int32_t mSysRefCount;
|
||||||
mutable int32_t mUserRefCount;
|
mutable int32_t mUserRefCount;
|
||||||
|
|
||||||
|
mutable const ObjectBase * mPrev;
|
||||||
|
mutable const ObjectBase * mNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
Program::Program(Element *in, Element *out)
|
Program::Program(Context *rsc, Element *in, Element *out) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mElementIn.set(in);
|
mElementIn.set(in);
|
||||||
mElementOut.set(out);
|
mElementOut.set(out);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace renderscript {
|
|||||||
class Program : public ObjectBase
|
class Program : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Program(Element *in, Element *out);
|
Program(Context *, Element *in, Element *out);
|
||||||
virtual ~Program();
|
virtual ~Program();
|
||||||
|
|
||||||
void bindAllocation(Allocation *);
|
void bindAllocation(Allocation *);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
ProgramFragment::ProgramFragment(Element *in, Element *out, bool pointSpriteEnable) :
|
ProgramFragment::ProgramFragment(Context *rsc, Element *in, Element *out, bool pointSpriteEnable) :
|
||||||
Program(in, out)
|
Program(rsc, in, out)
|
||||||
{
|
{
|
||||||
for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) {
|
for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) {
|
||||||
mEnvModes[ct] = RS_TEX_ENV_MODE_REPLACE;
|
mEnvModes[ct] = RS_TEX_ENV_MODE_REPLACE;
|
||||||
@@ -186,7 +186,7 @@ ProgramFragmentState::~ProgramFragmentState()
|
|||||||
|
|
||||||
void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h)
|
void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
ProgramFragment *pf = new ProgramFragment(NULL, NULL, false);
|
ProgramFragment *pf = new ProgramFragment(rsc, NULL, NULL, false);
|
||||||
mDefault.set(pf);
|
mDefault.set(pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ namespace renderscript {
|
|||||||
void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out, bool pointSpriteEnable)
|
void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out, bool pointSpriteEnable)
|
||||||
{
|
{
|
||||||
delete rsc->mStateFragment.mPF;
|
delete rsc->mStateFragment.mPF;
|
||||||
rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out, pointSpriteEnable);
|
rsc->mStateFragment.mPF = new ProgramFragment(rsc, (Element *)in, (Element *)out, pointSpriteEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_t slot, RsAllocation a)
|
void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_t slot, RsAllocation a)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ProgramFragment(Element *in, Element *out, bool pointSpriteEnable);
|
ProgramFragment(Context *, Element *in, Element *out, bool pointSpriteEnable);
|
||||||
virtual ~ProgramFragment();
|
virtual ~ProgramFragment();
|
||||||
|
|
||||||
virtual void setupGL(const Context *, ProgramFragmentState *);
|
virtual void setupGL(const Context *, ProgramFragmentState *);
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
ProgramFragmentStore::ProgramFragmentStore(Element *in, Element *out) :
|
ProgramFragmentStore::ProgramFragmentStore(Context *rsc, Element *in, Element *out) :
|
||||||
Program(in, out)
|
Program(rsc, in, out)
|
||||||
{
|
{
|
||||||
mDitherEnable = true;
|
mDitherEnable = true;
|
||||||
mBlendEnable = false;
|
mBlendEnable = false;
|
||||||
@@ -213,7 +213,7 @@ ProgramFragmentStoreState::~ProgramFragmentStoreState()
|
|||||||
|
|
||||||
void ProgramFragmentStoreState::init(Context *rsc, int32_t w, int32_t h)
|
void ProgramFragmentStoreState::init(Context *rsc, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
ProgramFragmentStore *pfs = new ProgramFragmentStore(NULL, NULL);
|
ProgramFragmentStore *pfs = new ProgramFragmentStore(rsc, NULL, NULL);
|
||||||
mDefault.set(pfs);
|
mDefault.set(pfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ namespace renderscript {
|
|||||||
void rsi_ProgramFragmentStoreBegin(Context * rsc, RsElement in, RsElement out)
|
void rsi_ProgramFragmentStoreBegin(Context * rsc, RsElement in, RsElement out)
|
||||||
{
|
{
|
||||||
delete rsc->mStateFragmentStore.mPFS;
|
delete rsc->mStateFragmentStore.mPFS;
|
||||||
rsc->mStateFragmentStore.mPFS = new ProgramFragmentStore((Element *)in, (Element *)out);
|
rsc->mStateFragmentStore.mPFS = new ProgramFragmentStore(rsc, (Element *)in, (Element *)out);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ProgramFragmentStoreState;
|
|||||||
class ProgramFragmentStore : public Program
|
class ProgramFragmentStore : public Program
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProgramFragmentStore(Element *in, Element *out);
|
ProgramFragmentStore(Context *, Element *in, Element *out);
|
||||||
virtual ~ProgramFragmentStore();
|
virtual ~ProgramFragmentStore();
|
||||||
|
|
||||||
virtual void setupGL(const Context *, ProgramFragmentStoreState *);
|
virtual void setupGL(const Context *, ProgramFragmentStoreState *);
|
||||||
|
|||||||
@@ -24,12 +24,13 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
ProgramRaster::ProgramRaster(Element *in,
|
ProgramRaster::ProgramRaster(Context *rsc,
|
||||||
|
Element *in,
|
||||||
Element *out,
|
Element *out,
|
||||||
bool pointSmooth,
|
bool pointSmooth,
|
||||||
bool lineSmooth,
|
bool lineSmooth,
|
||||||
bool pointSprite) :
|
bool pointSprite) :
|
||||||
Program(in, out)
|
Program(rsc, in, out)
|
||||||
{
|
{
|
||||||
mPointSmooth = pointSmooth;
|
mPointSmooth = pointSmooth;
|
||||||
mLineSmooth = lineSmooth;
|
mLineSmooth = lineSmooth;
|
||||||
@@ -95,7 +96,7 @@ ProgramRasterState::~ProgramRasterState()
|
|||||||
|
|
||||||
void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h)
|
void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h)
|
||||||
{
|
{
|
||||||
ProgramRaster *pr = new ProgramRaster(NULL, NULL, false, false, false);
|
ProgramRaster *pr = new ProgramRaster(rsc, NULL, NULL, false, false, false);
|
||||||
mDefault.set(pr);
|
mDefault.set(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +109,8 @@ RsProgramRaster rsi_ProgramRasterCreate(Context * rsc, RsElement in, RsElement o
|
|||||||
bool lineSmooth,
|
bool lineSmooth,
|
||||||
bool pointSprite)
|
bool pointSprite)
|
||||||
{
|
{
|
||||||
ProgramRaster *pr = new ProgramRaster(static_cast<Element *>(in),
|
ProgramRaster *pr = new ProgramRaster(rsc,
|
||||||
|
static_cast<Element *>(in),
|
||||||
static_cast<Element *>(out),
|
static_cast<Element *>(out),
|
||||||
pointSmooth,
|
pointSmooth,
|
||||||
lineSmooth,
|
lineSmooth,
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ class ProgramRasterState;
|
|||||||
class ProgramRaster : public Program
|
class ProgramRaster : public Program
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProgramRaster(Element *in,
|
ProgramRaster(Context *rsc,
|
||||||
|
Element *in,
|
||||||
Element *out,
|
Element *out,
|
||||||
bool pointSmooth,
|
bool pointSmooth,
|
||||||
bool lineSmooth,
|
bool lineSmooth,
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
ProgramVertex::ProgramVertex(Element *in, Element *out) :
|
ProgramVertex::ProgramVertex(Context *rsc, Element *in, Element *out) :
|
||||||
Program(in, out)
|
Program(rsc, in, out)
|
||||||
{
|
{
|
||||||
mTextureMatrixEnable = false;
|
mTextureMatrixEnable = false;
|
||||||
mLightCount = 0;
|
mLightCount = 0;
|
||||||
@@ -141,7 +141,7 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h)
|
|||||||
rsi_TypeAdd(rsc, RS_DIMENSION_X, 48);
|
rsi_TypeAdd(rsc, RS_DIMENSION_X, 48);
|
||||||
mAllocType = rsi_TypeCreate(rsc);
|
mAllocType = rsi_TypeCreate(rsc);
|
||||||
|
|
||||||
ProgramVertex *pv = new ProgramVertex(NULL, NULL);
|
ProgramVertex *pv = new ProgramVertex(rsc, NULL, NULL);
|
||||||
Allocation *alloc = (Allocation *)rsi_AllocationCreateTyped(rsc, mAllocType);
|
Allocation *alloc = (Allocation *)rsi_AllocationCreateTyped(rsc, mAllocType);
|
||||||
mDefaultAlloc.set(alloc);
|
mDefaultAlloc.set(alloc);
|
||||||
mDefault.set(pv);
|
mDefault.set(pv);
|
||||||
@@ -163,7 +163,7 @@ namespace renderscript {
|
|||||||
void rsi_ProgramVertexBegin(Context *rsc, RsElement in, RsElement out)
|
void rsi_ProgramVertexBegin(Context *rsc, RsElement in, RsElement out)
|
||||||
{
|
{
|
||||||
delete rsc->mStateVertex.mPV;
|
delete rsc->mStateVertex.mPV;
|
||||||
rsc->mStateVertex.mPV = new ProgramVertex((Element *)in, (Element *)out);
|
rsc->mStateVertex.mPV = new ProgramVertex(rsc, (Element *)in, (Element *)out);
|
||||||
}
|
}
|
||||||
|
|
||||||
RsProgramVertex rsi_ProgramVertexCreate(Context *rsc)
|
RsProgramVertex rsi_ProgramVertexCreate(Context *rsc)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ProgramVertex : public Program
|
|||||||
public:
|
public:
|
||||||
const static uint32_t MAX_LIGHTS = 8;
|
const static uint32_t MAX_LIGHTS = 8;
|
||||||
|
|
||||||
ProgramVertex(Element *in, Element *out);
|
ProgramVertex(Context *, Element *in, Element *out);
|
||||||
virtual ~ProgramVertex();
|
virtual ~ProgramVertex();
|
||||||
|
|
||||||
virtual void setupGL(const Context *rsc, ProgramVertexState *state);
|
virtual void setupGL(const Context *rsc, ProgramVertexState *state);
|
||||||
|
|||||||
@@ -25,17 +25,18 @@ using namespace android;
|
|||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
|
|
||||||
Sampler::Sampler()
|
Sampler::Sampler(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
// Should not get called.
|
// Should not get called.
|
||||||
rsAssert(0);
|
rsAssert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sampler::Sampler(RsSamplerValue magFilter,
|
Sampler::Sampler(Context *rsc,
|
||||||
|
RsSamplerValue magFilter,
|
||||||
RsSamplerValue minFilter,
|
RsSamplerValue minFilter,
|
||||||
RsSamplerValue wrapS,
|
RsSamplerValue wrapS,
|
||||||
RsSamplerValue wrapT,
|
RsSamplerValue wrapT,
|
||||||
RsSamplerValue wrapR)
|
RsSamplerValue wrapR) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mMagFilter = magFilter;
|
mMagFilter = magFilter;
|
||||||
mMinFilter = minFilter;
|
mMinFilter = minFilter;
|
||||||
@@ -138,7 +139,8 @@ RsSampler rsi_SamplerCreate(Context *rsc)
|
|||||||
SamplerState * ss = &rsc->mStateSampler;
|
SamplerState * ss = &rsc->mStateSampler;
|
||||||
|
|
||||||
|
|
||||||
Sampler * s = new Sampler(ss->mMagFilter,
|
Sampler * s = new Sampler(rsc,
|
||||||
|
ss->mMagFilter,
|
||||||
ss->mMinFilter,
|
ss->mMinFilter,
|
||||||
ss->mWrapS,
|
ss->mWrapS,
|
||||||
ss->mWrapT,
|
ss->mWrapT,
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class SamplerState;
|
|||||||
class Sampler : public ObjectBase
|
class Sampler : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Sampler(RsSamplerValue magFilter,
|
Sampler(Context *,
|
||||||
|
RsSamplerValue magFilter,
|
||||||
RsSamplerValue minFilter,
|
RsSamplerValue minFilter,
|
||||||
RsSamplerValue wrapS,
|
RsSamplerValue wrapS,
|
||||||
RsSamplerValue wrapT,
|
RsSamplerValue wrapT,
|
||||||
@@ -55,12 +56,12 @@ protected:
|
|||||||
int32_t mBoundSlot;
|
int32_t mBoundSlot;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Sampler();
|
Sampler(Context *);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SamplerState
|
class SamplerState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
Script::Script()
|
Script::Script(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
memset(&mEnviroment, 0, sizeof(mEnviroment));
|
memset(&mEnviroment, 0, sizeof(mEnviroment));
|
||||||
mEnviroment.mClearColor[0] = 0;
|
mEnviroment.mClearColor[0] = 0;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Script : public ObjectBase
|
|||||||
public:
|
public:
|
||||||
typedef void (* InvokeFunc_t)(void);
|
typedef void (* InvokeFunc_t)(void);
|
||||||
|
|
||||||
Script();
|
Script(Context *);
|
||||||
virtual ~Script();
|
virtual ~Script();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ using namespace android::renderscript;
|
|||||||
ScriptC * sc = (ScriptC *) tls->mScript
|
ScriptC * sc = (ScriptC *) tls->mScript
|
||||||
|
|
||||||
|
|
||||||
ScriptC::ScriptC()
|
ScriptC::ScriptC(Context *rsc) : Script(rsc)
|
||||||
{
|
{
|
||||||
mAccScript = NULL;
|
mAccScript = NULL;
|
||||||
memset(&mProgram, 0, sizeof(mProgram));
|
memset(&mProgram, 0, sizeof(mProgram));
|
||||||
@@ -106,7 +106,7 @@ void ScriptCState::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete mScript;
|
delete mScript;
|
||||||
mScript = new ScriptC();
|
mScript = new ScriptC(NULL);
|
||||||
|
|
||||||
mInt32Defines.clear();
|
mInt32Defines.clear();
|
||||||
mFloatDefines.clear();
|
mFloatDefines.clear();
|
||||||
@@ -391,6 +391,7 @@ RsScript rsi_ScriptCCreate(Context * rsc)
|
|||||||
|
|
||||||
ss->runCompiler(rsc, s);
|
ss->runCompiler(rsc, s);
|
||||||
s->incUserRef();
|
s->incUserRef();
|
||||||
|
s->setContext(rsc);
|
||||||
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
|
||||||
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
|
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
|
||||||
s->mSlotNames[ct] = ss->mSlotNames[ct];
|
s->mSlotNames[ct] = ss->mSlotNames[ct];
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
typedef int (*RunScript_t)(uint32_t launchIndex);
|
typedef int (*RunScript_t)(uint32_t launchIndex);
|
||||||
typedef void (*VoidFunc_t)();
|
typedef void (*VoidFunc_t)();
|
||||||
|
|
||||||
ScriptC();
|
ScriptC(Context *);
|
||||||
virtual ~ScriptC();
|
virtual ~ScriptC();
|
||||||
|
|
||||||
struct Program_t {
|
struct Program_t {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ using namespace android::renderscript;
|
|||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
|
|
||||||
SimpleMesh::SimpleMesh()
|
SimpleMesh::SimpleMesh(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ namespace renderscript {
|
|||||||
|
|
||||||
RsSimpleMesh rsi_SimpleMeshCreate(Context *rsc, RsType prim, RsType idx, RsType *vtx, uint32_t vtxCount, uint32_t primType)
|
RsSimpleMesh rsi_SimpleMeshCreate(Context *rsc, RsType prim, RsType idx, RsType *vtx, uint32_t vtxCount, uint32_t primType)
|
||||||
{
|
{
|
||||||
SimpleMesh *sm = new SimpleMesh();
|
SimpleMesh *sm = new SimpleMesh(rsc);
|
||||||
sm->incUserRef();
|
sm->incUserRef();
|
||||||
|
|
||||||
sm->mIndexType.set((const Type *)idx);
|
sm->mIndexType.set((const Type *)idx);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace renderscript {
|
|||||||
class SimpleMesh : public ObjectBase
|
class SimpleMesh : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SimpleMesh();
|
SimpleMesh(Context *);
|
||||||
~SimpleMesh();
|
~SimpleMesh();
|
||||||
|
|
||||||
ObjectBaseRef<const Type> mIndexType;
|
ObjectBaseRef<const Type> mIndexType;
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ bool ThreadIO::playCoreCommands(Context *con, bool waitForCommand)
|
|||||||
con->timerSet(Context::RS_TIMER_IDLE);
|
con->timerSet(Context::RS_TIMER_IDLE);
|
||||||
}
|
}
|
||||||
const void * data = mToCore.get(&cmdID, &cmdSize);
|
const void * data = mToCore.get(&cmdID, &cmdSize);
|
||||||
|
if (!cmdSize) {
|
||||||
|
// exception occured, probably shutdown.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (con->logTimes) {
|
if (con->logTimes) {
|
||||||
con->timerSet(Context::RS_TIMER_INTERNAL);
|
con->timerSet(Context::RS_TIMER_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
using namespace android;
|
using namespace android;
|
||||||
using namespace android::renderscript;
|
using namespace android::renderscript;
|
||||||
|
|
||||||
Type::Type()
|
Type::Type(Context *rsc) : ObjectBase(rsc)
|
||||||
{
|
{
|
||||||
mLODs = 0;
|
mLODs = 0;
|
||||||
mLODCount = 0;
|
mLODCount = 0;
|
||||||
@@ -363,7 +363,7 @@ RsType rsi_TypeCreate(Context *rsc)
|
|||||||
{
|
{
|
||||||
TypeState * stc = &rsc->mStateType;
|
TypeState * stc = &rsc->mStateType;
|
||||||
|
|
||||||
Type * st = new Type();
|
Type * st = new Type(rsc);
|
||||||
st->incUserRef();
|
st->incUserRef();
|
||||||
st->setDimX(stc->mX);
|
st->setDimX(stc->mX);
|
||||||
st->setDimY(stc->mY);
|
st->setDimY(stc->mY);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace renderscript {
|
|||||||
class Type : public ObjectBase
|
class Type : public ObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Type();
|
Type(Context *);
|
||||||
virtual ~Type();
|
virtual ~Type();
|
||||||
|
|
||||||
Type * createTex2D(const Element *, size_t w, size_t h, bool mip);
|
Type * createTex2D(const Element *, size_t w, size_t h, bool mip);
|
||||||
|
|||||||
Reference in New Issue
Block a user