2 * Author: Max Lingua <sunmax@libero.it>
5 #ifndef _S3V_CONTEXT_H_
6 #define _S3V_CONTEXT_H_
12 #include "s3v_macros.h"
13 #include "s3v_screen.h"
19 /* Flags for context */
20 #define S3V_FRONT_BUFFER 0x00000001
21 #define S3V_BACK_BUFFER 0x00000002
22 #define S3V_DEPTH_BUFFER 0x00000004
25 #define S3V_MAX_TEXTURE_SIZE 2048
27 /* These are the minimum requirements and should probably be increased */
28 #define MAX_MODELVIEW_STACK 16
29 #define MAX_PROJECTION_STACK 2
30 #define MAX_TEXTURE_STACK 2
32 extern void s3vDDUpdateHWState(GLcontext
*ctx
);
33 extern s3vScreenPtr
s3vCreateScreen(__DRIscreenPrivate
*sPriv
);
34 extern void s3vDestroyScreen(__DRIscreenPrivate
*sPriv
);
35 extern GLboolean
s3vCreateContext( Display
*dpy
,
36 const __GLcontextModes
*glVisual
,
37 __DRIcontextPrivate
*driContextPriv
,
38 void *sharedContextPrivate
);
40 #define S3V_UPLOAD_ALL 0xffffffff
41 /* #define S3V_UPLOAD_CLIPRECTS 0x00000002 */
42 #define S3V_UPLOAD_ALPHA 0x00000004
43 #define S3V_UPLOAD_BLEND 0x00000008
44 #define S3V_UPLOAD_DEPTH 0x00000010
45 #define S3V_UPLOAD_VIEWPORT 0x00000020
46 #define S3V_UPLOAD_SHADE 0x00000040
47 #define S3V_UPLOAD_CLIP 0x00000080
48 #define S3V_UPLOAD_MASKS 0x00000100
49 #define S3V_UPLOAD_WINDOW 0x00000200 /* defunct */
50 #define S3V_UPLOAD_GEOMETRY 0x00000400
51 #define S3V_UPLOAD_POLYGON 0x00000800
52 #define S3V_UPLOAD_DITHER 0x00001000
53 #define S3V_UPLOAD_LOGICOP 0x00002000
54 #define S3V_UPLOAD_FOG 0x00004000
55 #define S3V_UPLOAD_LIGHT 0x00008000
56 #define S3V_UPLOAD_CONTEXT 0x00010000
57 #define S3V_UPLOAD_TEX0 0x00020000
58 #define S3V_UPLOAD_STIPPLE 0x00040000
59 #define S3V_UPLOAD_TRANSFORM 0x00080000
60 #define S3V_UPLOAD_LINEMODE 0x00100000
61 #define S3V_UPLOAD_POINTMODE 0x00200000
62 #define S3V_UPLOAD_TRIMODE 0x00400000
64 #define S3V_NEW_CLIP 0x00000001
65 #define S3V_NEW_WINDOW 0x00000002
66 #define S3V_NEW_CONTEXT 0x00000004
67 #define S3V_NEW_TEXTURE 0x00000008 /* defunct */
68 #define S3V_NEW_ALPHA 0x00000010
69 #define S3V_NEW_DEPTH 0x00000020
70 #define S3V_NEW_MASKS 0x00000040
71 #define S3V_NEW_POLYGON 0x00000080
72 #define S3V_NEW_CULL 0x00000100
73 #define S3V_NEW_LOGICOP 0x00000200
74 #define S3V_NEW_FOG 0x00000400
75 #define S3V_NEW_LIGHT 0x00000800
76 #define S3V_NEW_STIPPLE 0x00001000
77 #define S3V_NEW_ALL 0xffffffff
79 #define S3V_FALLBACK_TRI 0x00000001
80 #define S3V_FALLBACK_TEXTURE 0x00000002
83 typedef struct s3v_context s3vContextRec
;
84 typedef struct s3v_context
*s3vContextPtr
;
85 typedef struct s3v_texture_object_t
*s3vTextureObjectPtr
;
87 #define VALID_S3V_TEXTURE_OBJECT(tobj) (tobj)
89 #define S3V_TEX_MAXLEVELS 12
91 /* For shared texture space managment, these texture objects may also
92 * be used as proxies for regions of texture memory containing other
93 * client's textures. Such proxy textures (not to be confused with GL
94 * proxy textures) are subject to the same LRU aging we use for our
95 * own private textures, and thus we have a mechanism where we can
96 * fairly decide between kicking out our own textures and those of
99 * Non-local texture objects have a valid MemBlock to describe the
100 * region managed by the other client, and can be identified by
103 struct s3v_texture_object_t
{
104 struct s3v_texture_object_t
*next
, *prev
;
107 struct gl_texture_object
*globj
;
123 GLint firstLevel
, lastLevel
; /* upload tObj->Image[first .. lastLevel] */
126 const struct gl_texture_image
*image
;
127 int offset
; /* into BufAddr */
130 } image
[S3V_TEX_MAXLEVELS
];
134 CARD32 TextureColorMode
;
135 CARD32 TextureFilterMode
;
136 CARD32 TextureBorderColor
;
138 CARD32 TextureMipSize
;
140 CARD32 TextureBaseAddr
[S3V_TEX_MAXLEVELS
];
141 CARD32 TextureFormat
;
142 CARD32 TextureReadMode
;
145 #define S3V_NO_PALETTE 0x0
146 #define S3V_USE_PALETTE 0x1
147 #define S3V_UPDATE_PALETTE 0x2
148 #define S3V_FALLBACK_PALETTE 0x4
150 void s3vUpdateTextureState( GLcontext
*ctx
);
152 void s3vDestroyTexObj( s3vContextPtr vmesa
, s3vTextureObjectPtr t
);
153 void s3vUploadTexImages( s3vContextPtr vmesa
, s3vTextureObjectPtr t
);
155 void s3vResetGlobalLRU( s3vContextPtr vmesa
);
156 void s3vTexturesGone( s3vContextPtr vmesa
,
157 GLuint start
, GLuint end
,
160 void s3vEmitHwState( s3vContextPtr vmesa
);
161 void s3vGetLock( s3vContextPtr vmesa
, GLuint flags
);
162 void s3vInitExtensions( GLcontext
*ctx
);
163 void s3vInitDriverFuncs( GLcontext
*ctx
);
164 void s3vInitSpanFuncs( GLcontext
*ctx
);
165 void s3vInitState( s3vContextPtr vmesa
);
166 void s3vInitHW( s3vContextPtr vmesa
);
167 void s3vInitStateFuncs( GLcontext
*ctx
);
168 void s3vInitTextureFuncs( GLcontext
*ctx
);
169 void s3vInitTriFuncs( GLcontext
*ctx
);
171 void s3vUpdateWindow( GLcontext
*ctx
);
172 void s3vUpdateViewportOffset( GLcontext
*ctx
);
174 void s3vPrintLocalLRU( s3vContextPtr vmesa
);
175 void s3vPrintGlobalLRU( s3vContextPtr vmesa
);
177 extern void s3vFallback( s3vContextPtr vmesa
, GLuint bit
, GLboolean mode
);
178 #define FALLBACK( imesa, bit, mode ) s3vFallback( imesa, bit, mode )
180 /* Use the templated vertex formats. Only one of these is used in s3v.
182 #define TAG(x) s3v##x
183 #include "tnl_dd/t_dd_vertex.h"
186 typedef void (*s3v_quad_func
)( s3vContextPtr
,
191 typedef void (*s3v_tri_func
)( s3vContextPtr
,
195 typedef void (*s3v_line_func
)( s3vContextPtr
,
198 typedef void (*s3v_point_func
)( s3vContextPtr
,
202 /* static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end); */
203 typedef void (*emit_func
)( GLcontext
*, GLuint
, GLuint
);
206 GLcontext
*glCtx
; /* Mesa context */
208 __DRIcontextPrivate
*driContext
;
209 __DRIscreenPrivate
*driScreen
;
210 __DRIdrawablePrivate
*driDrawable
;
218 /* Temporaries for translating away float colors
220 struct gl_client_array UbyteColor
;
221 struct gl_client_array UbyteSecondaryColor
;
223 /* Mirrors of some DRI state
225 Display
*display
; /* X server display */
227 drmContext hHWContext
;
231 GLuint numClipRects
; /* Cliprects for the draw buffer */
232 XF86DRIClipRectPtr pClipRects
;
234 CARD32
* buf
; /* FIXME */
241 s3vScreenPtr s3vScreen
; /* Screen private DRI data */
246 s3v_point_func draw_point
;
247 s3v_line_func draw_line
;
248 s3v_tri_func draw_tri
;
249 s3v_quad_func draw_quad
;
253 GLuint SetupNewInputs
;
256 GLuint vertex_format
;
258 GLuint vertex_stride_shift
;
261 GLfloat hw_viewport
[16];
263 GLenum render_primitive
;
267 s3vTextureObjectPtr CurrentTexObj
[2];
268 struct s3v_texture_object_t TexObjList
;
269 struct s3v_texture_object_t SwappedOut
;
270 GLenum TexEnvImageFmt
[2];
280 /* max was here: don't touch */
282 unsigned int S3V_REG
[S3V_REGS_NUM
];
293 CARD32 ScissorWH
; /* SubScissorWH */ /* RectWH */
306 CARD32 TextureBorderColor
;
312 CARD32 _tri
[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */
313 CARD32 alpha_cmd
; /* actual alpha cmd */
315 CARD32 _alpha_tex
; /* tex alpha type */
316 /* (3d_mode) 0 = 3d line/gourad tri; 1 = 3d tex tri */
319 GLfloat backface_sign
;
322 int restore_primitive
;
327 CARD32 AreaStippleMode
;
329 CARD32 LBWriteFormat
;
333 CARD32 AntialiasMode
;
334 GLfloat ViewportScaleX
;
335 GLfloat ViewportScaleY
;
336 GLfloat ViewportScaleZ
;
337 GLfloat ViewportOffsetX
;
338 GLfloat ViewportOffsetY
;
339 GLfloat ViewportOffsetZ
;
352 int AB_FBReadMode_Save
;
354 int ColorMaterialMode
;
355 int FBHardwareWriteMask
;
379 int Window
; /* GID part probably should be in draw priv */
381 int x
, y
, w
, h
; /* Probably should be in drawable priv */
382 int FrameCount
; /* Probably should be in drawable priv */
383 int NotClipped
; /* Probably should be in drawable priv */
384 int WindowChanged
; /* Probably should be in drawabl... */
390 int Texture1DEnabled
;
391 int Texture2DEnabled
;
395 float ModelViewProj
[16];
398 float ModelViewStack
[(MAX_MODELVIEW_STACK
-1)*16];
400 float ProjStack
[(MAX_PROJECTION_STACK
-1)*16];
402 float TextureStack
[(MAX_TEXTURE_STACK
-1)*16];
406 #define S3VIRGEPACKCOLOR555( r, g, b, a ) \
407 ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
410 #define S3VIRGEPACKCOLOR565( r, g, b ) \
411 ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
413 #define S3VIRGEPACKCOLOR888( r, g, b ) \
414 (((r) << 16) | ((g) << 8) | (b))
416 #define S3VIRGEPACKCOLOR8888( r, g, b, a ) \
417 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
419 #define S3VIRGEPACKCOLOR4444( r, g, b, a ) \
420 ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
422 static __inline GLuint
s3vPackColor( GLuint cpp
,
423 GLubyte r
, GLubyte g
,
424 GLubyte b
, GLubyte a
)
427 DEBUG(("cpp = %i, r=0x%x, g=0x%x, b=0x%x, a=0x%x\n", cpp
, r
, g
, b
, a
));
431 ret
= S3VIRGEPACKCOLOR555( r
, g
, b
, a
);
432 DEBUG(("ret = 0x%x\n", ret
));
435 return PACK_COLOR_8888( a
, r
, g
, b
);
441 #define S3V_CONTEXT(ctx) ((s3vContextPtr)(ctx->DriverCtx))
443 #endif /* _S3V_CONTEXT_H_ */