From f565ab2dd59ce1a6571a8b83746a7952d5c54c92 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 26 Feb 2006 12:46:51 +0000 Subject: [PATCH] For some reason, streaming copies to write-combined regions are extremely sensitive to the characteristics of how the source data is retrieved. By reordering the source reads in the rgba to bgra conversion, the speed of this operation increases by half. --- src/mesa/main/texstore.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index bfac3090866..47247e30cb5 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1222,6 +1222,43 @@ _mesa_texstore_argb8888(STORE_PARAMS) dstImage += dstImageStride; } } + else if (!ctx->_ImageTransferState && + !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_argb8888 && + srcFormat == GL_RGBA && + (srcType == GL_UNSIGNED_BYTE && littleEndian)) { + + int img, row, col; + GLubyte *dstImage = (GLubyte *) dstAddr + + dstZoffset * dstImageStride + + dstYoffset * dstRowStride + + dstXoffset * dstFormat->TexelBytes; + + /* For some reason, streaming copies to write-combined regions + * are extremely sensitive to the characteristics of how the + * source data is retrieved. By reordering the source reads to + * be in-order, the speed of this operation increases by half. + * Strangely the same isn't required for the RGB path, above. + */ + for (img = 0; img < srcDepth; img++) { + const GLint srcRowStride = _mesa_image_row_stride(srcPacking, + srcWidth, srcFormat, srcType); + GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking, + srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0); + GLubyte *dstRow = dstImage; + for (row = 0; row < srcHeight; row++) { + for (col = 0; col < srcWidth; col++) { + *(GLuint *)(dstRow + col * 4) = (srcRow[col * 4 + RCOMP] << 16 | + srcRow[col * 4 + GCOMP] << 8 | + srcRow[col * 4 + BCOMP] << 0 | + srcRow[col * 4 + ACOMP] << 24); + } + dstRow += dstRowStride; + srcRow += srcRowStride; + } + dstImage += dstImageStride; + } + } else if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && dstFormat == &_mesa_texformat_argb8888 &&