Merge change 23064 into eclair
* changes: Implement async data/subData. Implement TriangleMeshBuilder in SimpleMesh which replaces TriangleMesh. Update Film to use new builder.
This commit is contained in:
@@ -47,28 +47,62 @@ public class Allocation extends BaseObj {
|
|||||||
mRS.nAllocationUploadToTexture(mID, baseMipLevel);
|
mRS.nAllocationUploadToTexture(mID, baseMipLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void uploadToBufferObject() {
|
||||||
|
mRS.nAllocationUploadToBufferObject(mID);
|
||||||
|
}
|
||||||
|
|
||||||
public void data(int[] d) {
|
public void data(int[] d) {
|
||||||
mRS.nAllocationData(mID, d);
|
int size = 0;
|
||||||
|
if(mType != null && mType.mElement != null) {
|
||||||
|
size = mType.mElement.mSize;
|
||||||
|
for(int ct=0; ct < mType.mValues.length; ct++) {
|
||||||
|
if(mType.mValues[ct] != 0) {
|
||||||
|
size *= mType.mValues[ct];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((d.length * 4) < size) {
|
||||||
|
throw new IllegalArgumentException("Array too small for allocation type.");
|
||||||
|
}
|
||||||
|
Log.e("rs", "Alloc data size=" + size);
|
||||||
|
mRS.nAllocationData(mID, d, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mRS.nAllocationData(mID, d, d.length * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void data(float[] d) {
|
public void data(float[] d) {
|
||||||
mRS.nAllocationData(mID, d);
|
int size = 0;
|
||||||
|
if(mType != null && mType.mElement != null) {
|
||||||
|
size = mType.mElement.mSize;
|
||||||
|
for(int ct=0; ct < mType.mValues.length; ct++) {
|
||||||
|
if(mType.mValues[ct] != 0) {
|
||||||
|
size *= mType.mValues[ct];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((d.length * 4) < size) {
|
||||||
|
throw new IllegalArgumentException("Array too small for allocation type.");
|
||||||
|
}
|
||||||
|
Log.e("rs", "Alloc data size=" + size);
|
||||||
|
mRS.nAllocationData(mID, d, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mRS.nAllocationData(mID, d, d.length * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subData1D(int off, int count, int[] d) {
|
public void subData1D(int off, int count, int[] d) {
|
||||||
mRS.nAllocationSubData1D(mID, off, count, d);
|
mRS.nAllocationSubData1D(mID, off, count, d, count * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subData1D(int off, int count, float[] d) {
|
public void subData1D(int off, int count, float[] d) {
|
||||||
mRS.nAllocationSubData1D(mID, off, count, d);
|
mRS.nAllocationSubData1D(mID, off, count, d, d.length * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
|
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
|
||||||
mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d);
|
mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
|
public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
|
||||||
mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d);
|
mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readData(int[] d) {
|
public void readData(int[] d) {
|
||||||
@@ -221,20 +255,6 @@ public class Allocation extends BaseObj {
|
|||||||
Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions);
|
Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions);
|
||||||
return createFromBitmapBoxed(rs, b, dstFmt, genMips);
|
return createFromBitmapBoxed(rs, b, dstFmt, genMips);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public static Allocation createFromObject(RenderScript rs, Object o) {
|
|
||||||
Class c = o.getClass();
|
|
||||||
Type t;
|
|
||||||
if(c.isArray()) {
|
|
||||||
t = Type.createFromClass(rs, c, Array.getLength(o));
|
|
||||||
} else {
|
|
||||||
t = Type.createFromClass(rs, c, 1);
|
|
||||||
}
|
|
||||||
Allocation alloc = createTyped(rs, t);
|
|
||||||
t.destroy();
|
|
||||||
return alloc;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,30 +25,31 @@ import java.lang.reflect.Field;
|
|||||||
public class Element extends BaseObj {
|
public class Element extends BaseObj {
|
||||||
final int mPredefinedID;
|
final int mPredefinedID;
|
||||||
final boolean mIsPredefined;
|
final boolean mIsPredefined;
|
||||||
|
final int mSize;
|
||||||
|
|
||||||
public static final Element USER_U8 = new Element(0);
|
public static final Element USER_U8 = new Element(0, 1);
|
||||||
public static final Element USER_I8 = new Element(1);
|
public static final Element USER_I8 = new Element(1, 1);
|
||||||
public static final Element USER_U16 = new Element(2);
|
public static final Element USER_U16 = new Element(2, 2);
|
||||||
public static final Element USER_I16 = new Element(3);
|
public static final Element USER_I16 = new Element(3, 2);
|
||||||
public static final Element USER_U32 = new Element(4);
|
public static final Element USER_U32 = new Element(4, 4);
|
||||||
public static final Element USER_I32 = new Element(5);
|
public static final Element USER_I32 = new Element(5, 4);
|
||||||
public static final Element USER_FLOAT = new Element(6);
|
public static final Element USER_FLOAT = new Element(6, 4);
|
||||||
|
|
||||||
public static final Element A_8 = new Element(7);
|
public static final Element A_8 = new Element(7, 1);
|
||||||
public static final Element RGB_565 = new Element(8);
|
public static final Element RGB_565 = new Element(8, 2);
|
||||||
public static final Element RGB_888 = new Element(11);
|
public static final Element RGB_888 = new Element(11, 2);
|
||||||
public static final Element RGBA_5551 = new Element(9);
|
public static final Element RGBA_5551 = new Element(9, 2);
|
||||||
public static final Element RGBA_4444 = new Element(10);
|
public static final Element RGBA_4444 = new Element(10, 2);
|
||||||
public static final Element RGBA_8888 = new Element(12);
|
public static final Element RGBA_8888 = new Element(12, 4);
|
||||||
|
|
||||||
public static final Element INDEX_16 = new Element(13);
|
public static final Element INDEX_16 = new Element(13, 2);
|
||||||
public static final Element INDEX_32 = new Element(14);
|
public static final Element INDEX_32 = new Element(14, 2);
|
||||||
public static final Element XY_F32 = new Element(15);
|
public static final Element XY_F32 = new Element(15, 8);
|
||||||
public static final Element XYZ_F32 = new Element(16);
|
public static final Element XYZ_F32 = new Element(16, 12);
|
||||||
public static final Element ST_XY_F32 = new Element(17);
|
public static final Element ST_XY_F32 = new Element(17, 16);
|
||||||
public static final Element ST_XYZ_F32 = new Element(18);
|
public static final Element ST_XYZ_F32 = new Element(18, 20);
|
||||||
public static final Element NORM_XYZ_F32 = new Element(19);
|
public static final Element NORM_XYZ_F32 = new Element(19, 24);
|
||||||
public static final Element NORM_ST_XYZ_F32 = new Element(20);
|
public static final Element NORM_ST_XYZ_F32 = new Element(20, 32);
|
||||||
|
|
||||||
void initPredef(RenderScript rs) {
|
void initPredef(RenderScript rs) {
|
||||||
mID = rs.nElementGetPredefined(mPredefinedID);
|
mID = rs.nElementGetPredefined(mPredefinedID);
|
||||||
@@ -121,18 +122,20 @@ public class Element extends BaseObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Element(int predef) {
|
Element(int predef, int size) {
|
||||||
super(null);
|
super(null);
|
||||||
mID = 0;
|
mID = 0;
|
||||||
mPredefinedID = predef;
|
mPredefinedID = predef;
|
||||||
mIsPredefined = true;
|
mIsPredefined = true;
|
||||||
|
mSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element(int id, RenderScript rs) {
|
Element(int id, RenderScript rs, int size) {
|
||||||
super(rs);
|
super(rs);
|
||||||
mID = id;
|
mID = id;
|
||||||
mPredefinedID = 0;
|
mPredefinedID = 0;
|
||||||
mIsPredefined = false;
|
mIsPredefined = false;
|
||||||
|
mSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() throws IllegalStateException {
|
public void destroy() throws IllegalStateException {
|
||||||
@@ -168,6 +171,7 @@ public class Element extends BaseObj {
|
|||||||
RenderScript mRS;
|
RenderScript mRS;
|
||||||
Entry[] mEntries;
|
Entry[] mEntries;
|
||||||
int mEntryCount;
|
int mEntryCount;
|
||||||
|
int mSizeBits;
|
||||||
|
|
||||||
private class Entry {
|
private class Entry {
|
||||||
Element mElement;
|
Element mElement;
|
||||||
@@ -182,6 +186,7 @@ public class Element extends BaseObj {
|
|||||||
mRS = rs;
|
mRS = rs;
|
||||||
mEntryCount = 0;
|
mEntryCount = 0;
|
||||||
mEntries = new Entry[8];
|
mEntries = new Entry[8];
|
||||||
|
mSizeBits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addEntry(Entry e) {
|
void addEntry(Entry e) {
|
||||||
@@ -201,6 +206,7 @@ public class Element extends BaseObj {
|
|||||||
Entry en = new Entry();
|
Entry en = new Entry();
|
||||||
en.mElement = e;
|
en.mElement = e;
|
||||||
addEntry(en);
|
addEntry(en);
|
||||||
|
mSizeBits += e.mSize * 8;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +217,7 @@ public class Element extends BaseObj {
|
|||||||
en.mIsNormalized = isNormalized;
|
en.mIsNormalized = isNormalized;
|
||||||
en.mBits = bits;
|
en.mBits = bits;
|
||||||
en.mName = name;
|
en.mName = name;
|
||||||
|
mSizeBits += bits;
|
||||||
addEntry(en);
|
addEntry(en);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -236,6 +243,12 @@ public class Element extends BaseObj {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addFloatXY(String prefix) {
|
||||||
|
add(DataType.FLOAT, DataKind.X, false, 32, prefix + "X");
|
||||||
|
add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "Y");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addFloatXYZ() {
|
public Builder addFloatXYZ() {
|
||||||
add(DataType.FLOAT, DataKind.X, false, 32, null);
|
add(DataType.FLOAT, DataKind.X, false, 32, null);
|
||||||
add(DataType.FLOAT, DataKind.Y, false, 32, null);
|
add(DataType.FLOAT, DataKind.Y, false, 32, null);
|
||||||
@@ -243,17 +256,49 @@ public class Element extends BaseObj {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addFloatXYZ(String prefix) {
|
||||||
|
add(DataType.FLOAT, DataKind.X, false, 32, prefix + "X");
|
||||||
|
add(DataType.FLOAT, DataKind.Y, false, 32, prefix + "Y");
|
||||||
|
add(DataType.FLOAT, DataKind.Z, false, 32, prefix + "Z");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addFloatST() {
|
public Builder addFloatST() {
|
||||||
add(DataType.FLOAT, DataKind.S, false, 32, null);
|
add(DataType.FLOAT, DataKind.S, false, 32, null);
|
||||||
add(DataType.FLOAT, DataKind.T, false, 32, null);
|
add(DataType.FLOAT, DataKind.T, false, 32, null);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addFloatST(String prefix) {
|
||||||
|
add(DataType.FLOAT, DataKind.S, false, 32, prefix + "S");
|
||||||
|
add(DataType.FLOAT, DataKind.T, false, 32, prefix + "T");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addFloatNorm() {
|
||||||
|
add(DataType.FLOAT, DataKind.NX, false, 32, null);
|
||||||
|
add(DataType.FLOAT, DataKind.NY, false, 32, null);
|
||||||
|
add(DataType.FLOAT, DataKind.NZ, false, 32, null);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addFloatNorm(String prefix) {
|
||||||
|
add(DataType.FLOAT, DataKind.NX, false, 32, prefix + "NX");
|
||||||
|
add(DataType.FLOAT, DataKind.NY, false, 32, prefix + "NY");
|
||||||
|
add(DataType.FLOAT, DataKind.NZ, false, 32, prefix + "NZ");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addFloatPointSize() {
|
public Builder addFloatPointSize() {
|
||||||
add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, null);
|
add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, null);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addFloatPointSize(String name) {
|
||||||
|
add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, name);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addFloatRGB() {
|
public Builder addFloatRGB() {
|
||||||
add(DataType.FLOAT, DataKind.RED, false, 32, null);
|
add(DataType.FLOAT, DataKind.RED, false, 32, null);
|
||||||
add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
|
add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
|
||||||
@@ -261,6 +306,13 @@ public class Element extends BaseObj {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addFloatRGB(String prefix) {
|
||||||
|
add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "R");
|
||||||
|
add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "G");
|
||||||
|
add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "B");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addFloatRGBA() {
|
public Builder addFloatRGBA() {
|
||||||
add(DataType.FLOAT, DataKind.RED, false, 32, null);
|
add(DataType.FLOAT, DataKind.RED, false, 32, null);
|
||||||
add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
|
add(DataType.FLOAT, DataKind.GREEN, false, 32, null);
|
||||||
@@ -269,6 +321,14 @@ public class Element extends BaseObj {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addFloatRGBA(String prefix) {
|
||||||
|
add(DataType.FLOAT, DataKind.RED, false, 32, prefix + "R");
|
||||||
|
add(DataType.FLOAT, DataKind.GREEN, false, 32, prefix + "G");
|
||||||
|
add(DataType.FLOAT, DataKind.BLUE, false, 32, prefix + "B");
|
||||||
|
add(DataType.FLOAT, DataKind.ALPHA, false, 32, prefix + "A");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder addUNorm8RGBA() {
|
public Builder addUNorm8RGBA() {
|
||||||
add(DataType.UNSIGNED, DataKind.RED, true, 8, null);
|
add(DataType.UNSIGNED, DataKind.RED, true, 8, null);
|
||||||
add(DataType.UNSIGNED, DataKind.GREEN, true, 8, null);
|
add(DataType.UNSIGNED, DataKind.GREEN, true, 8, null);
|
||||||
@@ -277,6 +337,14 @@ public class Element extends BaseObj {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder addUNorm8RGBA(String prefix) {
|
||||||
|
add(DataType.UNSIGNED, DataKind.RED, true, 8, prefix + "R");
|
||||||
|
add(DataType.UNSIGNED, DataKind.GREEN, true, 8, prefix + "G");
|
||||||
|
add(DataType.UNSIGNED, DataKind.BLUE, true, 8, prefix + "B");
|
||||||
|
add(DataType.UNSIGNED, DataKind.ALPHA, true, 8, prefix + "A");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
static synchronized Element internalCreate(RenderScript rs, Builder b) {
|
static synchronized Element internalCreate(RenderScript rs, Builder b) {
|
||||||
rs.nElementBegin();
|
rs.nElementBegin();
|
||||||
for (int ct=0; ct < b.mEntryCount; ct++) {
|
for (int ct=0; ct < b.mEntryCount; ct++) {
|
||||||
@@ -292,7 +360,7 @@ public class Element extends BaseObj {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int id = rs.nElementCreate();
|
int id = rs.nElementCreate();
|
||||||
return new Element(id, rs);
|
return new Element(id, rs, (b.mSizeBits + 7) >> 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element create() {
|
public Element create() {
|
||||||
|
|||||||
@@ -97,12 +97,13 @@ public class RenderScript {
|
|||||||
native int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp);
|
native int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp);
|
||||||
|
|
||||||
native void nAllocationUploadToTexture(int alloc, int baseMioLevel);
|
native void nAllocationUploadToTexture(int alloc, int baseMioLevel);
|
||||||
native void nAllocationData(int id, int[] d);
|
native void nAllocationUploadToBufferObject(int alloc);
|
||||||
native void nAllocationData(int id, float[] d);
|
native void nAllocationData(int id, int[] d, int sizeBytes);
|
||||||
native void nAllocationSubData1D(int id, int off, int count, int[] d);
|
native void nAllocationData(int id, float[] d, int sizeBytes);
|
||||||
native void nAllocationSubData1D(int id, int off, int count, float[] d);
|
native void nAllocationSubData1D(int id, int off, int count, int[] d, int sizeBytes);
|
||||||
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d);
|
native void nAllocationSubData1D(int id, int off, int count, float[] d, int sizeBytes);
|
||||||
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d);
|
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes);
|
||||||
|
native void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes);
|
||||||
native void nAllocationRead(int id, int[] d);
|
native void nAllocationRead(int id, int[] d);
|
||||||
native void nAllocationRead(int id, float[] d);
|
native void nAllocationRead(int id, float[] d);
|
||||||
native void nAllocationDataFromObject(int id, Type t, Object o);
|
native void nAllocationDataFromObject(int id, Type t, Object o);
|
||||||
|
|||||||
@@ -167,5 +167,150 @@ public class SimpleMesh extends BaseObj {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class TriangleMeshBuilder {
|
||||||
|
float mVtxData[];
|
||||||
|
int mVtxCount;
|
||||||
|
int mIndexData[];
|
||||||
|
int mIndexCount;
|
||||||
|
RenderScript mRS;
|
||||||
|
Element mElement;
|
||||||
|
|
||||||
|
int mVtxSize;
|
||||||
|
boolean mNorm;
|
||||||
|
boolean mTex;
|
||||||
|
|
||||||
|
public TriangleMeshBuilder(RenderScript rs, int vtxSize, boolean norm, boolean tex) {
|
||||||
|
mRS = rs;
|
||||||
|
mVtxCount = 0;
|
||||||
|
mIndexCount = 0;
|
||||||
|
mVtxData = new float[128];
|
||||||
|
mIndexData = new int[128];
|
||||||
|
mVtxSize = vtxSize;
|
||||||
|
mNorm = norm;
|
||||||
|
mTex = tex;
|
||||||
|
|
||||||
|
if(vtxSize < 2 || vtxSize > 3) {
|
||||||
|
throw new IllegalArgumentException("Vertex size out of range.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeSpace(int count) {
|
||||||
|
if((mVtxCount + count) >= mVtxData.length) {
|
||||||
|
float t[] = new float[mVtxData.length * 2];
|
||||||
|
System.arraycopy(mVtxData, 0, t, 0, mVtxData.length);
|
||||||
|
mVtxData = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add_XY(float x, float y) {
|
||||||
|
if((mVtxSize != 2) || mNorm || mTex) {
|
||||||
|
throw new IllegalStateException("add mistmatch with declaired components.");
|
||||||
|
}
|
||||||
|
makeSpace(2);
|
||||||
|
mVtxData[mVtxCount++] = x;
|
||||||
|
mVtxData[mVtxCount++] = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add_XYZ(float x, float y, float z) {
|
||||||
|
if((mVtxSize != 3) || mNorm || mTex) {
|
||||||
|
throw new IllegalStateException("add mistmatch with declaired components.");
|
||||||
|
}
|
||||||
|
makeSpace(3);
|
||||||
|
mVtxData[mVtxCount++] = x;
|
||||||
|
mVtxData[mVtxCount++] = y;
|
||||||
|
mVtxData[mVtxCount++] = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add_XY_ST(float x, float y, float s, float t) {
|
||||||
|
if((mVtxSize != 2) || mNorm || !mTex) {
|
||||||
|
throw new IllegalStateException("add mistmatch with declaired components.");
|
||||||
|
}
|
||||||
|
makeSpace(4);
|
||||||
|
mVtxData[mVtxCount++] = x;
|
||||||
|
mVtxData[mVtxCount++] = y;
|
||||||
|
mVtxData[mVtxCount++] = s;
|
||||||
|
mVtxData[mVtxCount++] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add_XYZ_ST(float x, float y, float z, float s, float t) {
|
||||||
|
if((mVtxSize != 3) || mNorm || !mTex) {
|
||||||
|
throw new IllegalStateException("add mistmatch with declaired components.");
|
||||||
|
}
|
||||||
|
makeSpace(5);
|
||||||
|
mVtxData[mVtxCount++] = x;
|
||||||
|
mVtxData[mVtxCount++] = y;
|
||||||
|
mVtxData[mVtxCount++] = z;
|
||||||
|
mVtxData[mVtxCount++] = s;
|
||||||
|
mVtxData[mVtxCount++] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add_XYZ_ST_NORM(float x, float y, float z, float s, float t, float nx, float ny, float nz) {
|
||||||
|
if((mVtxSize != 3) || !mNorm || !mTex) {
|
||||||
|
throw new IllegalStateException("add mistmatch with declaired components.");
|
||||||
|
}
|
||||||
|
makeSpace(8);
|
||||||
|
mVtxData[mVtxCount++] = x;
|
||||||
|
mVtxData[mVtxCount++] = y;
|
||||||
|
mVtxData[mVtxCount++] = z;
|
||||||
|
mVtxData[mVtxCount++] = s;
|
||||||
|
mVtxData[mVtxCount++] = t;
|
||||||
|
mVtxData[mVtxCount++] = nx;
|
||||||
|
mVtxData[mVtxCount++] = ny;
|
||||||
|
mVtxData[mVtxCount++] = nz;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTriangle(int idx1, int idx2, int idx3) {
|
||||||
|
if((mIndexCount + 3) >= mIndexData.length) {
|
||||||
|
int t[] = new int[mIndexData.length * 2];
|
||||||
|
System.arraycopy(mIndexData, 0, t, 0, mIndexData.length);
|
||||||
|
mIndexData = t;
|
||||||
|
}
|
||||||
|
mIndexData[mIndexCount++] = idx1;
|
||||||
|
mIndexData[mIndexCount++] = idx2;
|
||||||
|
mIndexData[mIndexCount++] = idx3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleMesh create() {
|
||||||
|
Element.Builder b = new Element.Builder(mRS);
|
||||||
|
int floatCount = mVtxSize;
|
||||||
|
if(mVtxSize == 2) {
|
||||||
|
b.addFloatXY();
|
||||||
|
} else {
|
||||||
|
b.addFloatXYZ();
|
||||||
|
}
|
||||||
|
if(mTex) {
|
||||||
|
floatCount += 2;
|
||||||
|
b.addFloatST();
|
||||||
|
}
|
||||||
|
if(mNorm) {
|
||||||
|
floatCount += 3;
|
||||||
|
b.addFloatNorm();
|
||||||
|
}
|
||||||
|
mElement = b.create();
|
||||||
|
|
||||||
|
Builder smb = new Builder(mRS);
|
||||||
|
smb.addVertexType(mElement, mVtxCount / floatCount);
|
||||||
|
smb.setIndexType(Element.INDEX_16, mIndexCount);
|
||||||
|
smb.setPrimitive(Primitive.TRIANGLE);
|
||||||
|
SimpleMesh sm = smb.create();
|
||||||
|
|
||||||
|
Allocation vertexAlloc = sm.createVertexAllocation(0);
|
||||||
|
Allocation indexAlloc = sm.createIndexAllocation();
|
||||||
|
sm.bindVertexAllocation(vertexAlloc, 0);
|
||||||
|
sm.bindIndexAllocation(indexAlloc);
|
||||||
|
|
||||||
|
vertexAlloc.data(mVtxData);
|
||||||
|
vertexAlloc.uploadToBufferObject();
|
||||||
|
|
||||||
|
// This is safe because length is a pow2
|
||||||
|
for(int ct=0; ct < (mIndexCount+1); ct += 2) {
|
||||||
|
mIndexData[ct >> 1] = mIndexData[ct] | (mIndexData[ct+1] << 16);
|
||||||
|
}
|
||||||
|
indexAlloc.data(mIndexData);
|
||||||
|
indexAlloc.uploadToBufferObject();
|
||||||
|
|
||||||
|
return sm;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ static void
|
|||||||
nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str)
|
nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
LOG_API("nAssignName, con(%p), obj(%p)", con, obj);
|
LOG_API("nAssignName, con(%p), obj(%p)", con, (void *)obj);
|
||||||
|
|
||||||
jint len = _env->GetArrayLength(str);
|
jint len = _env->GetArrayLength(str);
|
||||||
jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0);
|
jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0);
|
||||||
@@ -345,6 +345,14 @@ nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip)
|
|||||||
rsAllocationUploadToTexture(con, (RsAllocation)a, mip);
|
rsAllocationUploadToTexture(con, (RsAllocation)a, mip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nAllocationUploadToBufferObject(JNIEnv *_env, jobject _this, jint a)
|
||||||
|
{
|
||||||
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
|
LOG_API("nAllocationUploadToBufferObject, con(%p), a(%p)", con, (RsAllocation)a);
|
||||||
|
rsAllocationUploadToBufferObject(con, (RsAllocation)a);
|
||||||
|
}
|
||||||
|
|
||||||
static RsElementPredefined SkBitmapToPredefined(SkBitmap::Config cfg)
|
static RsElementPredefined SkBitmapToPredefined(SkBitmap::Config cfg)
|
||||||
{
|
{
|
||||||
switch (cfg) {
|
switch (cfg) {
|
||||||
@@ -413,68 +421,68 @@ nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jbool
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationData_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data)
|
nAllocationData_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
|
LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
|
||||||
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
||||||
rsAllocationData(con, (RsAllocation)alloc, ptr);
|
rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes);
|
||||||
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationData_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data)
|
nAllocationData_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
|
LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len);
|
||||||
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
||||||
rsAllocationData(con, (RsAllocation)alloc, ptr);
|
rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes);
|
||||||
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data)
|
nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len);
|
LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len);
|
||||||
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
||||||
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr);
|
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
||||||
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data)
|
nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len);
|
LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len);
|
||||||
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
||||||
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr);
|
rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes);
|
||||||
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationSubData2D_i(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data)
|
nAllocationSubData2D_i(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
|
LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
|
||||||
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
jint *ptr = _env->GetIntArrayElements(data, NULL);
|
||||||
rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr);
|
rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes);
|
||||||
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseIntArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data)
|
nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data, int sizeBytes)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
jint len = _env->GetArrayLength(data);
|
jint len = _env->GetArrayLength(data);
|
||||||
LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
|
LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len);
|
||||||
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
jfloat *ptr = _env->GetFloatArrayElements(data, NULL);
|
||||||
rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr);
|
rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes);
|
||||||
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
_env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +524,7 @@ nAllocationDataFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _type
|
|||||||
const TypeFieldCache *tfc = &tc->fields[ct];
|
const TypeFieldCache *tfc = &tc->fields[ct];
|
||||||
buf = tfc->ptr(_env, _o, tfc->field, buf);
|
buf = tfc->ptr(_env, _o, tfc->field, buf);
|
||||||
}
|
}
|
||||||
rsAllocationData(con, (RsAllocation)alloc, bufAlloc);
|
rsAllocationData(con, (RsAllocation)alloc, bufAlloc, tc->size);
|
||||||
const uint32_t * tmp = (const uint32_t *)bufAlloc;
|
const uint32_t * tmp = (const uint32_t *)bufAlloc;
|
||||||
free(bufAlloc);
|
free(bufAlloc);
|
||||||
}
|
}
|
||||||
@@ -748,7 +756,7 @@ static void
|
|||||||
nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a)
|
nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, script, r, g, b, a);
|
LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a);
|
||||||
rsScriptSetClearColor(con, (RsScript)script, r, g, b, a);
|
rsScriptSetClearColor(con, (RsScript)script, r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,7 +764,7 @@ static void
|
|||||||
nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d)
|
nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, script, d);
|
LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d);
|
||||||
rsScriptSetClearDepth(con, (RsScript)script, d);
|
rsScriptSetClearDepth(con, (RsScript)script, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +772,7 @@ static void
|
|||||||
nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil)
|
nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, script, stencil);
|
LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil);
|
||||||
rsScriptSetClearStencil(con, (RsScript)script, stencil);
|
rsScriptSetClearStencil(con, (RsScript)script, stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -772,7 +780,7 @@ static void
|
|||||||
nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone)
|
nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, script, timeZone);
|
LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone);
|
||||||
|
|
||||||
jint length = _env->GetArrayLength(timeZone);
|
jint length = _env->GetArrayLength(timeZone);
|
||||||
jbyte* timeZone_ptr;
|
jbyte* timeZone_ptr;
|
||||||
@@ -1005,7 +1013,7 @@ static void
|
|||||||
nProgramVertexBindAllocation(JNIEnv *_env, jobject _this, jint vpv, jint a)
|
nProgramVertexBindAllocation(JNIEnv *_env, jobject _this, jint vpv, jint a)
|
||||||
{
|
{
|
||||||
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
|
||||||
LOG_API("nProgramVertexBindAllocation, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramVertex)vpv, slot, (RsAllocation)a);
|
LOG_API("nProgramVertexBindAllocation, con(%p), vpf(%p), a(%p)", con, (RsProgramVertex)vpv, (RsAllocation)a);
|
||||||
rsProgramVertexBindAllocation(con, (RsProgramFragment)vpv, (RsAllocation)a);
|
rsProgramVertexBindAllocation(con, (RsProgramFragment)vpv, (RsAllocation)a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1230,14 +1238,15 @@ static JNINativeMethod methods[] = {
|
|||||||
{"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized },
|
{"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized },
|
||||||
{"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized },
|
{"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized },
|
||||||
{"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
|
{"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap },
|
||||||
{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
|
{"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed },
|
||||||
{"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture },
|
{"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture },
|
||||||
{"nAllocationData", "(I[I)V", (void*)nAllocationData_i },
|
{"nAllocationUploadToBufferObject","(I)V", (void*)nAllocationUploadToBufferObject },
|
||||||
{"nAllocationData", "(I[F)V", (void*)nAllocationData_f },
|
{"nAllocationData", "(I[II)V", (void*)nAllocationData_i },
|
||||||
{"nAllocationSubData1D", "(III[I)V", (void*)nAllocationSubData1D_i },
|
{"nAllocationData", "(I[FI)V", (void*)nAllocationData_f },
|
||||||
{"nAllocationSubData1D", "(III[F)V", (void*)nAllocationSubData1D_f },
|
{"nAllocationSubData1D", "(III[II)V", (void*)nAllocationSubData1D_i },
|
||||||
{"nAllocationSubData2D", "(IIIII[I)V", (void*)nAllocationSubData2D_i },
|
{"nAllocationSubData1D", "(III[FI)V", (void*)nAllocationSubData1D_f },
|
||||||
{"nAllocationSubData2D", "(IIIII[F)V", (void*)nAllocationSubData2D_f },
|
{"nAllocationSubData2D", "(IIIII[II)V", (void*)nAllocationSubData2D_i },
|
||||||
|
{"nAllocationSubData2D", "(IIIII[FI)V", (void*)nAllocationSubData2D_f },
|
||||||
{"nAllocationRead", "(I[I)V", (void*)nAllocationRead_i },
|
{"nAllocationRead", "(I[I)V", (void*)nAllocationRead_i },
|
||||||
{"nAllocationRead", "(I[F)V", (void*)nAllocationRead_f },
|
{"nAllocationRead", "(I[F)V", (void*)nAllocationRead_f },
|
||||||
{"nAllocationDataFromObject", "(ILandroid/renderscript/Type;Ljava/lang/Object;)V", (void*)nAllocationDataFromObject },
|
{"nAllocationDataFromObject", "(ILandroid/renderscript/Type;Ljava/lang/Object;)V", (void*)nAllocationDataFromObject },
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ int main(int index)
|
|||||||
|
|
||||||
float trans = Pos_translate;
|
float trans = Pos_translate;
|
||||||
float rot = Pos_rotate;
|
float rot = Pos_rotate;
|
||||||
|
|
||||||
matrixLoadScale(mat1, 2.f, 2.f, 2.f);
|
matrixLoadScale(mat1, 2.f, 2.f, 2.f);
|
||||||
matrixTranslate(mat1, 0.f, 0.f, trans);
|
matrixTranslate(mat1, 0.f, 0.f, trans);
|
||||||
matrixRotate(mat1, 90.f, 0.f, 0.f, 1.f);
|
matrixRotate(mat1, 90.f, 0.f, 0.f, 1.f);
|
||||||
matrixRotate(mat1, rot, 1.f, 0.f, 0.f);
|
matrixRotate(mat1, rot, 1.f, 0.f, 0.f);
|
||||||
storeMatrix(3, 0, mat1);
|
vpLoadModelMatrix(mat1);
|
||||||
|
|
||||||
// Draw the lighting effect in the strip and fill the Z buffer.
|
// Draw the lighting effect in the strip and fill the Z buffer.
|
||||||
drawTriangleMesh(NAMED_mesh);
|
drawSimpleMesh(NAMED_mesh);
|
||||||
|
|
||||||
|
|
||||||
// Start of images.
|
// Start of images.
|
||||||
bindProgramFragmentStore(NAMED_PSImages);
|
bindProgramFragmentStore(NAMED_PSImages);
|
||||||
@@ -74,31 +74,21 @@ int main(int index)
|
|||||||
pos = pos - 0.75f;
|
pos = pos - 0.75f;
|
||||||
|
|
||||||
offset = offset + triangleOffsetsCount / 2;
|
offset = offset + triangleOffsetsCount / 2;
|
||||||
|
if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
|
||||||
int drawit = 1;
|
|
||||||
if (offset < 0) {
|
|
||||||
drawit = 0;
|
|
||||||
}
|
|
||||||
if (offset >= triangleOffsetsCount) {
|
|
||||||
drawit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
|
|
||||||
if (drawit) {
|
|
||||||
int start = offset -2;
|
int start = offset -2;
|
||||||
int end = offset + 2;
|
int end = offset + 2;
|
||||||
|
|
||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
if (end > triangleOffsetsCount) {
|
if (end >= triangleOffsetsCount) {
|
||||||
end = triangleOffsetsCount;
|
end = triangleOffsetsCount-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
|
bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
|
||||||
matrixLoadTranslate(mat1, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
|
matrixLoadTranslate(mat1, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
|
||||||
vpLoadTextureMatrix(mat1);
|
vpLoadTextureMatrix(mat1);
|
||||||
drawTriangleMeshRange(NAMED_mesh, loadI32(4, start), loadI32(4, end) - loadI32(4, start));
|
drawSimpleMeshRange(NAMED_mesh, loadI32(4, start), (loadI32(4, end) - loadI32(4, start)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ public class FilmRS {
|
|||||||
private RenderScript mRS;
|
private RenderScript mRS;
|
||||||
private Script mScriptStrip;
|
private Script mScriptStrip;
|
||||||
private Script mScriptImage;
|
private Script mScriptImage;
|
||||||
private Element mElementVertex;
|
|
||||||
private Element mElementIndex;
|
|
||||||
private Sampler mSampler;
|
private Sampler mSampler;
|
||||||
private ProgramStore mPSBackground;
|
private ProgramStore mPSBackground;
|
||||||
private ProgramStore mPSImages;
|
private ProgramStore mPSImages;
|
||||||
@@ -88,7 +86,7 @@ public class FilmRS {
|
|||||||
private Allocation mAllocOffsetsTex;
|
private Allocation mAllocOffsetsTex;
|
||||||
private Allocation mAllocOffsets;
|
private Allocation mAllocOffsets;
|
||||||
|
|
||||||
private RenderScript.TriangleMesh mMesh;
|
private SimpleMesh mMesh;
|
||||||
private Light mLight;
|
private Light mLight;
|
||||||
|
|
||||||
private FilmStripMesh mFSM;
|
private FilmStripMesh mFSM;
|
||||||
@@ -186,7 +184,6 @@ public class FilmRS {
|
|||||||
mip++;
|
mip++;
|
||||||
a.setConstraint(Dimension.LOD, mip);
|
a.setConstraint(Dimension.LOD, mip);
|
||||||
}
|
}
|
||||||
a.destroy();
|
|
||||||
|
|
||||||
mImages[ct].uploadToTexture(1);
|
mImages[ct].uploadToTexture(1);
|
||||||
mBufferIDs[ct] = mImages[ct].getID();
|
mBufferIDs[ct] = mImages[ct].getID();
|
||||||
@@ -204,13 +201,8 @@ public class FilmRS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initRS() {
|
private void initRS() {
|
||||||
mElementVertex = Element.NORM_ST_XYZ_F32;
|
|
||||||
mElementIndex = Element.INDEX_16;
|
|
||||||
|
|
||||||
mRS.triangleMeshBegin(mElementVertex, mElementIndex);
|
|
||||||
mFSM = new FilmStripMesh();
|
mFSM = new FilmStripMesh();
|
||||||
mFSM.init(mRS);
|
mMesh = mFSM.init(mRS);
|
||||||
mMesh = mRS.triangleMeshCreate();
|
|
||||||
mMesh.setName("mesh");
|
mMesh.setName("mesh");
|
||||||
|
|
||||||
initPFS();
|
initPFS();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.lang.Math;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import android.renderscript.RenderScript;
|
import android.renderscript.RenderScript;
|
||||||
|
import android.renderscript.SimpleMesh;
|
||||||
|
|
||||||
|
|
||||||
class FilmStripMesh {
|
class FilmStripMesh {
|
||||||
@@ -72,27 +73,23 @@ class FilmStripMesh {
|
|||||||
dx /= len;
|
dx /= len;
|
||||||
dy /= len;
|
dy /= len;
|
||||||
dz /= len;
|
dz /= len;
|
||||||
|
|
||||||
nx = dx * dz;
|
nx = dx * dz;
|
||||||
ny = dy * dz;
|
ny = dy * dz;
|
||||||
nz = (float)java.lang.Math.sqrt(dx*dx + dy*dy);
|
nz = (float)java.lang.Math.sqrt(dx*dx + dy*dy);
|
||||||
|
|
||||||
len = (float)java.lang.Math.sqrt(nx*nx + ny*ny + nz*nz);
|
len = (float)java.lang.Math.sqrt(nx*nx + ny*ny + nz*nz);
|
||||||
nx /= len;
|
nx /= len;
|
||||||
ny /= len;
|
ny /= len;
|
||||||
nz /= len;
|
nz /= len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToRS(RenderScript rs) {
|
|
||||||
rs.triangleMeshAddVertex_XYZ_ST_NORM(x, y, z, s, t, nx, ny, nz);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] mTriangleOffsets;
|
int[] mTriangleOffsets;
|
||||||
float[] mTriangleOffsetsTex;
|
float[] mTriangleOffsetsTex;
|
||||||
int mTriangleOffsetsCount;
|
int mTriangleOffsetsCount;
|
||||||
|
|
||||||
void init(RenderScript rs)
|
SimpleMesh init(RenderScript rs)
|
||||||
{
|
{
|
||||||
float vtx[] = new float[] {
|
float vtx[] = new float[] {
|
||||||
60.431003f, 124.482050f,
|
60.431003f, 124.482050f,
|
||||||
@@ -203,11 +200,11 @@ class FilmStripMesh {
|
|||||||
-60.862074f, 120.872604f,
|
-60.862074f, 120.872604f,
|
||||||
-60.431003f, 124.482050f
|
-60.431003f, 124.482050f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
mTriangleOffsets = new int[64];
|
mTriangleOffsets = new int[64];
|
||||||
mTriangleOffsetsTex = new float[64];
|
mTriangleOffsetsTex = new float[64];
|
||||||
|
|
||||||
mTriangleOffsets[0] = 0;
|
mTriangleOffsets[0] = 0;
|
||||||
mTriangleOffsetsCount = 1;
|
mTriangleOffsetsCount = 1;
|
||||||
|
|
||||||
@@ -215,6 +212,8 @@ class FilmStripMesh {
|
|||||||
t.nxyz(1, 0, 0);
|
t.nxyz(1, 0, 0);
|
||||||
int count = vtx.length / 2;
|
int count = vtx.length / 2;
|
||||||
|
|
||||||
|
SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(rs, 3, true, true);
|
||||||
|
|
||||||
float runningS = 0;
|
float runningS = 0;
|
||||||
for (int ct=0; ct < (count-1); ct++) {
|
for (int ct=0; ct < (count-1); ct++) {
|
||||||
t.x = -vtx[ct*2] / 100.f;
|
t.x = -vtx[ct*2] / 100.f;
|
||||||
@@ -228,16 +227,15 @@ class FilmStripMesh {
|
|||||||
t.ny /= len;
|
t.ny /= len;
|
||||||
t.y = -0.5f;
|
t.y = -0.5f;
|
||||||
t.t = 0;
|
t.t = 0;
|
||||||
//Log.e("xx", "vtx " + t.x + " " + t.y + " " + t.z);
|
tm.add_XYZ_ST_NORM(t.x, t.y, t.z, t.s, t.t, t.nx, t.ny, t.nz);
|
||||||
t.addToRS(rs);
|
//android.util.Log.e("rs", "vtx x="+t.x+" y="+t.y+" z="+t.z+" s="+t.s+" t="+t.t);
|
||||||
t.y = .5f;
|
t.y = .5f;
|
||||||
t.t = 1;
|
t.t = 1;
|
||||||
t.addToRS(rs);
|
tm.add_XYZ_ST_NORM(t.x, t.y, t.z, t.s, t.t, t.nx, t.ny, t.nz);
|
||||||
|
//android.util.Log.e("rs", "vtx x="+t.x+" y="+t.y+" z="+t.z+" s="+t.s+" t="+t.t);
|
||||||
|
|
||||||
//LOGE(" %f", runningS);
|
|
||||||
if((runningS*2) > mTriangleOffsetsCount) {
|
if((runningS*2) > mTriangleOffsetsCount) {
|
||||||
//LOGE("**** img %i %i", gTriangleOffsetsCount, ct*2);
|
mTriangleOffsets[mTriangleOffsetsCount] = ct*2 * 3;
|
||||||
mTriangleOffsets[mTriangleOffsetsCount] = ct*2;
|
|
||||||
mTriangleOffsetsTex[mTriangleOffsetsCount] = t.s;
|
mTriangleOffsetsTex[mTriangleOffsetsCount] = t.s;
|
||||||
mTriangleOffsetsCount ++;
|
mTriangleOffsetsCount ++;
|
||||||
}
|
}
|
||||||
@@ -245,9 +243,10 @@ class FilmStripMesh {
|
|||||||
|
|
||||||
count = (count * 2 - 2);
|
count = (count * 2 - 2);
|
||||||
for (int ct=0; ct < (count-2); ct+= 2) {
|
for (int ct=0; ct < (count-2); ct+= 2) {
|
||||||
rs.triangleMeshAddTriangle(ct, ct+1, ct+2);
|
tm.addTriangle(ct, ct+1, ct+2);
|
||||||
rs.triangleMeshAddTriangle(ct+1, ct+3, ct+2);
|
tm.addTriangle(ct+1, ct+3, ct+2);
|
||||||
}
|
}
|
||||||
|
return tm.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,9 @@ AllocationUploadToBufferObject {
|
|||||||
AllocationData {
|
AllocationData {
|
||||||
param RsAllocation va
|
param RsAllocation va
|
||||||
param const void * data
|
param const void * data
|
||||||
|
param uint32_t bytes
|
||||||
|
handcodeApi
|
||||||
|
togglePlay
|
||||||
}
|
}
|
||||||
|
|
||||||
Allocation1DSubData {
|
Allocation1DSubData {
|
||||||
@@ -137,6 +140,9 @@ Allocation1DSubData {
|
|||||||
param uint32_t xoff
|
param uint32_t xoff
|
||||||
param uint32_t count
|
param uint32_t count
|
||||||
param const void *data
|
param const void *data
|
||||||
|
param uint32_t bytes
|
||||||
|
handcodeApi
|
||||||
|
togglePlay
|
||||||
}
|
}
|
||||||
|
|
||||||
Allocation2DSubData {
|
Allocation2DSubData {
|
||||||
@@ -146,6 +152,7 @@ Allocation2DSubData {
|
|||||||
param uint32_t w
|
param uint32_t w
|
||||||
param uint32_t h
|
param uint32_t h
|
||||||
param const void *data
|
param const void *data
|
||||||
|
param uint32_t bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocationRead {
|
AllocationRead {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace renderscript {
|
|||||||
RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
|
RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
Adapter1D *a = new Adapter1D();
|
Adapter1D *a = new Adapter1D();
|
||||||
a->incRef();
|
a->incUserRef();
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ namespace renderscript {
|
|||||||
RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
|
RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
Adapter2D *a = new Adapter2D();
|
Adapter2D *a = new Adapter2D();
|
||||||
a->incRef();
|
a->incUserRef();
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,9 +115,14 @@ void Allocation::uploadToBufferObject()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Allocation::data(const void *data)
|
void Allocation::data(const void *data, uint32_t sizeBytes)
|
||||||
{
|
{
|
||||||
memcpy(mPtr, data, mType->getSizeBytes());
|
uint32_t size = mType->getSizeBytes();
|
||||||
|
if (size != sizeBytes) {
|
||||||
|
LOGE("Allocation::data called with mismatched size expected %i, got %i", size, sizeBytes);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(mPtr, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Allocation::read(void *data)
|
void Allocation::read(void *data)
|
||||||
@@ -125,16 +130,22 @@ void Allocation::read(void *data)
|
|||||||
memcpy(data, mPtr, mType->getSizeBytes());
|
memcpy(data, mPtr, mType->getSizeBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Allocation::subData(uint32_t xoff, uint32_t count, const void *data)
|
void Allocation::subData(uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes)
|
||||||
{
|
{
|
||||||
uint32_t eSize = mType->getElementSizeBytes();
|
uint32_t eSize = mType->getElementSizeBytes();
|
||||||
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
|
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
|
||||||
ptr += eSize * xoff;
|
ptr += eSize * xoff;
|
||||||
memcpy(ptr, data, count * eSize);
|
uint32_t size = count * eSize;
|
||||||
|
|
||||||
|
if (size != sizeBytes) {
|
||||||
|
LOGE("Allocation::subData called with mismatched size expected %i, got %i", size, sizeBytes);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(ptr, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Allocation::subData(uint32_t xoff, uint32_t yoff,
|
void Allocation::subData(uint32_t xoff, uint32_t yoff,
|
||||||
uint32_t w, uint32_t h, const void *data)
|
uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes)
|
||||||
{
|
{
|
||||||
uint32_t eSize = mType->getElementSizeBytes();
|
uint32_t eSize = mType->getElementSizeBytes();
|
||||||
uint32_t lineSize = eSize * w;
|
uint32_t lineSize = eSize * w;
|
||||||
@@ -143,6 +154,12 @@ void Allocation::subData(uint32_t xoff, uint32_t yoff,
|
|||||||
const uint8_t *src = static_cast<const uint8_t *>(data);
|
const uint8_t *src = static_cast<const uint8_t *>(data);
|
||||||
uint8_t *dst = static_cast<uint8_t *>(mPtr);
|
uint8_t *dst = static_cast<uint8_t *>(mPtr);
|
||||||
dst += eSize * (xoff + yoff * destW);
|
dst += eSize * (xoff + yoff * destW);
|
||||||
|
|
||||||
|
if ((lineSize * eSize * h) != sizeBytes) {
|
||||||
|
rsAssert(!"Allocation::subData called with mismatched size");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t line=yoff; line < (yoff+h); line++) {
|
for (uint32_t line=yoff; line < (yoff+h); line++) {
|
||||||
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
|
uint8_t * ptr = static_cast<uint8_t *>(mPtr);
|
||||||
memcpy(dst, src, lineSize);
|
memcpy(dst, src, lineSize);
|
||||||
@@ -152,7 +169,7 @@ void Allocation::subData(uint32_t xoff, uint32_t yoff,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff,
|
void Allocation::subData(uint32_t xoff, uint32_t yoff, uint32_t zoff,
|
||||||
uint32_t w, uint32_t h, uint32_t d, const void *data)
|
uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +187,7 @@ 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(type);
|
||||||
alloc->incRef();
|
alloc->incUserRef();
|
||||||
return alloc;
|
return alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +357,7 @@ RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h
|
|||||||
LOGE("Memory allocation failure");
|
LOGE("Memory allocation failure");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
texAlloc->incRef();
|
texAlloc->incUserRef();
|
||||||
|
|
||||||
ElementConverter_t cvt = pickConverter(dstFmt, srcFmt);
|
ElementConverter_t cvt = pickConverter(dstFmt, srcFmt);
|
||||||
cvt(texAlloc->getPtr(), data, w * h);
|
cvt(texAlloc->getPtr(), data, w * h);
|
||||||
@@ -451,7 +468,7 @@ RsAllocation rsi_AllocationCreateFromFile(Context *rsc, const char *file, bool g
|
|||||||
|
|
||||||
RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, type);
|
RsAllocation vTexAlloc = rsi_AllocationCreateTyped(rsc, type);
|
||||||
Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
|
Allocation *texAlloc = static_cast<Allocation *>(vTexAlloc);
|
||||||
texAlloc->incRef();
|
texAlloc->incUserRef();
|
||||||
if (texAlloc == NULL) {
|
if (texAlloc == NULL) {
|
||||||
LOGE("Memory allocation failure");
|
LOGE("Memory allocation failure");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@@ -503,24 +520,24 @@ RsAllocation rsi_AllocationCreateFromFile(Context *rsc, const char *file, bool g
|
|||||||
return texAlloc;
|
return texAlloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data)
|
void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes)
|
||||||
{
|
{
|
||||||
Allocation *a = static_cast<Allocation *>(va);
|
Allocation *a = static_cast<Allocation *>(va);
|
||||||
a->data(data);
|
a->data(data, sizeBytes);
|
||||||
rsc->allocationCheck(a);
|
rsc->allocationCheck(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data)
|
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);
|
Allocation *a = static_cast<Allocation *>(va);
|
||||||
a->subData(xoff, count, data);
|
a->subData(xoff, count, data, sizeBytes);
|
||||||
rsc->allocationCheck(a);
|
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)
|
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);
|
Allocation *a = static_cast<Allocation *>(va);
|
||||||
a->subData(xoff, yoff, w, h, data);
|
a->subData(xoff, yoff, w, h, data, sizeBytes);
|
||||||
rsc->allocationCheck(a);
|
rsc->allocationCheck(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,12 +53,12 @@ public:
|
|||||||
uint32_t getBufferObjectID() const {return mBufferID;}
|
uint32_t getBufferObjectID() const {return mBufferID;}
|
||||||
|
|
||||||
|
|
||||||
void data(const void *data);
|
void data(const void *data, uint32_t sizeBytes);
|
||||||
void subData(uint32_t xoff, uint32_t count, const void *data);
|
void subData(uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes);
|
||||||
void subData(uint32_t xoff, uint32_t yoff,
|
void subData(uint32_t xoff, uint32_t yoff,
|
||||||
uint32_t w, uint32_t h, const void *data);
|
uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes);
|
||||||
void subData(uint32_t xoff, uint32_t yoff, uint32_t zoff,
|
void subData(uint32_t xoff, uint32_t yoff, uint32_t zoff,
|
||||||
uint32_t w, uint32_t h, uint32_t d, const void *data);
|
uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
|
||||||
|
|
||||||
void read(void *data);
|
void read(void *data);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ void Context::initEGL()
|
|||||||
configAttribsPtr[1] = 16;
|
configAttribsPtr[1] = 16;
|
||||||
configAttribsPtr += 2;
|
configAttribsPtr += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
configAttribsPtr[0] = EGL_NONE;
|
configAttribsPtr[0] = EGL_NONE;
|
||||||
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
|
rsAssert(configAttribsPtr < (configAttribs + (sizeof(configAttribs) / sizeof(EGLint))));
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ void Context::initEGL()
|
|||||||
|
|
||||||
status_t err = EGLUtils::selectConfigForNativeWindow(mEGL.mDisplay, configAttribs, mWndSurface, &mEGL.mConfig);
|
status_t err = EGLUtils::selectConfigForNativeWindow(mEGL.mDisplay, configAttribs, mWndSurface, &mEGL.mConfig);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOGE("couldn't find an EGLConfig matching the screen format\n");
|
LOGE("couldn't find an EGLConfig matching the screen format\n");
|
||||||
}
|
}
|
||||||
//eglChooseConfig(mEGL.mDisplay, configAttribs, &mEGL.mConfig, 1, &mEGL.mNumConfigs);
|
//eglChooseConfig(mEGL.mDisplay, configAttribs, &mEGL.mConfig, 1, &mEGL.mNumConfigs);
|
||||||
|
|
||||||
@@ -76,11 +77,11 @@ void Context::initEGL()
|
|||||||
mGL.mRenderer = glGetString(GL_RENDERER);
|
mGL.mRenderer = glGetString(GL_RENDERER);
|
||||||
mGL.mExtensions = glGetString(GL_EXTENSIONS);
|
mGL.mExtensions = glGetString(GL_EXTENSIONS);
|
||||||
|
|
||||||
//LOGV("EGL Version %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion);
|
LOGV("EGL Version %i %i", mEGL.mMajorVersion, mEGL.mMinorVersion);
|
||||||
//LOGV("GL Version %s", mGL.mVersion);
|
LOGV("GL Version %s", mGL.mVersion);
|
||||||
//LOGV("GL Vendor %s", mGL.mVendor);
|
LOGV("GL Vendor %s", mGL.mVendor);
|
||||||
//LOGV("GL Renderer %s", mGL.mRenderer);
|
LOGV("GL Renderer %s", mGL.mRenderer);
|
||||||
//LOGV("GL Extensions %s", mGL.mExtensions);
|
LOGV("GL Extensions %s", mGL.mExtensions);
|
||||||
|
|
||||||
if ((strlen((const char *)mGL.mVersion) < 12) || memcmp(mGL.mVersion, "OpenGL ES-CM", 12)) {
|
if ((strlen((const char *)mGL.mVersion) < 12) || memcmp(mGL.mVersion, "OpenGL ES-CM", 12)) {
|
||||||
LOGE("Error, OpenGL ES Lite not supported");
|
LOGE("Error, OpenGL ES Lite not supported");
|
||||||
@@ -432,7 +433,7 @@ void Context::objDestroyOOBRun()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t ct = 0; ct < mObjDestroy.mDestroyList.size(); ct++) {
|
for (size_t ct = 0; ct < mObjDestroy.mDestroyList.size(); ct++) {
|
||||||
mObjDestroy.mDestroyList[ct]->decRef();
|
mObjDestroy.mDestroyList[ct]->decUserRef();
|
||||||
}
|
}
|
||||||
mObjDestroy.mDestroyList.clear();
|
mObjDestroy.mDestroyList.clear();
|
||||||
mObjDestroy.mNeedToEmpty = false;
|
mObjDestroy.mNeedToEmpty = false;
|
||||||
@@ -522,7 +523,7 @@ void rsi_ObjDestroy(Context *rsc, void *obj)
|
|||||||
{
|
{
|
||||||
ObjectBase *ob = static_cast<ObjectBase *>(obj);
|
ObjectBase *ob = static_cast<ObjectBase *>(obj);
|
||||||
rsc->removeName(ob);
|
rsc->removeName(ob);
|
||||||
ob->decRef();
|
ob->decUserRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsi_ContextSetDefineF(Context *rsc, const char* name, float value)
|
void rsi_ContextSetDefineF(Context *rsc, const char* name, float value)
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ void Element::setComponent(uint32_t idx, Component *c)
|
|||||||
rsAssert(!mComponents[idx].get());
|
rsAssert(!mComponents[idx].get());
|
||||||
rsAssert(idx < mComponentCount);
|
rsAssert(idx < mComponentCount);
|
||||||
mComponents[idx].set(c);
|
mComponents[idx].set(c);
|
||||||
c->incRef();
|
c->incUserRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ RsElement rsi_ElementGetPredefined(Context *rsc, RsElementPredefined predef)
|
|||||||
|
|
||||||
rsAssert(sec->mPredefinedList[predef].mEnum == predef);
|
rsAssert(sec->mPredefinedList[predef].mEnum == predef);
|
||||||
Element * e = sec->mPredefinedList[predef].mElement;
|
Element * e = sec->mPredefinedList[predef].mElement;
|
||||||
e->incRef();
|
e->incUserRef();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ RsElement rsi_ElementCreate(Context *rsc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rsc->mStateElement.mComponentBuildList.clear();
|
rsc->mStateElement.mComponentBuildList.clear();
|
||||||
se->incRef();
|
se->incUserRef();
|
||||||
return se;
|
return se;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
47
libs/rs/rsHandcode.h
Normal file
47
libs/rs/rsHandcode.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
#define DATA_SYNC_SIZE 1024
|
||||||
|
|
||||||
|
static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes)
|
||||||
|
{
|
||||||
|
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||||
|
uint32_t size = sizeof(RS_CMD_AllocationData);
|
||||||
|
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||||
|
size += (sizeBytes + 3) & ~3;
|
||||||
|
}
|
||||||
|
RS_CMD_AllocationData *cmd = static_cast<RS_CMD_AllocationData *>(io->mToCore.reserve(size));
|
||||||
|
cmd->va = va;
|
||||||
|
cmd->bytes = sizeBytes;
|
||||||
|
cmd->data = data;
|
||||||
|
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||||
|
cmd->data = (void *)(cmd+1);
|
||||||
|
memcpy(cmd+1, data, sizeBytes);
|
||||||
|
io->mToCore.commit(RS_CMD_ID_AllocationData, size);
|
||||||
|
} else {
|
||||||
|
io->mToCore.commitSync(RS_CMD_ID_AllocationData, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes)
|
||||||
|
{
|
||||||
|
ThreadIO *io = &((Context *)rsc)->mIO;
|
||||||
|
uint32_t size = sizeof(RS_CMD_Allocation1DSubData);
|
||||||
|
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||||
|
size += (sizeBytes + 3) & ~3;
|
||||||
|
}
|
||||||
|
RS_CMD_Allocation1DSubData *cmd = static_cast<RS_CMD_Allocation1DSubData *>(io->mToCore.reserve(size));
|
||||||
|
cmd->va = va;
|
||||||
|
cmd->xoff = xoff;
|
||||||
|
cmd->count = count;
|
||||||
|
cmd->data = data;
|
||||||
|
cmd->bytes = sizeBytes;
|
||||||
|
if (sizeBytes < DATA_SYNC_SIZE) {
|
||||||
|
cmd->data = (void *)(cmd+1);
|
||||||
|
memcpy(cmd+1, data, sizeBytes);
|
||||||
|
io->mToCore.commit(RS_CMD_ID_Allocation1DSubData, size);
|
||||||
|
} else {
|
||||||
|
io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubData, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ RsLight rsi_LightCreate(Context *rsc)
|
|||||||
{
|
{
|
||||||
Light *l = new Light(rsc->mStateLight.mIsLocal,
|
Light *l = new Light(rsc->mStateLight.mIsLocal,
|
||||||
rsc->mStateLight.mIsMono);
|
rsc->mStateLight.mIsMono);
|
||||||
l->incRef();
|
l->incUserRef();
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,28 +21,51 @@ using namespace android::renderscript;
|
|||||||
|
|
||||||
ObjectBase::ObjectBase()
|
ObjectBase::ObjectBase()
|
||||||
{
|
{
|
||||||
mRefCount = 0;
|
mUserRefCount = 0;
|
||||||
|
mSysRefCount = 0;
|
||||||
mName = NULL;
|
mName = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectBase::~ObjectBase()
|
ObjectBase::~ObjectBase()
|
||||||
{
|
{
|
||||||
//LOGV("~ObjectBase %p ref %i", this, mRefCount);
|
//LOGV("~ObjectBase %p ref %i", this, mRefCount);
|
||||||
rsAssert(!mRefCount);
|
rsAssert(!mUserRefCount);
|
||||||
|
rsAssert(!mSysRefCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectBase::incRef() const
|
void ObjectBase::incUserRef() const
|
||||||
{
|
{
|
||||||
mRefCount ++;
|
mUserRefCount ++;
|
||||||
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
|
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectBase::decRef() const
|
void ObjectBase::incSysRef() const
|
||||||
{
|
{
|
||||||
rsAssert(mRefCount > 0);
|
mSysRefCount ++;
|
||||||
mRefCount --;
|
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectBase::decUserRef() const
|
||||||
|
{
|
||||||
|
rsAssert(mUserRefCount > 0);
|
||||||
|
mUserRefCount --;
|
||||||
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||||
if (!mRefCount) {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectBase::decSysRef() const
|
||||||
|
{
|
||||||
|
rsAssert(mSysRefCount > 0);
|
||||||
|
mSysRefCount --;
|
||||||
|
//LOGV("ObjectBase %p dec ref %i", this, mRefCount);
|
||||||
|
if (!(mSysRefCount | mUserRefCount)) {
|
||||||
if (mName) {
|
if (mName) {
|
||||||
LOGV("Deleting RS object %p, name %s", this, mName);
|
LOGV("Deleting RS object %p, name %s", this, mName);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -30,8 +30,11 @@ public:
|
|||||||
ObjectBase();
|
ObjectBase();
|
||||||
virtual ~ObjectBase();
|
virtual ~ObjectBase();
|
||||||
|
|
||||||
void incRef() const;
|
void incSysRef() const;
|
||||||
void decRef() const;
|
void decSysRef() const;
|
||||||
|
|
||||||
|
void incUserRef() const;
|
||||||
|
void decUserRef() const;
|
||||||
|
|
||||||
const char * getName() const {
|
const char * getName() const {
|
||||||
return mName;
|
return mName;
|
||||||
@@ -41,13 +44,14 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
char * mName;
|
char * mName;
|
||||||
mutable int32_t mRefCount;
|
mutable int32_t mSysRefCount;
|
||||||
|
mutable int32_t mUserRefCount;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class ObjectBaseRef
|
class ObjectBaseRef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObjectBaseRef() {
|
ObjectBaseRef() {
|
||||||
@@ -57,14 +61,14 @@ public:
|
|||||||
ObjectBaseRef(const ObjectBaseRef &ref) {
|
ObjectBaseRef(const ObjectBaseRef &ref) {
|
||||||
mRef = ref.get();
|
mRef = ref.get();
|
||||||
if (mRef) {
|
if (mRef) {
|
||||||
mRef->incRef();
|
mRef->incSysRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectBaseRef(T *ref) {
|
ObjectBaseRef(T *ref) {
|
||||||
mRef = ref;
|
mRef = ref;
|
||||||
if (mRef) {
|
if (mRef) {
|
||||||
ref->incRef();
|
ref->incSysRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +81,7 @@ public:
|
|||||||
clear();
|
clear();
|
||||||
mRef = ref;
|
mRef = ref;
|
||||||
if (mRef) {
|
if (mRef) {
|
||||||
ref->incRef();
|
ref->incSysRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +92,7 @@ public:
|
|||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
if (mRef) {
|
if (mRef) {
|
||||||
mRef->decRef();
|
mRef->decSysRef();
|
||||||
}
|
}
|
||||||
mRef = NULL;
|
mRef = NULL;
|
||||||
}
|
}
|
||||||
@@ -97,8 +101,8 @@ public:
|
|||||||
return mRef;
|
return mRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T * operator-> () const {
|
inline T * operator-> () const {
|
||||||
return mRef;
|
return mRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void rsi_ProgramFragmentSetSlot(Context *rsc, uint32_t slot, bool enable, RsTexE
|
|||||||
RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc)
|
RsProgramFragment rsi_ProgramFragmentCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
ProgramFragment *pf = rsc->mStateFragment.mPF;
|
ProgramFragment *pf = rsc->mStateFragment.mPF;
|
||||||
pf->incRef();
|
pf->incUserRef();
|
||||||
rsc->mStateFragment.mPF = 0;
|
rsc->mStateFragment.mPF = 0;
|
||||||
return pf;
|
return pf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ void rsi_ProgramFragmentStoreBlendFunc(Context *rsc, RsBlendSrcFunc src, RsBlend
|
|||||||
RsProgramFragmentStore rsi_ProgramFragmentStoreCreate(Context *rsc)
|
RsProgramFragmentStore rsi_ProgramFragmentStoreCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
ProgramFragmentStore *pfs = rsc->mStateFragmentStore.mPFS;
|
ProgramFragmentStore *pfs = rsc->mStateFragmentStore.mPFS;
|
||||||
pfs->incRef();
|
pfs->incUserRef();
|
||||||
rsc->mStateFragmentStore.mPFS = 0;
|
rsc->mStateFragmentStore.mPFS = 0;
|
||||||
return pfs;
|
return pfs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,10 +143,10 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h)
|
|||||||
|
|
||||||
Matrix m;
|
Matrix m;
|
||||||
m.loadOrtho(0,w, h,0, -1,1);
|
m.loadOrtho(0,w, h,0, -1,1);
|
||||||
alloc->subData(RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0]);
|
alloc->subData(RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0], 16*4);
|
||||||
|
|
||||||
m.loadIdentity();
|
m.loadIdentity();
|
||||||
alloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0]);
|
alloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ void rsi_ProgramVertexBegin(Context *rsc, RsElement in, RsElement out)
|
|||||||
RsProgramVertex rsi_ProgramVertexCreate(Context *rsc)
|
RsProgramVertex rsi_ProgramVertexCreate(Context *rsc)
|
||||||
{
|
{
|
||||||
ProgramVertex *pv = rsc->mStateVertex.mPV;
|
ProgramVertex *pv = rsc->mStateVertex.mPV;
|
||||||
pv->incRef();
|
pv->incUserRef();
|
||||||
rsc->mStateVertex.mPV = 0;
|
rsc->mStateVertex.mPV = 0;
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ RsSampler rsi_SamplerCreate(Context *rsc)
|
|||||||
ss->mWrapS,
|
ss->mWrapS,
|
||||||
ss->mWrapT,
|
ss->mWrapT,
|
||||||
ss->mWrapR);
|
ss->mWrapR);
|
||||||
s->incRef();
|
s->incUserRef();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ RsScript rsi_ScriptCCreate(Context * rsc)
|
|||||||
ss->runCompiler(rsc);
|
ss->runCompiler(rsc);
|
||||||
|
|
||||||
ScriptC *s = new ScriptC();
|
ScriptC *s = new ScriptC();
|
||||||
s->incRef();
|
s->incUserRef();
|
||||||
s->mAccScript = ss->mAccScript;
|
s->mAccScript = ss->mAccScript;
|
||||||
ss->mAccScript = NULL;
|
ss->mAccScript = NULL;
|
||||||
s->mEnviroment = ss->mEnviroment;
|
s->mEnviroment = ss->mEnviroment;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void SimpleMesh::renderRange(uint32_t start, uint32_t len) const
|
|||||||
|
|
||||||
if (mIndexType.get()) {
|
if (mIndexType.get()) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer->getBufferObjectID());
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer->getBufferObjectID());
|
||||||
glDrawElements(mGLPrimitive, len, GL_UNSIGNED_SHORT, (GLvoid *)(start * 2));
|
glDrawElements(mGLPrimitive, len, GL_UNSIGNED_SHORT, (uint16_t *)(start * 2));
|
||||||
} else {
|
} else {
|
||||||
glDrawArrays(mGLPrimitive, start, len);
|
glDrawArrays(mGLPrimitive, start, len);
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,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();
|
||||||
sm->incRef();
|
sm->incUserRef();
|
||||||
|
|
||||||
sm->mIndexType.set((const Type *)idx);
|
sm->mIndexType.set((const Type *)idx);
|
||||||
sm->mPrimitiveType.set((const Type *)prim);
|
sm->mPrimitiveType.set((const Type *)prim);
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ RsTriangleMesh rsi_TriangleMeshCreate(Context *rsc)
|
|||||||
memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize);
|
memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize);
|
||||||
tm->analyzeElement();
|
tm->analyzeElement();
|
||||||
|
|
||||||
tm->incRef();
|
tm->incUserRef();
|
||||||
return tm;
|
return tm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ void Type::enableGLVertexBuffer() const
|
|||||||
|
|
||||||
uint32_t stride = mElement->getSizeBytes();
|
uint32_t stride = mElement->getSizeBytes();
|
||||||
if (mGL.mVtx.size) {
|
if (mGL.mVtx.size) {
|
||||||
|
//LOGE("va vtx %i %x, %i, %p", mGL.mVtx.size, mGL.mVtx.type, stride, (void *)mGL.mVtx.offset);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertexPointer(mGL.mVtx.size,
|
glVertexPointer(mGL.mVtx.size,
|
||||||
mGL.mVtx.type,
|
mGL.mVtx.type,
|
||||||
@@ -260,9 +261,10 @@ void Type::enableGLVertexBuffer() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mGL.mNorm.size) {
|
if (mGL.mNorm.size) {
|
||||||
|
//LOGE("va norm %i %x, %i, %p", mGL.mNorm.size, mGL.mNorm.type, stride, (void *)mGL.mNorm.offset);
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
rsAssert(mGL.mNorm.size == 3);
|
rsAssert(mGL.mNorm.size == 3);
|
||||||
glNormalPointer(mGL.mNorm.size,
|
glNormalPointer(mGL.mNorm.type,
|
||||||
stride,
|
stride,
|
||||||
(void *)mGL.mNorm.offset);
|
(void *)mGL.mNorm.offset);
|
||||||
}
|
}
|
||||||
@@ -277,6 +279,7 @@ void Type::enableGLVertexBuffer() const
|
|||||||
|
|
||||||
for (uint32_t ct=0; ct < RS_MAX_TEXTURE; ct++) {
|
for (uint32_t ct=0; ct < RS_MAX_TEXTURE; ct++) {
|
||||||
if (mGL.mTex[ct].size) {
|
if (mGL.mTex[ct].size) {
|
||||||
|
//LOGE("va tex%i %i %x, %i, %p", ct, mGL.mTex[ct].size, mGL.mTex[ct].type, stride, (void *)mGL.mTex[ct].offset);
|
||||||
glClientActiveTexture(GL_TEXTURE0 + ct);
|
glClientActiveTexture(GL_TEXTURE0 + ct);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoordPointer(mGL.mTex[ct].size,
|
glTexCoordPointer(mGL.mTex[ct].size,
|
||||||
@@ -361,7 +364,7 @@ RsType rsi_TypeCreate(Context *rsc)
|
|||||||
TypeState * stc = &rsc->mStateType;
|
TypeState * stc = &rsc->mStateType;
|
||||||
|
|
||||||
Type * st = new Type();
|
Type * st = new Type();
|
||||||
st->incRef();
|
st->incUserRef();
|
||||||
st->setDimX(stc->mX);
|
st->setDimX(stc->mX);
|
||||||
st->setDimY(stc->mY);
|
st->setDimY(stc->mY);
|
||||||
st->setDimZ(stc->mZ);
|
st->setDimZ(stc->mZ);
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ void printApiCpp(FILE *f)
|
|||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
fprintf(f, "using namespace android;\n");
|
fprintf(f, "using namespace android;\n");
|
||||||
fprintf(f, "using namespace android::renderscript;\n");
|
fprintf(f, "using namespace android::renderscript;\n");
|
||||||
|
fprintf(f, "#include \"rsHandcode.h\"\n");
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
for(ct=0; ct < apiCount; ct++) {
|
for(ct=0; ct < apiCount; ct++) {
|
||||||
@@ -149,30 +150,39 @@ void printApiCpp(FILE *f)
|
|||||||
|
|
||||||
printFuncDecl(f, api, "rs", 0);
|
printFuncDecl(f, api, "rs", 0);
|
||||||
fprintf(f, "\n{\n");
|
fprintf(f, "\n{\n");
|
||||||
fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
|
if (api->handcodeApi) {
|
||||||
//fprintf(f, " LOGE(\"add command %s\\n\");\n", api->name);
|
fprintf(f, " rsHCAPI_%s(rsc", api->name);
|
||||||
fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->mToCore.reserve(sizeof(RS_CMD_%s)));\n", api->name, api->name, api->name);
|
for(ct2=0; ct2 < api->paramCount; ct2++) {
|
||||||
fprintf(f, " uint32_t size = sizeof(RS_CMD_%s);\n", api->name);
|
const VarType *vt = &api->params[ct2];
|
||||||
|
fprintf(f, ", %s", vt->name);
|
||||||
|
}
|
||||||
|
fprintf(f, ");\n");
|
||||||
|
} else {
|
||||||
|
fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n");
|
||||||
|
//fprintf(f, " LOGE(\"add command %s\\n\");\n", api->name);
|
||||||
|
fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->mToCore.reserve(sizeof(RS_CMD_%s)));\n", api->name, api->name, api->name);
|
||||||
|
fprintf(f, " uint32_t size = sizeof(RS_CMD_%s);\n", api->name);
|
||||||
|
|
||||||
for(ct2=0; ct2 < api->paramCount; ct2++) {
|
for(ct2=0; ct2 < api->paramCount; ct2++) {
|
||||||
const VarType *vt = &api->params[ct2];
|
const VarType *vt = &api->params[ct2];
|
||||||
needFlush += vt->ptrLevel;
|
needFlush += vt->ptrLevel;
|
||||||
fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
|
fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
|
||||||
}
|
}
|
||||||
if (api->ret.typeName[0]) {
|
if (api->ret.typeName[0]) {
|
||||||
needFlush = 1;
|
needFlush = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, " io->mToCore.commit");
|
fprintf(f, " io->mToCore.commit");
|
||||||
if (needFlush) {
|
if (needFlush) {
|
||||||
fprintf(f, "Sync");
|
fprintf(f, "Sync");
|
||||||
}
|
}
|
||||||
fprintf(f, "(RS_CMD_ID_%s, size);\n", api->name);
|
fprintf(f, "(RS_CMD_ID_%s, size);\n", api->name);
|
||||||
|
|
||||||
if (api->ret.typeName[0]) {
|
if (api->ret.typeName[0]) {
|
||||||
fprintf(f, " return reinterpret_cast<");
|
fprintf(f, " return reinterpret_cast<");
|
||||||
printVarType(f, &api->ret);
|
printVarType(f, &api->ret);
|
||||||
fprintf(f, ">(io->mToCoreRet);\n");
|
fprintf(f, ">(io->mToCoreRet);\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(f, "};\n\n");
|
fprintf(f, "};\n\n");
|
||||||
}
|
}
|
||||||
@@ -191,6 +201,7 @@ void printPlaybackCpp(FILE *f)
|
|||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
fprintf(f, "namespace android {\n");
|
fprintf(f, "namespace android {\n");
|
||||||
fprintf(f, "namespace renderscript {\n");
|
fprintf(f, "namespace renderscript {\n");
|
||||||
|
fprintf(f, "#include \"rsHandcode.h\"\n");
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
for(ct=0; ct < apiCount; ct++) {
|
for(ct=0; ct < apiCount; ct++) {
|
||||||
@@ -198,20 +209,22 @@ void printPlaybackCpp(FILE *f)
|
|||||||
|
|
||||||
fprintf(f, "void rsp_%s(Context *con, const void *vp)\n", api->name);
|
fprintf(f, "void rsp_%s(Context *con, const void *vp)\n", api->name);
|
||||||
fprintf(f, "{\n");
|
fprintf(f, "{\n");
|
||||||
//fprintf(f, " LOGE(\"play command %s\\n\");\n", api->name);
|
if (api->handcodePlay) {
|
||||||
fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
|
fprintf(f, " rsHCPLAY_%s(con, vp);\n", api->name);
|
||||||
fprintf(f, " ");
|
} else {
|
||||||
if (api->ret.typeName[0]) {
|
//fprintf(f, " LOGE(\"play command %s\\n\");\n", api->name);
|
||||||
fprintf(f, "con->mIO.mToCoreRet = (intptr_t)");
|
fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
|
||||||
|
fprintf(f, " ");
|
||||||
|
if (api->ret.typeName[0]) {
|
||||||
|
fprintf(f, "con->mIO.mToCoreRet = (intptr_t)");
|
||||||
|
}
|
||||||
|
fprintf(f, "rsi_%s(con", api->name);
|
||||||
|
for(ct2=0; ct2 < api->paramCount; ct2++) {
|
||||||
|
const VarType *vt = &api->params[ct2];
|
||||||
|
fprintf(f, ",\n cmd->%s", vt->name);
|
||||||
|
}
|
||||||
|
fprintf(f, ");\n");
|
||||||
}
|
}
|
||||||
fprintf(f, "rsi_%s(con", api->name);
|
|
||||||
for(ct2=0; ct2 < api->paramCount; ct2++) {
|
|
||||||
const VarType *vt = &api->params[ct2];
|
|
||||||
fprintf(f, ",");
|
|
||||||
fprintf(f, "\n cmd->%s", vt->name);
|
|
||||||
}
|
|
||||||
fprintf(f, ");\n");
|
|
||||||
|
|
||||||
fprintf(f, "};\n\n");
|
fprintf(f, "};\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ extern VarType *currType;
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char name[256];
|
char name[256];
|
||||||
int sync;
|
int sync;
|
||||||
|
int handcodeApi;
|
||||||
|
int handcodePlay;
|
||||||
int paramCount;
|
int paramCount;
|
||||||
VarType ret;
|
VarType ret;
|
||||||
VarType params[16];
|
VarType params[16];
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ ID [a-zA-Z_][a-zA-Z0-9_]*
|
|||||||
apis[apiCount].sync = 1;
|
apis[apiCount].sync = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<api_entry2>"handcodeApi" {
|
||||||
|
apis[apiCount].handcodeApi = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
<api_entry2>"handcodePlay" {
|
||||||
|
apis[apiCount].handcodePlay = 1;
|
||||||
|
}
|
||||||
|
|
||||||
<api_entry2>"ret" {
|
<api_entry2>"ret" {
|
||||||
currType = &apis[apiCount].ret;
|
currType = &apis[apiCount].ret;
|
||||||
typeNextState = api_entry2;
|
typeNextState = api_entry2;
|
||||||
|
|||||||
Reference in New Issue
Block a user