diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index af740ddb65..ad0fae577c 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -457,6 +457,14 @@ uint32 Texture::getStoredMipSize(uint16 level) const { return 0; } +gpu::Resource::Size Texture::getStoredSize() const { + auto size = 0; + for (int level = 0; level < evalNumMips(); ++level) { + size += getStoredMipSize(level); + } + return size; +} + uint16 Texture::evalNumSamplesUsed(uint16 numSamplesTried) { uint16 sample = numSamplesTried; if (numSamplesTried <= 1) diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 80fbc867e3..1a8885f075 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -288,9 +288,12 @@ public: Stamp getStamp() const { return _stamp; } Stamp getDataStamp() const { return _storage->getStamp(); } - // The size in bytes of data stored in the texture + // The theoretical size in bytes of data stored in the texture Size getSize() const { return _size; } + // The actual size in bytes of data stored in the texture + Size getStoredSize() const; + // Resize, unless auto mips mode would destroy all the sub mips Size resize1D(uint16 width, uint16 numSamples); Size resize2D(uint16 width, uint16 height, uint16 numSamples); diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 4cac3903a5..3ba36dc2da 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -338,10 +338,13 @@ void NetworkTexture::setImage(void* voidTexture, int originalWidth, if (gpuTexture) { _width = gpuTexture->getWidth(); _height = gpuTexture->getHeight(); + setBytes(gpuTexture->getStoredSize()); } else { + // FIXME: If !gpuTexture, we failed to load! _width = _height = 0; + qWarning() << "Texture did not load"; } - + finishedLoading(true); emit networkTextureCreated(qWeakPointerCast (_self));