Mesa (master): mesa: Return the correct internal fmt when a generic compressed fmt was used

Ian Romanick idr at kemper.freedesktop.org
Tue Jul 26 02:58:22 UTC 2011


Module: Mesa
Branch: master
Commit: 143b65f7612c255f29d08392192098b1c2bf4b62
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=143b65f7612c255f29d08392192098b1c2bf4b62

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jul 22 15:26:24 2011 -0700

mesa: Return the correct internal fmt when a generic compressed fmt was used

If an application requests a generic compressed format for a texture
and the driver does not pick a specific compressed format, return the
generic base format (e.g., GL_RGBA) for the GL_TEXTURE_INTERNAL_FORMAT
query.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=3165
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/texparam.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 4b9dcb5..c4ec295 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -915,9 +915,23 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
             *params = _mesa_compressed_format_to_glenum(ctx, texFormat);
          }
          else {
-            /* return the user's requested internal format */
-            *params = img->InternalFormat;
-         }
+	    /* If the true internal format is not compressed but the user
+	     * requested a generic compressed format, we have to return the
+	     * generic base format that matches.
+	     *
+	     * From page 119 (page 129 of the PDF) of the OpenGL 1.3 spec:
+	     *
+	     *     "If no specific compressed format is available,
+	     *     internalformat is instead replaced by the corresponding base
+	     *     internal format."
+	     *
+	     * Otherwise just return the user's requested internal format
+	     */
+	    const GLenum f =
+	       _mesa_gl_compressed_format_base_format(img->InternalFormat);
+
+	    *params = (f != 0) ? f : img->InternalFormat;
+	 }
          break;
       case GL_TEXTURE_BORDER:
          *params = img->Border;




More information about the mesa-commit mailing list