Mesa (main): mesa: Avoid temp images in _mesa_texstore_*_dxt* for stride = 0

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 27 02:12:24 UTC 2022


Module: Mesa
Branch: main
Commit: 7577ca7e6a41029be3a336a48382e73549573a5d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7577ca7e6a41029be3a336a48382e73549573a5d

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon May  2 13:10:07 2022 -0700

mesa: Avoid temp images in _mesa_texstore_*_dxt* for stride = 0

We're getting a source stride of 0 here sometimes, which I believe means
to just use the natural stride, which is what we wanted anyway.  No need
to fall back to a temporary image in that case.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16631>

---

 src/mesa/main/texcompress_s3tc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index b6695512dcb..5f41320a67f 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -59,7 +59,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
    if (!(srcFormat == GL_RGB || srcFormat == GL_RGBA) ||
        srcType != GL_UNSIGNED_BYTE ||
        ctx->_ImageTransferState ||
-       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
+       _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) != srccomps * srcWidth * sizeof(GLubyte) ||
        srcPacking->SkipImages ||
        srcPacking->SwapBytes) {
       /* convert image to RGB/GLubyte */
@@ -105,6 +105,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
    const GLubyte *pixels;
    GLubyte *dst;
    const GLubyte *tempImage = NULL;
+   int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
 
    assert(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
           dstFormat == MESA_FORMAT_SRGBA_DXT1);
@@ -112,12 +113,11 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
    if (srcFormat != GL_RGBA ||
        srcType != GL_UNSIGNED_BYTE ||
        ctx->_ImageTransferState ||
-       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
+       _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) != rgbaRowStride ||
        srcPacking->SkipImages ||
        srcPacking->SwapBytes) {
       /* convert image to RGBA/GLubyte */
       GLubyte *tempImageSlices[1];
-      int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
       tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
       if (!tempImage)
          return GL_FALSE; /* out of memory */
@@ -160,6 +160,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
    const GLubyte *pixels;
    GLubyte *dst;
    const GLubyte *tempImage = NULL;
+   int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
 
    assert(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
           dstFormat == MESA_FORMAT_SRGBA_DXT3);
@@ -167,12 +168,11 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
    if (srcFormat != GL_RGBA ||
        srcType != GL_UNSIGNED_BYTE ||
        ctx->_ImageTransferState ||
-       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
+       _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) != rgbaRowStride ||
        srcPacking->SkipImages ||
        srcPacking->SwapBytes) {
       /* convert image to RGBA/GLubyte */
       GLubyte *tempImageSlices[1];
-      int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
       tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
       if (!tempImage)
          return GL_FALSE; /* out of memory */
@@ -214,6 +214,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
    const GLubyte *pixels;
    GLubyte *dst;
    const GLubyte *tempImage = NULL;
+   int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
 
    assert(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
           dstFormat == MESA_FORMAT_SRGBA_DXT5);
@@ -221,12 +222,11 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
    if (srcFormat != GL_RGBA ||
        srcType != GL_UNSIGNED_BYTE ||
        ctx->_ImageTransferState ||
-       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
+       _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) != rgbaRowStride ||
        srcPacking->SkipImages ||
        srcPacking->SwapBytes) {
       /* convert image to RGBA/GLubyte */
       GLubyte *tempImageSlices[1];
-      int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
       tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
       if (!tempImage)
          return GL_FALSE; /* out of memory */



More information about the mesa-commit mailing list