android - Renderscript, what is the `in` parameter? -


i trying understand renderscript. have @ code, , let me know in parameter ? not allocation object, element? why array then?

(i got code here, , modified it, http://www.jayway.com/2014/02/11/renderscript-on-android-basics/)

#pragma version(1) #pragma rs java_package_name(foo.bar)  rs_allocation inpixels; int height; int width;  void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {     float3 pixel = convert_float4(in[0]).rgb;      pixel.r = (pixel.r + pixel.g + pixel.b)/3;     pixel.g = (pixel.r + pixel.g + pixel.b)/3;     pixel.b = (pixel.r + pixel.g + pixel.b)/3;      int topright     //float4 f4 = rsunpackcolor8888(*(uchar*)rsgetelementat(inpixels, x+1, y+1));      out->xyz = convert_uchar3(pixel); } 

what line convert_float4(in[0]) do? index 0 point ? first pixel? if want access next pixel should increase one?

the uchar4 , float3 types same find in opencl. vector values containing 4 , 3 components, respectively. convert_float4() , convert_uchar3() functions provided renderscript correct, fast conversion between different types.

the in parameter pointer current element in kernel operating. x , y values tell element within allocation in corresponds. should not attempt use array , directly access other elements. if do, risk touching memory in process not have access. renderscript processing dataset in parallel, may done on different threads or different processor (gpu). depends on hardware implementation.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -