From 191ff938221efa41d68d123af033f6d2eb3de1b6 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 11 Jun 2020 03:04:09 +0200 Subject: [PATCH] Optimize DXT1 index order fixing. --- server/TracyTextureCompression.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/TracyTextureCompression.cpp b/server/TracyTextureCompression.cpp index 93250086..d2849f82 100644 --- a/server/TracyTextureCompression.cpp +++ b/server/TracyTextureCompression.cpp @@ -219,10 +219,11 @@ void TextureCompression::FixOrder( char* data, size_t blocks ) assert( blocks > 0 ); do { - uint8_t tmp[4]; - memcpy( tmp, data+4, 4 ); - for( int k=0; k<4; k++ ) tmp[k] = DxtcIndexTable[(uint8_t)tmp[k]]; - memcpy( data+4, tmp, 4 ); + uint32_t res = 0; + uint32_t tmp; + memcpy( &tmp, data+4, 4 ); + for( int k=0; k<4; k++ ) res |= DxtcIndexTable[(tmp >> (k*8)) & 0xFF] << (k*8); + memcpy( data+4, &res, 4 ); data += 8; } while( --blocks );