+ _tnl_array_destroy( ctx );
+ _tnl_vtx_destroy( ctx );
+ _tnl_save_destroy( ctx );
+ _tnl_destroy_pipeline( ctx );
+ _ae_destroy_context( ctx );
+
+ FREE(tnl);
+ ctx->swtnl_context = NULL;
+}
+
+
+void
+_tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ if (new_state & (_NEW_HINT)) {
+ ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog);
+ tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+ || !tnl->AllowPixelFog;
+ }
+
+ if (new_state & _NEW_ARRAY) {
+ tnl->pipeline.run_input_changes |= ctx->Array.NewState; /* overkill */
+ }
+
+ _ae_invalidate_state(ctx, new_state);
+
+ tnl->pipeline.run_state_changes |= new_state;
+ tnl->pipeline.build_state_changes |= (new_state &
+ tnl->pipeline.build_state_trigger);
+
+ tnl->vtx.eval.new_state |= new_state;
+
+ /* Calculate tnl->render_inputs:
+ */
+ if (ctx->Visual.rgbMode) {
+ tnl->render_inputs = (_TNL_BIT_POS|
+ _TNL_BIT_COLOR0|
+ (ctx->Texture._EnabledCoordUnits << _TNL_ATTRIB_TEX0));
+
+ if (NEED_SECONDARY_COLOR(ctx))
+ tnl->render_inputs |= _TNL_BIT_COLOR1;
+ }
+ else {
+ tnl->render_inputs |= (_TNL_BIT_POS|_TNL_BIT_INDEX);
+ }
+
+ if (ctx->Fog.Enabled)
+ tnl->render_inputs |= _TNL_BIT_FOG;
+
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL)
+ tnl->render_inputs |= _TNL_BIT_EDGEFLAG;
+
+ if (ctx->RenderMode == GL_FEEDBACK)
+ tnl->render_inputs |= _TNL_BIT_TEX0;
+
+ if (ctx->Point._Attenuated ||
+ (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled))
+ tnl->render_inputs |= _TNL_BIT_POINTSIZE;
+}
+
+
+void
+_tnl_wakeup_exec( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ install_driver_callbacks(ctx);
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
+
+ /* Hook our functions into exec and compile dispatch tables.
+ */
+ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
+
+ /* Call all appropriate driver callbacks to revive state.
+ */
+ _tnl_MakeCurrent( ctx, ctx->DrawBuffer, ctx->ReadBuffer );