简体   繁体   English

从RenderScript全局值获取返回Java的值

[英]Getting the value from a RenderScript global back to Java

I'm incrementing the value of a global in RS with the aim of passing it back to Java on kernel completion. 我正在增加RS中的global的值,目的是在内核完成时将其传递回Java。 rsDebug shows the value rising on each iteration, but mScript.get_var() returns the initial value of 1. What's the right way to get the last value of MAX? rsDebug显示每次迭代时该值都会增加,但是mScript.get_var()返回的初始值为1。什么是获取MAX的最后一个值的正确方法?

RS: RS:

int MAX = 1;

void root(const input* in, float* out){
    MAX = MAX+1;
    rsDebug("MAX",MAX);
    *out = atan2(in->first, in->second);
} 

Java: Java的:

float[] out = new float[100000];
mScript.forEach_root(mInAllocation, mOutAllocation);
mOutAllocation.copyTo(out);
Log.i("Max Count...", Integer.toString(mScript.get_MAX()));

get_var only returns the last value set by Java, not the last value set by the RS code. get_var仅返回Java设置的最后一个值,而不返回RS代码设置的最后一个值。 at some point in the future this is going to be addressed, but it hasn't yet. 在将来的某个时候,这将得到解决,但尚未解决。 for now, the way around is to stash the value in an RS Allocation and copy it back to Java. 目前,解决方法是将值存储在RS分配中,然后将其复制回Java。

yeah, it's not great. 是的,那不是很好。 sorry, it's on my list of things to address (I almost did it, but it's far more complicated than I initially thought because of BaseObjs that can be set from RS). 抱歉,它在我要解决的事情清单上(我几乎做了,但是由于可以从RS设置BaseObjs,它比我最初想象的要复杂得多)。

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

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