diff options
author | 2011-06-14 11:13:19 -0700 | |
---|---|---|
committer | 2011-06-14 11:13:19 -0700 | |
commit | 304b1f5497155bcf91e7b855cfab7a675e80bf26 (patch) | |
tree | 3a73f3855d29591f9b74f4967d594ec2476262b1 | |
parent | bd3e537980027f4502a13c204b3c7b9d10adad31 (diff) |
Allocation copy functions.
Change-Id: Idce6d44a4f4bb2e399284a40c0f90dc1bff912fd
-rw-r--r-- | api/current.txt | 4 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 45 | ||||
-rw-r--r-- | graphics/java/android/renderscript/AllocationAdapter.java | 48 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 20 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 27 | ||||
-rw-r--r-- | libs/rs/RenderScriptDefines.h | 12 | ||||
-rw-r--r-- | libs/rs/driver/rsdAllocation.cpp | 26 | ||||
-rw-r--r-- | libs/rs/driver/rsdAllocation.h | 21 | ||||
-rw-r--r-- | libs/rs/driver/rsdCore.cpp | 3 | ||||
-rw-r--r-- | libs/rs/driver/rsdRuntimeStubs.cpp | 23 | ||||
-rw-r--r-- | libs/rs/rs.spec | 15 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 17 | ||||
-rw-r--r-- | libs/rs/rsRuntime.h | 15 | ||||
-rw-r--r-- | libs/rs/rsScriptC_Lib.cpp | 23 | ||||
-rw-r--r-- | libs/rs/rs_hal.h | 21 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_graphics.rsh | 11 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_math.rsh | 52 | ||||
-rw-r--r-- | libs/rs/scriptc/rs_types.rsh | 17 |
18 files changed, 386 insertions, 14 deletions
diff --git a/api/current.txt b/api/current.txt index 89654b8e6257..22211e2c17cb 100644 --- a/api/current.txt +++ b/api/current.txt @@ -16495,6 +16495,7 @@ package android.renderscript { method public void copy1DRangeFrom(int, int, short[]); method public void copy1DRangeFrom(int, int, byte[]); method public void copy1DRangeFrom(int, int, float[]); + method public void copy1DRangeFrom(int, int, android.renderscript.Allocation, int); method public void copy1DRangeFromUnchecked(int, int, int[]); method public void copy1DRangeFromUnchecked(int, int, short[]); method public void copy1DRangeFromUnchecked(int, int, byte[]); @@ -16503,6 +16504,7 @@ package android.renderscript { method public void copy2DRangeFrom(int, int, int, int, short[]); method public void copy2DRangeFrom(int, int, int, int, int[]); method public void copy2DRangeFrom(int, int, int, int, float[]); + method public void copy2DRangeFrom(int, int, int, int, android.renderscript.Allocation, int, int); method public void copy2DRangeFrom(int, int, android.graphics.Bitmap); method public void copyFrom(android.renderscript.BaseObj[]); method public void copyFrom(int[]); @@ -16567,8 +16569,10 @@ package android.renderscript { method public void subData1D(int, int, short[]); method public void subData1D(int, int, byte[]); method public void subData1D(int, int, float[]); + method public void subData1D(int, int, android.renderscript.AllocationAdapter, int); method public void subData2D(int, int, int, int, int[]); method public void subData2D(int, int, int, int, float[]); + method public void subData2D(int, int, int, int, android.renderscript.AllocationAdapter, int, int); method public void subElementData(int, int, android.renderscript.FieldPacker); } diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 3c8aba36563a..a63abb9f9bc7 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -588,13 +588,29 @@ public class Allocation extends BaseObj { * * @param off The offset of the first element to be copied. * @param count The number of elements to be copied. - * @param d the source data array + * @param d the source data array. */ public void copy1DRangeFrom(int off, int count, float[] d) { validateIsFloat32(); copy1DRangeFromUnchecked(off, count, d); } + /** + * Copy part of an allocation from another allocation. + * + * @param off The offset of the first element to be copied. + * @param count The number of elements to be copied. + * @param data the source data allocation. + * @param dataOff off The offset of the first element in data to + * be copied. + */ + public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) { + mRS.nAllocationData2D(getID(), off, 0, + 0, Type.CubemapFace.POSITVE_X.mID, + count, 1, data.getID(), dataOff, 0, + 0, Type.CubemapFace.POSITVE_X.mID); + } + private void validate2DRange(int xoff, int yoff, int w, int h) { if (xoff < 0 || yoff < 0) { throw new RSIllegalArgumentException("Offset cannot be negative."); @@ -609,9 +625,8 @@ public class Allocation extends BaseObj { } /** - * Copy a rectanglular region from the array into the - * allocation. The incoming array is assumed to be tightly - * packed. + * Copy a rectangular region from the array into the allocation. + * The incoming array is assumed to be tightly packed. * * @param xoff X offset of the region to update * @param yoff Y offset of the region to update @@ -644,6 +659,28 @@ public class Allocation extends BaseObj { } /** + * Copy a rectangular region into the allocation from another + * allocation. + * + * @param xoff X offset of the region to update. + * @param yoff Y offset of the region to update. + * @param w Width of the incoming region to update. + * @param h Height of the incoming region to update. + * @param data source allocation. + * @param dataXoff X offset in data of the region to update. + * @param dataYoff Y offset in data of the region to update. + */ + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, + Allocation data, int dataXoff, int dataYoff) { + mRS.validate(); + validate2DRange(xoff, yoff, w, h); + mRS.nAllocationData2D(getID(), xoff, yoff, + 0, Type.CubemapFace.POSITVE_X.mID, + w, h, data.getID(), dataXoff, dataYoff, + 0, Type.CubemapFace.POSITVE_X.mID); + } + + /** * Copy a bitmap into an allocation. The height and width of * the update will use the height and width of the incoming * bitmap. diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java index f2fedea3a530..07a1f5ddc423 100644 --- a/graphics/java/android/renderscript/AllocationAdapter.java +++ b/graphics/java/android/renderscript/AllocationAdapter.java @@ -33,7 +33,7 @@ public class AllocationAdapter extends Allocation { private Allocation mAlloc; private int mSelectedLOD = 0; - private Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITVE_X;; + private Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITVE_X; AllocationAdapter(int id, RenderScript rs, Allocation alloc) { super(id, rs, null, alloc.mUsage); @@ -163,15 +163,54 @@ public class AllocationAdapter extends Allocation { mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize); } + /** + * Copy part of an allocation from another allocation. + * + * @param off The offset of the first element to be copied. + * @param count The number of elements to be copied. + * @param data the source data allocation. + * @param dataOff off The offset of the first element in data to + * be copied. + */ + public void subData1D(int off, int count, AllocationAdapter data, int dataOff) { + mRS.nAllocationData2D(getID(), off, 0, + mSelectedLOD, mSelectedFace.mID, + count, 1, data.getID(), dataOff, 0, + data.mSelectedLOD, data.mSelectedFace.mID); + } + public void subData2D(int xoff, int yoff, int w, int h, int[] d) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, + w, h, d, d.length * 4); } public void subData2D(int xoff, int yoff, int w, int h, float[] d) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, + w, h, d, d.length * 4); + } + + /** + * Copy a rectangular region into the allocation from another + * allocation. + * + * @param xoff X offset of the region to update. + * @param yoff Y offset of the region to update. + * @param w Width of the incoming region to update. + * @param h Height of the incoming region to update. + * @param data source allocation. + * @param dataXoff X offset in data of the region to update. + * @param dataYoff Y offset in data of the region to update. + */ + public void subData2D(int xoff, int yoff, int w, int h, + AllocationAdapter data, int dataXoff, int dataYoff) { + mRS.validate(); + mRS.nAllocationData2D(getID(), xoff, yoff, + mSelectedLOD, mSelectedFace.mID, + w, h, data.getID(), dataXoff, dataYoff, + data.mSelectedLOD, data.mSelectedFace.mID); } public void readData(int[] d) { @@ -185,12 +224,15 @@ public class AllocationAdapter extends Allocation { } public void setLOD(int lod) { + mSelectedLOD = lod; } public void setFace(Type.CubemapFace cf) { + mSelectedFace = cf; } public void setY(int y) { + mSelectedDimY = y; } public void setZ(int z) { diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 17f0fa649527..2110e37582ae 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -295,6 +295,26 @@ public class RenderScript { rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes); } + native void rsnAllocationData2D(int con, + int dstAlloc, int dstXoff, int dstYoff, + int dstMip, int dstFace, + int width, int height, + int srcAlloc, int srcXoff, int srcYoff, + int srcMip, int srcFace); + synchronized void nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff, + int dstMip, int dstFace, + int width, int height, + int srcAlloc, int srcXoff, int srcYoff, + int srcMip, int srcFace) { + validate(); + rsnAllocationData2D(mContext, + dstAlloc, dstXoff, dstYoff, + dstMip, dstFace, + width, height, + srcAlloc, srcXoff, srcYoff, + srcMip, srcFace); + } + native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes); synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) { validate(); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 60b39b01162a..7e53cc4df237 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -468,7 +468,7 @@ nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, - 0, RS_ALLOCATION_CUBMAP_FACE_POSITVE_X, + 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, w, h, ptr, bitmap.getSize()); bitmap.unlockPixels(); } @@ -589,6 +589,30 @@ nAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint } static void +nAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con, + jint dstAlloc, jint dstXoff, jint dstYoff, + jint dstMip, jint dstFace, + jint width, jint height, + jint srcAlloc, jint srcXoff, jint srcYoff, + jint srcMip, jint srcFace) +{ + LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff, dstYoff," + " dstMip(%i), dstFace(%i), width(%i), height(%i)," + " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", + con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, + width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); + + rsAllocationCopy2DRange(con, + (RsAllocation)dstAlloc, + dstXoff, dstYoff, + dstMip, dstFace, + width, height, + (RsAllocation)srcAlloc, + srcXoff, srcYoff, + srcMip, srcFace); +} + +static void nAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data) { jint len = _env->GetArrayLength(data); @@ -1217,6 +1241,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s }, {"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b }, {"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, +{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc }, {"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, {"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s }, {"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b }, diff --git a/libs/rs/RenderScriptDefines.h b/libs/rs/RenderScriptDefines.h index ee9645c37bcd..d092520feb81 100644 --- a/libs/rs/RenderScriptDefines.h +++ b/libs/rs/RenderScriptDefines.h @@ -110,12 +110,12 @@ enum RsAllocationMipmapControl { }; enum RsAllocationCubemapFace { - RS_ALLOCATION_CUBMAP_FACE_POSITVE_X = 0, - RS_ALLOCATION_CUBMAP_FACE_NEGATIVE_X = 1, - RS_ALLOCATION_CUBMAP_FACE_POSITVE_Y = 2, - RS_ALLOCATION_CUBMAP_FACE_NEGATIVE_Y = 3, - RS_ALLOCATION_CUBMAP_FACE_POSITVE_Z = 4, - RS_ALLOCATION_CUBMAP_FACE_NEGATIVE_Z = 5 + RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0, + RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1, + RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2, + RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3, + RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4, + RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5 }; enum RsDataType { diff --git a/libs/rs/driver/rsdAllocation.cpp b/libs/rs/driver/rsdAllocation.cpp index 2e13e9d0b5a0..8bfc1857d4bf 100644 --- a/libs/rs/driver/rsdAllocation.cpp +++ b/libs/rs/driver/rsdAllocation.cpp @@ -378,6 +378,32 @@ void rsdAllocationData3D(const Context *rsc, const Allocation *alloc, } +void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, + const android::renderscript::Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstLod, uint32_t count, + const android::renderscript::Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcLod){ +} + +void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, + const android::renderscript::Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, + RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, + const android::renderscript::Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, + RsAllocationCubemapFace srcFace) { +} + +void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, + const android::renderscript::Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, + uint32_t dstLod, RsAllocationCubemapFace dstFace, + uint32_t w, uint32_t h, uint32_t d, + const android::renderscript::Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, + uint32_t srcLod, RsAllocationCubemapFace srcFace) { +} + void rsdAllocationElementData1D(const Context *rsc, const Allocation *alloc, uint32_t x, const void *data, uint32_t cIdx, uint32_t sizeBytes) { diff --git a/libs/rs/driver/rsdAllocation.h b/libs/rs/driver/rsdAllocation.h index d7385cee64cf..7555c4ab0711 100644 --- a/libs/rs/driver/rsdAllocation.h +++ b/libs/rs/driver/rsdAllocation.h @@ -80,6 +80,27 @@ void rsdAllocationData3D(const android::renderscript::Context *rsc, uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); +void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, + const android::renderscript::Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstLod, uint32_t count, + const android::renderscript::Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcLod); +void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, + const android::renderscript::Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, + RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, + const android::renderscript::Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, + RsAllocationCubemapFace srcFace); +void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, + const android::renderscript::Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, + uint32_t dstLod, RsAllocationCubemapFace dstFace, + uint32_t w, uint32_t h, uint32_t d, + const android::renderscript::Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, + uint32_t srcLod, RsAllocationCubemapFace srcFace); + void rsdAllocationElementData1D(const android::renderscript::Context *rsc, const android::renderscript::Allocation *alloc, uint32_t x, diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp index 01cc369a8e01..38f6895f26fd 100644 --- a/libs/rs/driver/rsdCore.cpp +++ b/libs/rs/driver/rsdCore.cpp @@ -74,6 +74,9 @@ static RsdHalFunctions FunctionTable = { rsdAllocationData1D, rsdAllocationData2D, rsdAllocationData3D, + rsdAllocationData1D_alloc, + rsdAllocationData2D_alloc, + rsdAllocationData3D_alloc, rsdAllocationElementData1D, rsdAllocationElementData2D }, diff --git a/libs/rs/driver/rsdRuntimeStubs.cpp b/libs/rs/driver/rsdRuntimeStubs.cpp index 9cbff9526b16..bd8b3c325dce 100644 --- a/libs/rs/driver/rsdRuntimeStubs.cpp +++ b/libs/rs/driver/rsdRuntimeStubs.cpp @@ -88,6 +88,26 @@ static void SC_AllocationSyncAll(Allocation *a) { rsrAllocationSyncAll(rsc, sc, a, RS_ALLOCATION_USAGE_SCRIPT); } +static void SC_AllocationCopy1DRange(Allocation *dstAlloc, + uint32_t dstOff, + uint32_t dstMip, + uint32_t count, + Allocation *srcAlloc, + uint32_t srcOff, uint32_t srcMip) { + GET_TLS(); +} + +static void SC_AllocationCopy2DRange(Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, + uint32_t dstMip, uint32_t dstFace, + uint32_t width, uint32_t height, + Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, + uint32_t srcMip, uint32_t srcFace) { + GET_TLS(); +} + + const Allocation * SC_getAllocation(const void *ptr) { GET_TLS(); return rsrGetAllocation(rsc, sc, ptr); @@ -566,8 +586,11 @@ static RsdSymbolTable gSyms[] = { { "_Z21rsAllocationMarkDirty13rs_allocation", (void *)&SC_AllocationSyncAll, true }, { "_Z20rsgAllocationSyncAll13rs_allocation", (void *)&SC_AllocationSyncAll, false }, { "_Z20rsgAllocationSyncAll13rs_allocationj", (void *)&SC_AllocationSyncAll2, false }, + { "_Z20rsgAllocationSyncAll13rs_allocation24rs_allocation_usage_type", (void *)&SC_AllocationSyncAll2, false }, { "_Z15rsGetAllocationPKv", (void *)&SC_GetAllocation, true }, + { "_Z23rsAllocationCopy1DRange13rs_allocationjjjS_jj", (void *)&SC_AllocationCopy1DRange, false }, + { "_Z23rsAllocationCopy2DRange13rs_allocationjjj26rs_allocation_cubemap_facejjS_jjjS0_", (void *)&SC_AllocationCopy2DRange, false }, // Messaging diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 87d764d2f006..963a6e78dc29 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -209,6 +209,21 @@ AllocationResize2D { param uint32_t dimY } +AllocationCopy2DRange { + param RsAllocation dest + param uint32_t destXoff + param uint32_t destYoff + param uint32_t destMip + param uint32_t destFace + param uint32_t width + param uint32_t height + param RsAllocation src + param uint32_t srcXoff + param uint32_t srcYoff + param uint32_t srcMip + param uint32_t srcFace + } + SamplerCreate { param RsSamplerValue magFilter param RsSamplerValue minFilter diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index bff36603e9d9..f3e0c0a75291 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -532,6 +532,23 @@ RsAllocation rsi_AllocationCubeCreateFromBitmap(Context *rsc, RsType vtype, return texAlloc; } +void rsi_AllocationCopy2DRange(Context *rsc, + RsAllocation dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, + uint32_t dstMip, uint32_t dstFace, + uint32_t width, uint32_t height, + RsAllocation srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, + uint32_t srcMip, uint32_t srcFace) { + Allocation *dst = static_cast<Allocation *>(dstAlloc); + Allocation *src= static_cast<Allocation *>(srcAlloc); + rsc->mHal.funcs.allocation.allocData2D(rsc, dst, dstXoff, dstYoff, dstMip, + (RsAllocationCubemapFace)dstFace, + width, height, + src, srcXoff, srcYoff,srcMip, + (RsAllocationCubemapFace)srcFace); +} + } } diff --git a/libs/rs/rsRuntime.h b/libs/rs/rsRuntime.h index 6d45285e6d9f..cb962a815dc3 100644 --- a/libs/rs/rsRuntime.h +++ b/libs/rs/rsRuntime.h @@ -85,6 +85,21 @@ void rsrMeshComputeBoundingBox(Context *, Script *, Mesh *, void rsrColor(Context *, Script *, float r, float g, float b, float a); void rsrFinish(Context *, Script *); void rsrAllocationSyncAll(Context *, Script *, Allocation *); + +void rsrAllocationCopy1DRange(Context *, Allocation *dstAlloc, + uint32_t dstOff, + uint32_t dstMip, + uint32_t count, + Allocation *srcAlloc, + uint32_t srcOff, uint32_t srcMip); +void rsrAllocationCopy2DRange(Context *, Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, + uint32_t dstMip, uint32_t dstFace, + uint32_t width, uint32_t height, + Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, + uint32_t srcMip, uint32_t srcFace); + void rsrClearColor(Context *, Script *, float r, float g, float b, float a); void rsrClearDepth(Context *, Script *, float v); uint32_t rsrGetWidth(Context *, Script *); diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp index 4ee0a3ec4e5e..ec15bc0233a5 100644 --- a/libs/rs/rsScriptC_Lib.cpp +++ b/libs/rs/rsScriptC_Lib.cpp @@ -164,6 +164,29 @@ void rsrAllocationSyncAll(Context *rsc, Script *sc, Allocation *a, RsAllocationU a->syncAll(rsc, usage); } +void rsrAllocationCopy1DRange(Context *rsc, Allocation *dstAlloc, + uint32_t dstOff, + uint32_t dstMip, + uint32_t count, + Allocation *srcAlloc, + uint32_t srcOff, uint32_t srcMip) { + rsi_AllocationCopy2DRange(rsc, dstAlloc, dstOff, 0, + dstMip, 0, count, 1, + srcAlloc, srcOff, 0, srcMip, 0); +} + +void rsrAllocationCopy2DRange(Context *rsc, Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, + uint32_t dstMip, uint32_t dstFace, + uint32_t width, uint32_t height, + Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, + uint32_t srcMip, uint32_t srcFace) { + rsi_AllocationCopy2DRange(rsc, dstAlloc, dstXoff, dstYoff, + dstMip, dstFace, width, height, + srcAlloc, srcXoff, srcYoff, srcMip, srcFace); +} + const Allocation * rsrGetAllocation(Context *rsc, Script *s, const void *ptr) { ScriptC *sc = (ScriptC *)s; return sc->ptrToAllocation(ptr); diff --git a/libs/rs/rs_hal.h b/libs/rs/rs_hal.h index 7bb09bbf5597..928dca5376ed 100644 --- a/libs/rs/rs_hal.h +++ b/libs/rs/rs_hal.h @@ -112,6 +112,27 @@ typedef struct { uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); + // Allocation to allocation copies + void (*allocData1D)(const Context *rsc, + const Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstLod, uint32_t count, + const Allocation *srcAlloc, uint32_t srcXoff, uint32_t srcLod); + void (*allocData2D)(const Context *rsc, + const Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, + RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, + const Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, + RsAllocationCubemapFace srcFace); + void (*allocData3D)(const Context *rsc, + const Allocation *dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, + uint32_t dstLod, RsAllocationCubemapFace dstFace, + uint32_t w, uint32_t h, uint32_t d, + const Allocation *srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, + uint32_t srcLod, RsAllocationCubemapFace srcFace); + void (*elementData1D)(const Context *rsc, const Allocation *alloc, uint32_t x, const void *data, uint32_t elementOff, uint32_t sizeBytes); void (*elementData2D)(const Context *rsc, const Allocation *alloc, uint32_t x, uint32_t y, diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh index d53bc952ded5..9a8a4e66a03d 100644 --- a/libs/rs/scriptc/rs_graphics.rsh +++ b/libs/rs/scriptc/rs_graphics.rsh @@ -144,6 +144,17 @@ extern void __attribute__((overloadable)) rsgAllocationSyncAll(rs_allocation alloc); /** + * Sync the contents of an allocation from memory space + * specified by source. + * + * @param alloc + * @param source + */ +extern void __attribute__((overloadable)) + rsgAllocationSyncAll(rs_allocation alloc, + rs_allocation_usage_type source); + +/** * Low performance utility function for drawing a simple rectangle. Not * intended for drawing large quantities of geometry. * diff --git a/libs/rs/scriptc/rs_math.rsh b/libs/rs/scriptc/rs_math.rsh index 6e3cfdb77529..584317e0476c 100644 --- a/libs/rs/scriptc/rs_math.rsh +++ b/libs/rs/scriptc/rs_math.rsh @@ -136,6 +136,58 @@ extern uint32_t __attribute__((overloadable)) extern uint32_t __attribute__((overloadable)) rsAllocationGetDimFaces(rs_allocation); +/** + * Copy part of an allocation from another allocation. + * + * @param dstAlloc Allocation to copy data into. + * @param dstOff The offset of the first element to be copied in + * the destination allocation. + * @param dstMip Mip level in the destination allocation. + * @param count The number of elements to be copied. + * @param srcAlloc The source data allocation. + * @param srcOff The offset of the first element in data to be + * copied in the source allocation. + * @param srcMip Mip level in the source allocation. + */ +extern void __attribute__((overloadable)) + rsAllocationCopy1DRange(rs_allocation dstAlloc, + uint32_t dstOff, uint32_t dstMip, + uint32_t count, + rs_allocation srcAlloc, + uint32_t srcOff, uint32_t srcMip); + +/** + * Copy a rectangular region into the allocation from another + * allocation. + * + * @param dstAlloc allocation to copy data into. + * @param dstXoff X offset of the region to update in the + * destination allocation. + * @param dstYoff Y offset of the region to update in the + * destination allocation. + * @param dstMip Mip level in the destination allocation. + * @param dstFace Cubemap face of the destination allocation, + * ignored for allocations that aren't cubemaps. + * @param width Width of the incoming region to update. + * @param height Height of the incoming region to update. + * @param srcAlloc The source data allocation. + * @param srcXoff X offset in data of the source allocation. + * @param srcYoff Y offset in data of the source allocation. + * @param srcMip Mip level in the source allocation. + * @param srcFace Cubemap face of the source allocation, + * ignored for allocations that aren't cubemaps. + */ +extern void __attribute__((overloadable)) + rsAllocationCopy2DRange(rs_allocation dstAlloc, + uint32_t dstXoff, uint32_t dstYoff, + uint32_t dstMip, + rs_allocation_cubemap_face dstFace, + uint32_t width, uint32_t height, + rs_allocation srcAlloc, + uint32_t srcXoff, uint32_t srcYoff, + uint32_t srcMip, + rs_allocation_cubemap_face srcFace); + // Extract a single element from an allocation. extern const void * __attribute__((overloadable)) rsGetElementAt(rs_allocation, uint32_t x); diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh index d9f4b4b9b948..536d1f04da48 100644 --- a/libs/rs/scriptc/rs_types.rsh +++ b/libs/rs/scriptc/rs_types.rsh @@ -88,4 +88,21 @@ typedef float4 rs_quaternion; #define RS_PACKED __attribute__((packed, aligned(4))) +typedef enum { + RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X = 0, + RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_X = 1, + RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Y = 2, + RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Y = 3, + RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_Z = 4, + RS_ALLOCATION_CUBEMAP_FACE_NEGATIVE_Z = 5 +} rs_allocation_cubemap_face; + +typedef enum { + RS_ALLOCATION_USAGE_SCRIPT = 0x0001, + RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE = 0x0002, + RS_ALLOCATION_USAGE_GRAPHICS_VERTEX = 0x0004, + RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS = 0x0008, + RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET = 0x0010 +} rs_allocation_usage_type; + #endif |