From: Pyry Haulos Date: Tue, 28 Oct 2014 23:07:42 +0000 (-0700) Subject: Endianness fixes to bilinear & fuzzy image compares X-Git-Tag: upstream/0.1.0~2097 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74731a6adf5816339b00b854a513b1b950ad4357;p=platform%2Fupstream%2FVK-GL-CTS.git Endianness fixes to bilinear & fuzzy image compares Change-Id: I1f5560a60ed85ef4b4c6fa2a5417649eeb7a4c7f --- diff --git a/framework/common/tcuBilinearImageCompare.cpp b/framework/common/tcuBilinearImageCompare.cpp index 26e896b..9b53ff9 100644 --- a/framework/common/tcuBilinearImageCompare.cpp +++ b/framework/common/tcuBilinearImageCompare.cpp @@ -37,7 +37,8 @@ enum NUM_SUBPIXEL_BITS = 8 //!< Number of subpixel bits used when doing bilinear interpolation. }; -// \todo [2013-03-26 pyry] Big-endian architectures? +// \note Algorithm assumes that colors are packed to 32-bit values as dictated by +// tcu::RGBA::*_SHIFT values. template static inline deUint8 getChannel (deUint32 color) @@ -45,10 +46,17 @@ static inline deUint8 getChannel (deUint32 color) return (deUint8)((color >> (Channel*8)) & 0xff); } +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) inline deUint32 readRGBA8Raw (const ConstPixelBufferAccess& src, deUint32 x, deUint32 y) { return *(const deUint32*)((const deUint8*)src.getDataPtr() + y*src.getRowPitch() + x*4); } +#else +inline deUint32 readRGBA8Raw (const ConstPixelBufferAccess& src, deUint32 x, deUint32 y) +{ + return deReverseBytes32(*(const deUint32*)((const deUint8*)src.getDataPtr() + y*src.getRowPitch() + x*4)); +} +#endif inline RGBA readRGBA8 (const ConstPixelBufferAccess& src, deUint32 x, deUint32 y) { diff --git a/framework/common/tcuFuzzyImageCompare.cpp b/framework/common/tcuFuzzyImageCompare.cpp index fcf6252..cfcd576 100644 --- a/framework/common/tcuFuzzyImageCompare.cpp +++ b/framework/common/tcuFuzzyImageCompare.cpp @@ -34,8 +34,6 @@ namespace tcu using std::vector; -// \todo [2012-12-13 pyry] Big-endian architectures? - template static inline deUint8 getChannel (deUint32 color) { @@ -82,11 +80,13 @@ static inline deUint32 readUnorm8 (const tcu::ConstPixelBufferAccess& src, int x return v; } +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) template<> inline deUint32 readUnorm8<4> (const tcu::ConstPixelBufferAccess& src, int x, int y) { return *(const deUint32*)((const deUint8*)src.getDataPtr() + src.getRowPitch()*y + x*4); } +#endif template static inline void writeUnorm8 (const tcu::PixelBufferAccess& dst, int x, int y, deUint32 val) @@ -97,11 +97,13 @@ static inline void writeUnorm8 (const tcu::PixelBufferAccess& dst, int x, int y, ptr[c] = getChannel(val, c); } +#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN) template<> inline void writeUnorm8<4> (const tcu::PixelBufferAccess& dst, int x, int y, deUint32 val) { *(deUint32*)((deUint8*)dst.getDataPtr() + dst.getRowPitch()*y + x*4) = val; } +#endif static inline float compareColors (deUint32 pa, deUint32 pb, int minErrThreshold) { diff --git a/framework/delibs/debase/deInt32.h b/framework/delibs/debase/deInt32.h index aa4c8cb..a360f62 100644 --- a/framework/delibs/debase/deInt32.h +++ b/framework/delibs/debase/deInt32.h @@ -337,6 +337,20 @@ DE_INLINE int dePop32 (int a) return (int)t; } +/*--------------------------------------------------------------------*//*! + * \brief Reverse bytes in 32-bit integer (for example MSB -> LSB). + * \param a Input value. + * \return The input with bytes reversed + *//*--------------------------------------------------------------------*/ +DE_INLINE deUint32 deReverseBytes32 (deUint32 v) +{ + deUint32 b0 = v << 24; + deUint32 b1 = (v & 0x0000ff00) << 8; + deUint32 b2 = (v & 0x00ff0000) >> 8; + deUint32 b3 = v >> 24; + return b0|b1|b2|b3; +} + DE_INLINE deInt32 deSafeMul32 (deInt32 a, deInt32 b) { deInt32 res = a * b;