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.
This commit is contained in:
Keith Whitwell 2009-06-30 17:04:11 +01:00
parent 2e570be852
commit 7e91d035b9
1 changed files with 24 additions and 16 deletions

View File

@ -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;