From 6910891c7f71d97379c43914adc6443ae9e99aef Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 2 May 2022 12:59:12 -0700 Subject: [PATCH] mesa: Avoid temp images in _mesa_texstore_rgb_dxt1 for GL_RGBA source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compressor can handle 3 or 4-component sources, so allow a GL_RGBA source and just pass that along with the correct number of components. Reviewed-by: Marek Olšák Part-of: --- src/mesa/main/texcompress_s3tc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index c16e6e93da7..3470a7dc561 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -51,11 +51,12 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) const GLubyte *pixels; GLubyte *dst; const GLubyte *tempImage = NULL; + int srccomps = srcFormat == GL_RGB ? 3 : 4; assert(dstFormat == MESA_FORMAT_RGB_DXT1 || dstFormat == MESA_FORMAT_SRGB_DXT1); - if (srcFormat != GL_RGB || + if (!(srcFormat == GL_RGB || srcFormat == GL_RGBA) || srcType != GL_UNSIGNED_BYTE || ctx->_ImageTransferState || ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth || @@ -76,6 +77,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) srcPacking); pixels = tempImage; srcFormat = GL_RGB; + srccomps = 3; } else { pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight, @@ -84,7 +86,8 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) dst = dstSlices[0]; - tx_compress_dxt1(3, srcWidth, srcHeight, pixels, dst, dstRowStride, 3); + tx_compress_dxt1(srccomps, srcWidth, srcHeight, pixels, + dst, dstRowStride, 3); free((void *) tempImage);