2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keith@tungstengraphics.com>
30 #include "api_arrayelt.h"
39 void brw_save_init( GLcontext
*ctx
)
41 struct brw_save_context
*save
= CALLOC_STRUCT(brw_save_context
);
43 if (ctx
->swtnl_im
== NULL
) {
44 ctx
->swtnl_im
= CALLOC_STRUCT(brw_exec_save
);
48 IMM_CONTEXT(ctx
)->save
= save
;
50 /* Initialize the arrayelt helper
52 if (!ctx
->aelt_context
&&
53 !_ae_create_context( ctx
))
56 brw_save_api_init( save
);
59 ctx
->Driver
.CurrentSavePrimitive
= PRIM_UNKNOWN
;
63 void brw_save_destroy( GLcontext
*ctx
)
65 struct brw_save_context
*save
= IMM_CONTEXT(ctx
)->save
;
68 IMM_CONTEXT(ctx
)->save
= NULL
;
71 if (ctx
->aelt_context
) {
72 _ae_destroy_context( ctx
);
73 ctx
->aelt_context
= NULL
;
76 if (IMM_CONTEXT(ctx
)->exec
== NULL
&&
77 IMM_CONTEXT(ctx
)->save
== NULL
) {
78 FREE(IMM_CONTEXT(ctx
));
84 void brw_save_invalidate_state( GLcontext
*ctx
, GLuint new_state
)
86 _ae_invalidate_state(ctx
, new_state
);
90 /* Note that this can occur during the playback of a display list:
92 void brw_save_fallback( GLcontext
*ctx
, GLboolean fallback
)
94 struct brw_save_context
*save
= IMM_CONTEXT(ctx
)->save
;
97 save
->replay_flags
|= BRW_SAVE_FALLBACK
;
99 save
->replay_flags
&= ~BRW_SAVE_FALLBACK
;
103 /* I don't see any reason to swap this code out on fallbacks. It
104 * wouldn't really mean anything to do so anyway as the old lists are
105 * still around from pre-fallback. Instead, the above code ensures
106 * that vertices are routed back through immediate mode dispatch on
109 * The below can be moved into init or removed:
111 void brw_save_wakeup( GLcontext
*ctx
)
113 ctx
->Driver
.NewList
= brw_save_NewList
;
114 ctx
->Driver
.EndList
= brw_save_EndList
;
115 ctx
->Driver
.SaveFlushVertices
= brw_save_SaveFlushVertices
;
116 ctx
->Driver
.BeginCallList
= brw_save_BeginCallList
;
117 ctx
->Driver
.EndCallList
= brw_save_EndCallList
;
118 ctx
->Driver
.NotifySaveBegin
= brw_save_NotifyBegin
;
120 /* Assume we haven't been getting state updates either:
122 brw_save_invalidate_state( ctx
, ~0 );