[Mesa-dev] [PATCH v2 5/7] mesa: Fix _mesa_texstore_signed_rgb?8888 for big-endian.

Richard Sandiford rsandifo at linux.vnet.ibm.com
Tue Jul 22 03:02:09 PDT 2014


MESA_FORMAT_x8y8z8w8 means a format in which "x" is the least
signficant byte and "w" is the most significant byte.  Most
functions get that right, but the signed ones access the
bytes from an array rather than an integer, so they need
to take endianness into account.  This isn't too onerous
since both orders are already handled.

Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
---
 src/mesa/main/texstore.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index ae52bd3..22fc1e2 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2276,6 +2276,7 @@ static GLboolean
 _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
 {
    const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+   const GLboolean littleEndian = _mesa_little_endian();
 
    ASSERT(dstFormat == MESA_FORMAT_X8B8G8R8_SNORM ||
           dstFormat == MESA_FORMAT_R8G8B8X8_SNORM);
@@ -2298,7 +2299,7 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
          GLbyte *dstRow = (GLbyte *) dstSlices[img];
          for (row = 0; row < srcHeight; row++) {
             GLbyte *dst = dstRow;
-            if (dstFormat == MESA_FORMAT_X8B8G8R8_SNORM) {
+            if ((dstFormat == MESA_FORMAT_X8B8G8R8_SNORM) == littleEndian) {
                for (col = 0; col < srcWidth; col++) {
                   dst[3] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
                   dst[2] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]);
@@ -2336,6 +2337,7 @@ static GLboolean
 _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
 {
    const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+   const GLboolean littleEndian = _mesa_little_endian();
 
    ASSERT(dstFormat == MESA_FORMAT_A8B8G8R8_SNORM ||
           dstFormat == MESA_FORMAT_R8G8B8A8_SNORM);
@@ -2358,7 +2360,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
          GLbyte *dstRow = (GLbyte *) dstSlices[img];
          for (row = 0; row < srcHeight; row++) {
             GLbyte *dst = dstRow;
-            if (dstFormat == MESA_FORMAT_A8B8G8R8_SNORM) {
+            if ((dstFormat == MESA_FORMAT_A8B8G8R8_SNORM) == littleEndian) {
                for (col = 0; col < srcWidth; col++) {
                   dst[3] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]);
                   dst[2] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]);
-- 
1.8.3.1



More information about the mesa-dev mailing list