[Mesa-dev] [PATCH 2/3] mesa: don't use memcpy fast path for GetTexImage if base format is different

Marek Olšák maraeo at gmail.com
Wed Feb 6 15:29:44 PST 2013


The Mesa format can be RGBA8888_REV, the format/type can be
GL_RGBA/GL_UNSIGNED_BYTE, but the actual texture internal format can be
LUMINANCE_ALPHA, INTENSITY, etc. Therefore we should look at the base
internal format as well.

NOTE: This is a candidate for the stable branches.
---
 src/mesa/main/texgetimage.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 9441ce6..c6068f2 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -479,16 +479,18 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type,
 {
    const GLenum target = texImage->TexObject->Target;
    GLboolean memCopy = GL_FALSE;
+   GLenum texBaseFormat = _mesa_get_format_base_format(texImage->TexFormat);
 
    /*
     * Check if we can use memcpy to copy from the hardware texture
     * format to the user's format/type.
     * Note that GL's pixel transfer ops don't apply to glGetTexImage()
     */
-   if (target == GL_TEXTURE_1D ||
-       target == GL_TEXTURE_2D ||
-       target == GL_TEXTURE_RECTANGLE ||
-       _mesa_is_cube_face(target)) {
+   if ((target == GL_TEXTURE_1D ||
+        target == GL_TEXTURE_2D ||
+        target == GL_TEXTURE_RECTANGLE ||
+        _mesa_is_cube_face(target)) &&
+       texBaseFormat == texImage->_BaseFormat) {
       memCopy = _mesa_format_matches_format_and_type(texImage->TexFormat,
                                                      format, type,
                                                      ctx->Pack.SwapBytes);
-- 
1.7.10.4



More information about the mesa-dev mailing list