I create typed RS allocations this way:
mRS = RenderScript.create(mContext);
Element.Builder eb = new Element.Builder(mRS);
eb.add(Element.F32_3(mRS), "xyz");
eb.add(Element.F32_2(mRS), "uv");
Element eStride_XYZUV = eb.create();
mInAllocation = Allocation.createSized(mRS, eStride_XYZUV, animLand.getArray().length / 5);
mOutAllocation = Allocation.createSized(mRS, eStride_XYZUV, animLand.getArray().length / 5);
animLand.getArray()
is an array of float
. I can copy data to input allocation:
mInAllocation.copyFromUnchecked(animLand.getArray());
However, when I try to retrieve data from out allocation this way:
mOutAllocation.copyTo(animLand.getArray());
I get exception:
android.renderscript.RSIllegalArgumentException: 32 bit float source does not match allocation type null
How can I access data from output Allocation
with array of my custom Element
? There are methods to copy to arrays/bitmaps but only for primitive Element
types.
It works if I use primitive F32
type but I would like to use typed data:
mInAllocation = Allocation.createSized(mRS, Element.F32(mRS), animLand.getArray().length);
mOutAllocation = Allocation.createSized(mRS, Element.F32(mRS), animLand.getArray().length);
...
mInAllocation.copyFromUnchecked(animLand.getArray());
...
mOutAllocation.copyTo(animLand.getArray());