mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 15:33:02 +02:00
Remove magic number for kv and image sizes
This commit is contained in:
parent
e4e554aaea
commit
c7ac82b4e2
3 changed files with 8 additions and 6 deletions
|
@ -193,7 +193,7 @@ void KtxStorage::assignMipData(uint16 level, const storage::StoragePointer& stor
|
|||
|
||||
auto data = file->mutableData();
|
||||
data += ktx::KTX_HEADER_SIZE + _ktxDescriptor->header.bytesOfKeyValueData + _ktxDescriptor->images[level]._imageOffset;
|
||||
data += 4;
|
||||
data += ktx::IMAGE_SIZE_WIDTH;
|
||||
|
||||
auto offset = _ktxDescriptor->getValueOffsetForKey(ktx::HIFI_MIN_POPULATED_MIP_KEY);
|
||||
{
|
||||
|
@ -207,7 +207,7 @@ void KtxStorage::assignMipData(uint16 level, const storage::StoragePointer& stor
|
|||
memcpy(data, storage->data(), _ktxDescriptor->images[level]._imageSize);
|
||||
_minMipLevelAvailable = level;
|
||||
if (offset > 0) {
|
||||
memcpy(file->mutableData() + ktx::KTX_HEADER_SIZE + 4 + offset, (void*)&_minMipLevelAvailable, 1);
|
||||
memcpy(file->mutableData() + ktx::KTX_HEADER_SIZE + ktx::KV_SIZE_WIDTH + offset, (void*)&_minMipLevelAvailable, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
|||
}
|
||||
images.emplace_back(ktx::Image(imageOffset, (uint32_t)mip->getSize(), 0, cubeFaces));
|
||||
}
|
||||
imageOffset += static_cast<uint32_t>(mip->getSize()) + 4;
|
||||
imageOffset += static_cast<uint32_t>(mip->getSize()) + ktx::IMAGE_SIZE_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -390,6 +390,8 @@ namespace ktx {
|
|||
};
|
||||
static const size_t KTX_HEADER_SIZE = 64;
|
||||
static_assert(sizeof(Header) == KTX_HEADER_SIZE, "KTX Header size is static and should not change from the spec");
|
||||
static const size_t KV_SIZE_WIDTH = 4; // Number of bytes for keyAndValueByteSize
|
||||
static const size_t IMAGE_SIZE_WIDTH = 4; // Number of bytes for imageSize
|
||||
|
||||
// Key Values
|
||||
struct KeyValue {
|
||||
|
|
|
@ -429,7 +429,7 @@ void NetworkTexture::startMipRangeRequest(uint16_t low, uint16_t high) {
|
|||
} else {
|
||||
ByteRange range;
|
||||
range.fromInclusive = ktx::KTX_HEADER_SIZE + _originalKtxDescriptor->header.bytesOfKeyValueData
|
||||
+ _originalKtxDescriptor->images[low]._imageOffset + 4;
|
||||
+ _originalKtxDescriptor->images[low]._imageOffset + ktx::IMAGE_SIZE_WIDTH;
|
||||
range.toExclusive = ktx::KTX_HEADER_SIZE + _originalKtxDescriptor->header.bytesOfKeyValueData
|
||||
+ _originalKtxDescriptor->images[high + 1]._imageOffset;
|
||||
_ktxMipRequest->setByteRange(range);
|
||||
|
@ -622,8 +622,8 @@ void NetworkTexture::maybeHandleFinishedInitialLoad() {
|
|||
}
|
||||
ktxData -= image._imageSize;
|
||||
texture->assignStoredMip(static_cast<gpu::uint16>(level), image._imageSize, ktxData);
|
||||
ktxData -= 4;
|
||||
imageSizeRemaining -= (image._imageSize + 4);
|
||||
ktxData -= 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
|
||||
|
|
Loading…
Reference in a new issue