fix up radeon span functions using latest r200 code from Brian,
[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_TEX(i) (0x10<<(i))
43 #define I830_UPLOAD_TEXBLEND(i) (0x100<<(i))
44 #define I830_UPLOAD_TEX_ALL (0x0f0)
45 #define I830_UPLOAD_TEXBLEND_ALL (0xf00)
46
47 /* State structure offsets - these will probably disappear.
48 */
49 #define I830_DESTREG_CBUFADDR0 0
50 #define I830_DESTREG_CBUFADDR1 1
51 #define I830_DESTREG_CBUFADDR2 2
52 #define I830_DESTREG_DBUFADDR0 3
53 #define I830_DESTREG_DBUFADDR1 4
54 #define I830_DESTREG_DBUFADDR2 5
55 #define I830_DESTREG_DV0 6
56 #define I830_DESTREG_DV1 7
57 #define I830_DESTREG_SENABLE 8
58 #define I830_DESTREG_SR0 9
59 #define I830_DESTREG_SR1 10
60 #define I830_DESTREG_SR2 11
61 #define I830_DEST_SETUP_SIZE 12
62
63 #define I830_CTXREG_STATE1 0
64 #define I830_CTXREG_STATE2 1
65 #define I830_CTXREG_STATE3 2
66 #define I830_CTXREG_STATE4 3
67 #define I830_CTXREG_STATE5 4
68 #define I830_CTXREG_IALPHAB 5
69 #define I830_CTXREG_STENCILTST 6
70 #define I830_CTXREG_ENABLES_1 7
71 #define I830_CTXREG_ENABLES_2 8
72 #define I830_CTXREG_AA 9
73 #define I830_CTXREG_FOGCOLOR 10
74 #define I830_CTXREG_BLENDCOLOR0 11
75 #define I830_CTXREG_BLENDCOLOR1 12
76 #define I830_CTXREG_VF 13
77 #define I830_CTXREG_VF2 14
78 #define I830_CTXREG_MCSB0 15
79 #define I830_CTXREG_MCSB1 16
80 #define I830_CTX_SETUP_SIZE 17
81
82 #define I830_STPREG_ST0 0
83 #define I830_STPREG_ST1 1
84 #define I830_STP_SETUP_SIZE 2
85
86 #define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
87 #define I830_TEXREG_TM0S0 1
88 #define I830_TEXREG_TM0S1 2
89 #define I830_TEXREG_TM0S2 3
90 #define I830_TEXREG_TM0S3 4
91 #define I830_TEXREG_TM0S4 5
92 #define I830_TEXREG_MCS 6 /* _3DSTATE_MAP_COORD_SETS */
93 #define I830_TEXREG_CUBE 7 /* _3DSTATE_MAP_SUBE */
94 #define I830_TEX_SETUP_SIZE 8
95
96 #define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
97
98 struct i830_texture_object
99 {
100 struct intel_texture_object intel;
101 GLuint Setup[I830_TEX_SETUP_SIZE];
102 };
103
104 #define I830_TEX_UNITS 4
105
106 struct i830_hw_state {
107 GLuint Ctx[I830_CTX_SETUP_SIZE];
108 GLuint Buffer[I830_DEST_SETUP_SIZE];
109 GLuint Stipple[I830_STP_SETUP_SIZE];
110 GLuint Tex[I830_TEX_UNITS][I830_TEX_SETUP_SIZE];
111 GLuint TexBlend[I830_TEX_UNITS][I830_TEXBLEND_SIZE];
112 GLuint TexBlendWordsUsed[I830_TEX_UNITS];
113 GLuint emitted; /* I810_UPLOAD_* */
114 GLuint active;
115 };
116
117 struct i830_context
118 {
119 struct intel_context intel;
120
121 GLuint last_index;
122
123 struct i830_hw_state meta, initial, state, *current;
124 };
125
126 typedef struct i830_context *i830ContextPtr;
127 typedef struct i830_texture_object *i830TextureObjectPtr;
128
129 #define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx))
130
131
132
133 #define I830_STATECHANGE(i830, flag) \
134 do { \
135 INTEL_FIREVERTICES( &i830->intel ); \
136 i830->state.emitted &= ~flag; \
137 } while (0)
138
139 #define I830_ACTIVESTATE(i830, flag, mode) \
140 do { \
141 INTEL_FIREVERTICES( &i830->intel ); \
142 if (mode) \
143 i830->state.active |= flag; \
144 else \
145 i830->state.active &= ~flag; \
146 } while (0)
147
148 /* i830_vtbl.c
149 */
150 extern void
151 i830InitVtbl( i830ContextPtr i830 );
152
153 /* i830_context.c
154 */
155 extern GLboolean
156 i830CreateContext( const __GLcontextModes *mesaVis,
157 __DRIcontextPrivate *driContextPriv,
158 void *sharedContextPrivate);
159
160 /* i830_tex.c, i830_texstate.c
161 */
162 extern void
163 i830UpdateTextureState( intelContextPtr intel );
164
165 extern void
166 i830InitTextureFuncs( struct dd_function_table *functions );
167
168 extern intelTextureObjectPtr
169 i830AllocTexObj( struct gl_texture_object *tObj );
170
171 /* i830_texblend.c
172 */
173 extern GLuint i830SetTexEnvCombine(i830ContextPtr i830,
174 const struct gl_tex_env_combine_state * combine, GLint blendUnit,
175 GLuint texel_op, GLuint *state, const GLfloat *factor );
176
177 extern void
178 i830EmitTextureBlend( i830ContextPtr i830 );
179
180
181 /* i830_state.c
182 */
183 extern void
184 i830InitStateFuncs( struct dd_function_table *functions );
185
186 extern void
187 i830EmitState( i830ContextPtr i830 );
188
189 extern void
190 i830InitState( i830ContextPtr i830 );
191
192 /* i830_metaops.c
193 */
194 extern GLboolean
195 i830TryTextureReadPixels( GLcontext *ctx,
196 GLint x, GLint y, GLsizei width, GLsizei height,
197 GLenum format, GLenum type,
198 const struct gl_pixelstore_attrib *pack,
199 GLvoid *pixels );
200
201 extern GLboolean
202 i830TryTextureDrawPixels( GLcontext *ctx,
203 GLint x, GLint y, GLsizei width, GLsizei height,
204 GLenum format, GLenum type,
205 const struct gl_pixelstore_attrib *unpack,
206 const GLvoid *pixels );
207
208 extern void
209 i830ClearWithTris( intelContextPtr intel, GLbitfield mask,
210 GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
211
212
213
214 #endif
215