From 24e63456c6cd41b50fd5187ec1570ed0d38facca Mon Sep 17 00:00:00 2001 From: Lectem Date: Wed, 19 Oct 2016 17:47:00 +0200 Subject: [PATCH] Fix compression for non multiple of 4 texture size If the width or the height was not a multiple of 4, we would read data outside of the bitmap array --- src/nvtt/BlockCompressor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvtt/BlockCompressor.cpp b/src/nvtt/BlockCompressor.cpp index 6b39636..89e15fb 100644 --- a/src/nvtt/BlockCompressor.cpp +++ b/src/nvtt/BlockCompressor.cpp @@ -262,8 +262,8 @@ void FloatColorCompressorTask(void * data, int i) Vector4 colors[16]; float weights[16]; - const uint block_w = min(d->w, 4U); - const uint block_h = min(d->h, 4U); + const uint block_w = min(d->w - block_x * 4U, 4U); + const uint block_h = min(d->h - block_y * 4U, 4U); uint x, y; for (y = 0; y < block_h; y++) {