2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
32 * Keith Whitwell <keith@tungstengraphics.com>
33 * Nicolai Haehnle <prefect_@gmx.net>
36 #ifndef __RADEON_CONTEXT_H__
37 #define __RADEON_CONTEXT_H__
40 #include "radeon_screen.h"
44 struct radeon_context
;
45 typedef struct radeon_context radeonContextRec
;
46 typedef struct radeon_context
* radeonContextPtr
;
48 static __inline GLuint
radeonPackColor(GLuint cpp
,
49 GLubyte r
, GLubyte g
, GLubyte b
, GLubyte a
)
53 return PACK_COLOR_565(r
, g
, b
);
55 return PACK_COLOR_8888(a
, r
, g
, b
);
62 /* Rasterizing fallbacks */
63 /* See correponding strings in r200_swtcl.c */
64 #define RADEON_FALLBACK_TEXTURE 0x01
65 #define RADEON_FALLBACK_DRAW_BUFFER 0x02
66 #define RADEON_FALLBACK_STENCIL 0x04
67 #define RADEON_FALLBACK_RENDER_MODE 0x08
68 #define RADEON_FALLBACK_BLEND_EQ 0x10
69 #define RADEON_FALLBACK_BLEND_FUNC 0x20
70 #define RADEON_FALLBACK_DISABLE 0x40
71 #define RADEON_FALLBACK_BORDER_MODE 0x80
73 extern void radeonFallback(GLcontext
* ctx
, GLuint bit
, GLboolean mode
);
75 #define FALLBACK( radeon, bit, mode ) do { \
76 if ( 0 ) fprintf( stderr, "FALLBACK in %s: #%d=%d\n", \
77 __FUNCTION__, bit, mode ); \
78 radeonFallback( (radeon)->glCtx, bit, mode ); \
83 extern void radeonTclFallback(GLcontext
* ctx
, GLuint bit
, GLboolean mode
);
85 #define RADEON_TCL_FALLBACK_RASTER 0x0001 /* rasterization */
86 #define RADEON_TCL_FALLBACK_UNFILLED 0x0002 /* unfilled tris */
87 #define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE 0x0004 /* twoside tris */
88 #define RADEON_TCL_FALLBACK_MATERIAL 0x0008 /* material in vb */
89 #define RADEON_TCL_FALLBACK_TEXGEN_0 0x0010 /* texgen, unit 0 */
90 #define RADEON_TCL_FALLBACK_TEXGEN_1 0x0020 /* texgen, unit 1 */
91 #define RADEON_TCL_FALLBACK_TEXGEN_2 0x0040 /* texgen, unit 2 */
92 #define RADEON_TCL_FALLBACK_TEXGEN_3 0x0080 /* texgen, unit 3 */
93 #define RADEON_TCL_FALLBACK_TEXGEN_4 0x0100 /* texgen, unit 4 */
94 #define RADEON_TCL_FALLBACK_TEXGEN_5 0x0200 /* texgen, unit 5 */
95 #define RADEON_TCL_FALLBACK_TCL_DISABLE 0x0400 /* user disable */
96 #define RADEON_TCL_FALLBACK_BITMAP 0x0800 /* draw bitmap with points */
97 #define RADEON_TCL_FALLBACK_VERTEX_PROGRAM 0x1000 /* vertex program active */
99 #define TCL_FALLBACK( ctx, bit, mode ) radeonTclFallback( ctx, bit, mode )
102 struct radeon_dri_mirror
{
103 __DRIcontextPrivate
*context
; /* DRI context */
104 __DRIscreenPrivate
*screen
; /* DRI screen */
105 __DRIdrawablePrivate
*drawable
; /* DRI drawable bound to this ctx */
107 drm_context_t hwContext
;
108 drm_hw_lock_t
*hwLock
;
114 * Derived state for internal purposes.
116 struct radeon_scissor_state
{
117 drm_clip_rect_t rect
;
120 GLuint numClipRects
; /* Cliprects active */
121 GLuint numAllocedClipRects
; /* Cliprects available */
122 drm_clip_rect_t
*pClipRects
;
125 struct radeon_colorbuffer_state
{
127 GLint drawOffset
, drawPitch
;
130 struct radeon_pixel_state
{
131 GLint readOffset
, readPitch
;
134 struct radeon_state
{
135 struct radeon_colorbuffer_state color
;
136 struct radeon_pixel_state pixel
;
137 struct radeon_scissor_state scissor
;
141 * Common per-context variables shared by R200 and R300.
142 * R200- and R300-specific code "derive" their own context from this
145 struct radeon_context
{
146 GLcontext
*glCtx
; /* Mesa context */
147 radeonScreenPtr radeonScreen
; /* Screen private DRI data */
156 /* Drawable, cliprect and scissor information */
157 GLuint numClipRects
; /* Cliprects for the draw buffer */
158 drm_clip_rect_t
*pClipRects
;
159 unsigned int lastStamp
;
160 GLboolean lost_context
;
161 drm_radeon_sarea_t
*sarea
; /* Private SAREA data */
163 /* Mirrors of some DRI state */
164 struct radeon_dri_mirror dri
;
170 drm_radeon_irq_wait_t iw
;
172 /* VBI / buffer swap */
177 int64_t swap_missed_ust
;
180 GLuint swap_missed_count
;
182 PFNGLXGETUSTPROC get_ust
;
185 struct radeon_state state
;
187 /* Configuration cache
189 driOptionCache optionCache
;
192 #define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
194 extern void radeonSwapBuffers(__DRIdrawablePrivate
* dPriv
);
195 extern GLboolean
radeonInitContext(radeonContextPtr radeon
,
196 struct dd_function_table
* functions
,
197 const __GLcontextModes
* glVisual
,
198 __DRIcontextPrivate
* driContextPriv
,
199 void *sharedContextPrivate
);
200 extern void radeonCleanupContext(radeonContextPtr radeon
);
201 extern GLboolean
radeonMakeCurrent(__DRIcontextPrivate
* driContextPriv
,
202 __DRIdrawablePrivate
* driDrawPriv
,
203 __DRIdrawablePrivate
* driReadPriv
);
204 extern GLboolean
radeonUnbindContext(__DRIcontextPrivate
* driContextPriv
);
206 /* ================================================================
212 extern int RADEON_DEBUG
;
214 #define RADEON_DEBUG 0
217 #define DEBUG_TEXTURE 0x0001
218 #define DEBUG_STATE 0x0002
219 #define DEBUG_IOCTL 0x0004
220 #define DEBUG_PRIMS 0x0008
221 #define DEBUG_VERTS 0x0010
222 #define DEBUG_FALLBACKS 0x0020
223 #define DEBUG_VFMT 0x0040
224 #define DEBUG_CODEGEN 0x0080
225 #define DEBUG_VERBOSE 0x0100
226 #define DEBUG_DRI 0x0200
227 #define DEBUG_DMA 0x0400
228 #define DEBUG_SANITY 0x0800
229 #define DEBUG_SYNC 0x1000
230 #define DEBUG_PIXEL 0x2000
231 #define DEBUG_MEMORY 0x4000
233 #endif /* __RADEON_CONTEXT_H__ */