我有三个Renderscript功能(在三个独立的RS文件中),这些功能曾经在Adroid 4.1.x手机上运行得很好。但是,在我升级到ADK 18后,他们开始遇到运行时错误,在同一部手机上崩溃。错误是这样的:
V/RenderScript( 3644): rsContextCreate dev=0x5a2f0fc0
V/RenderScript( 3644): 0x40051010 Launching thread(s), CPUs 0
V/ScriptC ( 3644): Create script for resource = levels
E/bcc ( 3644): CPU is krait2
E/bcc ( 3644): Cache dependency levels sha1 mismatch:
E/bcc ( 3644): given: 4144ab455aa71df31932ff5baf15583cf1775d72
E/bcc ( 3644): cached: d2ab2c2b568810d8ca0c39d730cb2494cae89106
V/ScriptC ( 3644): Create script for resource = sepia
E/bcc ( 3644): Cache dependency sepia sha1 mismatch:
E/bcc ( 3644): given: 6b15396c900dd23c700b8c13e7d5019fb72fcb0e
E/bcc ( 3644): cached: 8d011a42147f8d3895db549e0b3fe4a43ed49fe2
V/ScriptC ( 3644): Create script for resource = flip
E/bcinfo ( 3644): Could not parse bitcode file
E/bcinfo ( 3644): Invalid SWITCH record
E/RenderScript( 3644): bcinfo: failed to read script metadata
W/dalvikvm( 3644): threadid=1: thread exiting with uncaught exception (group=0x410f4498)
E/AndroidRuntime( 3644): FATAL EXCEPTION: main
值得注意的是,在4.2.x和更新的设备上,Renderscript功能仍然有效。
在“project.properties”文件中,我尝试了sdk.buildtools = 17.0.0,18.0.1,18.1.0,18.1.1和19.0.0。他们都没有在4.1.x手机上工作,尽管错误信息随着19.0.0略有改变。我搜索了错误消息“无法读取脚本元数据”。显然it was added by Stephen Hines。我不太了解斯蒂芬的变化,所以我想问下列问题:
导致崩溃的翻转者列在下面。欢迎提出建议和意见。谢谢!
#pragma version(1)
#pragma rs java_package_name(com.xxxx.yyyy.zzzz)
#include "rs_time.rsh"
rs_script flipScript;
rs_allocation gIn;
rs_allocation gOut;
int width;
int height;
int direction = 0;
void root(const uchar4 *v_in, uchar4 *v_out, const void *usrData, uint32_t x, uint32_t y) {
if(direction == 0) { // flip horizontally
const uchar4 *element = rsGetElementAt(gIn, width - x, y);
float4 color = rsUnpackColor8888(*element);
float4 output = {color.r, color.g, color.b};
*v_out = rsPackColorTo8888(output);
}
else if(direction == 1) { // flip vertically
const uchar4 *element = rsGetElementAt(gIn, x, height - y);
float4 color = rsUnpackColor8888(*element);
float4 output = {color.r, color.g, color.b};
*v_out = rsPackColorTo8888(output);
}
else if(direction == 2) { // rotate left
const uchar4 *element = rsGetElementAt(gIn, width - y, x);
float4 color = rsUnpackColor8888(*element);
float4 output = {color.r, color.g, color.b};
*v_out = rsPackColorTo8888(output);
}
else if(direction == 3) { // rotate right
const uchar4 *element = rsGetElementAt(gIn, y, height - x);
float4 color = rsUnpackColor8888(*element);
float4 output = {color.r, color.g, color.b};
*v_out = rsPackColorTo8888(output);
}
}
void flip(int testIdx) {
int64_t t0, t1;
int64_t t;
t0 = rsUptimeNanos();
rsForEach(flipScript, gIn, gOut);
t1 = rsUptimeNanos();
t = t1 - t0;
rsDebug(" flip: timer on RS side: ", t);
timeNanoSec[testIdx] = (float)t;
}
答案 0 :(得分:1)
您要编译哪些目标API?你能给我发一个apk或至少3个失败的.bc文件吗?
这看起来只是v16(JellyBean)设备的bitcode编码问题。它与您提到的更改列表无关,但实际上与在switch语句中合并范围值有关。这是编译器前端的一个错误,llvm-rs-cc。 Libbcc(设备上的编译器)正确地拒绝了v16设备无法读取的坏bitcode(即合并的情况范围)。我将在内部提交一个错误来修复它,并希望在将来的SDK更新中发布它。与此同时,我建议您使用RenderScript支持库,它会绕过这个特定的错误(因为它不会生成v16 bitcode)。