I am trying to call a Renderscript kernel inside a function inside the same Renderscript file, but I have no idea how to do it (and the Google documentation doesn't really help).
So I want to call this kernel:
uchar __attribute__((kernel)) nextPixel(uint32_t x) {
tImgIndexB = (uint32_t) (lBlackX[rsGetElementAt_uchar(num, x)] + lX) * 426 + (lBlackY[rsGetElementAt_uchar(num, x)] + lY);
tImgIndexW = (uint32_t) (lWhiteX[rsGetElementAt_uchar(num, x)] + lX) * 426 + (lWhiteY[rsGetElementAt_uchar(num, x)] + lY);
if (tImg[tImgIndexB] == 0 && tImg[tImgIndexW] == 1) {
output = 1;
tImg[lX*426+lY] = 3;
//lX += lBlackX[rsGetElementAt_uchar(num, x)];
//lY += lBlackY[rsGetElementAt_uchar(num, x)];
} else {
output = 0;
}
return output;
}
into a function like this:
void function() {
// call kernel 'nextPixel'
}
Thank you in advance.
That's not really how RS is intended to be used. The RS engine calls your kernel with the appropriate data and your kernel can call other functions. However, it's not really a normal case to have a function within your RS code call into an RS kernel.