texstore argb2101010: merge GL_RGBA and GL_RGB cases
authorJordan Justen <jordan.l.justen@intel.com>
Thu, 3 Jan 2013 06:32:47 +0000 (22:32 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Sat, 12 Jan 2013 09:46:02 +0000 (01:46 -0800)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/texstore.c

index 7511509377e7fa8150174f11cc76d859cec15ad9..a5c7712e095e5eaeb3ba6f5bb02a654feb52a9c6 100644 (file)
@@ -1714,18 +1714,20 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
                                                  srcPacking,
                                                  ctx->_ImageTransferState);
       const GLfloat *src = tempImage;
+      const GLushort aMask = (srcFormat == GL_RGB) ? 0xffff : 0;
       GLint img, row, col;
       if (!tempImage)
          return GL_FALSE;
       for (img = 0; img < srcDepth; img++) {
          GLubyte *dstRow = dstSlices[img];
-         if (baseInternalFormat == GL_RGBA) {
+         if (baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB) {
             for (row = 0; row < srcHeight; row++) {
                GLuint *dstUI = (GLuint *) dstRow;
                for (col = 0; col < srcWidth; col++) {
                   GLushort a,r,g,b;
 
                   UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+                  a = a | aMask;
                   UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
                   UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
                   UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
@@ -1734,20 +1736,6 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
                }
                dstRow += dstRowStride;
             }
-         } else if (baseInternalFormat == GL_RGB) {
-            for (row = 0; row < srcHeight; row++) {
-               GLuint *dstUI = (GLuint *) dstRow;
-               for (col = 0; col < srcWidth; col++) {
-                  GLushort r,g,b;
-
-                  UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
-                  UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
-                  UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
-                  dstUI[col] = PACK_COLOR_2101010_US(0xffff, r, g, b);
-                  src += 4;
-               }
-               dstRow += dstRowStride;
-            }
          } else {
             ASSERT(0);
          }