1 /* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_context.h,v 1.6 2002/12/16 16:18:50 dawes Exp $ */
3 * Copyright 2001 by Alan Hourihane.
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of Alan Hourihane not be used in
10 * advertising or publicity pertaining to distribution of the software without
11 * specific, written prior permission. Alan Hourihane makes no representations
12 * about the suitability of this software for any purpose. It is provided
13 * "as is" without express or implied warranty.
15 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 * PERFORMANCE OF THIS SOFTWARE.
23 * Authors: Alan Hourihane, <alanh@tungstengraphics.com>
27 #ifndef _GAMMA_CONTEXT_H_
28 #define _GAMMA_CONTEXT_H_
32 #include "drm_sarea.h"
34 #include "gamma_regs.h"
35 #include "gamma_macros.h"
36 #include "gamma_screen.h"
39 #include "glint_dri.h"
47 /* Flags for context */
48 #define GAMMA_FRONT_BUFFER 0x00000001
49 #define GAMMA_BACK_BUFFER 0x00000002
50 #define GAMMA_DEPTH_BUFFER 0x00000004
51 #define GAMMA_STENCIL_BUFFER 0x00000008
52 #define GAMMA_ACCUM_BUFFER 0x00000010
54 #define GAMMA_MAX_TEXTURE_SIZE 2048
56 /* These are the minimum requirements and should probably be increased */
57 #define MAX_MODELVIEW_STACK 16
58 #define MAX_PROJECTION_STACK 2
59 #define MAX_TEXTURE_STACK 2
61 extern void gammaDDUpdateHWState(GLcontext
*ctx
);
62 extern gammaScreenPtr
gammaCreateScreen(__DRIscreenPrivate
*sPriv
);
63 extern void gammaDestroyScreen(__DRIscreenPrivate
*sPriv
);
64 extern GLboolean
gammaCreateContext( const __GLcontextModes
*glVisual
,
65 __DRIcontextPrivate
*driContextPriv
,
66 void *sharedContextPrivate
);
68 #define GAMMA_UPLOAD_ALL 0xffffffff
69 #define GAMMA_UPLOAD_CLIPRECTS 0x00000002
70 #define GAMMA_UPLOAD_ALPHA 0x00000004
71 #define GAMMA_UPLOAD_BLEND 0x00000008
72 #define GAMMA_UPLOAD_DEPTH 0x00000010
73 #define GAMMA_UPLOAD_VIEWPORT 0x00000020
74 #define GAMMA_UPLOAD_SHADE 0x00000040
75 #define GAMMA_UPLOAD_CLIP 0x00000080
76 #define GAMMA_UPLOAD_MASKS 0x00000100
77 #define GAMMA_UPLOAD_WINDOW 0x00000200 /* defunct */
78 #define GAMMA_UPLOAD_GEOMETRY 0x00000400
79 #define GAMMA_UPLOAD_POLYGON 0x00000800
80 #define GAMMA_UPLOAD_DITHER 0x00001000
81 #define GAMMA_UPLOAD_LOGICOP 0x00002000
82 #define GAMMA_UPLOAD_FOG 0x00004000
83 #define GAMMA_UPLOAD_LIGHT 0x00008000
84 #define GAMMA_UPLOAD_CONTEXT 0x00010000
85 #define GAMMA_UPLOAD_TEX0 0x00020000
86 #define GAMMA_UPLOAD_STIPPLE 0x00040000
87 #define GAMMA_UPLOAD_TRANSFORM 0x00080000
88 #define GAMMA_UPLOAD_LINEMODE 0x00100000
89 #define GAMMA_UPLOAD_POINTMODE 0x00200000
90 #define GAMMA_UPLOAD_TRIMODE 0x00400000
92 #define GAMMA_NEW_CLIP 0x00000001
93 #define GAMMA_NEW_WINDOW 0x00000002
94 #define GAMMA_NEW_CONTEXT 0x00000004
95 #define GAMMA_NEW_TEXTURE 0x00000008 /* defunct */
96 #define GAMMA_NEW_ALPHA 0x00000010
97 #define GAMMA_NEW_DEPTH 0x00000020
98 #define GAMMA_NEW_MASKS 0x00000040
99 #define GAMMA_NEW_POLYGON 0x00000080
100 #define GAMMA_NEW_CULL 0x00000100
101 #define GAMMA_NEW_LOGICOP 0x00000200
102 #define GAMMA_NEW_FOG 0x00000400
103 #define GAMMA_NEW_LIGHT 0x00000800
104 #define GAMMA_NEW_STIPPLE 0x00001000
105 #define GAMMA_NEW_ALL 0xffffffff
107 #define GAMMA_FALLBACK_TRI 0x00000001
108 #define GAMMA_FALLBACK_TEXTURE 0x00000002
110 #define FLUSH_BATCH(gmesa) do { \
111 /*FLUSH_DMA_BUFFER(gmesa);*/ \
114 struct gamma_context
;
115 typedef struct gamma_context gammaContextRec
;
116 typedef struct gamma_context
*gammaContextPtr
;
117 typedef struct gamma_texture_object_t
*gammaTextureObjectPtr
;
119 #define VALID_GAMMA_TEXTURE_OBJECT(tobj) (tobj)
121 #define GAMMA_TEX_MAXLEVELS 12
123 /* For shared texture space managment, these texture objects may also
124 * be used as proxies for regions of texture memory containing other
125 * client's textures. Such proxy textures (not to be confused with GL
126 * proxy textures) are subject to the same LRU aging we use for our
127 * own private textures, and thus we have a mechanism where we can
128 * fairly decide between kicking out our own textures and those of
131 * Non-local texture objects have a valid MemBlock to describe the
132 * region managed by the other client, and can be identified by
135 struct gamma_texture_object_t
{
136 struct gamma_texture_object_t
*next
, *prev
;
139 struct gl_texture_object
*globj
;
154 GLint firstLevel
, lastLevel
; /* upload tObj->Image[0][first .. lastLevel] */
157 const struct gl_texture_image
*image
;
158 int offset
; /* into BufAddr */
161 } image
[GAMMA_TEX_MAXLEVELS
];
163 uint32_t TextureBaseAddr
[GAMMA_TEX_MAXLEVELS
];
164 uint32_t TextureAddressMode
;
165 uint32_t TextureColorMode
;
166 uint32_t TextureFilterMode
;
167 uint32_t TextureFormat
;
168 uint32_t TextureReadMode
;
169 uint32_t TextureBorderColor
;
172 #define GAMMA_NO_PALETTE 0x0
173 #define GAMMA_USE_PALETTE 0x1
174 #define GAMMA_UPDATE_PALETTE 0x2
175 #define GAMMA_FALLBACK_PALETTE 0x4
177 void gammaUpdateTextureState( GLcontext
*ctx
);
179 void gammaDestroyTexObj( gammaContextPtr gmesa
, gammaTextureObjectPtr t
);
180 void gammaSwapOutTexObj( gammaContextPtr gmesa
, gammaTextureObjectPtr t
);
181 void gammaUploadTexImages( gammaContextPtr gmesa
, gammaTextureObjectPtr t
);
183 void gammaResetGlobalLRU( gammaContextPtr gmesa
);
184 void gammaUpdateTexLRU( gammaContextPtr gmesa
, gammaTextureObjectPtr t
);
185 void gammaTexturesGone( gammaContextPtr gmesa
,
186 GLuint start
, GLuint end
,
189 void gammaEmitHwState( gammaContextPtr gmesa
);
190 void gammaDDInitExtensions( GLcontext
*ctx
);
191 void gammaDDInitDriverFuncs( GLcontext
*ctx
);
192 void gammaDDInitSpanFuncs( GLcontext
*ctx
);
193 void gammaDDInitState( gammaContextPtr gmesa
);
194 void gammaInitHW( gammaContextPtr gmesa
);
195 void gammaDDInitStateFuncs( GLcontext
*ctx
);
196 void gammaDDInitTextureFuncs( struct dd_function_table
*table
);
197 void gammaInitTextureObjects( GLcontext
*ctx
);
198 void gammaDDInitTriFuncs( GLcontext
*ctx
);
200 void gammaUpdateWindow( GLcontext
*ctx
);
201 void gammaUpdateViewportOffset( GLcontext
*ctx
);
203 void gammaPrintLocalLRU( gammaContextPtr gmesa
);
204 void gammaPrintGlobalLRU( gammaContextPtr gmesa
);
206 extern void gammaFallback( gammaContextPtr gmesa
, GLuint bit
, GLboolean mode
);
207 #define FALLBACK( imesa, bit, mode ) gammaFallback( imesa, bit, mode )
209 /* Use the templated vertex formats. Only one of these is used in gamma.
211 #define TAG(x) gamma##x
212 #include "tnl_dd/t_dd_vertex.h"
215 typedef void (*gamma_quad_func
)( gammaContextPtr
,
219 const gammaVertex
* );
220 typedef void (*gamma_tri_func
)( gammaContextPtr
,
223 const gammaVertex
* );
224 typedef void (*gamma_line_func
)( gammaContextPtr
,
226 const gammaVertex
* );
227 typedef void (*gamma_point_func
)( gammaContextPtr
,
228 const gammaVertex
* );
231 struct gamma_context
{
232 GLcontext
*glCtx
; /* Mesa context */
234 __DRIcontextPrivate
*driContext
;
235 __DRIscreenPrivate
*driScreen
;
236 __DRIdrawablePrivate
*driDrawable
;
242 GLINTSAREADRIPtr sarea
;
244 /* Mirrors of some DRI state
246 drm_context_t hHWContext
;
247 drm_hw_lock_t
*driHwLock
;
250 GLuint numClipRects
; /* Cliprects for the draw buffer */
251 drm_clip_rect_t
*pClipRects
;
253 dmaBuf buf
; /* DMA buffer for regular cmds */
258 dmaBuf WCbuf
; /* DMA buffer for window changed cmds */
263 gammaScreenPtr gammaScreen
; /* Screen private DRI data */
268 gamma_point_func draw_point
;
269 gamma_line_func draw_line
;
270 gamma_tri_func draw_tri
;
271 gamma_quad_func draw_quad
;
275 GLuint SetupNewInputs
;
278 GLuint vertex_format
;
280 GLuint vertex_stride_shift
;
283 GLfloat hw_viewport
[16];
285 GLenum render_primitive
;
289 gammaTextureObjectPtr CurrentTexObj
[2];
290 struct gamma_texture_object_t TexObjList
;
291 struct gamma_texture_object_t SwappedOut
;
292 GLenum TexEnvImageFmt
[2];
296 unsigned int lastSwap
;
300 unsigned int lastStamp
;
308 uint32_t AreaStippleMode
;
309 uint32_t LBReadFormat
;
310 uint32_t LBWriteFormat
;
313 uint32_t TriangleMode
;
314 uint32_t AntialiasMode
;
315 GLfloat ViewportScaleX
;
316 GLfloat ViewportScaleY
;
317 GLfloat ViewportScaleZ
;
318 GLfloat ViewportOffsetX
;
319 GLfloat ViewportOffsetY
;
320 GLfloat ViewportOffsetZ
;
333 int AB_FBReadMode_Save
;
335 int ColorMaterialMode
;
336 int FBHardwareWriteMask
;
360 int Window
; /* GID part probably should be in draw priv */
362 int x
, y
, w
, h
; /* Probably should be in drawable priv */
363 int FrameCount
; /* Probably should be in drawable priv */
364 int NotClipped
; /* Probably should be in drawable priv */
365 int WindowChanged
; /* Probably should be in drawabl... */
371 int Texture1DEnabled
;
372 int Texture2DEnabled
;
376 float ModelViewProj
[16];
379 float ModelViewStack
[(MAX_MODELVIEW_STACK
-1)*16];
381 float ProjStack
[(MAX_PROJECTION_STACK
-1)*16];
383 float TextureStack
[(MAX_TEXTURE_STACK
-1)*16];
387 static __inline GLuint
gammaPackColor( GLuint cpp
,
388 GLubyte r
, GLubyte g
,
389 GLubyte b
, GLubyte a
)
393 return PACK_COLOR_565( r
, g
, b
);
395 return PACK_COLOR_8888( a
, r
, g
, b
);
401 #define GAMMA_CONTEXT(ctx) ((gammaContextPtr)(ctx->DriverCtx))
403 #endif /* _GAMMA_CONTEXT_H_ */