Mesa (master): mesa: Make formats.c "datatype" values match glGetTexLevelParameter return.

Eric Anholt anholt at kemper.freedesktop.org
Tue Nov 22 22:09:46 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 17 13:56:30 2011 -0800

mesa: Make formats.c "datatype" values match glGetTexLevelParameter return.

The formats.c code's "datatype" value is "what does this value mean",
i.e. unorm or snorm or float, and is the return value from the
GL_TEXTURE_RED_TYPE class of queries.  The depth formats were marked
as GL_UNSIGNED_INT, which is what we use for integer, and not what we
should be returning from the glGetTexLevelParameter.

In texstore, we were inappropriately using it as an argument to
_mesa_unpack_depth_span() that was expecting a value like
GL_UNSIGNED_INT or GL_UNSIGNED_SHORT.  Just hardcode
_mesa_unpack_depth_span()'s arguments for now, though it looks like
the consumers of that interface would be happier with using
MESA_FORMAT.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/formats.c  |   12 ++++++------
 src/mesa/main/readpix.c  |    4 ++--
 src/mesa/main/texstore.c |    7 ++++++-
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index c6febb0..b934bd4 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -414,7 +414,7 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       MESA_FORMAT_Z24_S8,          /* Name */
       "MESA_FORMAT_Z24_S8",        /* StrName */
       GL_DEPTH_STENCIL,            /* BaseFormat */
-      GL_UNSIGNED_INT,             /* DataType */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
       0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
       0, 0, 0, 24, 8,              /* Lum/Int/Index/Depth/StencilBits */
       1, 1, 4                      /* BlockWidth/Height,Bytes */
@@ -423,7 +423,7 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       MESA_FORMAT_S8_Z24,          /* Name */
       "MESA_FORMAT_S8_Z24",        /* StrName */
       GL_DEPTH_STENCIL,            /* BaseFormat */
-      GL_UNSIGNED_INT,             /* DataType */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
       0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
       0, 0, 0, 24, 8,              /* Lum/Int/Index/Depth/StencilBits */
       1, 1, 4                      /* BlockWidth/Height,Bytes */
@@ -432,7 +432,7 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       MESA_FORMAT_Z16,             /* Name */
       "MESA_FORMAT_Z16",           /* StrName */
       GL_DEPTH_COMPONENT,          /* BaseFormat */
-      GL_UNSIGNED_INT,             /* DataType */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
       0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
       0, 0, 0, 16, 0,              /* Lum/Int/Index/Depth/StencilBits */
       1, 1, 2                      /* BlockWidth/Height,Bytes */
@@ -441,7 +441,7 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       MESA_FORMAT_X8_Z24,          /* Name */
       "MESA_FORMAT_X8_Z24",        /* StrName */
       GL_DEPTH_COMPONENT,          /* BaseFormat */
-      GL_UNSIGNED_INT,             /* DataType */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
       0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
       0, 0, 0, 24, 0,              /* Lum/Int/Index/Depth/StencilBits */
       1, 1, 4                      /* BlockWidth/Height,Bytes */
@@ -450,7 +450,7 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       MESA_FORMAT_Z24_X8,          /* Name */
       "MESA_FORMAT_Z24_X8",        /* StrName */
       GL_DEPTH_COMPONENT,          /* BaseFormat */
-      GL_UNSIGNED_INT,             /* DataType */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
       0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
       0, 0, 0, 24, 0,              /* Lum/Int/Index/Depth/StencilBits */
       1, 1, 4                      /* BlockWidth/Height,Bytes */
@@ -459,7 +459,7 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       MESA_FORMAT_Z32,             /* Name */
       "MESA_FORMAT_Z32",           /* StrName */
       GL_DEPTH_COMPONENT,          /* BaseFormat */
-      GL_UNSIGNED_INT,             /* DataType */
+      GL_UNSIGNED_NORMALIZED,      /* DataType */
       0, 0, 0, 0,                  /* Red/Green/Blue/AlphaBits */
       0, 0, 0, 32, 0,              /* Lum/Int/Index/Depth/StencilBits */
       1, 1, 4                      /* BlockWidth/Height,Bytes */
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
index 8048a72..a7b7ed7 100644
--- a/src/mesa/main/readpix.c
+++ b/src/mesa/main/readpix.c
@@ -60,7 +60,7 @@ fast_read_depth_pixels( struct gl_context *ctx,
    if (packing->SwapBytes)
       return GL_FALSE;
 
-   if (_mesa_get_format_datatype(rb->Format) != GL_UNSIGNED_INT)
+   if (_mesa_get_format_datatype(rb->Format) != GL_UNSIGNED_NORMALIZED)
       return GL_FALSE;
 
    if (!((type == GL_UNSIGNED_SHORT && rb->Format == MESA_FORMAT_Z16) ||
@@ -381,7 +381,7 @@ fast_read_depth_stencil_pixels_separate(struct gl_context *ctx,
    GLubyte *depthMap, *stencilMap;
    int depthStride, stencilStride, i, j;
 
-   if (_mesa_get_format_datatype(depthRb->Format) != GL_UNSIGNED_INT)
+   if (_mesa_get_format_datatype(depthRb->Format) != GL_UNSIGNED_NORMALIZED)
       return GL_FALSE;
 
    ctx->Driver.MapRenderbuffer(ctx, depthRb, x, y, width, height,
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 05c1964..aae6b4b 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -986,12 +986,17 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
 {
    const GLuint depthScale = 0xffffffff;
    const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
-   const GLenum dstType = _mesa_get_format_datatype(dstFormat);
+   GLenum dstType;
    (void) dims;
    ASSERT(dstFormat == MESA_FORMAT_Z32 ||
           dstFormat == MESA_FORMAT_Z32_FLOAT);
    ASSERT(texelBytes == sizeof(GLuint));
 
+   if (dstFormat == MESA_FORMAT_Z32)
+      dstType = GL_UNSIGNED_INT;
+   else
+      dstType = GL_FLOAT;
+
    if (ctx->Pixel.DepthScale == 1.0f &&
        ctx->Pixel.DepthBias == 0.0f &&
        !srcPacking->SwapBytes &&




More information about the mesa-commit mailing list