summaryrefslogtreecommitdiff
path: root/rsElement.cpp
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
commit2d1220c27ae91f0b307f283fe66cb767b63dfe38 (patch)
treeb2a90e5296b22469df9f43d2b0c9097eca90a9ab /rsElement.cpp
parent795e405d18a2523ab81bcad47e3256ad66aefb24 (diff)
downloadrs-2d1220c27ae91f0b307f283fe66cb767b63dfe38.tar.gz
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 'rsElement.cpp')
-rw-r--r--rsElement.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/rsElement.cpp b/rsElement.cpp
index df90ce49..56c31b66 100644
--- a/rsElement.cpp
+++ b/rsElement.cpp
@@ -23,6 +23,7 @@ using namespace android::renderscript;
Element::Element(Context *rsc) : ObjectBase(rsc) {
mBits = 0;
+ mBitsUnpadded = 0;
mFields = NULL;
mFieldCount = 0;
mHasReference = false;
@@ -60,6 +61,18 @@ size_t Element::getSizeBits() const {
return total;
}
+size_t Element::getSizeBitsUnpadded() const {
+ if (!mFieldCount) {
+ return mBitsUnpadded;
+ }
+
+ size_t total = 0;
+ for (size_t ct=0; ct < mFieldCount; ct++) {
+ total += mFields[ct].e->mBitsUnpadded * mFields[ct].arraySize;
+ }
+ return total;
+}
+
void Element::dumpLOGV(const char *prefix) const {
ObjectBase::dumpLOGV(prefix);
ALOGV("%s Element: fieldCount: %zu, size bytes: %zu", prefix, mFieldCount, getSizeBytes());
@@ -146,14 +159,18 @@ Element *Element::createFromStream(Context *rsc, IStream *stream) {
void Element::compute() {
if (mFieldCount == 0) {
mBits = mComponent.getBits();
+ mBitsUnpadded = mComponent.getBitsUnpadded();
mHasReference = mComponent.isReference();
return;
}
size_t bits = 0;
+ size_t bitsUnpadded = 0;
for (size_t ct=0; ct < mFieldCount; ct++) {
mFields[ct].offsetBits = bits;
+ mFields[ct].offsetBitsUnpadded = bitsUnpadded;
bits += mFields[ct].e->getSizeBits() * mFields[ct].arraySize;
+ bitsUnpadded += mFields[ct].e->getSizeBitsUnpadded() * mFields[ct].arraySize;
if (mFields[ct].e->mHasReference) {
mHasReference = true;