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
;
41 #include "tnl/t_vertex.h"
43 #include "i830_screen.h"
46 #define TAG(x) i830##x
47 #include "tnl_dd/t_dd_vertex.h"
50 #define DV_PF_555 (1<<8)
51 #define DV_PF_565 (2<<8)
52 #define DV_PF_8888 (3<<8)
54 #define I830_TEX_MAXLEVELS 10
56 #define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx->DriverCtx))
57 #define GET_DISPATCH_AGE(imesa) imesa->sarea->last_dispatch
58 #define GET_ENQUEUE_AGE(imesa) imesa->sarea->last_enqueue
61 typedef void (*i830_tri_func
)(i830ContextPtr
, i830Vertex
*, i830Vertex
*,
63 typedef void (*i830_line_func
)(i830ContextPtr
, i830Vertex
*, i830Vertex
*);
64 typedef void (*i830_point_func
)(i830ContextPtr
, i830Vertex
*);
66 #define I830_MAX_TEXTURE_UNITS 4
68 #define I830_FALLBACK_TEXTURE 0x1
69 #define I830_FALLBACK_DRAW_BUFFER 0x2
70 #define I830_FALLBACK_READ_BUFFER 0x4
71 #define I830_FALLBACK_COLORMASK 0x8
72 #define I830_FALLBACK_RENDERMODE 0x10
73 #define I830_FALLBACK_STENCIL 0x20
74 #define I830_FALLBACK_STIPPLE 0x40
75 #define I830_FALLBACK_USER 0x80
85 GLuint TexBlendWordsUsed
[I830_MAX_TEXTURE_UNITS
];
86 GLuint TexBlend
[I830_MAX_TEXTURE_UNITS
][I830_TEXBLEND_SIZE
];
87 GLuint Init_TexBlend
[I830_MAX_TEXTURE_UNITS
][I830_TEXBLEND_SIZE
];
88 GLuint Init_TexBlendWordsUsed
[I830_MAX_TEXTURE_UNITS
];
89 GLuint Init_BufferSetup
[I830_DEST_SETUP_SIZE
];
90 GLuint LodBias
[I830_MAX_TEXTURE_UNITS
];
92 GLenum palette_format
;
96 GLuint Init_Setup
[I830_CTX_SETUP_SIZE
];
98 drmBufPtr vertex_dma_buffer
;
101 GLboolean mask_green
;
103 GLboolean mask_alpha
;
111 int depth_clear_mask
;
112 int stencil_clear_mask
;
118 GLuint LastTexEnabled
;
119 GLuint TexEnabledMask
;
121 /* Texture object bookkeeping
124 driTexHeap
* texture_heaps
[1];
125 driTextureObject swapped
;
127 struct i830_texture_object_t
*CurrentTexObj
[I830_MAX_TEXTURE_UNITS
];
129 /* Rasterization and vertex state:
137 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
138 GLuint vertex_attr_count
;
139 char *verts
; /* points to tnl->clipspace.vertex_buf */
142 /* State for i830tris.c.
145 GLmatrix ViewportMatrix
;
146 GLenum render_primitive
;
147 GLenum reduced_primitive
;
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
];
171 unsigned int lastStamp
;
172 GLboolean hw_stipple
;
174 GLenum TexEnvImageFmt
[2];
176 /* State which can't be computed completely on the fly:
182 /* Funny mesa mirrors
189 GLframebuffer
*glBuffer
;
191 /* These refer to the current draw (front vs. back) buffer:
193 char *drawMap
; /* draw buffer address in virtual mem */
195 int drawX
; /* origin of drawable in draw buffer */
197 GLuint numClipRects
; /* cliprects for that buffer */
198 drm_clip_rect_t
*pClipRects
;
209 drm_clip_rect_t draw_rect
;
210 drm_clip_rect_t scissor_rect
;
212 drm_context_t hHWContext
;
216 __DRIdrawablePrivate
*driDrawable
; /**< DRI drawable bound to this
217 * context for drawing.
219 __DRIdrawablePrivate
*driReadable
; /**< DRI drawable bound to this
220 * context for reading.
224 * Drawable used by Mesa for software fallbacks for reading and
225 * writing. It is set by Mesa's \c SetBuffer callback, and will always be
226 * either \c i830_context_t::driDrawable or \c i830_context_t::driReadable.
229 __DRIdrawablePrivate
* mesa_drawable
;
231 __DRIscreenPrivate
*driScreen
;
232 i830ScreenPrivate
*i830Screen
;
236 * Configuration cache
238 driOptionCache optionCache
;
242 #define I830_TEX_UNIT_ENABLED(unit) (1<<unit)
243 #define VALID_I830_TEXTURE_OBJECT(tobj) (tobj)
245 #define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx->DriverCtx))
246 #define I830_DRIVER_DATA(vb) ((i830VertexBufferPtr)((vb)->driver_data))
247 #define GET_DISPATCH_AGE(imesa) imesa->sarea->last_dispatch
248 #define GET_ENQUEUE_AGE(imesa) imesa->sarea->last_enqueue
251 /* Lock the hardware and validate our state.
253 #define LOCK_HARDWARE( imesa ) \
256 DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
257 (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
259 i830GetLock( imesa, 0 ); \
263 /* Unlock the hardware using the global current context
265 #define UNLOCK_HARDWARE(imesa) \
267 imesa->perf_boxes |= imesa->sarea->perf_boxes; \
268 DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext); \
271 /* This is the wrong way to do it, I'm sure. Otherwise the drm
272 * bitches that I've already got the heavyweight lock. At worst,
273 * this is 3 ioctls. The best solution probably only gets me down
274 * to 2 ioctls in the worst case.
276 #define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
277 LOCK_HARDWARE( imesa ); \
278 i830RegetLockQuiescent( imesa ); \
283 extern void i830GetLock(i830ContextPtr imesa
, GLuint flags
);
284 extern void i830EmitHwStateLocked(i830ContextPtr imesa
);
285 extern void i830EmitDrawingRectangle(i830ContextPtr imesa
);
286 extern void i830XMesaSetBackClipRects(i830ContextPtr imesa
);
287 extern void i830XMesaSetFrontClipRects(i830ContextPtr imesa
);
288 extern void i830DDExtensionsInit(GLcontext
*ctx
);
289 extern void i830DDInitDriverFuncs(GLcontext
*ctx
);
290 extern void i830DDUpdateHwState(GLcontext
*ctx
);
292 #define SUBPIXEL_X 0.125
293 #define SUBPIXEL_Y 0.125
296 /* ================================================================
301 extern int I830_DEBUG
;
306 #define DEBUG_TEXTURE 0x1
307 #define DEBUG_STATE 0x2
308 #define DEBUG_IOCTL 0x4
309 #define DEBUG_PRIMS 0x8
310 #define DEBUG_VERTS 0x10
311 #define DEBUG_FALLBACKS 0x20
312 #define DEBUG_VERBOSE 0x40
313 #define DEBUG_DRI 0x80
314 #define DEBUG_DMA 0x100
315 #define DEBUG_SANITY 0x200
316 #define DEBUG_SYNC 0x400
317 #define DEBUG_SLEEP 0x800
320 #define PCI_CHIP_845_G 0x2562
321 #define PCI_CHIP_I830_M 0x3577
322 #define PCI_CHIP_I855_GM 0x3582
323 #define PCI_CHIP_I865_G 0x2572