Is it possible to use a kernel without RenderScript using rsForEach ? There are many examples of using rsForEach to invoke the root kernel from the built-in RenderScript function:
They bind the script itself to a variable in the context of RenderScript, and then call the root kernel from RenderScript. For example, in the Activity class:
... mScript = new ScriptC_gradient(mRS);
And in gradient.rs :
#pragma version(1) #pragma rs java_package_name(com.example.android.rs.hellocompute) rs_allocation gOut; rs_allocation gIn; rs_script gScript; void gradient() { rsForEach(gScript, gIn, gOut); } void root(const uchar4 *v_in, uchar4 *v_out, ...
But if I have another gray kernel, can I call it after root , inside gradient ?
But the documentation for rsForEach seems to indicate that it does not support anything like this. Perhaps this can be done by setting something in rs_script_call_t , but the document is quite sharp in this type: (Checked September 20, 2013)
typedef struct rs_script_call rs_script_call_t**
Structure for providing additional information for calling rsForEach. Originally used to limit the call to a subset of cells in a distribution.
This question is mainly out of curiosity. I expect the preferred method is to call them from Java:
... mScript = new ScriptC_gradient(mRS);
They seem to be in sync. If you define root and gray as follows:
void root(...) { rsDebug("root", 0,0); } void gray(...) { rsDebug("gray", 1,1); }
then calling forEach_root and then forEach_gray causes "root, {0,0}" to register in NxM times before it starts to register "gray, {1,1}" - I did not find any documentation that guarantees that, though. Does anyone know where this is?