[Mesa-dev] [PATCH 05/14] mesa: simplify save_Begin() error checking
Brian Paul
brianp at vmware.com
Wed Apr 24 17:32:19 PDT 2013
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.
---
src/mesa/main/dlist.c | 33 +++++++++++++--------------------
1 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 9eb13fb..57f862b 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));
+ }
}
}
--
1.7.3.4
More information about the mesa-dev
mailing list