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.
25 #ifndef I810CONTEXT_INC
26 #define I810CONTEXT_INC
28 typedef struct i810_context_t i810Context
;
29 typedef struct i810_context_t
*i810ContextPtr
;
30 typedef struct i810_texture_object_t
*i810TextureObjectPtr
;
36 #include "i810screen.h"
40 /* Reasons to disable hardware rasterization.
42 #define I810_FALLBACK_TEXTURE 0x1
43 #define I810_FALLBACK_DRAW_BUFFER 0x2
44 #define I810_FALLBACK_READ_BUFFER 0x4
45 #define I810_FALLBACK_COLORMASK 0x8
46 #define I810_FALLBACK_SPECULAR 0x20
47 #define I810_FALLBACK_LOGICOP 0x40
48 #define I810_FALLBACK_RENDERMODE 0x80
49 #define I810_FALLBACK_STENCIL 0x100
50 #define I810_FALLBACK_BLEND_EQ 0x200
51 #define I810_FALLBACK_BLEND_FUNC 0x400
55 #define PCI_CHIP_I810 0x7121
56 #define PCI_CHIP_I810_DC100 0x7123
57 #define PCI_CHIP_I810_E 0x7125
58 #define PCI_CHIP_I815 0x1132
61 #define IS_I810(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I810 || \
62 imesa->i810Screen->deviceID == PCI_CHIP_I810_DC100 || \
63 imesa->i810Screen->deviceID == PCI_CHIP_I810_E)
64 #define IS_I815(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I815)
67 #define I810_UPLOAD_TEX(i) (I810_UPLOAD_TEX0<<(i))
69 /* Use the templated vertex formats:
71 #define TAG(x) i810##x
72 #include "tnl_dd/t_dd_vertex.h"
75 typedef void (*i810_tri_func
)( i810ContextPtr
, i810Vertex
*, i810Vertex
*,
77 typedef void (*i810_line_func
)( i810ContextPtr
, i810Vertex
*, i810Vertex
* );
78 typedef void (*i810_point_func
)( i810ContextPtr
, i810Vertex
* );
80 struct i810_context_t
{
84 /* Texture object bookkeeping
87 driTexHeap
* texture_heaps
[1];
88 driTextureObject swapped
;
90 struct i810_texture_object_t
*CurrentTexObj
[2];
93 /* Bit flag to keep track of fallbacks.
97 /* State for i810vb.c and i810tris.c.
99 GLuint new_state
; /* _NEW_* flags */
100 GLuint SetupNewInputs
;
103 GLmatrix ViewportMatrix
;
104 GLenum render_primitive
;
105 GLenum reduced_primitive
;
109 drmBufPtr vertex_buffer
;
113 GLuint vertex_last_prim
;
115 GLboolean upload_cliprects
;
118 /* Fallback rasterization functions
120 i810_point_func draw_point
;
121 i810_line_func draw_line
;
122 i810_tri_func draw_tri
;
126 GLuint dirty
; /* I810_UPLOAD_* */
127 GLuint Setup
[I810_CTX_SETUP_SIZE
];
128 GLuint BufferSetup
[I810_DEST_SETUP_SIZE
];
130 int vertex_stride_shift
;
131 unsigned int lastStamp
;
132 GLboolean stipple_in_hw
;
134 GLenum TexEnvImageFmt
[2];
136 /* State which can't be computed completely on the fly:
142 /* Funny mesa mirrors
149 GLframebuffer
*glBuffer
;
150 GLboolean doPageFlip
;
152 /* These refer to the current draw (front vs. back) buffer:
154 int drawX
; /* origin of drawable in draw buffer */
156 GLuint numClipRects
; /* cliprects for that buffer */
157 drm_clip_rect_t
*pClipRects
;
166 drm_clip_rect_t draw_rect
;
167 drm_clip_rect_t scissor_rect
;
169 drm_context_t hHWContext
;
170 drm_hw_lock_t
*driHwLock
;
173 __DRIdrawablePrivate
*driDrawable
;
174 __DRIscreenPrivate
*driScreen
;
175 i810ScreenPrivate
*i810Screen
;
180 #define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
182 #define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
183 #define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
186 /* Lock the hardware and validate our state.
188 #define LOCK_HARDWARE( imesa ) \
191 DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
192 (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
194 i810GetLock( imesa, 0 ); \
199 /* Release the kernel lock.
201 #define UNLOCK_HARDWARE(imesa) \
202 DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
205 /* This is the wrong way to do it, I'm sure. Otherwise the drm
206 * bitches that I've already got the heavyweight lock. At worst,
207 * this is 3 ioctls. The best solution probably only gets me down
208 * to 2 ioctls in the worst case.
210 #define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
211 LOCK_HARDWARE( imesa ); \
212 i810RegetLockQuiescent( imesa ); \
216 extern void i810GetLock( i810ContextPtr imesa
, GLuint flags
);
217 extern void i810EmitHwStateLocked( i810ContextPtr imesa
);
218 extern void i810EmitScissorValues( i810ContextPtr imesa
, int box_nr
, int emit
);
219 extern void i810EmitDrawingRectangle( i810ContextPtr imesa
);
220 extern void i810XMesaSetBackClipRects( i810ContextPtr imesa
);
221 extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa
);
223 #define SUBPIXEL_X -.5
224 #define SUBPIXEL_Y -.5
226 /* ================================================================
231 extern int I810_DEBUG
;
236 #define DEBUG_TEXTURE 0x1
237 #define DEBUG_STATE 0x2
238 #define DEBUG_IOCTL 0x4
239 #define DEBUG_PRIMS 0x8
240 #define DEBUG_VERTS 0x10
241 #define DEBUG_FALLBACKS 0x20
242 #define DEBUG_VERBOSE 0x40
243 #define DEBUG_DRI 0x80
244 #define DEBUG_DMA 0x100
245 #define DEBUG_SANITY 0x200
246 #define DEBUG_SYNC 0x400
247 #define DEBUG_SLEEP 0x800