Getting the value from a RenderScript global back to Java

隐身守侯 提交于 2019-12-13 02:09:38

问题


I'm incrementing the value of a global in RS with the aim of passing it back to Java on kernel completion. 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?

RS:

int MAX = 1;

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

Java:

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

回答1:


get_var only returns the last value set by Java, not the last value set by the RS code. 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.

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).



来源:https://stackoverflow.com/questions/19528982/getting-the-value-from-a-renderscript-global-back-to-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!