简体   繁体   中英

Renderscript kernel method signature

I'm writing question mostly expecting Tim Murray or Stephen Hines to see and drop some knowledge on us.

Since Honeycomb, Renderscript had quite a few changes since the deprecation of the actual rendering and pushing towards general computing, some pragmas and kernel changing, and because of those I'm confused on what's the latest "official way" of writing a kernel.

There're two main ways around the web in the shapes of examples, blog post or Google I/O presentations, they're:

void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {

and

uchar4 __attribute__((kernel)) root(uchar4 v_in, uint32_t x, uint32_t y) {

being the mains differences the second signature you must return the output value. Also there're the variants where you can use other method name (instead of root ).

So the main question:

what's the latest "correct" way of defining kernels?

The 2nd is the preferred signature. Passing by value allows the compiler to make better optimizations. You can use any name you want for the kernel. "root" is a legacy of graphics which would always call it to refresh the screen.

The coordinate parameters are optional. You can omit the X & Y if you do not need them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM