2 * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Alan Hourihane not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Alan Hourihane makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
14 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
22 * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
24 * Trident CyberBladeXP driver.
27 #ifndef _TRIDENT_CONTEXT_H_
28 #define _TRIDENT_CONTEXT_H_
31 #include "main/macros.h"
32 #include "main/mtypes.h"
36 #define SUBPIXEL_X (0.0F)
37 #define SUBPIXEL_Y (0.125F)
39 #define _TRIDENT_NEW_VERTEX (_NEW_TEXTURE | \
40 _DD_NEW_TRI_UNFILLED | \
41 _DD_NEW_TRI_LIGHT_TWOSIDE)
43 #define TRIDENT_FALLBACK_TEXTURE 0x01
44 #define TRIDENT_FALLBACK_DRAW_BUFFER 0x02
46 #define TRIDENT_NEW_CLIP 0x01
48 #define TRIDENT_UPLOAD_COMMAND_D 0x00000001
49 #define TRIDENT_UPLOAD_CONTEXT 0x04000000
50 #define TRIDENT_UPLOAD_CLIPRECTS 0x80000000
52 #define TAG(x) trident##x
53 #include "tnl_dd/t_dd_vertex.h"
56 /* these require that base be dword-aligned */
57 static INLINE
void MMIO_OUT32(unsigned char *base
, unsigned int offset
,
60 unsigned int *addr
= (unsigned int *)(base
+ offset
);
64 static INLINE
unsigned int MMIO_IN32(unsigned char *base
, unsigned int offset
)
66 unsigned int *addr
= (unsigned int *)(base
+ offset
);
70 #define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val)
71 #define MMIO_IN8(base, offset) *((base) + (offset))
73 struct trident_context
;
74 typedef struct trident_context tridentContextRec
;
75 typedef struct trident_context
*tridentContextPtr
;
77 typedef void (*trident_quad_func
)( tridentContextPtr
,
78 const tridentVertex
*,
79 const tridentVertex
*,
80 const tridentVertex
*,
81 const tridentVertex
* );
82 typedef void (*trident_tri_func
)( tridentContextPtr
,
83 const tridentVertex
*,
84 const tridentVertex
*,
85 const tridentVertex
* );
86 typedef void (*trident_line_func
)( tridentContextPtr
,
87 const tridentVertex
*,
88 const tridentVertex
* );
89 typedef void (*trident_point_func
)( tridentContextPtr
,
90 const tridentVertex
* );
93 drm_handle_t handle
; /* Handle to the DRM region */
94 drmSize size
; /* Size of the DRM region */
95 unsigned char *map
; /* Mapping of the DRM region */
96 } tridentRegionRec
, *tridentRegionPtr
;
99 __DRIscreenPrivate
*driScreen
; /* Back pointer to DRI screen */
101 drmBufMapPtr buffers
;
103 unsigned int frontOffset
;
104 unsigned int frontPitch
;
105 unsigned int backOffset
;
106 unsigned int backPitch
;
107 unsigned int depthOffset
;
108 unsigned int depthPitch
;
114 unsigned int sarea_priv_offset
;
117 tridentRegionRec mmio
;
118 } tridentScreenRec
, *tridentScreenPtr
;
121 * tridentRenderbuffer, derived from Mesa's gl_renderbuffer
124 struct gl_renderbuffer Base
;
125 /* XXX per-window info should go here */
127 } tridentRenderbuffer
;
130 struct trident_context
{
131 GLcontext
*glCtx
; /* Mesa context */
133 __DRIcontextPrivate
*driContext
;
134 __DRIscreenPrivate
*driScreen
;
135 __DRIdrawablePrivate
*driDrawable
;
142 drm_trident_sarea_t
*sarea
;
145 /* Temporaries for translating away float colors:
147 struct gl_client_array UbyteColor
;
148 struct gl_client_array UbyteSecondaryColor
;
150 /* Mirrors of some DRI state
152 int lastStamp
; /* mirror driDrawable->lastStamp */
154 drm_context_t hHWContext
;
158 tridentScreenPtr tridentScreen
; /* Screen private DRI data */
160 /* Visual, drawable, cliprect and scissor information
163 GLint drawOffset
, drawPitch
;
164 GLint drawX
, drawY
; /* origin of drawable in draw buffer */
165 GLint readOffset
, readPitch
;
167 GLuint numClipRects
; /* Cliprects for the draw buffer */
168 drm_clip_rect_t
*pClipRects
;
171 drm_clip_rect_t ScissorRect
; /* Current software scissor */
175 GLuint SetupNewInputs
;
177 GLfloat hw_viewport
[16];
179 GLuint vertex_format
;
181 GLuint vertex_stride_shift
;
187 GLenum render_primitive
;
189 trident_point_func draw_point
;
190 trident_line_func draw_line
;
191 trident_tri_func draw_tri
;
192 trident_quad_func draw_quad
;
195 gammaTextureObjectPtr CurrentTexObj
[2];
196 struct gamma_texture_object_t TexObjList
;
197 struct gamma_texture_object_t SwappedOut
;
198 GLenum TexEnvImageFmt
[2];
200 struct mem_block
*texHeap
;
218 void tridentDDInitExtensions( GLcontext
*ctx
);
219 void tridentDDInitDriverFuncs( GLcontext
*ctx
);
220 void tridentDDInitSpanFuncs( GLcontext
*ctx
);
221 void tridentDDInitState( tridentContextPtr tmesa
);
222 void tridentInitHW( tridentContextPtr tmesa
);
223 void tridentDDInitStateFuncs( GLcontext
*ctx
);
224 void tridentDDInitTextureFuncs( GLcontext
*ctx
);
225 void tridentDDInitTriFuncs( GLcontext
*ctx
);
227 extern void tridentBuildVertices( GLcontext
*ctx
,
231 extern void tridentInitVB( GLcontext
*ctx
);
232 extern void tridentCopyBuffer( const __DRIdrawablePrivate
*dPriv
);
233 extern void tridentFallback( tridentContextPtr tmesa
, GLuint bit
,
235 extern void tridentCheckTexSizes( GLcontext
*ctx
);
236 extern void tridentChooseVertexState( GLcontext
*ctx
);
237 extern void tridentDDUpdateHWState( GLcontext
*ctx
);
238 extern void tridentUploadHwStateLocked( tridentContextPtr tmesa
);
240 #define TRIDENT_CONTEXT(ctx) ((tridentContextPtr)(ctx->DriverCtx))
242 #endif /* _TRIDENT_CONTEXT_H_ */