Minor r200 vertex program cleanups. Remove disabled leftovers from r300 vertex progra...
[mesa.git] / src / mesa / drivers / dri / i965 / brw_save.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.3
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 *
24 * Authors:
25 * Keith Whitwell <keith@tungstengraphics.com>
26 */
27
28
29 #include "mtypes.h"
30 #include "api_arrayelt.h"
31 #include "dlist.h"
32 #include "vtxfmt.h"
33 #include "imports.h"
34
35 #include "brw_save.h"
36
37
38
39 void brw_save_init( GLcontext *ctx )
40 {
41 struct brw_save_context *save = CALLOC_STRUCT(brw_save_context);
42
43 if (ctx->swtnl_im == NULL) {
44 ctx->swtnl_im = CALLOC_STRUCT(brw_exec_save);
45 }
46
47 save->ctx = ctx;
48 IMM_CONTEXT(ctx)->save = save;
49
50 /* Initialize the arrayelt helper
51 */
52 if (!ctx->aelt_context &&
53 !_ae_create_context( ctx ))
54 return;
55
56 brw_save_api_init( save );
57 brw_save_wakeup(ctx);
58
59 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
60 }
61
62
63 void brw_save_destroy( GLcontext *ctx )
64 {
65 struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
66 if (save) {
67 FREE(save);
68 IMM_CONTEXT(ctx)->save = NULL;
69 }
70
71 if (ctx->aelt_context) {
72 _ae_destroy_context( ctx );
73 ctx->aelt_context = NULL;
74 }
75
76 if (IMM_CONTEXT(ctx)->exec == NULL &&
77 IMM_CONTEXT(ctx)->save == NULL) {
78 FREE(IMM_CONTEXT(ctx));
79 ctx->swtnl_im = NULL;
80 }
81 }
82
83
84 void brw_save_invalidate_state( GLcontext *ctx, GLuint new_state )
85 {
86 _ae_invalidate_state(ctx, new_state);
87 }
88
89
90 /* Note that this can occur during the playback of a display list:
91 */
92 void brw_save_fallback( GLcontext *ctx, GLboolean fallback )
93 {
94 struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
95
96 if (fallback)
97 save->replay_flags |= BRW_SAVE_FALLBACK;
98 else
99 save->replay_flags &= ~BRW_SAVE_FALLBACK;
100 }
101
102
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
107 * fallback.
108 *
109 * The below can be moved into init or removed:
110 */
111 void brw_save_wakeup( GLcontext *ctx )
112 {
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;
119
120 /* Assume we haven't been getting state updates either:
121 */
122 brw_save_invalidate_state( ctx, ~0 );
123 }
124
125
126