diff options
Diffstat (limited to 'rs/java/android/renderscript/RenderScript.java')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 296 |
1 files changed, 213 insertions, 83 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index e86c46153b08..f08c9853f873 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -302,6 +302,55 @@ public class RenderScript { rsnContextResume(mContext); } + native long rsnClosureCreate(long con, long kernelID, long returnValue, + long[] fieldIDs, long[] values, int[] sizes, long[] depClosures, + long[] depFieldIDs); + synchronized long nClosureCreate(long kernelID, long returnValue, + long[] fieldIDs, long[] values, int[] sizes, long[] depClosures, + long[] depFieldIDs) { + validate(); + return rsnClosureCreate(mContext, kernelID, returnValue, fieldIDs, values, + sizes, depClosures, depFieldIDs); + } + + native long rsnInvokeClosureCreate(long con, long invokeID, byte[] params, + long[] fieldIDs, long[] values, int[] sizes); + synchronized long nInvokeClosureCreate(long invokeID, byte[] params, + long[] fieldIDs, long[] values, int[] sizes) { + validate(); + return rsnInvokeClosureCreate(mContext, invokeID, params, fieldIDs, + values, sizes); + } + + native void rsnClosureSetArg(long con, long closureID, int index, + long value, int size); + synchronized void nClosureSetArg(long closureID, int index, long value, + int size) { + validate(); + rsnClosureSetArg(mContext, closureID, index, value, size); + } + + native void rsnClosureSetGlobal(long con, long closureID, long fieldID, + long value, int size); + // Does this have to be synchronized? + synchronized void nClosureSetGlobal(long closureID, long fieldID, + long value, int size) { + validate(); // TODO: is this necessary? + rsnClosureSetGlobal(mContext, closureID, fieldID, value, size); + } + + native long rsnScriptGroup2Create(long con, String cachePath, long[] closures); + synchronized long nScriptGroup2Create(String cachePath, long[] closures) { + validate(); + return rsnScriptGroup2Create(mContext, cachePath, closures); + } + + native void rsnScriptGroup2Execute(long con, long groupID); + synchronized void nScriptGroup2Execute(long groupID) { + validate(); + rsnScriptGroup2Execute(mContext, groupID); + } + native void rsnAssignName(long con, long obj, byte[] name); synchronized void nAssignName(long obj, byte[] name) { validate(); @@ -436,16 +485,18 @@ public class RenderScript { } - native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt); - synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) { + native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt, + int mSize, boolean usePadding); + synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt, + int mSize, boolean usePadding) { validate(); - rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); + rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID, mSize, usePadding); } - native void rsnAllocationElementData1D(long con,long id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes); - synchronized void nAllocationElementData1D(long id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) { + native void rsnAllocationElementData(long con,long id, int xoff, int yoff, int zoff, int mip, int compIdx, byte[] d, int sizeBytes); + synchronized void nAllocationElementData(long id, int xoff, int yoff, int zoff, int mip, int compIdx, byte[] d, int sizeBytes) { validate(); - rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes); + rsnAllocationElementData(mContext, id, xoff, yoff, zoff, mip, compIdx, d, sizeBytes); } native void rsnAllocationData2D(long con, @@ -469,11 +520,13 @@ public class RenderScript { } native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, - int w, int h, Object d, int sizeBytes, int dt); + int w, int h, Object d, int sizeBytes, int dt, + int mSize, boolean usePadding); synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face, - int w, int h, Object d, int sizeBytes, Element.DataType dt) { + int w, int h, Object d, int sizeBytes, Element.DataType dt, + int mSize, boolean usePadding) { validate(); - rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); + rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID, mSize, usePadding); } native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, Bitmap b); @@ -501,33 +554,56 @@ public class RenderScript { } native void rsnAllocationData3D(long con, long id, int xoff, int yoff, int zoff, int mip, - int w, int h, int depth, Object d, int sizeBytes, int dt); + int w, int h, int depth, Object d, int sizeBytes, int dt, + int mSize, boolean usePadding); synchronized void nAllocationData3D(long id, int xoff, int yoff, int zoff, int mip, - int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) { + int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt, + int mSize, boolean usePadding) { validate(); - rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID); + rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, + dt.mID, mSize, usePadding); } - native void rsnAllocationRead(long con, long id, Object d, int dt); - synchronized void nAllocationRead(long id, Object d, Element.DataType dt) { + native void rsnAllocationRead(long con, long id, Object d, int dt, int mSize, boolean usePadding); + synchronized void nAllocationRead(long id, Object d, Element.DataType dt, int mSize, boolean usePadding) { validate(); - rsnAllocationRead(mContext, id, d, dt.mID); + rsnAllocationRead(mContext, id, d, dt.mID, mSize, usePadding); } native void rsnAllocationRead1D(long con, long id, int off, int mip, int count, Object d, - int sizeBytes, int dt); + int sizeBytes, int dt, int mSize, boolean usePadding); synchronized void nAllocationRead1D(long id, int off, int mip, int count, Object d, - int sizeBytes, Element.DataType dt) { + int sizeBytes, Element.DataType dt, int mSize, boolean usePadding) { validate(); - rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); + rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID, mSize, usePadding); + } + + native void rsnAllocationElementRead(long con,long id, int xoff, int yoff, int zoff, + int mip, int compIdx, byte[] d, int sizeBytes); + synchronized void nAllocationElementRead(long id, int xoff, int yoff, int zoff, + int mip, int compIdx, byte[] d, int sizeBytes) { + validate(); + rsnAllocationElementRead(mContext, id, xoff, yoff, zoff, mip, compIdx, d, sizeBytes); } native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face, - int w, int h, Object d, int sizeBytes, int dt); + int w, int h, Object d, int sizeBytes, int dt, + int mSize, boolean usePadding); synchronized void nAllocationRead2D(long id, int xoff, int yoff, int mip, int face, - int w, int h, Object d, int sizeBytes, Element.DataType dt) { + int w, int h, Object d, int sizeBytes, Element.DataType dt, + int mSize, boolean usePadding) { + validate(); + rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID, mSize, usePadding); + } + + native void rsnAllocationRead3D(long con, long id, int xoff, int yoff, int zoff, int mip, + int w, int h, int depth, Object d, int sizeBytes, int dt, + int mSize, boolean usePadding); + synchronized void nAllocationRead3D(long id, int xoff, int yoff, int zoff, int mip, + int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt, + int mSize, boolean usePadding) { validate(); - rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); + rsnAllocationRead3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID, mSize, usePadding); } native long rsnAllocationGetType(long con, long id); @@ -542,6 +618,20 @@ public class RenderScript { rsnAllocationResize1D(mContext, id, dimX); } + native long rsnAllocationAdapterCreate(long con, long allocId, long typeId); + synchronized long nAllocationAdapterCreate(long allocId, long typeId) { + validate(); + return rsnAllocationAdapterCreate(mContext, allocId, typeId); + } + + native void rsnAllocationAdapterOffset(long con, long id, int x, int y, int z, + int mip, int face, int a1, int a2, int a3, int a4); + synchronized void nAllocationAdapterOffset(long id, int x, int y, int z, + int mip, int face, int a1, int a2, int a3, int a4) { + validate(); + rsnAllocationAdapterOffset(mContext, id, x, y, z, mip, face, a1, a2, a3, a4); + } + native long rsnFileA3DCreateFromAssetStream(long con, long assetStream); synchronized long nFileA3DCreateFromAssetStream(long assetStream) { validate(); @@ -605,52 +695,14 @@ public class RenderScript { validate(); rsnScriptInvoke(mContext, id, slot); } - native void rsnScriptForEach(long con, long id, int slot, long ain, long aout, byte[] params); - native void rsnScriptForEach(long con, long id, int slot, long ain, long aout); - native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, byte[] params, - int xstart, int xend, int ystart, int yend, int zstart, int zend); - native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, - int xstart, int xend, int ystart, int yend, int zstart, int zend); - synchronized void nScriptForEach(long id, int slot, long ain, long aout, byte[] params) { - validate(); - if (params == null) { - rsnScriptForEach(mContext, id, slot, ain, aout); - } else { - rsnScriptForEach(mContext, id, slot, ain, aout, params); - } - } - synchronized void nScriptForEachClipped(long id, int slot, long ain, long aout, byte[] params, - int xstart, int xend, int ystart, int yend, int zstart, int zend) { - validate(); - if (params == null) { - rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend); - } else { - rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend); - } - } - - /** - * Multi-input code. - * - */ + native void rsnScriptForEach(long con, long id, int slot, long[] ains, + long aout, byte[] params, int[] limits); - // @hide - native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout, byte[] params, - int xstart, int xend, int ystart, int yend, int zstart, int zend); - // @hide - native void rsnScriptForEachMultiClipped(long con, long id, int slot, long[] ains, long aout, - int xstart, int xend, int ystart, int yend, int zstart, int zend); - - // @hide - synchronized void nScriptForEachMultiClipped(long id, int slot, long[] ains, long aout, byte[] params, - int xstart, int xend, int ystart, int yend, int zstart, int zend) { - validate(); - if (params == null) { - rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, xstart, xend, ystart, yend, zstart, zend); - } else { - rsnScriptForEachMultiClipped(mContext, id, slot, ains, aout, params, xstart, xend, ystart, yend, zstart, zend); - } + synchronized void nScriptForEach(long id, int slot, long[] ains, long aout, + byte[] params, int[] limits) { + validate(); + rsnScriptForEach(mContext, id, slot, ains, aout, params, limits); } native void rsnScriptInvokeV(long con, long id, int slot, byte[] params); @@ -743,6 +795,12 @@ public class RenderScript { return rsnScriptKernelIDCreate(mContext, sid, slot, sig); } + native long rsnScriptInvokeIDCreate(long con, long sid, int slot); + synchronized long nScriptInvokeIDCreate(long sid, int slot) { + validate(); + return rsnScriptInvokeIDCreate(mContext, sid, slot); + } + native long rsnScriptFieldIDCreate(long con, long sid, int slot); synchronized long nScriptFieldIDCreate(long sid, int slot) { validate(); @@ -850,14 +908,59 @@ public class RenderScript { rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); } - native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, long loop, float q); - synchronized long nPathCreate(int prim, boolean isStatic, long vtx, long loop, float q) { + native void rsnScriptIntrinsicBLAS_Single(long con, long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + float alpha, long A, long B, float beta, long C, int incX, int incY, + int KL, int KU); + synchronized void nScriptIntrinsicBLAS_Single(long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + float alpha, long A, long B, float beta, long C, int incX, int incY, + int KL, int KU) { + validate(); + rsnScriptIntrinsicBLAS_Single(mContext, id, func, TransA, TransB, Side, Uplo, Diag, M, N, K, alpha, A, B, beta, C, incX, incY, KL, KU); + } + + native void rsnScriptIntrinsicBLAS_Double(long con, long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + double alpha, long A, long B, double beta, long C, int incX, int incY, + int KL, int KU); + synchronized void nScriptIntrinsicBLAS_Double(long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + double alpha, long A, long B, double beta, long C, int incX, int incY, + int KL, int KU) { + validate(); + rsnScriptIntrinsicBLAS_Double(mContext, id, func, TransA, TransB, Side, Uplo, Diag, M, N, K, alpha, A, B, beta, C, incX, incY, KL, KU); + } + + native void rsnScriptIntrinsicBLAS_Complex(long con, long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + float alphaX, float alphaY, long A, long B, float betaX, float betaY, long C, int incX, int incY, + int KL, int KU); + synchronized void nScriptIntrinsicBLAS_Complex(long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + float alphaX, float alphaY, long A, long B, float betaX, float betaY, long C, int incX, int incY, + int KL, int KU) { validate(); - return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q); + rsnScriptIntrinsicBLAS_Complex(mContext, id, func, TransA, TransB, Side, Uplo, Diag, M, N, K, alphaX, alphaY, A, B, betaX, betaY, C, incX, incY, KL, KU); } + native void rsnScriptIntrinsicBLAS_Z(long con, long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + double alphaX, double alphaY, long A, long B, double betaX, double betaY, long C, int incX, int incY, + int KL, int KU); + synchronized void nScriptIntrinsicBLAS_Z(long id, int func, int TransA, + int TransB, int Side, int Uplo, int Diag, int M, int N, int K, + double alphaX, double alphaY, long A, long B, double betaX, double betaY, long C, int incX, int incY, + int KL, int KU) { + validate(); + rsnScriptIntrinsicBLAS_Z(mContext, id, func, TransA, TransB, Side, Uplo, Diag, M, N, K, alphaX, alphaY, A, B, betaX, betaY, C, incX, incY, KL, KU); + } + + long mDev; long mContext; + private boolean mDestroyed = false; + @SuppressWarnings({"FieldCanBeLocal"}) MessageThread mMessageThread; @@ -869,6 +972,7 @@ public class RenderScript { Element mElement_I32; Element mElement_U64; Element mElement_I64; + Element mElement_F16; Element mElement_F32; Element mElement_F64; Element mElement_BOOLEAN; @@ -892,6 +996,10 @@ public class RenderScript { Element mElement_RGBA_4444; Element mElement_RGBA_8888; + Element mElement_HALF_2; + Element mElement_HALF_3; + Element mElement_HALF_4; + Element mElement_FLOAT_2; Element mElement_FLOAT_3; Element mElement_FLOAT_4; @@ -1040,8 +1148,10 @@ public class RenderScript { * their priority to LOW to avoid starving forground processes. */ public enum Priority { - LOW (Process.THREAD_PRIORITY_BACKGROUND + (5 * Process.THREAD_PRIORITY_LESS_FAVORABLE)), - NORMAL (Process.THREAD_PRIORITY_DISPLAY); + // These values used to represent official thread priority values + // now they are simply enums to be used by the runtime side + LOW (15), + NORMAL (-8); int mID; Priority(int id) { @@ -1295,6 +1405,38 @@ public class RenderScript { nContextFinish(); } + private void helpDestroy() { + boolean shouldDestroy = false; + synchronized(this) { + if (!mDestroyed) { + shouldDestroy = true; + mDestroyed = true; + } + } + + if (shouldDestroy) { + nContextFinish(); + + nContextDeinitToClient(mContext); + mMessageThread.mRun = false; + try { + mMessageThread.join(); + } catch(InterruptedException e) { + } + + nContextDestroy(); + + nDeviceDestroy(mDev); + mDev = 0; + } + } + + protected void finalize() throws Throwable { + helpDestroy(); + super.finalize(); + } + + /** * Destroys this RenderScript context. Once this function is called, * using this context or any objects belonging to this context is @@ -1303,19 +1445,7 @@ public class RenderScript { */ public void destroy() { validate(); - nContextFinish(); - - nContextDeinitToClient(mContext); - mMessageThread.mRun = false; - try { - mMessageThread.join(); - } catch(InterruptedException e) { - } - - nContextDestroy(); - - nDeviceDestroy(mDev); - mDev = 0; + helpDestroy(); } boolean isAlive() { |