From bd016a2601a741799bc76734deae0cb9ebcb2b8f Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 15 Sep 2015 15:23:26 +0200 Subject: mesa: Fix texture compression on big-endian systems Various pieces of code to create compressed textures will first generate an uncompressed RGBA texture into a temporary buffer, and then read from that buffer while creating the final compressed texture in the requested format. The code reading from the temporary buffer assumes the buffer is formatted as an array of bytes in RGBA order. However, the buffer is filled using a _mesa_texstore call with MESA_FORMAT_R8G8B8A8_UNORM format -- this is defined as an array of *integers* holding the RGBA values in packed format (least-significant to most-significant). This means incorrect bytes are accessed on big-endian systems. This patch fixes this by using the MESA_FORMAT_A8B8G8R8_UNORM format instead on big-endian systems when filling the buffer. This fixes about 100 piglit test case failures on s390x for me. Signed-off-by: Ulrich Weigand Tested-by: Oded Gabbay Cc: "10.6" "11.0" Signed-off-by: Dave Airlie --- src/mesa/main/texcompress_rgtc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/texcompress_rgtc.c') diff --git a/src/mesa/main/texcompress_rgtc.c b/src/mesa/main/texcompress_rgtc.c index 66de1f17d8b..8cab7a56b1a 100644 --- a/src/mesa/main/texcompress_rgtc.c +++ b/src/mesa/main/texcompress_rgtc.c @@ -196,9 +196,11 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_LA_LATC2_UNORM); if (baseInternalFormat == GL_RG) - tempFormat = MESA_FORMAT_R8G8_UNORM; + tempFormat = _mesa_little_endian() ? MESA_FORMAT_R8G8_UNORM + : MESA_FORMAT_G8R8_UNORM; else - tempFormat = MESA_FORMAT_L8A8_UNORM; + tempFormat = _mesa_little_endian() ? MESA_FORMAT_L8A8_UNORM + : MESA_FORMAT_A8L8_UNORM; rgRowStride = 2 * srcWidth * sizeof(GLubyte); tempImage = malloc(srcWidth * srcHeight * 2 * sizeof(GLubyte)); -- cgit v1.2.3