From ac2bc39a27ca30ff9b95b549b78fa5d3193b9487 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 11 May 2017 14:10:03 -0700 Subject: [PATCH] try, try again --- libraries/shared/src/shared/Storage.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libraries/shared/src/shared/Storage.cpp b/libraries/shared/src/shared/Storage.cpp index ec29a8d7f8..6a6393ff73 100644 --- a/libraries/shared/src/shared/Storage.cpp +++ b/libraries/shared/src/shared/Storage.cpp @@ -39,9 +39,11 @@ StoragePointer Storage::toFileStorage(const QString& filename) const { } MemoryStorage::MemoryStorage(size_t size, const uint8_t* data) : _size(size) { - // alloc smallest number of 4-byte chunks that will cover size bytes. The buffer is padded out to a multiple - // of 4 to force an alignment that glTextureSubImage2D can later use. - _data.resize((size + 3) & ~0x3); + // we end up calling glCompressedTextureSubImage2D with this, and the rows of the image are expected + // to be word aligned. This is fine in all cases except for 1x1 images and 2x2 images. For 1x1, + // there is only one row, so the problem is avoided. For 2x2, we add 2 extra bytes so there's + // room for the second row. + _data.resize(size == 4 ? 6 : size); if (data) { memcpy(_data.data(), data, size); }