1 /* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.h,v 1.12 2002/12/16 16:18:52 dawes Exp $ */
2 /**************************************************************************
4 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 on the rights to use, copy, modify, merge, publish, distribute, sub
12 license, and/or sell copies of the Software, and to permit persons to whom
13 the Software is furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice (including the next
16 paragraph) shall be included in all copies or substantial portions of the
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
31 * Kevin E. Martin <martin@valinux.com>
32 * Gareth Hughes <gareth@valinux.com>
36 #ifndef __R128_CONTEXT_H__
37 #define __R128_CONTEXT_H__
44 #include "tnl/t_vertex.h"
51 typedef struct r128_context r128ContextRec
;
52 typedef struct r128_context
*r128ContextPtr
;
54 #include "r128_lock.h"
55 #include "r128_texobj.h"
56 #include "r128_screen.h"
58 /* Flags for what context state needs to be updated:
60 #define R128_NEW_ALPHA 0x0001
61 #define R128_NEW_DEPTH 0x0002
62 #define R128_NEW_FOG 0x0004
63 #define R128_NEW_CLIP 0x0008
64 #define R128_NEW_CULL 0x0010
65 #define R128_NEW_MASKS 0x0020
66 #define R128_NEW_RENDER_NOT 0x0040
67 #define R128_NEW_WINDOW 0x0080
68 #define R128_NEW_CONTEXT 0x0100
69 #define R128_NEW_ALL 0x01ff
71 /* Flags for software fallback cases:
73 #define R128_FALLBACK_TEXTURE 0x0001
74 #define R128_FALLBACK_DRAW_BUFFER 0x0002
75 #define R128_FALLBACK_READ_BUFFER 0x0004
76 #define R128_FALLBACK_STENCIL 0x0008
77 #define R128_FALLBACK_RENDER_MODE 0x0010
78 #define R128_FALLBACK_LOGICOP 0x0020
79 #define R128_FALLBACK_SEP_SPECULAR 0x0040
80 #define R128_FALLBACK_BLEND_EQ 0x0080
81 #define R128_FALLBACK_BLEND_FUNC 0x0100
82 #define R128_FALLBACK_PROJTEX 0x0200
83 #define R128_FALLBACK_DISABLE 0x0400
86 /* Use the templated vertex format:
88 #define TAG(x) r128##x
89 #include "tnl_dd/t_dd_vertex.h"
92 /* Reasons why the GL_BLEND fallback mightn't work:
94 #define R128_BLEND_ENV_COLOR 0x1
95 #define R128_BLEND_MULTITEX 0x2
97 /* Subpixel offsets for window coordinates (triangles):
99 #define SUBPIXEL_X (0.0F)
100 #define SUBPIXEL_Y (0.125F)
103 typedef void (*r128_tri_func
)( r128ContextPtr
,
108 typedef void (*r128_line_func
)( r128ContextPtr
,
112 typedef void (*r128_point_func
)( r128ContextPtr
,
116 struct r128_context
{
117 GLcontext
*glCtx
; /* Mesa context */
119 /* Driver and hardware state management
122 GLuint dirty
; /* Hardware state to be updated */
123 drm_r128_context_regs_t setup
;
127 GLuint vertex_format
;
128 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
129 GLuint vertex_attr_count
;
130 char *verts
; /* points to tnl->clipspace.vertex_buf */
132 int coloroffset
, specoffset
;
133 int tnl_state
; /* tnl->render_inputs for this _tnl_install_attrs */
138 GLfloat hw_viewport
[16];
141 u_int32_t ClearColor
; /* Color used to clear color buffer */
142 u_int32_t ClearDepth
; /* Value used to clear depth buffer */
143 u_int32_t ClearStencil
; /* Value used to clear stencil */
145 /* Map GL texture units onto hardware
149 GLuint tex_combine
[2];
153 /* Texture object bookkeeping
156 driTexHeap
* texture_heaps
[ R128_NR_TEX_HEAPS
];
157 driTextureObject swapped
;
159 r128TexObjPtr CurrentTexObj
[2];
163 /* Fallback rasterization functions
165 r128_point_func draw_point
;
166 r128_line_func draw_line
;
167 r128_tri_func draw_tri
;
174 GLenum render_primitive
;
180 /* Drawable, cliprect and scissor information
182 GLint drawOffset
, drawPitch
;
183 GLint readOffset
, readPitch
;
185 GLuint numClipRects
; /* Cliprects for the draw buffer */
186 drm_clip_rect_t
*pClipRects
;
189 drm_clip_rect_t ScissorRect
; /* Current software scissor */
191 /* Mirrors of some DRI state
193 __DRIcontextPrivate
*driContext
; /* DRI context */
194 __DRIscreenPrivate
*driScreen
; /* DRI screen */
195 __DRIdrawablePrivate
*driDrawable
; /* DRI drawable bound to this ctx */
197 unsigned int lastStamp
; /* mirror driDrawable->lastStamp */
199 drm_context_t hHWContext
;
200 drm_hw_lock_t
*driHwLock
;
203 r128ScreenPtr r128Screen
; /* Screen private DRI data */
204 drm_r128_sarea_t
*sarea
; /* Private SAREA data */
206 /* Performance counters
208 GLuint boxes
; /* Draw performance boxes */
209 GLuint hardwareWentIdle
;
212 GLuint c_textureSwaps
;
213 GLuint c_textureBytes
;
214 GLuint c_vertexBuffers
;
221 /* Configuration cache
223 driOptionCache optionCache
;
226 #define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx))
228 #define R128_IS_PLAIN( rmesa ) \
229 (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128)
230 #define R128_IS_PRO( rmesa ) \
231 (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_PRO)
232 #define R128_IS_MOBILITY( rmesa ) \
233 (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
236 extern GLboolean
r128CreateContext( const __GLcontextModes
*glVisual
,
237 __DRIcontextPrivate
*driContextPriv
,
238 void *sharedContextPrivate
);
240 extern void r128DestroyContext( __DRIcontextPrivate
* );
242 extern GLboolean
r128MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
243 __DRIdrawablePrivate
*driDrawPriv
,
244 __DRIdrawablePrivate
*driReadPriv
);
246 extern GLboolean
r128UnbindContext( __DRIcontextPrivate
*driContextPriv
);
248 /* ================================================================
252 #define ENABLE_PERF_BOXES 0
255 extern int R128_DEBUG
;
260 #define DEBUG_ALWAYS_SYNC 0x01
261 #define DEBUG_VERBOSE_API 0x02
262 #define DEBUG_VERBOSE_MSG 0x04
263 #define DEBUG_VERBOSE_LRU 0x08
264 #define DEBUG_VERBOSE_DRI 0x10
265 #define DEBUG_VERBOSE_IOCTL 0x20
266 #define DEBUG_VERBOSE_2D 0x40
267 #define DEBUG_VERBOSE_FALL 0x80
269 #endif /* __R128_CONTEXT_H__ */