2 * GLX Hardware Device Driver for Intel i810
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.
24 /* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810context.h,v 1.9 2002/12/16 16:18:51 dawes Exp $ */
26 #ifndef I810CONTEXT_INC
27 #define I810CONTEXT_INC
29 typedef struct i810_context_t i810Context
;
30 typedef struct i810_context_t
*i810ContextPtr
;
31 typedef struct i810_texture_object_t
*i810TextureObjectPtr
;
37 #include "i810screen.h"
41 /* Reasons to disable hardware rasterization.
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
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
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)
68 #define I810_UPLOAD_TEX(i) (I810_UPLOAD_TEX0<<(i))
70 /* Use the templated vertex formats:
72 #define TAG(x) i810##x
73 #include "tnl_dd/t_dd_vertex.h"
76 typedef void (*i810_tri_func
)( i810ContextPtr
, i810Vertex
*, i810Vertex
*,
78 typedef void (*i810_line_func
)( i810ContextPtr
, i810Vertex
*, i810Vertex
* );
79 typedef void (*i810_point_func
)( i810ContextPtr
, i810Vertex
* );
81 struct i810_context_t
{
85 /* Texture object bookkeeping
88 driTexHeap
* texture_heaps
[1];
89 driTextureObject swapped
;
91 struct i810_texture_object_t
*CurrentTexObj
[2];
94 /* Bit flag to keep track of fallbacks.
98 /* State for i810vb.c and i810tris.c.
100 GLuint new_state
; /* _NEW_* flags */
101 GLuint SetupNewInputs
;
104 GLmatrix ViewportMatrix
;
105 GLenum render_primitive
;
106 GLenum reduced_primitive
;
110 drmBufPtr vertex_buffer
;
114 GLuint vertex_last_prim
;
116 GLboolean upload_cliprects
;
119 /* Fallback rasterization functions
121 i810_point_func draw_point
;
122 i810_line_func draw_line
;
123 i810_tri_func draw_tri
;
127 GLuint dirty
; /* I810_UPLOAD_* */
128 GLuint Setup
[I810_CTX_SETUP_SIZE
];
129 GLuint BufferSetup
[I810_DEST_SETUP_SIZE
];
131 int vertex_stride_shift
;
132 unsigned int lastStamp
;
133 GLboolean stipple_in_hw
;
135 GLenum TexEnvImageFmt
[2];
137 /* State which can't be computed completely on the fly:
143 /* Funny mesa mirrors
150 GLframebuffer
*glBuffer
;
151 GLboolean doPageFlip
;
153 /* These refer to the current draw (front vs. back) buffer:
155 char *drawMap
; /* draw buffer address in virtual mem */
157 int drawX
; /* origin of drawable in draw buffer */
159 GLuint numClipRects
; /* cliprects for that buffer */
160 drm_clip_rect_t
*pClipRects
;
169 drm_clip_rect_t draw_rect
;
170 drm_clip_rect_t scissor_rect
;
172 drm_context_t hHWContext
;
173 drm_hw_lock_t
*driHwLock
;
176 __DRIdrawablePrivate
*driDrawable
;
177 __DRIscreenPrivate
*driScreen
;
178 i810ScreenPrivate
*i810Screen
;
183 #define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
185 #define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
186 #define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
189 /* Lock the hardware and validate our state.
191 #define LOCK_HARDWARE( imesa ) \
194 DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
195 (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
197 i810GetLock( imesa, 0 ); \
202 /* Release the kernel lock.
204 #define UNLOCK_HARDWARE(imesa) \
205 DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
208 /* This is the wrong way to do it, I'm sure. Otherwise the drm
209 * bitches that I've already got the heavyweight lock. At worst,
210 * this is 3 ioctls. The best solution probably only gets me down
211 * to 2 ioctls in the worst case.
213 #define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
214 LOCK_HARDWARE( imesa ); \
215 i810RegetLockQuiescent( imesa ); \
219 extern void i810GetLock( i810ContextPtr imesa
, GLuint flags
);
220 extern void i810EmitHwStateLocked( i810ContextPtr imesa
);
221 extern void i810EmitScissorValues( i810ContextPtr imesa
, int box_nr
, int emit
);
222 extern void i810EmitDrawingRectangle( i810ContextPtr imesa
);
223 extern void i810XMesaSetBackClipRects( i810ContextPtr imesa
);
224 extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa
);
226 #define SUBPIXEL_X -.5
227 #define SUBPIXEL_Y -.5
229 /* ================================================================
234 extern int I810_DEBUG
;
239 #define DEBUG_TEXTURE 0x1
240 #define DEBUG_STATE 0x2
241 #define DEBUG_IOCTL 0x4
242 #define DEBUG_PRIMS 0x8
243 #define DEBUG_VERTS 0x10
244 #define DEBUG_FALLBACKS 0x20
245 #define DEBUG_VERBOSE 0x40
246 #define DEBUG_DRI 0x80
247 #define DEBUG_DMA 0x100
248 #define DEBUG_SANITY 0x200
249 #define DEBUG_SYNC 0x400
250 #define DEBUG_SLEEP 0x800