1 /**************************************************************************
3 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Kevin E. Martin <martin@valinux.com>
31 * Gareth Hughes <gareth@valinux.com>
35 #ifndef __R128_CONTEXT_H__
36 #define __R128_CONTEXT_H__
42 #include "main/mtypes.h"
43 #include "tnl/t_vertex.h"
50 typedef struct r128_context r128ContextRec
;
51 typedef struct r128_context
*r128ContextPtr
;
53 #include "r128_lock.h"
54 #include "r128_texobj.h"
55 #include "r128_screen.h"
57 /* Flags for what context state needs to be updated:
59 #define R128_NEW_ALPHA 0x0001
60 #define R128_NEW_DEPTH 0x0002
61 #define R128_NEW_FOG 0x0004
62 #define R128_NEW_CLIP 0x0008
63 #define R128_NEW_CULL 0x0010
64 #define R128_NEW_MASKS 0x0020
65 #define R128_NEW_RENDER_NOT 0x0040
66 #define R128_NEW_WINDOW 0x0080
67 #define R128_NEW_CONTEXT 0x0100
68 #define R128_NEW_ALL 0x01ff
70 /* Flags for software fallback cases:
72 #define R128_FALLBACK_TEXTURE 0x0001
73 #define R128_FALLBACK_DRAW_BUFFER 0x0002
74 #define R128_FALLBACK_READ_BUFFER 0x0004
75 #define R128_FALLBACK_STENCIL 0x0008
76 #define R128_FALLBACK_RENDER_MODE 0x0010
77 #define R128_FALLBACK_LOGICOP 0x0020
78 #define R128_FALLBACK_SEP_SPECULAR 0x0040
79 #define R128_FALLBACK_BLEND_EQ 0x0080
80 #define R128_FALLBACK_BLEND_FUNC 0x0100
81 #define R128_FALLBACK_PROJTEX 0x0200
82 #define R128_FALLBACK_DISABLE 0x0400
85 /* Use the templated vertex format:
87 #define TAG(x) r128##x
88 #include "tnl_dd/t_dd_vertex.h"
91 /* Reasons why the GL_BLEND fallback mightn't work:
93 #define R128_BLEND_ENV_COLOR 0x1
94 #define R128_BLEND_MULTITEX 0x2
96 /* Subpixel offsets for window coordinates (triangles):
98 #define SUBPIXEL_X (0.0F)
99 #define SUBPIXEL_Y (0.125F)
102 typedef void (*r128_tri_func
)( r128ContextPtr
,
107 typedef void (*r128_line_func
)( r128ContextPtr
,
111 typedef void (*r128_point_func
)( r128ContextPtr
,
115 struct r128_context
{
116 GLcontext
*glCtx
; /* Mesa context */
118 /* Driver and hardware state management
121 GLuint dirty
; /* Hardware state to be updated */
122 drm_r128_context_regs_t setup
;
126 GLuint vertex_format
;
127 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
128 GLuint vertex_attr_count
;
129 char *verts
; /* points to tnl->clipspace.vertex_buf */
131 int coloroffset
, specoffset
;
132 DECLARE_RENDERINPUTS(tnl_state_bitset
); /* tnl->render_inputs for this _tnl_install_attrs */
137 GLfloat hw_viewport
[16];
140 uint32_t ClearColor
; /* Color used to clear color buffer */
141 uint32_t ClearDepth
; /* Value used to clear depth buffer */
142 uint32_t ClearStencil
; /* Value used to clear stencil */
144 /* Map GL texture units onto hardware
148 GLuint tex_combine
[2];
152 /* Texture object bookkeeping
155 driTexHeap
* texture_heaps
[ R128_NR_TEX_HEAPS
];
156 driTextureObject swapped
;
158 r128TexObjPtr CurrentTexObj
[2];
162 /* Fallback rasterization functions
164 r128_point_func draw_point
;
165 r128_line_func draw_line
;
166 r128_tri_func draw_tri
;
173 GLenum render_primitive
;
179 /* Cliprect and scissor information
181 GLuint numClipRects
; /* Cliprects for the draw buffer */
182 drm_clip_rect_t
*pClipRects
;
185 drm_clip_rect_t ScissorRect
; /* Current software scissor */
187 /* Mirrors of some DRI state
189 __DRIcontextPrivate
*driContext
; /* DRI context */
190 __DRIscreenPrivate
*driScreen
; /* DRI screen */
191 __DRIdrawablePrivate
*driDrawable
; /* DRI drawable bound to this ctx */
193 unsigned int lastStamp
; /* mirror driDrawable->lastStamp */
195 drm_context_t hHWContext
;
196 drm_hw_lock_t
*driHwLock
;
199 r128ScreenPtr r128Screen
; /* Screen private DRI data */
200 drm_r128_sarea_t
*sarea
; /* Private SAREA data */
202 /* Performance counters
204 GLuint boxes
; /* Draw performance boxes */
205 GLuint hardwareWentIdle
;
208 GLuint c_textureSwaps
;
209 GLuint c_textureBytes
;
210 GLuint c_vertexBuffers
;
212 /* Configuration cache
214 driOptionCache optionCache
;
217 #define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx))
219 #define R128_IS_PLAIN( rmesa ) \
220 (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128)
221 #define R128_IS_PRO( rmesa ) \
222 (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_PRO)
223 #define R128_IS_MOBILITY( rmesa ) \
224 (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
227 extern GLboolean
r128CreateContext( const __GLcontextModes
*glVisual
,
228 __DRIcontextPrivate
*driContextPriv
,
229 void *sharedContextPrivate
);
231 extern void r128DestroyContext( __DRIcontextPrivate
* );
233 extern GLboolean
r128MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
234 __DRIdrawablePrivate
*driDrawPriv
,
235 __DRIdrawablePrivate
*driReadPriv
);
237 extern GLboolean
r128UnbindContext( __DRIcontextPrivate
*driContextPriv
);
239 /* ================================================================
243 #define ENABLE_PERF_BOXES 0
246 extern int R128_DEBUG
;
251 #define DEBUG_ALWAYS_SYNC 0x01
252 #define DEBUG_VERBOSE_API 0x02
253 #define DEBUG_VERBOSE_MSG 0x04
254 #define DEBUG_VERBOSE_LRU 0x08
255 #define DEBUG_VERBOSE_DRI 0x10
256 #define DEBUG_VERBOSE_IOCTL 0x20
257 #define DEBUG_VERBOSE_2D 0x40
258 #define DEBUG_VERBOSE_FALL 0x80
260 #endif /* __R128_CONTEXT_H__ */