diff options
Diffstat (limited to 'libs/rs/rsAdapter.cpp')
-rw-r--r-- | libs/rs/rsAdapter.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/rs/rsAdapter.cpp b/libs/rs/rsAdapter.cpp index 2a705a1..8d363fd 100644 --- a/libs/rs/rsAdapter.cpp +++ b/libs/rs/rsAdapter.cpp @@ -143,8 +143,19 @@ void * Adapter2D::getElement(uint32_t x, uint32_t y) const { rsAssert(mAllocation.get()); rsAssert(mAllocation->getPtr()); rsAssert(mAllocation->getType()); + if (mFace != 0 && !mAllocation->getType()->getDimFaces()) { + LOGE("Adapter wants cubemap face, but allocation has none"); + return NULL; + } + uint8_t * ptr = static_cast<uint8_t *>(mAllocation->getPtr()); ptr += mAllocation->getType()->getLODOffset(mLOD, x, y); + + if (mFace != 0) { + uint32_t totalSizeBytes = mAllocation->getType()->getSizeBytes(); + uint32_t faceOffset = totalSizeBytes / 6; + ptr += faceOffset * mFace; + } return ptr; } |