Fix an incorrect assert that doesn't account for element array size.
Change-Id: Ibcb5c55d91967603391a1721137d010a85025990
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index f285f5b..11c2427 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -487,6 +487,7 @@
final byte[] data = fp.getData();
int eSize = mType.mElement.mElements[component_number].getSizeBytes();
+ eSize *= mType.mElement.mArraySizes[component_number];
if (data.length != eSize) {
throw new RSIllegalArgumentException("Field packer sizelength " + data.length +
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 972e3d6..fd85b07 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -124,7 +124,8 @@
}
const Element * e = mHal.state.type->getElement()->getField(cIdx);
- if (sizeBytes != e->getSizeBytes()) {
+ uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
+ if (sizeBytes != e->getSizeBytes() * elemArraySize) {
ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
return;
@@ -157,8 +158,8 @@
}
const Element * e = mHal.state.type->getElement()->getField(cIdx);
-
- if (sizeBytes != e->getSizeBytes()) {
+ uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx);
+ if (sizeBytes != e->getSizeBytes() * elemArraySize) {
ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes());
rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size.");
return;