Mesa (master): mesa: add special case in texstore. c for GL_LUMINANCE_ALPHA src image

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Feb 22 13:30:29 UTC 2012


Module: Mesa
Branch: master
Commit: 0df14f9a55383641a9097900272a35ae1cfda4cb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0df14f9a55383641a9097900272a35ae1cfda4cb

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Nov 17 16:03:35 2011 -0700

mesa: add special case in texstore.c for GL_LUMINANCE_ALPHA src image

About a 10% improvement over the swizzle-copy path.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/mesa/main/texstore.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 8c51a94..e8190c3 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1350,6 +1350,32 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
    }
    else if (!ctx->_ImageTransferState &&
             !srcPacking->SwapBytes &&
+            dstFormat == MESA_FORMAT_ARGB8888 &&
+            srcFormat == GL_LUMINANCE_ALPHA &&
+            baseInternalFormat == GL_RGBA &&
+            srcType == GL_UNSIGNED_BYTE) {
+      /* special case of storing LA -> ARGB8888 */
+      int img, row, col;
+      const GLint srcRowStride =
+         _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
+      for (img = 0; img < srcDepth; img++) {
+         const GLubyte *srcRow = (const GLubyte *)
+            _mesa_image_address(dims, srcPacking, srcAddr, srcWidth,
+                                srcHeight, srcFormat, srcType, img, 0, 0);
+         GLubyte *dstRow = dstSlices[img];
+         for (row = 0; row < srcHeight; row++) {
+            GLuint *d4 = (GLuint *) dstRow;
+            for (col = 0; col < srcWidth; col++) {
+               GLubyte l = srcRow[col * 2 + 0], a = srcRow[col * 2 + 1];
+               d4[col] = PACK_COLOR_8888(a, l, l, l);
+            }
+            dstRow += dstRowStride;
+            srcRow += srcRowStride;
+         }
+      }
+   }
+   else if (!ctx->_ImageTransferState &&
+            !srcPacking->SwapBytes &&
 	    dstFormat == MESA_FORMAT_ARGB8888 &&
             srcFormat == GL_RGBA &&
 	    baseInternalFormat == GL_RGBA &&




More information about the mesa-commit mailing list