Merge "Fixing vector element alignment issues."

This commit is contained in:
Jason Sams
2011-11-29 18:00:06 -08:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 15 deletions

View File

@@ -106,13 +106,18 @@ public:
uint32_t vertexPos = i*vertexSize;
float *vertexPtr = dataPtr + vertexPos;
uint32_t elemIndex = 0;
for (uint32_t c = 0; c < mChannels.size(); c ++) {
// Skip empty channels
if (mChannels[c].mData.size() == 0) {
continue;
}
// This will address vector element alignment issues
uint32_t elemlOffset = vertexDataElem->getFieldOffsetBytes(elemIndex)/sizeof(float);
elemIndex ++;
float *channelPtr = vertexPtr + elemlOffset;
for (uint32_t cStride = 0; cStride < mChannels[c].mStride; cStride ++) {
*(vertexPtr++) = mChannels[c].mData[i * mChannels[c].mStride + cStride];
*(channelPtr++) = mChannels[c].mData[i * mChannels[c].mStride + cStride];
}
}
}

View File

@@ -44,21 +44,11 @@ void rsdAllocationDestroy(const Context *rsc, Allocation *alloc) {
// We only care to implement allocation memory initialization and destruction
// because we need no other renderscript hal features for serialization
static RsdHalFunctions FunctionTable = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,NULL },
{
rsdAllocationInit,
rsdAllocationDestroy,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
},
{ NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL, NULL },
{ NULL, NULL, NULL }, { NULL, NULL, NULL }, { NULL, NULL },
{ NULL, NULL, NULL},
};
// No-op initizlizer for rs context hal since we only
static RsdHalFunctions FunctionTable;
bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
memset(&FunctionTable, 0, sizeof(FunctionTable));
FunctionTable.allocation.init = rsdAllocationInit;
FunctionTable.allocation.destroy = rsdAllocationDestroy;
rsc->mHal.funcs = FunctionTable;
return true;
}