2 * GLX Hardware Device Driver for Intel i830
3 * Copyright (C) 1999 Keith Whitwell
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:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
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.
25 /* Adapted for use in the I830M driver:
26 * Jeff Hartmann <jhartmann@2d3d.com>
28 /* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.h,v 1.7 2003/02/06 04:18:01 dawes Exp $ */
30 #ifndef I830CONTEXT_INC
31 #define I830CONTEXT_INC
33 typedef struct i830_context_t i830Context
;
34 typedef struct i830_context_t
*i830ContextPtr
;
35 typedef struct i830_texture_object_t
*i830TextureObjectPtr
;
42 #include "i830_screen.h"
45 #define TAG(x) i830##x
46 #include "tnl_dd/t_dd_vertex.h"
49 #define DV_PF_555 (1<<8)
50 #define DV_PF_565 (2<<8)
51 #define DV_PF_8888 (3<<8)
53 #define I830_TEX_MAXLEVELS 10
55 #define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx->DriverCtx))
56 #define GET_DISPATCH_AGE(imesa) imesa->sarea->last_dispatch
57 #define GET_ENQUEUE_AGE(imesa) imesa->sarea->last_enqueue
60 typedef void (*i830_tri_func
)(i830ContextPtr
, i830Vertex
*, i830Vertex
*,
62 typedef void (*i830_line_func
)(i830ContextPtr
, i830Vertex
*, i830Vertex
*);
63 typedef void (*i830_point_func
)(i830ContextPtr
, i830Vertex
*);
65 #define I830_FALLBACK_TEXTURE 0x1
66 #define I830_FALLBACK_DRAW_BUFFER 0x2
67 #define I830_FALLBACK_READ_BUFFER 0x4
68 #define I830_FALLBACK_COLORMASK 0x8
69 #define I830_FALLBACK_RENDERMODE 0x10
70 #define I830_FALLBACK_STENCIL 0x20
71 #define I830_FALLBACK_STIPPLE 0x40
72 #define I830_FALLBACK_USER 0x80
82 GLuint TexBlendWordsUsed
[I830_TEXBLEND_COUNT
];
83 GLuint TexBlend
[I830_TEXBLEND_COUNT
][I830_TEXBLEND_SIZE
];
84 GLuint Init_TexBlend
[I830_TEXBLEND_COUNT
][I830_TEXBLEND_SIZE
];
85 GLuint Init_TexBlendWordsUsed
[I830_TEXBLEND_COUNT
];
86 GLuint Init_TexBlendColorPipeNum
[I830_TEXBLEND_COUNT
];
87 GLuint TexBlendColorPipeNum
[I830_TEXBLEND_COUNT
];
88 GLuint Init_BufferSetup
[I830_DEST_SETUP_SIZE
];
91 GLenum palette_format
;
95 GLuint Init_Setup
[I830_CTX_SETUP_SIZE
];
97 drmBufPtr vertex_dma_buffer
;
100 GLboolean mask_green
;
102 GLboolean mask_alpha
;
110 int depth_clear_mask
;
111 int stencil_clear_mask
;
117 GLuint LastTexEnabled
;
118 GLuint TexEnabledMask
;
120 /* Texture object bookkeeping
123 driTexHeap
* texture_heaps
[1];
124 driTextureObject swapped
;
126 struct i830_texture_object_t
*CurrentTexObj
[2];
128 /* Rasterization and vertex state:
133 /* Temporaries for translating away float colors:
135 struct gl_client_array UbyteColor
;
136 struct gl_client_array UbyteSecondaryColor
;
138 /* State for i830vb.c and i830tris.c.
140 GLuint SetupNewInputs
;
143 GLmatrix ViewportMatrix
;
144 GLenum render_primitive
;
145 GLenum reduced_primitive
;
147 GLuint vertex_format
;
150 drmBufPtr vertex_buffer
;
154 GLuint vertex_last_prim
;
156 GLboolean upload_cliprects
;
159 /* Fallback rasterization functions
161 i830_point_func draw_point
;
162 i830_line_func draw_line
;
163 i830_tri_func draw_tri
;
167 GLuint dirty
; /* I810_UPLOAD_* */
168 GLuint Setup
[I830_CTX_SETUP_SIZE
];
169 GLuint BufferSetup
[I830_DEST_SETUP_SIZE
];
170 GLuint StippleSetup
[I830_STP_SETUP_SIZE
];
172 int vertex_stride_shift
;
173 unsigned int lastStamp
;
174 GLboolean hw_stipple
;
176 GLenum TexEnvImageFmt
[2];
178 /* State which can't be computed completely on the fly:
184 /* Funny mesa mirrors
191 GLframebuffer
*glBuffer
;
193 /* These refer to the current draw (front vs. back) buffer:
195 char *drawMap
; /* draw buffer address in virtual mem */
197 int drawX
; /* origin of drawable in draw buffer */
199 GLuint numClipRects
; /* cliprects for that buffer */
200 XF86DRIClipRectPtr pClipRects
;
211 XF86DRIClipRectRec draw_rect
;
212 XF86DRIClipRectRec scissor_rect
;
214 drmContext hHWContext
;
218 __DRIdrawablePrivate
*driDrawable
;
219 __DRIscreenPrivate
*driScreen
;
220 i830ScreenPrivate
*i830Screen
;
225 #define I830_TEX_UNIT_ENABLED(unit) (1<<unit)
226 #define VALID_I830_TEXTURE_OBJECT(tobj) (tobj)
228 #define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx->DriverCtx))
229 #define I830_DRIVER_DATA(vb) ((i830VertexBufferPtr)((vb)->driver_data))
230 #define GET_DISPATCH_AGE(imesa) imesa->sarea->last_dispatch
231 #define GET_ENQUEUE_AGE(imesa) imesa->sarea->last_enqueue
234 /* Lock the hardware and validate our state.
236 #define LOCK_HARDWARE( imesa ) \
239 DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
240 (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
242 i830GetLock( imesa, 0 ); \
246 /* Unlock the hardware using the global current context
248 #define UNLOCK_HARDWARE(imesa) \
250 imesa->perf_boxes |= imesa->sarea->perf_boxes; \
251 DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext); \
254 /* This is the wrong way to do it, I'm sure. Otherwise the drm
255 * bitches that I've already got the heavyweight lock. At worst,
256 * this is 3 ioctls. The best solution probably only gets me down
257 * to 2 ioctls in the worst case.
259 #define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
260 LOCK_HARDWARE( imesa ); \
261 i830RegetLockQuiescent( imesa ); \
266 extern void i830GetLock(i830ContextPtr imesa
, GLuint flags
);
267 extern void i830EmitHwStateLocked(i830ContextPtr imesa
);
268 extern void i830EmitDrawingRectangle(i830ContextPtr imesa
);
269 extern void i830XMesaSetBackClipRects(i830ContextPtr imesa
);
270 extern void i830XMesaSetFrontClipRects(i830ContextPtr imesa
);
271 extern void i830DDExtensionsInit(GLcontext
*ctx
);
272 extern void i830DDInitDriverFuncs(GLcontext
*ctx
);
273 extern void i830DDUpdateHwState(GLcontext
*ctx
);
275 #define SUBPIXEL_X 0.125
276 #define SUBPIXEL_Y 0.125
279 /* ================================================================
284 extern int I830_DEBUG
;
289 #define DEBUG_TEXTURE 0x1
290 #define DEBUG_STATE 0x2
291 #define DEBUG_IOCTL 0x4
292 #define DEBUG_PRIMS 0x8
293 #define DEBUG_VERTS 0x10
294 #define DEBUG_FALLBACKS 0x20
295 #define DEBUG_VERBOSE 0x40
296 #define DEBUG_DRI 0x80
297 #define DEBUG_DMA 0x100
298 #define DEBUG_SANITY 0x200
299 #define DEBUG_SYNC 0x400
300 #define DEBUG_SLEEP 0x800
303 #define PCI_CHIP_845_G 0x2562
304 #define PCI_CHIP_I830_M 0x3577
305 #define PCI_CHIP_I855_GM 0x3582
306 #define PCI_CHIP_I865_G 0x2572