Function signature for __attribute__(kernel) function and usage of “OutAllocation”

I intend to process RGB data through RenderScript.

For this I've created Allocations in Java and passing them to RS Kernel function as below:

uchar3 __attribute__((kernel)) invert(uchar3 v_in, uint32_t v_out) {
v_in.r = ...;
v_in.g = ...;
v_in.b = ...;

However ideally I would like to work on v_out in similar way i.e. setting values for v_out.r, v_out.g and v_out.b. Currently I can not do this with uint32_t v_out.

Now if I define the above RS kernel as:

uchar3 __attribute__((kernel)) invert(uchar3 v_in, uchar3 v_out) {

I get below compile time error: error: Unexpected kernel invert() parameter 'v_out' of type 'uchar3 *'

Please suggest how to resolve this.

Compile time:

error: Unexpected kernel invert() parameter 'v_out' of type 'uchar3 *'


you should be defining this as

uchar3 __attribute__((kernel)) invert(uchar3 in);

that function will then be reflected as ScriptC_.forEach_invert(Allocation in, Allocation out). each element in in will be passed to invert, and each value returned from invert will be written to the corresponding location in out.

Define your own local variable of uchar3 type and then populate it before returning it:

uchar3 __attribute__((kernel)) invert(uchar3 in) {
    uchar3 out;
    out.r = ...
    out.g = ...
    out.b = ...
    return out;

The compiler is clever enough to notice what you are doing, so there won't be additional copies made of the output items.

Need Your Help

Git - Refraining from pushing some local changes


While working on my project's user interface, I test it locally. Thus, I want to be able to uncomment some remote includes in the HTML head, work for a bit, and then push the changes without the

Custom ActionLink with support of domain routing

I have application that accepts four different types of routes. Keyword link is the link of specific page and keyword user is the user that is the owner of the page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.