Mesa (mesa_7_5_branch): mesa/dlist: invalidate cached dlist compile state after CallList

Keith Whitwell keithw at kemper.freedesktop.org
Thu Jul 2 12:31:54 UTC 2009


Module: Mesa
Branch: mesa_7_5_branch
Commit: 7e91d035b9ef65adda39c8b164afa363477d7893
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e91d035b9ef65adda39c8b164afa363477d7893

Author: Keith Whitwell <keithw at vmware.com>
Date:   Tue Jun 30 17:04:11 2009 +0100

mesa/dlist: invalidate cached dlist compile state after CallList

When compiling a display list containing a CallList, it is necessary to
invalidate any assumption about the GL state after the recursive call
completes.

---

 src/mesa/main/dlist.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 93b8a8f..3e8b5a9 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -957,6 +957,20 @@ save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
    }
 }
 
+static void invalidate_saved_current_state( GLcontext *ctx )
+{
+   GLint i;
+
+   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+      ctx->ListState.ActiveAttribSize[i] = 0;
+
+   for (i = 0; i < MAT_ATTRIB_MAX; i++)
+      ctx->ListState.ActiveMaterialSize[i] = 0;
+
+   memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
+
+   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+}
 
 void GLAPIENTRY
 _mesa_save_CallList(GLuint list)
@@ -970,9 +984,10 @@ _mesa_save_CallList(GLuint list)
       n[1].ui = list;
    }
 
-   /* After this, we don't know what begin/end state we're in:
+   /* After this, we don't know what state we're in.  Invalidate all
+    * cached information previously gathered:
     */
-   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+   invalidate_saved_current_state( ctx );
 
    if (ctx->ExecuteFlag) {
       _mesa_CallList(list);
@@ -1015,9 +1030,10 @@ _mesa_save_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
       }
    }
 
-   /* After this, we don't know what begin/end state we're in:
+   /* After this, we don't know what state we're in.  Invalidate all
+    * cached information previously gathered:
     */
-   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+   invalidate_saved_current_state( ctx );
 
    if (ctx->ExecuteFlag) {
       CALL_CallLists(ctx->Exec, (n, type, lists));
@@ -6795,7 +6811,6 @@ void GLAPIENTRY
 _mesa_NewList(GLuint name, GLenum mode)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLint i;
 
    FLUSH_CURRENT(ctx, 0);       /* must be called before assert */
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -6823,22 +6838,15 @@ _mesa_NewList(GLuint name, GLenum mode)
    ctx->CompileFlag = GL_TRUE;
    ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
 
+   /* Reset acumulated list state:
+    */
+   invalidate_saved_current_state( ctx );
+
    /* Allocate new display list */
    ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
    ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
    ctx->ListState.CurrentPos = 0;
 
-   /* Reset acumulated list state:
-    */
-   for (i = 0; i < VERT_ATTRIB_MAX; i++)
-      ctx->ListState.ActiveAttribSize[i] = 0;
-
-   for (i = 0; i < MAT_ATTRIB_MAX; i++)
-      ctx->ListState.ActiveMaterialSize[i] = 0;
-
-   memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
-
-   ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
    ctx->Driver.NewList(ctx, name, mode);
 
    ctx->CurrentDispatch = ctx->Save;




More information about the mesa-commit mailing list