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>
35 #include "main/glheader.h"
36 #include "main/api_arrayelt.h"
37 #include "main/context.h"
38 #include "main/simple_list.h"
39 #include "main/imports.h"
40 #include "main/matrix.h"
41 #include "main/extensions.h"
42 #include "main/framebuffer.h"
43 #include "main/state.h"
45 #include "swrast/swrast.h"
46 #include "swrast_setup/swrast_setup.h"
50 #include "tnl/t_pipeline.h"
52 #include "drivers/common/driverfuncs.h"
54 #include "r200_context.h"
55 #include "r200_ioctl.h"
56 #include "r200_state.h"
57 #include "r200_span.h"
58 #include "r200_pixel.h"
60 #include "r200_swtcl.h"
62 #include "r200_maos.h"
63 #include "r200_vertprog.h"
65 #define need_GL_ARB_multisample
66 #define need_GL_ARB_texture_compression
67 #define need_GL_ARB_vertex_buffer_object
68 #define need_GL_ARB_vertex_program
69 #define need_GL_ATI_fragment_shader
70 #define need_GL_EXT_blend_minmax
71 #define need_GL_EXT_fog_coord
72 #define need_GL_EXT_multi_draw_arrays
73 #define need_GL_EXT_secondary_color
74 #define need_GL_EXT_blend_equation_separate
75 #define need_GL_EXT_blend_func_separate
76 #define need_GL_NV_vertex_program
77 #define need_GL_ARB_point_parameters
78 #include "extension_helper.h"
80 #define DRIVER_DATE "20060602"
84 #include "xmlpool.h" /* for symbolic values of enum-type options */
89 /* Return various strings for glGetString().
91 static const GLubyte
*r200GetString( GLcontext
*ctx
, GLenum name
)
93 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
94 static char buffer
[128];
96 GLuint agp_mode
= (rmesa
->radeon
.radeonScreen
->card_type
== RADEON_CARD_PCI
)? 0 :
97 rmesa
->radeon
.radeonScreen
->AGPMode
;
101 return (GLubyte
*)"Tungsten Graphics, Inc.";
104 offset
= driGetRendererString( buffer
, "R200", DRIVER_DATE
,
107 sprintf( & buffer
[ offset
], " %sTCL",
108 !(rmesa
->radeon
.TclFallback
& R200_TCL_FALLBACK_TCL_DISABLE
)
111 return (GLubyte
*)buffer
;
119 /* Extension strings exported by the R200 driver.
121 const struct dri_extension card_extensions
[] =
123 { "GL_ARB_multisample", GL_ARB_multisample_functions
},
124 { "GL_ARB_multitexture", NULL
},
125 { "GL_ARB_texture_border_clamp", NULL
},
126 { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions
},
127 { "GL_ARB_texture_env_add", NULL
},
128 { "GL_ARB_texture_env_combine", NULL
},
129 { "GL_ARB_texture_env_dot3", NULL
},
130 { "GL_ARB_texture_env_crossbar", NULL
},
131 { "GL_ARB_texture_mirrored_repeat", NULL
},
132 { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions
},
133 { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions
},
134 { "GL_EXT_blend_subtract", NULL
},
135 { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions
},
136 { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions
},
137 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
138 { "GL_EXT_stencil_wrap", NULL
},
139 { "GL_EXT_texture_edge_clamp", NULL
},
140 { "GL_EXT_texture_env_combine", NULL
},
141 { "GL_EXT_texture_env_dot3", NULL
},
142 { "GL_EXT_texture_filter_anisotropic", NULL
},
143 { "GL_EXT_texture_lod_bias", NULL
},
144 { "GL_EXT_texture_mirror_clamp", NULL
},
145 { "GL_EXT_texture_rectangle", NULL
},
146 { "GL_ATI_texture_env_combine3", NULL
},
147 { "GL_ATI_texture_mirror_once", NULL
},
148 { "GL_MESA_pack_invert", NULL
},
149 { "GL_NV_blend_square", NULL
},
150 { "GL_SGIS_generate_mipmap", NULL
},
154 const struct dri_extension blend_extensions
[] = {
155 { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions
},
156 { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions
},
160 const struct dri_extension ARB_vp_extension
[] = {
161 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions
}
164 const struct dri_extension NV_vp_extension
[] = {
165 { "GL_NV_vertex_program", GL_NV_vertex_program_functions
}
168 const struct dri_extension ATI_fs_extension
[] = {
169 { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions
}
172 const struct dri_extension point_extensions
[] = {
173 { "GL_ARB_point_sprite", NULL
},
174 { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions
},
178 extern const struct tnl_pipeline_stage _r200_render_stage
;
179 extern const struct tnl_pipeline_stage _r200_tcl_stage
;
181 static const struct tnl_pipeline_stage
*r200_pipeline
[] = {
183 /* Try and go straight to t&l
187 /* Catch any t&l fallbacks
189 &_tnl_vertex_transform_stage
,
190 &_tnl_normal_transform_stage
,
191 &_tnl_lighting_stage
,
192 &_tnl_fog_coordinate_stage
,
194 &_tnl_texture_transform_stage
,
195 &_tnl_point_attenuation_stage
,
196 &_tnl_vertex_program_stage
,
197 /* Try again to go to tcl?
198 * - no good for asymmetric-twoside (do with multipass)
199 * - no good for asymmetric-unfilled (do with multipass)
200 * - good for material
202 * - need to manipulate a bit of state
204 * - worth it/not worth it?
207 /* Else do them here.
209 /* &_r200_render_stage, */ /* FIXME: bugs with ut2003 */
210 &_tnl_render_stage
, /* FALLBACK: */
216 /* Initialize the driver's misc functions.
218 static void r200InitDriverFuncs( struct dd_function_table
*functions
)
220 functions
->GetBufferSize
= NULL
; /* OBSOLETE */
221 functions
->GetString
= r200GetString
;
224 static const struct dri_debug_control debug_control
[] =
226 { "fall", DEBUG_FALLBACKS
},
227 { "tex", DEBUG_TEXTURE
},
228 { "ioctl", DEBUG_IOCTL
},
229 { "prim", DEBUG_PRIMS
},
230 { "vert", DEBUG_VERTS
},
231 { "state", DEBUG_STATE
},
232 { "code", DEBUG_CODEGEN
},
233 { "vfmt", DEBUG_VFMT
},
234 { "vtxf", DEBUG_VFMT
},
235 { "verb", DEBUG_VERBOSE
},
236 { "dri", DEBUG_DRI
},
237 { "dma", DEBUG_DMA
},
238 { "san", DEBUG_SANITY
},
239 { "sync", DEBUG_SYNC
},
240 { "pix", DEBUG_PIXEL
},
241 { "mem", DEBUG_MEMORY
},
245 static void r200_get_lock(radeonContextPtr radeon
)
247 r200ContextPtr rmesa
= (r200ContextPtr
)radeon
;
248 drm_radeon_sarea_t
*sarea
= radeon
->sarea
;
251 R200_STATECHANGE( rmesa
, ctx
);
252 if (rmesa
->radeon
.sarea
->tiling_enabled
) {
253 rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLORPITCH
] |= R200_COLOR_TILE_ENABLE
;
255 else rmesa
->hw
.ctx
.cmd
[CTX_RB3D_COLORPITCH
] &= ~R200_COLOR_TILE_ENABLE
;
257 if ( sarea
->ctx_owner
!= rmesa
->radeon
.dri
.hwContext
) {
258 sarea
->ctx_owner
= rmesa
->radeon
.dri
.hwContext
;
261 for ( i
= 0 ; i
< rmesa
->radeon
.nr_heaps
; i
++ ) {
262 DRI_AGE_TEXTURES( rmesa
->radeon
.texture_heaps
[ i
] );
267 static void r200_vtbl_flush(GLcontext
*ctx
)
269 R200_FIREVERTICES(R200_CONTEXT(ctx
));
272 static void r200_vtbl_set_all_dirty(GLcontext
*ctx
)
274 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
275 rmesa
->hw
.all_dirty
= GL_TRUE
;
278 static void r200_init_vtbl(radeonContextPtr radeon
)
280 radeon
->vtbl
.get_lock
= r200_get_lock
;
281 radeon
->vtbl
.update_viewport_offset
= r200UpdateViewportOffset
;
282 radeon
->vtbl
.flush
= r200_vtbl_flush
;
283 radeon
->vtbl
.set_all_dirty
= r200_vtbl_set_all_dirty
;
284 radeon
->vtbl
.update_draw_buffer
= r200UpdateDrawBuffer
;
287 /* Create the device specific rendering context.
289 GLboolean
r200CreateContext( const __GLcontextModes
*glVisual
,
290 __DRIcontextPrivate
*driContextPriv
,
291 void *sharedContextPrivate
)
293 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
294 radeonScreenPtr screen
= (radeonScreenPtr
)(sPriv
->private);
295 struct dd_function_table functions
;
296 r200ContextPtr rmesa
;
297 GLcontext
*ctx
, *shareCtx
;
299 int tcl_mode
, fthrottle_mode
;
302 assert(driContextPriv
);
305 /* Allocate the R200 context */
306 rmesa
= (r200ContextPtr
) CALLOC( sizeof(*rmesa
) );
310 r200_init_vtbl(&rmesa
->radeon
);
311 /* init exp fog table data */
312 r200InitStaticFogData();
314 /* Parse configuration files.
315 * Do this here so that initialMaxAnisotropy is set before we create
316 * the default textures.
318 driParseConfigFiles (&rmesa
->radeon
.optionCache
, &screen
->optionCache
,
319 screen
->driScreen
->myNum
, "r200");
320 rmesa
->radeon
.initialMaxAnisotropy
= driQueryOptionf(&rmesa
->radeon
.optionCache
,
321 "def_max_anisotropy");
323 if ( driQueryOptionb( &rmesa
->radeon
.optionCache
, "hyperz" ) ) {
324 if ( sPriv
->drm_version
.minor
< 13 )
325 fprintf( stderr
, "DRM version 1.%d too old to support HyperZ, "
326 "disabling.\n", sPriv
->drm_version
.minor
);
328 rmesa
->using_hyperz
= GL_TRUE
;
331 if ( sPriv
->drm_version
.minor
>= 15 )
332 rmesa
->texmicrotile
= GL_TRUE
;
334 /* Init default driver functions then plug in our R200-specific functions
335 * (the texture functions are especially important)
337 _mesa_init_driver_functions(&functions
);
338 r200InitDriverFuncs(&functions
);
339 r200InitIoctlFuncs(&functions
);
340 r200InitStateFuncs(&functions
);
341 r200InitTextureFuncs(&functions
);
342 r200InitShaderFuncs(&functions
);
344 /* Allocate and initialize the Mesa context */
345 if (sharedContextPrivate
)
346 shareCtx
= ((r200ContextPtr
) sharedContextPrivate
)->radeon
.glCtx
;
349 rmesa
->radeon
.glCtx
= _mesa_create_context(glVisual
, shareCtx
,
350 &functions
, (void *) rmesa
);
351 if (!rmesa
->radeon
.glCtx
) {
355 driContextPriv
->driverPrivate
= rmesa
;
357 /* Init r200 context data */
358 rmesa
->radeon
.dri
.context
= driContextPriv
;
359 rmesa
->radeon
.dri
.screen
= sPriv
;
360 rmesa
->radeon
.dri
.drawable
= NULL
; /* Set by XMesaMakeCurrent */
361 rmesa
->radeon
.dri
.hwContext
= driContextPriv
->hHWContext
;
362 rmesa
->radeon
.dri
.hwLock
= &sPriv
->pSAREA
->lock
;
363 rmesa
->radeon
.dri
.fd
= sPriv
->fd
;
364 rmesa
->radeon
.dri
.drmMinor
= sPriv
->drm_version
.minor
;
366 rmesa
->radeon
.radeonScreen
= screen
;
367 rmesa
->radeon
.sarea
= (drm_radeon_sarea_t
*)((GLubyte
*)sPriv
->pSAREA
+
368 screen
->sarea_priv_offset
);
371 rmesa
->dma
.buf0_address
= rmesa
->radeon
.radeonScreen
->buffers
->list
[0].address
;
373 (void) memset( rmesa
->radeon
.texture_heaps
, 0, sizeof( rmesa
->radeon
.texture_heaps
) );
374 make_empty_list( & rmesa
->radeon
.swapped
);
376 rmesa
->radeon
.nr_heaps
= 1 /* screen->numTexHeaps */ ;
377 assert(rmesa
->radeon
.nr_heaps
< RADEON_NR_TEX_HEAPS
);
378 for ( i
= 0 ; i
< rmesa
->radeon
.nr_heaps
; i
++ ) {
379 rmesa
->radeon
.texture_heaps
[i
] = driCreateTextureHeap( i
, rmesa
,
382 RADEON_NR_TEX_REGIONS
,
383 (drmTextureRegionPtr
)rmesa
->radeon
.sarea
->tex_list
[i
],
384 & rmesa
->radeon
.sarea
->tex_age
[i
],
385 & rmesa
->radeon
.swapped
,
386 sizeof( radeonTexObj
),
387 (destroy_texture_object_t
*) r200DestroyTexObj
);
389 rmesa
->radeon
.texture_depth
= driQueryOptioni (&rmesa
->radeon
.optionCache
,
391 if (rmesa
->radeon
.texture_depth
== DRI_CONF_TEXTURE_DEPTH_FB
)
392 rmesa
->radeon
.texture_depth
= ( screen
->cpp
== 4 ) ?
393 DRI_CONF_TEXTURE_DEPTH_32
: DRI_CONF_TEXTURE_DEPTH_16
;
395 rmesa
->swtcl
.RenderIndex
= ~0;
396 rmesa
->hw
.all_dirty
= 1;
398 /* Set the maximum texture size small enough that we can guarentee that
399 * all texture units can bind a maximal texture and have all of them in
400 * texturable memory at once. Depending on the allow_large_textures driconf
401 * setting allow larger textures.
404 ctx
= rmesa
->radeon
.glCtx
;
405 ctx
->Const
.MaxTextureUnits
= driQueryOptioni (&rmesa
->radeon
.optionCache
,
407 ctx
->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureUnits
;
408 ctx
->Const
.MaxTextureCoordUnits
= ctx
->Const
.MaxTextureUnits
;
410 i
= driQueryOptioni( &rmesa
->radeon
.optionCache
, "allow_large_textures");
412 driCalculateMaxTextureLevels( rmesa
->radeon
.texture_heaps
,
413 rmesa
->radeon
.nr_heaps
,
416 11, /* max 2D texture size is 2048x2048 */
417 #if ENABLE_HW_3D_TEXTURE
418 8, /* max 3D texture size is 256^3 */
420 0, /* 3D textures unsupported */
422 11, /* max cube texture size is 2048x2048 */
423 11, /* max texture rectangle size is 2048x2048 */
428 ctx
->Const
.MaxTextureMaxAnisotropy
= 16.0;
430 /* No wide AA points.
432 ctx
->Const
.MinPointSize
= 1.0;
433 ctx
->Const
.MinPointSizeAA
= 1.0;
434 ctx
->Const
.MaxPointSizeAA
= 1.0;
435 ctx
->Const
.PointSizeGranularity
= 0.0625;
436 if (rmesa
->radeon
.radeonScreen
->drmSupportsPointSprites
)
437 ctx
->Const
.MaxPointSize
= 2047.0;
439 ctx
->Const
.MaxPointSize
= 1.0;
441 /* mesa initialization problem - _mesa_init_point was already called */
442 ctx
->Point
.MaxSize
= ctx
->Const
.MaxPointSize
;
444 ctx
->Const
.MinLineWidth
= 1.0;
445 ctx
->Const
.MinLineWidthAA
= 1.0;
446 ctx
->Const
.MaxLineWidth
= 10.0;
447 ctx
->Const
.MaxLineWidthAA
= 10.0;
448 ctx
->Const
.LineWidthGranularity
= 0.0625;
450 ctx
->Const
.VertexProgram
.MaxNativeInstructions
= R200_VSF_MAX_INST
;
451 ctx
->Const
.VertexProgram
.MaxNativeAttribs
= 12;
452 ctx
->Const
.VertexProgram
.MaxNativeTemps
= R200_VSF_MAX_TEMPS
;
453 ctx
->Const
.VertexProgram
.MaxNativeParameters
= R200_VSF_MAX_PARAM
;
454 ctx
->Const
.VertexProgram
.MaxNativeAddressRegs
= 1;
456 /* Initialize the software rasterizer and helper modules.
458 _swrast_CreateContext( ctx
);
459 _vbo_CreateContext( ctx
);
460 _tnl_CreateContext( ctx
);
461 _swsetup_CreateContext( ctx
);
462 _ae_create_context( ctx
);
464 /* Install the customized pipeline:
466 _tnl_destroy_pipeline( ctx
);
467 _tnl_install_pipeline( ctx
, r200_pipeline
);
469 /* Try and keep materials and vertices separate:
471 /* _tnl_isolate_materials( ctx, GL_TRUE ); */
474 /* Configure swrast and TNL to match hardware characteristics:
476 _swrast_allow_pixel_fog( ctx
, GL_FALSE
);
477 _swrast_allow_vertex_fog( ctx
, GL_TRUE
);
478 _tnl_allow_pixel_fog( ctx
, GL_FALSE
);
479 _tnl_allow_vertex_fog( ctx
, GL_TRUE
);
482 for ( i
= 0 ; i
< R200_MAX_TEXTURE_UNITS
; i
++ ) {
483 _math_matrix_ctr( &rmesa
->TexGenMatrix
[i
] );
484 _math_matrix_set_identity( &rmesa
->TexGenMatrix
[i
] );
486 _math_matrix_ctr( &rmesa
->tmpmat
);
487 _math_matrix_set_identity( &rmesa
->tmpmat
);
489 driInitExtensions( ctx
, card_extensions
, GL_TRUE
);
490 if (!(rmesa
->radeon
.radeonScreen
->chip_flags
& R200_CHIPSET_YCBCR_BROKEN
)) {
491 /* yuv textures don't work with some chips - R200 / rv280 okay so far
492 others get the bit ordering right but don't actually do YUV-RGB conversion */
493 _mesa_enable_extension( ctx
, "GL_MESA_ycbcr_texture" );
495 if (rmesa
->radeon
.glCtx
->Mesa_DXTn
) {
496 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
497 _mesa_enable_extension( ctx
, "GL_S3_s3tc" );
499 else if (driQueryOptionb (&rmesa
->radeon
.optionCache
, "force_s3tc_enable")) {
500 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
503 if (rmesa
->radeon
.radeonScreen
->drmSupportsCubeMapsR200
)
504 _mesa_enable_extension( ctx
, "GL_ARB_texture_cube_map" );
505 if (rmesa
->radeon
.radeonScreen
->drmSupportsBlendColor
) {
506 driInitExtensions( ctx
, blend_extensions
, GL_FALSE
);
508 if(rmesa
->radeon
.radeonScreen
->drmSupportsVertexProgram
)
509 driInitSingleExtension( ctx
, ARB_vp_extension
);
510 if(driQueryOptionb(&rmesa
->radeon
.optionCache
, "nv_vertex_program"))
511 driInitSingleExtension( ctx
, NV_vp_extension
);
513 if ((ctx
->Const
.MaxTextureUnits
== 6) && rmesa
->radeon
.radeonScreen
->drmSupportsFragShader
)
514 driInitSingleExtension( ctx
, ATI_fs_extension
);
515 if (rmesa
->radeon
.radeonScreen
->drmSupportsPointSprites
)
516 driInitExtensions( ctx
, point_extensions
, GL_FALSE
);
518 r200InitDriverFuncs( ctx
);
519 r200InitIoctlFuncs( ctx
);
520 r200InitStateFuncs( ctx
);
521 r200InitTextureFuncs( ctx
);
523 /* plug in a few more device driver functions */
524 /* XXX these should really go right after _mesa_init_driver_functions() */
525 r200InitPixelFuncs( ctx
);
526 r200InitSpanFuncs( ctx
);
527 r200InitTnlFuncs( ctx
);
528 r200InitState( rmesa
);
529 r200InitSwtcl( ctx
);
531 fthrottle_mode
= driQueryOptioni(&rmesa
->radeon
.optionCache
, "fthrottle_mode");
532 rmesa
->radeon
.iw
.irq_seq
= -1;
533 rmesa
->radeon
.irqsEmitted
= 0;
534 rmesa
->radeon
.do_irqs
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_IRQS
&&
535 rmesa
->radeon
.radeonScreen
->irq
);
537 rmesa
->radeon
.do_usleeps
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_USLEEPS
);
539 if (!rmesa
->radeon
.do_irqs
)
541 "IRQ's not enabled, falling back to %s: %d %d\n",
542 rmesa
->radeon
.do_usleeps
? "usleeps" : "busy waits",
544 rmesa
->radeon
.radeonScreen
->irq
);
546 rmesa
->prefer_gart_client_texturing
=
547 (getenv("R200_GART_CLIENT_TEXTURES") != 0);
549 (*sPriv
->systemTime
->getUST
)( & rmesa
->radeon
.swap_ust
);
553 R200_DEBUG
= driParseDebugString( getenv( "R200_DEBUG" ),
555 R200_DEBUG
|= driParseDebugString( getenv( "RADEON_DEBUG" ),
559 tcl_mode
= driQueryOptioni(&rmesa
->radeon
.optionCache
, "tcl_mode");
560 if (driQueryOptionb(&rmesa
->radeon
.optionCache
, "no_rast")) {
561 fprintf(stderr
, "disabling 3D acceleration\n");
562 FALLBACK(rmesa
, R200_FALLBACK_DISABLE
, 1);
564 else if (tcl_mode
== DRI_CONF_TCL_SW
|| getenv("R200_NO_TCL") ||
565 !(rmesa
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
)) {
566 if (rmesa
->radeon
.radeonScreen
->chip_flags
& RADEON_CHIPSET_TCL
) {
567 rmesa
->radeon
.radeonScreen
->chip_flags
&= ~RADEON_CHIPSET_TCL
;
568 fprintf(stderr
, "Disabling HW TCL support\n");
570 TCL_FALLBACK(rmesa
->radeon
.glCtx
, R200_TCL_FALLBACK_TCL_DISABLE
, 1);
577 /* Destroy the device specific context.
579 /* Destroy the Mesa and driver specific context data.
581 void r200DestroyContext( __DRIcontextPrivate
*driContextPriv
)
583 GET_CURRENT_CONTEXT(ctx
);
584 r200ContextPtr rmesa
= (r200ContextPtr
) driContextPriv
->driverPrivate
;
585 r200ContextPtr current
= ctx
? R200_CONTEXT(ctx
) : NULL
;
587 /* check if we're deleting the currently bound context */
588 if (rmesa
== current
) {
589 R200_FIREVERTICES( rmesa
);
590 _mesa_make_current(NULL
, NULL
, NULL
);
593 /* Free r200 context resources */
594 assert(rmesa
); /* should never be null */
596 GLboolean release_texture_heaps
;
599 release_texture_heaps
= (rmesa
->radeon
.glCtx
->Shared
->RefCount
== 1);
600 _swsetup_DestroyContext( rmesa
->radeon
.glCtx
);
601 _tnl_DestroyContext( rmesa
->radeon
.glCtx
);
602 _vbo_DestroyContext( rmesa
->radeon
.glCtx
);
603 _swrast_DestroyContext( rmesa
->radeon
.glCtx
);
605 r200DestroySwtcl( rmesa
->radeon
.glCtx
);
606 r200ReleaseArrays( rmesa
->radeon
.glCtx
, ~0 );
608 if (rmesa
->dma
.current
.buf
) {
609 r200ReleaseDmaRegion( rmesa
, &rmesa
->dma
.current
, __FUNCTION__
);
610 r200FlushCmdBuf( rmesa
, __FUNCTION__
);
613 if (rmesa
->radeon
.state
.scissor
.pClipRects
) {
614 FREE(rmesa
->radeon
.state
.scissor
.pClipRects
);
615 rmesa
->radeon
.state
.scissor
.pClipRects
= NULL
;
618 if ( release_texture_heaps
) {
619 /* This share group is about to go away, free our private
620 * texture object data.
624 for ( i
= 0 ; i
< rmesa
->radeon
.nr_heaps
; i
++ ) {
625 driDestroyTextureHeap( rmesa
->radeon
.texture_heaps
[ i
] );
626 rmesa
->radeon
.texture_heaps
[ i
] = NULL
;
629 assert( is_empty_list( & rmesa
->radeon
.swapped
) );
632 /* free the Mesa context */
633 rmesa
->radeon
.glCtx
->DriverCtx
= NULL
;
634 _mesa_destroy_context( rmesa
->radeon
.glCtx
);
636 /* free the option cache */
637 driDestroyOptionCache (&rmesa
->radeon
.optionCache
);
643 /* Force the context `c' to be the current context and associate with it
647 r200MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
648 __DRIdrawablePrivate
*driDrawPriv
,
649 __DRIdrawablePrivate
*driReadPriv
)
651 if ( driContextPriv
) {
652 r200ContextPtr newCtx
=
653 (r200ContextPtr
) driContextPriv
->driverPrivate
;
655 if (R200_DEBUG
& DEBUG_DRI
)
656 fprintf(stderr
, "%s ctx %p\n", __FUNCTION__
, (void *)newCtx
->radeon
.glCtx
);
658 newCtx
->radeon
.dri
.readable
= driReadPriv
;
660 if ( newCtx
->radeon
.dri
.drawable
!= driDrawPriv
||
661 newCtx
->radeon
.lastStamp
!= driDrawPriv
->lastStamp
) {
662 if (driDrawPriv
->swap_interval
== (unsigned)-1) {
663 driDrawPriv
->vblFlags
= (newCtx
->radeon
.radeonScreen
->irq
!= 0)
664 ? driGetDefaultVBlankFlags(&newCtx
->radeon
.optionCache
)
665 : VBLANK_FLAG_NO_IRQ
;
667 driDrawableInitVBlank( driDrawPriv
);
670 newCtx
->radeon
.dri
.drawable
= driDrawPriv
;
672 r200SetCliprects(newCtx
);
673 r200UpdateViewportOffset( newCtx
->radeon
.glCtx
);
676 _mesa_make_current( newCtx
->radeon
.glCtx
,
677 (GLframebuffer
*) driDrawPriv
->driverPrivate
,
678 (GLframebuffer
*) driReadPriv
->driverPrivate
);
680 _mesa_update_state( newCtx
->radeon
.glCtx
);
681 r200ValidateState( newCtx
->radeon
.glCtx
);
684 if (R200_DEBUG
& DEBUG_DRI
)
685 fprintf(stderr
, "%s ctx is null\n", __FUNCTION__
);
686 _mesa_make_current( NULL
, NULL
, NULL
);
689 if (R200_DEBUG
& DEBUG_DRI
)
690 fprintf(stderr
, "End %s\n", __FUNCTION__
);
694 /* Force the context `c' to be unbound from its buffer.
697 r200UnbindContext( __DRIcontextPrivate
*driContextPriv
)
699 r200ContextPtr rmesa
= (r200ContextPtr
) driContextPriv
->driverPrivate
;
701 if (R200_DEBUG
& DEBUG_DRI
)
702 fprintf(stderr
, "%s ctx %p\n", __FUNCTION__
, (void *)rmesa
->radeon
.glCtx
);