Remove _fullImageSize from ktx header

This commit is contained in:
Ryan Huffman 2017-05-16 15:53:07 -07:00
parent 7225326bfc
commit e0212ac32b
4 changed files with 9 additions and 12 deletions

View file

@ -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;
}

View file

@ -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) {
}

View file

@ -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;

View file

@ -655,13 +655,13 @@ void NetworkTexture::maybeHandleFinishedInitialLoad() {
// TODO Move image offset calculation to ktx ImageDescriptor
for (int level = static_cast<int>(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<gpu::uint16>(level), image._fullImageSize, ktxData);
ktxData -= image._imageSize;
texture->assignStoredMip(static_cast<gpu::uint16>(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