Fix uninitialized values in astc decompression
authorMika Isojärvi <misojarvi@google.com>
Fri, 12 Jun 2015 22:01:36 +0000 (15:01 -0700)
committerMika Isojärvi <misojarvi@google.com>
Fri, 12 Jun 2015 22:32:48 +0000 (15:32 -0700)
Change-Id: I2553d5108828c435271d5d2629bb60d0fee1663f

framework/common/tcuCompressedTexture.cpp

index 2be372e..7d0073b 100644 (file)
@@ -2140,7 +2140,7 @@ void computeColorEndpoints (ColorEndpointPair* dst, const Block128& blockData, c
        }
 }
 
-void unquantizeWeights (deUint32* dst, const ISEDecodedResult* weightGrid, const ASTCBlockMode& blockMode)
+void unquantizeWeights (deUint32 dst[64], const ISEDecodedResult* weightGrid, const ASTCBlockMode& blockMode)
 {
        const int                       numWeights      = computeNumWeights(blockMode);
        const ISEParams&        iseParams       = blockMode.weightISEParams;
@@ -2194,6 +2194,11 @@ void unquantizeWeights (deUint32* dst, const ISEDecodedResult* weightGrid, const
 
        for (int weightNdx = 0; weightNdx < numWeights; weightNdx++)
                dst[weightNdx] += dst[weightNdx] > 32 ? 1 : 0;
+
+       // Initialize nonexistent weights to poison values
+       for (int weightNdx = numWeights; weightNdx < 64; weightNdx++)
+               dst[weightNdx] = ~0u;
+
 }
 
 void interpolateWeights (TexelWeightPair* dst, const deUint32* unquantizedWeights, int blockWidth, int blockHeight, const ASTCBlockMode& blockMode)