From 738318bb75dea8dac4465f53850987f6062a732d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 4 Apr 2003 17:17:50 +0000 Subject: Rework gl[Copy]Tex[Sub]Image() error checking so that all level, width, height and depth checks are done via ctx->Driver.TestProxyTexImage(). This allows more flexiblity, like supporting larger, non-cubic 3D textures. --- src/mesa/drivers/osmesa/osmesa.c | 3 +-- src/mesa/drivers/x11/xm_dd.c | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 5 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 286662b628..195b432885 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,5 +1,3 @@ -/* $Id: osmesa.c,v 1.103 2003/04/01 17:28:55 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -48,6 +46,7 @@ #include "mtypes.h" #include "texformat.h" #include "texobj.h" +#include "teximage.h" #include "texstore.h" #include "array_cache/acache.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index eec0d8ad32..30a8b51723 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -1,5 +1,3 @@ -/* $Id: xm_dd.c,v 1.47 2003/04/01 17:28:11 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -36,6 +34,7 @@ #include "mtypes.h" #include "state.h" #include "texobj.h" +#include "teximage.h" #include "texstore.h" #include "texformat.h" #include "xmesaP.h" @@ -924,6 +923,39 @@ void xmesa_update_state( GLcontext *ctx, GLuint new_state ) +/** + * Called via ctx->Driver.TestProxyTeximage(). Normally, we'd just use + * the _mesa_test_proxy_teximage() fallback function, but we're going to + * special-case the 3D texture case to allow textures up to 512x512x32 + * texels. + */ +static GLboolean +test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, + GLint internalFormat, GLenum format, GLenum type, + GLint width, GLint height, GLint depth, GLint border) +{ + if (target == GL_PROXY_TEXTURE_3D) { + /* special case for 3D textures */ + if (width * height * depth > 512 * 512 * 64 || + width < 2 * border || _mesa_bitcount(width - 2 * border) != 1 || + height < 2 * border || _mesa_bitcount(height - 2 * border) != 1 || + depth < 2 * border || _mesa_bitcount(depth - 2 * border) != 1) { + /* Bad size, or too many texels */ + return GL_FALSE; + } + return GL_TRUE; + } + else { + /* use the fallback routine for 1D, 2D, cube and rect targets */ + return _mesa_test_proxy_teximage(ctx, target, level, internalFormat, + format, type, width, height, depth, + border); + } +} + + + + /* Setup pointers and other driver state that is constant for the life * of a context. */ @@ -957,7 +989,7 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d; ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; - ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; + ctx->Driver.TestProxyTexImage = test_proxy_teximage; ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d; ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d; -- cgit v1.2.3