summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/Element.java
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2011-11-15 15:15:21 -0800
committerAlex Sakhartchouk <alexst@google.com>2011-11-15 15:15:21 -0800
commite60149d2277da53c4a681b7f3971cf13cd4b012b (patch)
tree1bb4f453808bf3ebd87d6f724c7b1b73d5d54934 /graphics/java/android/renderscript/Element.java
parent7b95eba9f47a3992128d59a9ec593b887e4dac0e (diff)
Expand RS vector3 types to vector4.
BUG=5609007 The underlying LLVM implementation for vector3 types does this implicitly. If RS does not adjust its implementation, we will always be misaligned for any subsequent data after a vector3 type. We previously inserted padding into the reflected layers from llvm-rs-cc (hence the skip padding part of this change). We can safely ignore the padding now that the Java/native code is updated to use the expanded size. The compiler will also need modification to ensure that we don't mistakenly skip over any end-of-struct padding. Fixing the 3 component vector padding problem. Change-Id: If68af42287deb8f4b28addcd19a9fa314656be44
Diffstat (limited to 'graphics/java/android/renderscript/Element.java')
-rw-r--r--graphics/java/android/renderscript/Element.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java
index 8a9ca8550992..29306e4b52f5 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -690,7 +690,11 @@ public class Element extends BaseObj {
if ((dt != DataType.UNSIGNED_5_6_5) &&
(dt != DataType.UNSIGNED_4_4_4_4) &&
(dt != DataType.UNSIGNED_5_5_5_1)) {
- mSize = dt.mSize * size;
+ if (size == 3) {
+ mSize = dt.mSize * 4;
+ } else {
+ mSize = dt.mSize * size;
+ }
} else {
mSize = dt.mSize;
}
@@ -885,6 +889,7 @@ public class Element extends BaseObj {
String[] mElementNames;
int[] mArraySizes;
int mCount;
+ int mSkipPadding;
/**
* Create a builder object.
@@ -910,6 +915,21 @@ public class Element extends BaseObj {
if (arraySize < 1) {
throw new RSIllegalArgumentException("Array size cannot be less than 1.");
}
+
+ // Skip padding fields after a vector 3 type.
+ if (mSkipPadding != 0) {
+ if (name.startsWith("#padding_")) {
+ mSkipPadding = 0;
+ return this;
+ }
+ }
+
+ if (element.mVectorSize == 3) {
+ mSkipPadding = 1;
+ } else {
+ mSkipPadding = 0;
+ }
+
if(mCount == mElements.length) {
Element[] e = new Element[mCount + 8];
String[] s = new String[mCount + 8];