i965: relAddr local var (to make debug/test a little easier)
[mesa.git] / src / mesa / drivers / dri / i915 / i830_context.h
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef I830CONTEXT_INC
29 #define I830CONTEXT_INC
30
31 #include "intel_context.h"
32
33 #define I830_FALLBACK_TEXTURE 0x1000
34 #define I830_FALLBACK_COLORMASK 0x2000
35 #define I830_FALLBACK_STENCIL 0x4000
36 #define I830_FALLBACK_STIPPLE 0x8000
37 #define I830_FALLBACK_LOGICOP 0x10000
38
39 #define I830_UPLOAD_CTX 0x1
40 #define I830_UPLOAD_BUFFERS 0x2
41 #define I830_UPLOAD_STIPPLE 0x4
42 #define I830_UPLOAD_INVARIENT 0x8
43 #define I830_UPLOAD_TEX(i) (0x10<<(i))
44 #define I830_UPLOAD_TEXBLEND(i) (0x100<<(i))
45 #define I830_UPLOAD_TEX_ALL (0x0f0)
46 #define I830_UPLOAD_TEXBLEND_ALL (0xf00)
47
48 /* State structure offsets - these will probably disappear.
49 */
50 #define I830_DESTREG_CBUFADDR0 0
51 #define I830_DESTREG_CBUFADDR1 1
52 #define I830_DESTREG_DBUFADDR0 2
53 #define I830_DESTREG_DBUFADDR1 3
54 #define I830_DESTREG_DV0 4
55 #define I830_DESTREG_DV1 5
56 #define I830_DESTREG_SENABLE 6
57 #define I830_DESTREG_SR0 7
58 #define I830_DESTREG_SR1 8
59 #define I830_DESTREG_SR2 9
60 #define I830_DESTREG_DRAWRECT0 10
61 #define I830_DESTREG_DRAWRECT1 11
62 #define I830_DESTREG_DRAWRECT2 12
63 #define I830_DESTREG_DRAWRECT3 13
64 #define I830_DESTREG_DRAWRECT4 14
65 #define I830_DESTREG_DRAWRECT5 15
66 #define I830_DEST_SETUP_SIZE 16
67
68 #define I830_CTXREG_STATE1 0
69 #define I830_CTXREG_STATE2 1
70 #define I830_CTXREG_STATE3 2
71 #define I830_CTXREG_STATE4 3
72 #define I830_CTXREG_STATE5 4
73 #define I830_CTXREG_IALPHAB 5
74 #define I830_CTXREG_STENCILTST 6
75 #define I830_CTXREG_ENABLES_1 7
76 #define I830_CTXREG_ENABLES_2 8
77 #define I830_CTXREG_AA 9
78 #define I830_CTXREG_FOGCOLOR 10
79 #define I830_CTXREG_BLENDCOLOR0 11
80 #define I830_CTXREG_BLENDCOLOR1 12
81 #define I830_CTXREG_VF 13
82 #define I830_CTXREG_VF2 14
83 #define I830_CTXREG_MCSB0 15
84 #define I830_CTXREG_MCSB1 16
85 #define I830_CTX_SETUP_SIZE 17
86
87 #define I830_STPREG_ST0 0
88 #define I830_STPREG_ST1 1
89 #define I830_STP_SETUP_SIZE 2
90
91 #define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
92 #define I830_TEXREG_TM0S1 1
93 #define I830_TEXREG_TM0S2 2
94 #define I830_TEXREG_TM0S3 3
95 #define I830_TEXREG_TM0S4 4
96 #define I830_TEXREG_MCS 5 /* _3DSTATE_MAP_COORD_SETS */
97 #define I830_TEXREG_CUBE 6 /* _3DSTATE_MAP_SUBE */
98 #define I830_TEX_SETUP_SIZE 7
99
100 #define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
101
102 struct i830_texture_object
103 {
104 struct intel_texture_object intel;
105 GLuint Setup[I830_TEX_SETUP_SIZE];
106 };
107
108 #define I830_TEX_UNITS 4
109
110 struct i830_hw_state
111 {
112 GLuint Ctx[I830_CTX_SETUP_SIZE];
113 GLuint Buffer[I830_DEST_SETUP_SIZE];
114 GLuint Stipple[I830_STP_SETUP_SIZE];
115 GLuint Tex[I830_TEX_UNITS][I830_TEX_SETUP_SIZE];
116 GLuint TexBlend[I830_TEX_UNITS][I830_TEXBLEND_SIZE];
117 GLuint TexBlendWordsUsed[I830_TEX_UNITS];
118
119 struct intel_region *draw_region;
120 struct intel_region *depth_region;
121
122 /* Regions aren't actually that appropriate here as the memory may
123 * be from a PBO or FBO. Will have to do this for draw and depth for
124 * FBO's...
125 */
126 dri_bo *tex_buffer[I830_TEX_UNITS];
127 GLuint tex_offset[I830_TEX_UNITS];
128
129 GLuint emitted; /* I810_UPLOAD_* */
130 GLuint active;
131 };
132
133 struct i830_context
134 {
135 struct intel_context intel;
136
137 GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS];
138 DECLARE_RENDERINPUTS(last_index_bitset);
139
140 struct i830_hw_state meta, initial, state, *current;
141 };
142
143
144
145
146 #define I830_STATECHANGE(i830, flag) \
147 do { \
148 INTEL_FIREVERTICES( &i830->intel ); \
149 i830->state.emitted &= ~flag; \
150 } while (0)
151
152 #define I830_ACTIVESTATE(i830, flag, mode) \
153 do { \
154 INTEL_FIREVERTICES( &i830->intel ); \
155 if (mode) \
156 i830->state.active |= flag; \
157 else \
158 i830->state.active &= ~flag; \
159 } while (0)
160
161 /* i830_vtbl.c
162 */
163 extern void i830InitVtbl(struct i830_context *i830);
164
165 extern void
166 i830_state_draw_region(struct intel_context *intel,
167 struct i830_hw_state *state,
168 struct intel_region *color_region,
169 struct intel_region *depth_region);
170 /* i830_context.c
171 */
172 extern GLboolean
173 i830CreateContext(const __GLcontextModes * mesaVis,
174 __DRIcontextPrivate * driContextPriv,
175 void *sharedContextPrivate);
176
177 /* i830_tex.c, i830_texstate.c
178 */
179 extern void i830UpdateTextureState(struct intel_context *intel);
180
181 extern void i830InitTextureFuncs(struct dd_function_table *functions);
182
183 /* i830_texblend.c
184 */
185 extern GLuint i830SetTexEnvCombine(struct i830_context *i830,
186 const struct gl_tex_env_combine_state
187 *combine, GLint blendUnit, GLuint texel_op,
188 GLuint * state, const GLfloat * factor);
189
190 extern void i830EmitTextureBlend(struct i830_context *i830);
191
192
193 /* i830_state.c
194 */
195 extern void i830InitStateFuncs(struct dd_function_table *functions);
196
197 extern void i830EmitState(struct i830_context *i830);
198
199 extern void i830InitState(struct i830_context *i830);
200
201 /* i830_metaops.c
202 */
203 extern void i830InitMetaFuncs(struct i830_context *i830);
204
205 /*======================================================================
206 * Inline conversion functions. These are better-typed than the
207 * macros used previously:
208 */
209 static INLINE struct i830_context *
210 i830_context(GLcontext * ctx)
211 {
212 return (struct i830_context *) ctx;
213 }
214
215 #endif