[Mesa-dev] [PATCH 2/2] mesa: Make formats.c "datatype" values match glGetTexLevelParameter return.
Eric Anholt
eric at anholt.net
Fri Nov 18 18:10:35 PST 2011
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.
---
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 86b8753..a459d33 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) ||
@@ -358,7 +358,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 &&
--
1.7.7.3
More information about the mesa-dev
mailing list