简体   繁体   English

android渲染脚本功能

[英]android renderscript function

i'm doing my first step with renderscript, i'm stuck with a basic stuff... How to define a local function and call it in kernel function.我正在用渲染脚本做我的第一步,我被一个基本的东西困住了......如何定义一个本地函数并在内核函数中调用它。 I don't need this function to be invokable.我不需要这个函数是可调用的。 it just to make my code more readable by splitting task.它只是为了通过拆分任务使我的代码更具可读性。

uint8_t RS_KERNEL invert(uint8_t in, uint32_t x, uint32_t y) {
  foo(NULL);
  return in;
}

void foo(char* m){


}

Someone can tell me why this doesn't compile ?有人可以告诉我为什么这不能编译吗? Since I found nothing about, maybe it is not possible to use function inside kernel or even not possible to define not invokable function.由于我一无所获,可能无法在内核中使用函数,甚至无法定义不可调用的函数。

( i try function with no argument, with return type and so, but as soon as I want call function inside kernel, compilation failed... ) (我尝试没有参数的函数,返回类型等等,但是只要我想在内核中调用函数,编译就会失败......)

Thanks for your knowledge.谢谢你的知识。

I answer to myself with shame :)我羞愧地回答自己:)

-first, if you don't want the function to be invokable, you need to use the static keyword. -首先,如果您不希望该函数可调用,则需要使用 static 关键字。

-second, Java made me lazy. - 其次,Java 让我变得懒惰。 Of course it could not work, I use the function message() without previous declaration or definition.当然它不能工作,我在没有事先声明或定义的情况下使用函数 message() 。 So you need to put a declaration (or definition) before to use a function.所以你需要在使用函数之前放置一个声明(或定义)。 For god sake, this is C not Java :).看在上帝的份上,这是 C 而不是 Java :)。 I can not believe, it took me 2 days to figure it out.我简直不敢相信,我花了 2 天的时间才弄明白。

static void foo(char* m){


}

uint8_t RS_KERNEL invert(uint8_t in, uint32_t x, uint32_t y) {
  foo(NULL);
  return in;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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