From d5bdce1142d23e68404487e107532fd8dd545b1a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 1 May 2013 19:15:32 -0600 Subject: [PATCH] mesa: simplify save_Begin() error checking The old code was hard to understand and not entirely correct. Note that PRIM_INSIDE_UNKNOWN_PRIM is no longer set anywhere so we'll be able to remove that next. Reviewed-by: Jose Fonseca --- src/mesa/main/dlist.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 9eb13fb385e..57f862be2af 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -5646,28 +5646,21 @@ static void GLAPIENTRY save_Begin(GLenum mode) { GET_CURRENT_CONTEXT(ctx); - Node *n; - GLboolean error = GL_FALSE; - if (ctx->ExecuteFlag && !_mesa_valid_prim_mode(ctx, mode, "glBegin")) { - error = GL_TRUE; - } - else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) { - /* Typically the first begin. This may raise an error on - * playback, depending on whether CallList is issued from inside - * a begin/end or not. - */ - ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM; + if (!_mesa_is_valid_prim_mode(ctx, mode)) { + /* compile this error into the display list */ + _mesa_compile_error(ctx, GL_INVALID_ENUM, "glBegin(mode)"); } - else if (!_mesa_inside_dlist_begin_end(ctx)) { - ctx->Driver.CurrentSavePrimitive = mode; + else if (_mesa_inside_dlist_begin_end(ctx) && + ctx->Driver.CurrentSavePrimitive != PRIM_UNKNOWN) { + /* compile this error into the display list */ + _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive glBegin"); } else { - _mesa_compile_error(ctx, GL_INVALID_OPERATION, "recursive begin"); - error = GL_TRUE; - } + Node *n; + + ctx->Driver.CurrentSavePrimitive = mode; - if (!error) { /* Give the driver an opportunity to hook in an optimized * display list compiler. */ @@ -5679,10 +5672,10 @@ save_Begin(GLenum mode) if (n) { n[1].e = mode; } - } - if (ctx->ExecuteFlag) { - CALL_Begin(ctx->Exec, (mode)); + if (ctx->ExecuteFlag) { + CALL_Begin(ctx->Exec, (mode)); + } } } -- 2.30.2