summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-05-15 15:26:04 +0000
committerBrian Paul <[email protected]>2006-05-15 15:26:04 +0000
commit5e2e96b6f010853abcc5a38fd7283768438003b2 (patch)
tree3ce09bb2fb6d893dc4a150b4236f3f83d865a580
parentc8ea111166d55ec0bc12f08694117b974d570da8 (diff)
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.
-rw-r--r--src/mesa/main/context.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 36c5f2a6891..2379c6d7668 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);
}
}