summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2011-06-14 11:13:19 -0700
committerAlex Sakhartchouk <alexst@google.com>2011-06-14 11:13:19 -0700
commit304b1f5497155bcf91e7b855cfab7a675e80bf26 (patch)
tree3a73f3855d29591f9b74f4967d594ec2476262b1 /libs
parentbd3e537980027f4502a13c204b3c7b9d10adad31 (diff)
downloadframeworks_base-304b1f5497155bcf91e7b855cfab7a675e80bf26.zip
frameworks_base-304b1f5497155bcf91e7b855cfab7a675e80bf26.tar.gz
frameworks_base-304b1f5497155bcf91e7b855cfab7a675e80bf26.tar.bz2
Allocation copy functions.
Change-Id: Idce6d44a4f4bb2e399284a40c0f90dc1bff912fd
Diffstat (limited to 'libs')
-rw-r--r--libs/rs/RenderScriptDefines.h12
-rw-r--r--libs/rs/driver/rsdAllocation.cpp26
-rw-r--r--libs/rs/driver/rsdAllocation.h21
-rw-r--r--libs/rs/driver/rsdCore.cpp3
-rw-r--r--libs/rs/driver/rsdRuntimeStubs.cpp23
-rw-r--r--libs/rs/rs.spec15
-rw-r--r--libs/rs/rsAllocation.cpp17
-rw-r--r--libs/rs/rsRuntime.h15
-rw-r--r--libs/rs/rsScriptC_Lib.cpp23
-rw-r--r--libs/rs/rs_hal.h21
-rw-r--r--libs/rs/scriptc/rs_graphics.rsh11
-rw-r--r--libs/rs/scriptc/rs_math.rsh52
-rw-r--r--libs/rs/scriptc/rs_types.rsh17
13 files changed, 250 insertions, 6 deletions
diff --git a/libs/rs/RenderScriptDefines.h b/libs/rs/RenderScriptDefines.h
index ee9645c..d092520 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 2e13e9d..8bfc185 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 d7385ce..7555c4a 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 01cc369..38f6895 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 9cbff95..bd8b3c3 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 87d764d..963a6e7 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 bff3660..f3e0c0a 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 6d45285..cb962a8 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 4ee0a3e..ec15bc0 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 7bb09bb..928dca5 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 d53bc95..9a8a4e6 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 6e3cfdb..584317e 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 d9f4b4b..536d1f0 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