Mesa (master): mesa: Don't do [0, 1] clamping on glGetTexImage() of packed float formats.

Eric Anholt anholt at kemper.freedesktop.org
Fri Oct 28 19:10:34 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Oct 26 16:09:16 2011 -0700

mesa: Don't do [0, 1] clamping on glGetTexImage() of packed float formats.

>From the GL_EXT_packed_float spec:

    For an RGBA color, if <type> is not one of FLOAT,
    UNSIGNED_INT_5_9_9_9_REV_EXT, or UNSIGNED_INT_10F_11F_11F_REV_EXT,
    or if the CLAMP_READ_COLOR_ARB is TRUE, or CLAMP_READ_COLOR_ARB
    is FIXED_ONLY_ARB and the selected color (or texture) buffer is
    a fixed-point buffer, each component is first clamped to [0,1].
    Then the appropriate conversion formula from table 4.7 is applied
    the component."

(but we previously resolved that the CLAMP_READ_COLOR bit is not
relevant to glGetTexImage())

This fixes most of the cases in piglit GL_EXT_packed_float/pack.

Reviewed-by: Marek Ol ák <maraeo at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/texgetimage.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 06e0323..3adf7e3 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -50,7 +50,7 @@
  * Can the given type represent negative values?
  */
 static inline GLboolean
-type_with_negative_values(GLenum type)
+type_needs_clamping(GLenum type)
 {
    switch (type) {
    case GL_BYTE:
@@ -58,9 +58,11 @@ type_with_negative_values(GLenum type)
    case GL_INT:
    case GL_FLOAT:
    case GL_HALF_FLOAT_ARB:
-      return GL_TRUE;
-   default:
+   case GL_UNSIGNED_INT_10F_11F_11F_REV:
+   case GL_UNSIGNED_INT_5_9_9_9_REV:
       return GL_FALSE;
+   default:
+      return GL_TRUE;
    }
 }
 
@@ -219,7 +221,7 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions,
    /* In general, clamping does not apply to glGetTexImage, except when
     * the returned type of the image can't hold negative values.
     */
-   if (!type_with_negative_values(type)) {
+   if (type_needs_clamping(type)) {
       /* the returned image type can't have negative values */
       if (dataType == GL_FLOAT ||
           dataType == GL_SIGNED_NORMALIZED ||




More information about the mesa-commit mailing list