Reputation: 21
I've started to work with renderscript and wonder why it doesn't work on api 16 with support mode. For example in project https://github.com/harism/android_reimage in code :
scriptInvert = new ScriptC_invert(rs);
I catch Exception :
Caused by: android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed. at android.support.v8.renderscript.ScriptC.(ScriptC.java:69)
at io.github.harism.lib.reimage.ScriptC_invert.(ScriptC_invert.java:42)
at io.github.harism.lib.reimage.ScriptC_invert.(ScriptC_invert.java:34)
at io.github.harism.lib.reimage.ReImage.(ReImage.java:56)
at io.github.harism.lib.reimage.ReImage.from(ReImage.java:45)
Does someone have any idea why can this happen?
Example of .rs code that failed (https://github.com/harism/android_reimage/blob/master/reimage/src/main/rs/invert.rs):
#pragma version(1)
#pragma rs java_package_name(io.github.harism.lib.reimage)
#pragma rs_fp_relaxed
void invert(uchar4 *inout, uint32_t x, uint32_t y) {
inout->r = 0xFF - inout->r;
inout->g = 0xFF - inout->g;
inout->b = 0xFF - inout->b;
}
Upvotes: 0
Views: 1227
Reputation: 21
That's funny but I found a core of an issue... My .rs files was in library module. That caused an issue because internalCreate(rs, resources, resourceID) in ScriptC returned 0 (wasn't able to find raw .bc files).
Upvotes: 1
Reputation: 2622
I think the issue here might be proguard stripping the code. Can you try disabling proguard and/or updating it to not remove anything related to the RS support library (or your custom code)?
Upvotes: 0
Reputation: 15775
Rename the RS function to be root
if you'd like it to be automatically picked up as the kernel for your script. Or, change it to be:
void __attribute__((kernel)) invert(uchar4 *inout, uint32_t x, uint32_t y)
You will likely also run into a problem since you are not specifying an explicit output allocation. With the second form, replace the void
return value with uchar4
and be sure to set an output allocation in your java code.
Upvotes: 0