mesa: added "main/" prefix to includes, remove some -I paths from Makefile.template
[mesa.git] / src / mesa / drivers / dri / i810 / i810context.h
1 /*
2 * GLX Hardware Device Driver for Intel i810
3 * Copyright (C) 1999 Keith Whitwell
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24 /* $XFree86: xc/lib/GL/mesa/src/drv/i810/main/context.h,v 1.9 2002/12/16 16:18:51 dawes Exp $ */
25
26 #ifndef I810CONTEXT_INC
27 #define I810CONTEXT_INC
28
29 typedef struct i810_context_t i810Context;
30 typedef struct i810_context_t *i810ContextPtr;
31 typedef struct i810_texture_object_t *i810TextureObjectPtr;
32
33 #include "drm.h"
34 #include "main/mtypes.h"
35 #include "main/mm.h"
36
37 #include "i810screen.h"
38 #include "i810tex.h"
39
40
41 /* Reasons to disable hardware rasterization.
42 */
43 #define I810_FALLBACK_TEXTURE 0x1
44 #define I810_FALLBACK_DRAW_BUFFER 0x2
45 #define I810_FALLBACK_READ_BUFFER 0x4
46 #define I810_FALLBACK_COLORMASK 0x8
47 #define I810_FALLBACK_SPECULAR 0x20
48 #define I810_FALLBACK_LOGICOP 0x40
49 #define I810_FALLBACK_RENDERMODE 0x80
50 #define I810_FALLBACK_STENCIL 0x100
51 #define I810_FALLBACK_BLEND_EQ 0x200
52 #define I810_FALLBACK_BLEND_FUNC 0x400
53
54
55 #ifndef PCI_CHIP_I810
56 #define PCI_CHIP_I810 0x7121
57 #define PCI_CHIP_I810_DC100 0x7123
58 #define PCI_CHIP_I810_E 0x7125
59 #define PCI_CHIP_I815 0x1132
60 #endif
61
62 #define IS_I810(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I810 || \
63 imesa->i810Screen->deviceID == PCI_CHIP_I810_DC100 || \
64 imesa->i810Screen->deviceID == PCI_CHIP_I810_E)
65 #define IS_I815(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I815)
66
67
68 #define I810_UPLOAD_TEX(i) (I810_UPLOAD_TEX0<<(i))
69
70 /* Use the templated vertex formats:
71 */
72 #define TAG(x) i810##x
73 #include "tnl_dd/t_dd_vertex.h"
74 #undef TAG
75
76 typedef void (*i810_tri_func)( i810ContextPtr, i810Vertex *, i810Vertex *,
77 i810Vertex * );
78 typedef void (*i810_line_func)( i810ContextPtr, i810Vertex *, i810Vertex * );
79 typedef void (*i810_point_func)( i810ContextPtr, i810Vertex * );
80
81 struct i810_context_t {
82 GLint refcount;
83 GLcontext *glCtx;
84
85 /* Texture object bookkeeping
86 */
87 unsigned nr_heaps;
88 driTexHeap * texture_heaps[1];
89 driTextureObject swapped;
90
91 struct i810_texture_object_t *CurrentTexObj[2];
92
93
94 /* Bit flag to keep track of fallbacks.
95 */
96 GLuint Fallback;
97
98 /* State for i810vb.c and i810tris.c.
99 */
100 GLuint new_state; /* _NEW_* flags */
101 GLuint SetupNewInputs;
102 GLuint SetupIndex;
103 GLuint RenderIndex;
104 GLmatrix ViewportMatrix;
105 GLenum render_primitive;
106 GLenum reduced_primitive;
107 GLuint hw_primitive;
108 GLubyte *verts;
109
110 drmBufPtr vertex_buffer;
111 char *vertex_addr;
112 GLuint vertex_low;
113 GLuint vertex_high;
114 GLuint vertex_last_prim;
115
116 GLboolean upload_cliprects;
117
118
119 /* Fallback rasterization functions
120 */
121 i810_point_func draw_point;
122 i810_line_func draw_line;
123 i810_tri_func draw_tri;
124
125 /* Hardware state
126 */
127 GLuint dirty; /* I810_UPLOAD_* */
128 GLuint Setup[I810_CTX_SETUP_SIZE];
129 GLuint BufferSetup[I810_DEST_SETUP_SIZE];
130 int vertex_size;
131 int vertex_stride_shift;
132 unsigned int lastStamp;
133 GLboolean stipple_in_hw;
134
135 GLenum TexEnvImageFmt[2];
136
137 /* State which can't be computed completely on the fly:
138 */
139 GLuint LcsCullMode;
140 GLuint LcsLineWidth;
141 GLuint LcsPointSize;
142
143 /* Funny mesa mirrors
144 */
145 GLushort ClearColor;
146
147 /* DRI stuff
148 */
149 GLuint needClip;
150 GLframebuffer *glBuffer;
151 GLboolean doPageFlip;
152
153 /* These refer to the current draw (front vs. back) buffer:
154 */
155 int drawX; /* origin of drawable in draw buffer */
156 int drawY;
157 GLuint numClipRects; /* cliprects for that buffer */
158 drm_clip_rect_t *pClipRects;
159
160 int lastSwap;
161 int texAge;
162 int ctxAge;
163 int dirtyAge;
164
165
166 GLboolean scissor;
167 drm_clip_rect_t draw_rect;
168 drm_clip_rect_t scissor_rect;
169
170 drm_context_t hHWContext;
171 drm_hw_lock_t *driHwLock;
172 int driFd;
173
174 __DRIdrawablePrivate *driDrawable;
175 __DRIscreenPrivate *driScreen;
176 i810ScreenPrivate *i810Screen;
177 I810SAREAPtr sarea;
178 };
179
180
181 #define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
182
183 #define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
184 #define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
185
186
187 /* Lock the hardware and validate our state.
188 */
189 #define LOCK_HARDWARE( imesa ) \
190 do { \
191 char __ret=0; \
192 DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
193 (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
194 if (__ret) \
195 i810GetLock( imesa, 0 ); \
196 } while (0)
197
198
199
200 /* Release the kernel lock.
201 */
202 #define UNLOCK_HARDWARE(imesa) \
203 DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
204
205
206 /* This is the wrong way to do it, I'm sure. Otherwise the drm
207 * bitches that I've already got the heavyweight lock. At worst,
208 * this is 3 ioctls. The best solution probably only gets me down
209 * to 2 ioctls in the worst case.
210 */
211 #define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
212 LOCK_HARDWARE( imesa ); \
213 i810RegetLockQuiescent( imesa ); \
214 } while(0)
215
216
217 extern void i810GetLock( i810ContextPtr imesa, GLuint flags );
218 extern void i810EmitHwStateLocked( i810ContextPtr imesa );
219 extern void i810EmitScissorValues( i810ContextPtr imesa, int box_nr, int emit );
220 extern void i810EmitDrawingRectangle( i810ContextPtr imesa );
221 extern void i810XMesaSetBackClipRects( i810ContextPtr imesa );
222 extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa );
223
224 #define SUBPIXEL_X -.5
225 #define SUBPIXEL_Y -.5
226
227 /* ================================================================
228 * Debugging:
229 */
230 #define DO_DEBUG 1
231 #if DO_DEBUG
232 extern int I810_DEBUG;
233 #else
234 #define I810_DEBUG 0
235 #endif
236
237 #define DEBUG_TEXTURE 0x1
238 #define DEBUG_STATE 0x2
239 #define DEBUG_IOCTL 0x4
240 #define DEBUG_PRIMS 0x8
241 #define DEBUG_VERTS 0x10
242 #define DEBUG_FALLBACKS 0x20
243 #define DEBUG_VERBOSE 0x40
244 #define DEBUG_DRI 0x80
245 #define DEBUG_DMA 0x100
246 #define DEBUG_SANITY 0x200
247 #define DEBUG_SYNC 0x400
248 #define DEBUG_SLEEP 0x800
249
250 #endif