From 0df14f9a55383641a9097900272a35ae1cfda4cb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 17 Nov 2011 16:03:35 -0700 Subject: [PATCH] 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 --- src/mesa/main/texstore.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 8c51a948ede..e8190c3922c 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1348,6 +1348,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 && -- 2.30.2