从RenderScript全球回Java获取价值 [英] Getting the value from a RenderScript global back to Java

查看:162
本文介绍了从RenderScript全球回Java获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我递增全球的与它传递回Java内核完成的目标RS值。 rsDebug显示了每次迭代上涨的价值,但mScript.get_var()返回1的初始值是什么让MAX的最后一个值的正确方法?

RS:

  INT MAX = 1;无效根(常量输入*中,浮*总分){
    MAX = MAX + 1;
    rsDebug(MAXMAX);
    *总分= ATAN2(包含在>首先,在 - >第二个);
}

Java的:

 浮法[] =出新的浮动[100000]。
mScript.forEach_root(mInAllocation,mOutAllocation);
mOutAllocation.copyTo(出);
Log.i(最大计数......,Integer.toString(mScript.get_MAX()));


解决方案

get_var只返回被Java,而不是由RS code设置的最后一个值设定的最后一个值。在未来的某个时候这是要解决的,但它没有。就目前而言,倒过来就是藏匿在RS分配的值并将其复制回Java。

是的,这不是很大。对不起,这是我的事,以解决(我几乎做到了,但它远比我最初以为,因为可​​以从RS设置BaseObjs更复杂)。

名单

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()));

解决方案

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

这篇关于从RenderScript全球回Java获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆