diff options
author | Stephen Hines <srhines@google.com> | 2012-10-19 19:16:51 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2012-10-19 19:26:42 -0700 |
commit | 86087f2f1da630d43f4010c246619f3fd4fad286 (patch) | |
tree | ca8b5539592183813e183cea160fafe9b33a7256 /rsType.cpp | |
parent | 7fb897dd913e9de237852bdaefc8179e2f29c25b (diff) | |
download | rs-86087f2f1da630d43f4010c246619f3fd4fad286.tar.gz |
Revert "Remove offset functions from Type"
This reverts commit b99ed44dcffcc268958e86a7bdba2c683d729cf6.
Bug: 7378621
Change-Id: I60c23e02ae45e1141b7447232b2c7d7c5cb1ac38
Diffstat (limited to 'rsType.cpp')
-rw-r--r-- | rsType.cpp | 51 |
1 files changed, 46 insertions, 5 deletions
@@ -42,6 +42,7 @@ void Type::clear() { delete [] mHal.state.lodDimX; delete [] mHal.state.lodDimY; delete [] mHal.state.lodDimZ; + delete [] mHal.state.lodOffset; } mElement.clear(); memset(&mHal, 0, sizeof(mHal)); @@ -54,6 +55,11 @@ TypeState::~TypeState() { rsAssert(!mTypes.size()); } +size_t Type::getOffsetForFace(uint32_t face) const { + rsAssert(mHal.state.faces); + return 0; +} + void Type::compute() { uint32_t oldLODCount = mHal.state.lodCount; if (mDimLOD) { @@ -71,36 +77,71 @@ void Type::compute() { delete [] mHal.state.lodDimX; delete [] mHal.state.lodDimY; delete [] mHal.state.lodDimZ; + delete [] mHal.state.lodOffset; } mHal.state.lodDimX = new uint32_t[mHal.state.lodCount]; mHal.state.lodDimY = new uint32_t[mHal.state.lodCount]; mHal.state.lodDimZ = new uint32_t[mHal.state.lodCount]; + mHal.state.lodOffset = new uint32_t[mHal.state.lodCount]; } uint32_t tx = mHal.state.dimX; uint32_t ty = mHal.state.dimY; uint32_t tz = mHal.state.dimZ; - size_t packedSize = 0; + size_t offset = 0; for (uint32_t lod=0; lod < mHal.state.lodCount; lod++) { mHal.state.lodDimX[lod] = tx; mHal.state.lodDimY[lod] = ty; mHal.state.lodDimZ[lod] = tz; - packedSize += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes(); + mHal.state.lodOffset[lod] = offset; + offset += tx * rsMax(ty, 1u) * rsMax(tz, 1u) * mElement->getSizeBytes(); if (tx > 1) tx >>= 1; if (ty > 1) ty >>= 1; if (tz > 1) tz >>= 1; } // At this point the offset is the size of a mipmap chain; - mMipChainSizeBytes = packedSize; + mMipChainSizeBytes = offset; if (mHal.state.faces) { - packedSize *= 6; + offset *= 6; } - mTotalSizeBytes = packedSize; + mTotalSizeBytes = offset; mHal.state.element = mElement.get(); } +uint32_t Type::getLODOffset(uint32_t lod, uint32_t x) const { + uint32_t offset = mHal.state.lodOffset[lod]; + offset += x * mElement->getSizeBytes(); + return offset; +} + +uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y) const { + uint32_t offset = mHal.state.lodOffset[lod]; + offset += (x + y * mHal.state.lodDimX[lod]) * mElement->getSizeBytes(); + return offset; +} + +uint32_t Type::getLODOffset(uint32_t lod, uint32_t x, uint32_t y, uint32_t z) const { + uint32_t offset = mHal.state.lodOffset[lod]; + offset += (x + + y * mHal.state.lodDimX[lod] + + z * mHal.state.lodDimX[lod] * mHal.state.lodDimY[lod]) * mElement->getSizeBytes(); + return offset; +} + +uint32_t Type::getLODFaceOffset(uint32_t lod, RsAllocationCubemapFace face, + uint32_t x, uint32_t y) const { + uint32_t offset = mHal.state.lodOffset[lod]; + offset += (x + y * mHal.state.lodDimX[lod]) * mElement->getSizeBytes(); + + if (face != 0) { + uint32_t faceOffset = getSizeBytes() / 6; + offset += faceOffset * face; + } + return offset; +} + void Type::dumpLOGV(const char *prefix) const { char buf[1024]; ObjectBase::dumpLOGV(prefix); |