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 + +
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. +
+| 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 + | +
| 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 + | +
| type | Type of the allocation |
|---|---|
| usage | How 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. |
| mipmap | A boolean flag indicating if the allocation is mipmapped and has multiple levels of detail (LoD). |
| dimX | Size on dimension x. Must be non zero. |
| dimY | Size on dimension y. 0 for single-dimension allocations. |
| dimZ | Size 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_
For example, rsCreateAllocation_int4() returns an Allocation of int4 data type of + specified dimensions. +
+| rs_element rsCreateElement(rs_data_type data_type); + | +Added in API level 24 + | +
| data_type | Data 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. +
+| rs_element rsCreatePixelElement(rs_data_type data_type, rs_data_kind data_kind); + | +Added in API level 24 + | +
| data_type | Data type of the Element |
|---|---|
| data_kind | Data 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. +
+| 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 + | +
| element | An rs_element object that specifies the cell data type of an allocation. |
|---|---|
| dimX | Size on dimension x. Must be non zero. |
| dimY | Size on dimension y. 0 for single-dimension allocations. |
| dimZ | Size on dimension z. 0 for single-dimension and two-dimension allocations. |
| mipmaps | A boolean flag indicating if the allocation is mipmapped and has multiple levels of detail (LoD). |
| faces | A boolean flag indicating if the allocation is a cubemap that has cube faces. |
| yuv_format | Tye 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). +
+| rs_element rsCreateVectorElement(rs_data_type data_type, uint32_t vector_width); + | +Added in API level 24 + | +
| data_type | Data type of the Element |
|---|---|
| vector_width | Vector 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. +
+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 +
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. +
+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.
| 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 | |||||||||||||||||||||||
| script | Script to call. |
|---|---|
| input | Allocation to source data from. |
| output | Allocation to write date into. |
| output | Allocation to write data into. |
| usrData | User defined data to pass to the script. May be NULL. |
| sc | Extra control information used to select a sub-region of the allocation to be processed or suggest a walking strategy. May be NULL. |
| usrDataLen | Size of the userData structure. This will be used to perform a shallow copy of the data if necessary. |
| kernel | Function 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);
+}
+
| void rsForEachWithOptions(rs_kernel kernel, rs_script_call_t* options, ... ...); + | +Added in API level 24 + | +
| kernel | Function designator to a function that is defined with the kernel attribute. |
|---|---|
| options | Launch 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);
+
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); //...