[英]Android renderscript function set as kernel autmoatically, how to avoid it?
I compile renderscript code for Android API16+ 我为Android API16 +编译了renderscript代码
I have script function: 我有脚本功能:
void setBuffers(uchar *y, uchar *u, uchar *v){
...
}
With this I want to setup internal pointers (allocations) to the script. 有了这个,我想设置脚本的内部指针(分配)。 But compiler treats all functions with pointer parameters as if they had RS_KERNEL attribute, and makes it a kernel function, with Java code generated as forEach_setBuffers
, or complaining that y
must be int (true for kernels). 但编译器使用指针参数处理所有函数,就好像它们具有RS_KERNEL属性一样,并使其成为内核函数,Java代码生成为forEach_setBuffers
,或者抱怨y
必须为int(对于内核为true)。
I assume this auto-kernel mode was added as simplification so that we don't have to mark functions in scripts. 我假设这个自动内核模式被添加为简化,因此我们不必在脚本中标记函数。 Nice. 尼斯。
But I need to make the function invokable so that Java code contains invoke_setBuffers
instead. 但我需要使函数可调用,以便Java代码包含invoke_setBuffers
。 How do I make it? 我怎么做到的?
You can't have an invokable that accepts pointers, so that is why the "shortcut" of this being marked as a kernel is happening. 你不能拥有一个接受指针的invokable,所以这就是为什么这个标记为内核的“快捷方式”正在发生。 If you do have a function that takes pointers, but doesn't need to be reflected in Java, you can mark it "static" to make sure that it doesn't get treated as as kernel. 如果你有一个带指针的函数,但不需要在Java中反映,你可以将它标记为“静态”,以确保它不会被视为内核。 For taking actual Allocation data from Java, you should make this invokable take "rs_allocation" arguments instead. 要从Java获取实际的分配数据,您应该使这个可调用的取代“rs_allocation”参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.