diff --git a/docs/html/guide/topics/renderscript/reference/rs_allocation_create.jd b/docs/html/guide/topics/renderscript/reference/rs_allocation_create.jd new file mode 100644 index 0000000000000..2defca3d32d56 --- /dev/null +++ b/docs/html/guide/topics/renderscript/reference/rs_allocation_create.jd @@ -0,0 +1,1060 @@ +page.title=RenderScript Allocation Creation Functions + +@jd:body + +
+

Overview

+

The functions below are used to create allocations from within a script. +These functions can be called directly or indirectly from an invokable +function. It is an error if any control flow can result in calling these functions +from a RenderScript kernel function. +

+

Summary

+ + + + + + + + + + + + + + + + + + + + + + +
Functions
+ rsCreateAllocation + + Creates an rs_allocation object of given rs_type +
+ rsCreateElement + + Creates an rs_element object of the specified data type +
+ rsCreatePixelElement + + Creates an rs_element object of the specified data type and data kind +
+ rsCreateType + + Creates an rs_type object with the specified rs_element and shape attributes +
+ rsCreateVectorElement + + Creates an rs_element object of the specified data type and vector width +
+

Functions

+ +
+

+ rsCreateAllocation + : Creates an rs_allocation object of given rs_type +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
rs_allocation rsCreateAllocation(rs_type type); + Added in API level 24 +
rs_allocation rsCreateAllocation(rs_type type, uint32_t usage); + Added in API level 24 +
rs_allocation rsCreateAllocation_char(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_char(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_char(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_char2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_char2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_char2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_char3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_char3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_char3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_char4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_char4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_char4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_double(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_double(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_double(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_double2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_double2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_double2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_double3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_double3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_double3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_double4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_double4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_double4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_float(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_float(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_float(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_float2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_float2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_float2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_float3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_float3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_float3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_float4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_float4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_float4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_half(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_half(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_half(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_half2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_half2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_half2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_half3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_half3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_half3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_half4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_half4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_half4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_int(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_int(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_int(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_int2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_int2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_int2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_int3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_int3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_int3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_int4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_int4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_int4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_long(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_long(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_long(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_long2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_long2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_long2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_long3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_long3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_long3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_long4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_long4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_long4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_short(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_short(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_short(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_short2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_short2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_short2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_short3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_short3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_short3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_short4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_short4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_short4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uchar4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_uint4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ulong4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort2(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort2(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort2(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort3(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort3(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort3(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort4(uint32_t dimX); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort4(uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_allocation rsCreateAllocation_ushort4(uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
+
+
Parameters
+ + + + + + + +
typeType of the allocation
usageHow the allocation should be used. A valid value is either of the following or their combination:
RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE,
RS_ALLOCATION_USAGE_SCRIPT.
mipmapA boolean flag indicating if the allocation is mipmapped and has multiple levels of detail (LoD).
dimXSize on dimension x. Must be non zero.
dimYSize on dimension y. 0 for single-dimension allocations.
dimZSize on dimension z. 0 for single-dimension and two-dimension allocations.
+
+
+

Creates an rs_allocation object of the given rs_type and for the specified usages. +

+ +

RS_ALLOCATION_USAGE_SCRIPT and RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE are the + only supported usage flags for Allocations created from within a RenderScript + script. +

+ +

You can also use rsCreateAllocation_ wrapper functions to directly + create allocations of scalar and vector numerical types without creating + intermediate rs_element or rs_type objects. +

+ +

For example, rsCreateAllocation_int4() returns an Allocation of int4 data type of + specified dimensions. +

+
+
+ + +
+

+ rsCreateElement + : Creates an rs_element object of the specified data type +

+
+ + + + + +
rs_element rsCreateElement(rs_data_type data_type); + Added in API level 24 +
+
+
Parameters
+ + +
data_typeData type of the Element
+
+
+

Creates an rs_element object of the specified data type. The data kind of + the element will be set to RS_KIND_USER and vector width will be set to 1, + indicating non-vector. +

+
+
+ + +
+

+ rsCreatePixelElement + : Creates an rs_element object of the specified data type and data kind +

+
+ + + + + +
rs_element rsCreatePixelElement(rs_data_type data_type, rs_data_kind data_kind); + Added in API level 24 +
+
+
Parameters
+ + + +
data_typeData type of the Element
data_kindData kind of the Element
+
+
+

Creates an rs_element object of the specified data type and data kind. The + vector width of the rs_element object will be set to 1, indicating non-vector. +

+
+
+ + +
+

+ rsCreateType + : Creates an rs_type object with the specified rs_element and shape attributes +

+
+ + + + + + + + + + + + + + + + + +
rs_type rsCreateType(rs_element element, uint32_t dimX); + Added in API level 24 +
rs_type rsCreateType(rs_element element, uint32_t dimX, uint32_t dimY); + Added in API level 24 +
rs_type rsCreateType(rs_element element, uint32_t dimX, uint32_t dimY, uint32_t dimZ); + Added in API level 24 +
rs_type rsCreateType(rs_element element, uint32_t dimX, uint32_t dimY, uint32_t dimZ, bool mipmaps, bool faces, rs_yuv_format yuv_format); + Added in API level 24 +
+
+
Parameters
+ + + + + + + + +
elementAn rs_element object that specifies the cell data type of an allocation.
dimXSize on dimension x. Must be non zero.
dimYSize on dimension y. 0 for single-dimension allocations.
dimZSize on dimension z. 0 for single-dimension and two-dimension allocations.
mipmapsA boolean flag indicating if the allocation is mipmapped and has multiple levels of detail (LoD).
facesA boolean flag indicating if the allocation is a cubemap that has cube faces.
yuv_formatTye YUV layout.
+
+
+

Creates an rs_type object with the specified element and shape attributes. +

+ +

dimX specifies the size of the X dimension. +

+ +

dimY, if present and non-zero, indicates that the Y dimension is present and + indicates its size. +

+ +

dimZ, if present and non-zero, indicates that the Z dimension is present and + indicates its size. +

+ +

mipmaps indicates the presence of level of detail (LOD). +

+ +

faces indicates the presence of cubemap faces. +

+ +

yuv_format indicates the associated YUV format (or RS_YUV_NONE). +

+
+
+ + +
+

+ rsCreateVectorElement + : Creates an rs_element object of the specified data type and vector width +

+
+ + + + + +
rs_element rsCreateVectorElement(rs_data_type data_type, uint32_t vector_width); + Added in API level 24 +
+
+
Parameters
+ + + +
data_typeData type of the Element
vector_widthVector width
+
+
+

Creates an rs_element object of the specified data type and vector width. + Value of vector_width must be 2, 3 or 4. The data kind of the rs_element object will + be set to RS_KIND_USER. +

+
+
+ +
diff --git a/docs/html/guide/topics/renderscript/reference/rs_for_each.jd b/docs/html/guide/topics/renderscript/reference/rs_for_each.jd index 9ba56149f1425..8b19ba6e7542b 100644 --- a/docs/html/guide/topics/renderscript/reference/rs_for_each.jd +++ b/docs/html/guide/topics/renderscript/reference/rs_for_each.jd @@ -1,10 +1,10 @@ -page.title=RenderScript Kernel Invocation Functions and Types +page.title=RenderScript Kernel Launch Functions and Types @jd:body

Overview

-

The rsForEach() function can be used to invoke the root kernel of a script. +

The rsForEach() and rsForEachWithOptions() functions are used to launch foreach kernels.

The other functions are used to get the characteristics of the invocation of @@ -22,6 +22,14 @@ a rs_kernel_context Suggested cell processing order + + + rs_kernel + + + Handle to a kernel function + + rs_kernel_context @@ -46,7 +54,15 @@ a rs_kernel_context rsForEach - Invoke the root kernel of a script + Launches a kernel + + + + + rsForEachWithOptions + + + Launches a kernel with options @@ -198,6 +214,21 @@ locality when the processing is distributed over multiple cores.

+ +
+

+ rs_kernel + : Handle to a kernel function +

+
+

A typedef of: void*     Added in API level 24 +

+

An opaque type for a function that is defined with the kernel attribute. A value + of this type can be used in a rsForEach call to launch a kernel. +

+
+
+

@@ -249,7 +280,7 @@ versions, it will also be used to provide hint on how to best iterate over the cells.

-

The Start fields are inclusive and the End fields are exclusive. E.g. to iterate +

The Start fields are inclusive and the End fields are exclusive. For example, to iterate over cells 4, 5, 6, and 7 in the X dimension, set xStart to 4 and xEnd to 8.

@@ -260,14 +291,20 @@ over cells 4, 5, 6, and 7 in the X dimension, set xStart to 4 and xEnd to 8.

rsForEach - : Invoke the root kernel of a script + : Launches a kernel

+ + + + - @@ -300,35 +337,89 @@ over cells 4, 5, 6, and 7 in the X dimension, set xStart to 4 and xEnd to 8.
void rsForEach(rs_kernel kernel, ... ...); + Added in API level 24 +
void rsForEach(rs_script script, rs_allocation input, rs_allocation output); Added in API level 14 + API level 14 - 23
- + + +
scriptScript to call.
inputAllocation to source data from.
outputAllocation to write date into.
outputAllocation to write data into.
usrDataUser defined data to pass to the script. May be NULL.
scExtra control information used to select a sub-region of the allocation to be processed or suggest a walking strategy. May be NULL.
usrDataLenSize of the userData structure. This will be used to perform a shallow copy of the data if necessary.
kernelFunction designator of the kernel function to call, which must be defined with the kernel attribute.
...Input and output allocations
-

Invoke the kernel named "root" of the specified script. Like other kernels, this root() -function will be invoked repeatedly over the cells of the specificed allocation, filling -the output allocation with the results. +

Runs the kernel over zero or more input allocations. They are passed after the +rs_kernel argument. If the specified kernel returns a value, an output allocation +must be specified as the last argument. All input allocations, +and the output allocation if it exists, must have the same dimensions.

-

When rsForEach is called, the root script is launched immediately. rsForEach returns -only when the script has completed and the output allocation is ready to use. +

This is a synchronous function. A call to this function only returns after all +the work has completed. If the kernel +function returns any value, the call waits until all results have been written +to the output allocation.

-

The rs_script argument is typically initialized using a global variable set from Java. +

Up to API level 23, the kernel is implicitly specified as the kernel named +"root" in the specified script, and only a single input allocation can be used. +Starting in API level 24, an arbitrary kernel function can be used, +as specified by the kernel argument. +The kernel must be defined in the current script. In addition, more than one +input can be used.

-

The kernel can be invoked with just an input allocation or just an output allocation. -This can be done by defining an rs_allocation variable and not initializing it. E.g.
-rs_script gCustomScript;
-void specializedProcessing(rs_allocation in) {
-  rs_allocation ignoredOut;
-  rsForEach(gCustomScript, in, ignoredOut);
-}
+

For example,
+float __attribute__((kernel)) square(float a) {
+  return a * a;
+}
+
+void compute(rs_allocation ain, rs_allocation aout) {
+  rsForEach(square, ain, aout);
+}
+
+

+
+
+ + +
+

+ rsForEachWithOptions + : Launches a kernel with options +

+
+ + + + + +
void rsForEachWithOptions(rs_kernel kernel, rs_script_call_t* options, ... ...); + Added in API level 24 +
+
+
Parameters
+ + + + +
kernelFunction designator to a function that is defined with the kernel attribute.
optionsLaunch options
...Input and output allocations
+
+
+

Launches kernel in a way similar to rsForEach. However, instead of processing +all cells in the input, this function only processes cells in the subspace of +the index space specified in options. With the index space explicitly specified +by options, no input or output allocation is required for a kernel launch using +this API. If allocations are passed in, they must match the number of arguments +and return value expected by the kernel function. The output allocation is +present if and only if the kernel has a non-void return value.

-

If both input and output allocations are specified, they must have the same dimensions. +

For example,
+ rs_script_call_t opts = {0};
+ opts.xStart = 0;
+ opts.xEnd = dimX;
+ opts.yStart = 0;
+ opts.yEnd = dimY / 2;
+ rsForEachWithOptions(foo, &opts, out, out);
+

@@ -359,7 +450,7 @@ over and rarely used indices, like the Array0 index.

You can access the kernel context by adding a special parameter named "context" of -type rs_kernel_context to your kernel function. E.g.
+type rs_kernel_context to your kernel function. For example,
short RS_KERNEL myKernel(short value, uint32_t x, rs_kernel_context context) {
  // The current index in the common x, y, z dimensions are accessed by
  // adding these variables as arguments. For the more rarely used indices
@@ -644,7 +735,7 @@ over and rarely used indices, like the Array0 index.

You can access it by adding a special parameter named "context" of -type rs_kernel_context to your kernel function. E.g.
+type rs_kernel_context to your kernel function. For example,
int4 RS_KERNEL myKernel(int4 value, rs_kernel_context context) {
  uint32_t size = rsGetDimX(context); //...