From f87519fd1d59e2c9beb06feeeae08c58fd8b9a51 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 18 Jan 2018 16:58:18 -0800 Subject: [PATCH] BC3-5: Remove potentially misaligned uint64 read ARMv7 is fussy about this and explodes if src+2 isn't properly aligned, which is likely to be the case. VK-GL-CTS Issue: 954 Affects: dEQP-VK.texture.compressed.bc{3,4,5}* Components: Framework Change-Id: Idf0846603f4bf5d569a4084b8f399dd8da99221e --- framework/common/tcuCompressedTexture.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/framework/common/tcuCompressedTexture.cpp b/framework/common/tcuCompressedTexture.cpp index 083c052..3af1a7f 100644 --- a/framework/common/tcuCompressedTexture.cpp +++ b/framework/common/tcuCompressedTexture.cpp @@ -1341,6 +1341,17 @@ inline deInt8 extractModeBc7 (deUint8 src) return -1; } +inline deUint64 get64BitBlockLE (const deUint8* src, int blockNdx) +{ + // Same as get64BitBlock, but little-endian. + deUint64 block = 0; + + for (int i = 0; i < 8; i++) + block |= (deUint64)(src[blockNdx*8+i]) << (8ull*i); + + return block; +} + inline deUint32 getBits128 (deUint64 low, deUint64 high, deUint32 first, deUint32 last) { const deUint64 d[2] = { low, high }; @@ -1614,7 +1625,7 @@ void decompressBc3 (const PixelBufferAccess& dst, const deUint8* src) const deUint32 color0 = bgr16torgba32(color0_16); const deUint32 color1 = bgr16torgba32(color1_16); const deUint8* const indices8 = &src[12]; - const deUint64 alphaBits = *((deUint64*)&src[2]); + const deUint64 alphaBits = get64BitBlockLE(src, 0) >> 16; deUint32 alphas[8]; const deInt32 indices[16] = @@ -1702,7 +1713,7 @@ void decompressBc4 (const PixelBufferAccess& dst, const deUint8* src, bool hasSi const deUint8 red1 = src[1]; const deInt8 red0s = ((deInt8*)src)[0]; const deInt8 red1s = ((deInt8*)src)[1]; - const deUint64 indexBits = *((deUint64*)&src[2]); + const deUint64 indexBits = get64BitBlockLE(src, 0) >> 16; float reds[8]; const deInt32 indices[16] = @@ -1768,7 +1779,7 @@ void decompressBc5 (const PixelBufferAccess& dst, const deUint8* src, bool hasSi const deUint8 rg1 = src[offset + 1]; const deInt8 rg0s = ((deInt8*)src)[offset]; const deInt8 rg1s = ((deInt8*)src)[offset + 1]; - const deUint64 indexBits = *((deUint64*)&src[offset + 2]); + const deUint64 indexBits = get64BitBlockLE(src, c) >> 16; for (deUint32 i = 0; i < 16; i++) indices[c][i] = (indexBits >> (i * 3)) & 0x7; -- 2.7.4