From: Brian Paul Date: Mon, 15 May 2006 15:26:04 +0000 (+0000) Subject: Added a check_context_limits() function that checks that the ctx->Const.* X-Git-Tag: mesa-7.8~7563 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e2e96b6f010853abcc5a38fd7283768438003b2;p=platform%2Fupstream%2Fmesa.git Added a check_context_limits() function that checks that the ctx->Const.* fields are legal. May catch some driver development bugs. Called the first time a context is bound. --- diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 36c5f2a..2379c6d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1053,6 +1053,35 @@ _mesa_init_constants( GLcontext *ctx ) /** + * Do some sanity checks on the limits/constants for the given context. + * Only called the first time a context is bound. + */ +static void +check_context_limits(GLcontext *ctx) +{ + /* Many context limits/constants are limited by the size of + * internal arrays. + */ + assert(ctx->Const.MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS); + assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS); + assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS); + assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS); + + assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH); + assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH); + + /* make sure largest texture image is <= MAX_WIDTH in size */ + assert((1 << (ctx->Const.MaxTextureLevels -1 )) <= MAX_WIDTH); + assert((1 << (ctx->Const.MaxCubeTextureLevels -1 )) <= MAX_WIDTH); + assert((1 << (ctx->Const.Max3DTextureLevels -1 )) <= MAX_WIDTH); + + assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS); + + /* XXX probably add more tests */ +} + + +/** * Initialize the attribute groups in a GL context. * * \param ctx GL context. @@ -1647,6 +1676,7 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, drawBuffer->Width, drawBuffer->Height); _mesa_set_scissor(newCtx, 0, 0, drawBuffer->Width, drawBuffer->Height ); + check_context_limits(newCtx); } }