From 1ad7b99925e044f82e635f746c1ef2df77f69ac9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Sep 2005 02:29:50 +0000 Subject: Initial work for GL_EXT_packed_depth_stencil extension. glReadPixels done, glDrawPixels mostly done. --- src/mesa/main/teximage.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/mesa/main/teximage.c') diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index c19e5b0a5a..db78a6d24e 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -341,6 +341,16 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) } } + if (ctx->Extensions.EXT_packed_depth_stencil) { + switch (internalFormat) { + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + return GL_DEPTH_STENCIL_EXT; + default: + ; /* fallthrough */ + } + } + return -1; /* error */ } @@ -495,6 +505,23 @@ is_ycbcr_format(GLenum format) } +/** + * Test if the given image format is a Depth/Stencil format. + */ +static GLboolean +is_depthstencil_format(GLenum format) +{ + switch (format) { + case GL_DEPTH24_STENCIL8_EXT: + case GL_DEPTH_STENCIL_EXT: + return GL_TRUE; + default: + return GL_FALSE; + } +} + + + /** * Test if it is a supported compressed format. * @@ -1369,7 +1396,8 @@ texture_error_check( GLcontext *ctx, GLenum target, if ((is_color_format(internalFormat) && !colorFormat && !indexFormat) || (is_index_format(internalFormat) && !indexFormat) || (is_depth_format(internalFormat) != is_depth_format(format)) || - (is_ycbcr_format(internalFormat) != is_ycbcr_format(format))) { + (is_ycbcr_format(internalFormat) != is_ycbcr_format(format)) || + (is_depthstencil_format(internalFormat) != is_depthstencil_format(format))) { if (!isProxy) _mesa_error(ctx, GL_INVALID_OPERATION, "glTexImage(internalFormat/format)"); @@ -1992,6 +2020,11 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); } + if (!ctx->Extensions.EXT_packed_depth_stencil + && is_depthstencil_format(format)) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); + } + if (!pixels) return; @@ -2026,6 +2059,11 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); return; } + else if (is_depthstencil_format(format) + && !is_depthstencil_format(texImage->TexFormat->BaseFormat)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)"); + return; + } /* typically, this will call _mesa_get_teximage() */ ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels, -- cgit v1.2.3