[Mesa-dev] [PATCH 2/2] mesa: use new _mesa_inside_dlist_begin_end() function

Brian Paul brianp at vmware.com
Tue Apr 23 12:23:47 PDT 2013


---
 src/mesa/main/context.h     |   11 +++++++++++
 src/mesa/main/dlist.c       |    4 ++--
 src/mesa/vbo/vbo_save_api.c |    3 +--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 0525184..396cbd2 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -201,6 +201,17 @@ _mesa_inside_begin_end(const struct gl_context *ctx)
 
 
 /**
+ * Are we currently between glBegin and glEnd in a display list?
+ */
+static inline GLboolean
+_mesa_inside_dlist_begin_end(const struct gl_context *ctx)
+{
+   return ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END;
+}
+
+
+
+/**
  * \name Macros for flushing buffered rendering commands before state changes,
  * checking if inside glBegin/glEnd, etc.
  */
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 33aeffc..89af17c 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -3777,7 +3777,7 @@ save_ShadeModel(GLenum mode)
 
    /* Only save the value if we know the statechange will take effect:
     */
-   if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
+   if (!_mesa_inside_dlist_begin_end(ctx))
       ctx->ListState.Current.ShadeModel = mode;
 
    n = alloc_instruction(ctx, OPCODE_SHADE_MODEL, 1);
@@ -5657,7 +5657,7 @@ save_Begin(GLenum mode)
        */
       ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
    }
-   else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
+   else if (!_mesa_inside_dlist_begin_end(ctx)) {
       ctx->Driver.CurrentSavePrimitive = mode;
    }
    else {
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 6e833d5..7ede8f4 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1558,8 +1558,7 @@ vbo_save_EndList(struct gl_context *ctx)
 
    /* EndList called inside a (saved) Begin/End pair?
     */
-   if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) {
-
+   if (_mesa_inside_dlist_begin_end(ctx)) {
       if (save->prim_count > 0) {
          GLint i = save->prim_count - 1;
          ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
-- 
1.7.3.4



More information about the mesa-dev mailing list