From e0212ac32bc824de8a2345f054b6e1b7a500695f Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 16 May 2017 15:53:07 -0700 Subject: [PATCH] Remove _fullImageSize from ktx header --- libraries/gpu/src/gpu/Texture_ktx.cpp | 4 ++-- libraries/ktx/src/ktx/KTX.h | 5 +---- libraries/ktx/src/ktx/Writer.cpp | 4 ++-- .../src/model-networking/TextureCache.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 85fd5f044c..e033355514 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -239,8 +239,8 @@ void KtxStorage::assignMipData(uint16 level, const storage::StoragePointer& stor } auto& imageDesc = _ktxDescriptor->images[level]; - if (storage->size() != imageDesc._fullImageSize) { - qWarning() << "Invalid image size: " << storage->size() << ", expected: " << imageDesc._fullImageSize + if (storage->size() != imageDesc._imageSize) { + qWarning() << "Invalid image size: " << storage->size() << ", expected: " << imageDesc._imageSize << ", level: " << level << ", filename: " << QString::fromStdString(_filename); return; } diff --git a/libraries/ktx/src/ktx/KTX.h b/libraries/ktx/src/ktx/KTX.h index 69a34d3507..3f220abac3 100644 --- a/libraries/ktx/src/ktx/KTX.h +++ b/libraries/ktx/src/ktx/KTX.h @@ -424,15 +424,12 @@ namespace ktx { // will have a byte offset of 0. const size_t _imageOffset; const uint32_t _imageSize; - // The full size of this image / mip level. This will be equivalent to _imageSize except when _numFaces > 1 - const uint32_t _fullImageSize; const uint32_t _faceSize; const uint32_t _padding; ImageHeader(bool cube, size_t imageOffset, uint32_t imageSize, uint32_t padding) : _numFaces(cube ? NUM_CUBEMAPFACES : 1), _imageOffset(imageOffset), - _imageSize(imageSize), - _fullImageSize(imageSize * _numFaces), + _imageSize(imageSize * _numFaces), _faceSize(imageSize), _padding(padding) { } diff --git a/libraries/ktx/src/ktx/Writer.cpp b/libraries/ktx/src/ktx/Writer.cpp index 3afe705499..2dcd0ea583 100644 --- a/libraries/ktx/src/ktx/Writer.cpp +++ b/libraries/ktx/src/ktx/Writer.cpp @@ -89,7 +89,7 @@ namespace ktx { for (uint32_t l = 0; l < numMips; l++) { if (imageDescriptors.size() > l) { storageSize += sizeof(uint32_t); - storageSize += imageDescriptors[l]._fullImageSize; + storageSize += imageDescriptors[l]._imageSize; storageSize += Header::evalPadding(imageDescriptors[l]._imageSize); } } @@ -158,7 +158,7 @@ namespace ktx { } #endif currentDestPtr += sizeof(uint32_t); - currentDestPtr += descriptors[i]._fullImageSize; + currentDestPtr += descriptors[i]._imageSize; } return destByteSize; diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 2880762987..8683d56b6b 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -655,13 +655,13 @@ void NetworkTexture::maybeHandleFinishedInitialLoad() { // TODO Move image offset calculation to ktx ImageDescriptor for (int level = static_cast(images.size()) - 1; level >= 0; --level) { auto& image = images[level]; - if (image._fullImageSize > imageSizeRemaining) { + if (image._imageSize > imageSizeRemaining) { break; } - ktxData -= image._fullImageSize; - texture->assignStoredMip(static_cast(level), image._fullImageSize, ktxData); + ktxData -= image._imageSize; + texture->assignStoredMip(static_cast(level), image._imageSize, ktxData); ktxData -= ktx::IMAGE_SIZE_WIDTH; - imageSizeRemaining -= (image._fullImageSize + ktx::IMAGE_SIZE_WIDTH); + imageSizeRemaining -= (image._imageSize + ktx::IMAGE_SIZE_WIDTH); } // We replace the texture with the one stored in the cache. This deals with the possible race condition of two different