r100/r200: fix front rendering issue.
[mesa.git] / src / mesa / drivers / dri / r200 / r200_context.c
1 /*
2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
3
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.
7
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:
15
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.
19
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.
27
28 **************************************************************************/
29
30 /*
31 * Authors:
32 * Keith Whitwell <keith@tungstengraphics.com>
33 */
34
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"
44
45 #include "swrast/swrast.h"
46 #include "swrast_setup/swrast_setup.h"
47 #include "vbo/vbo.h"
48
49 #include "tnl/tnl.h"
50 #include "tnl/t_pipeline.h"
51
52 #include "drivers/common/driverfuncs.h"
53
54 #include "r200_context.h"
55 #include "r200_ioctl.h"
56 #include "r200_state.h"
57 #include "r200_pixel.h"
58 #include "r200_tex.h"
59 #include "r200_swtcl.h"
60 #include "r200_tcl.h"
61 #include "r200_maos.h"
62 #include "r200_vertprog.h"
63
64 #include "radeon_span.h"
65
66 #define need_GL_ARB_multisample
67 #define need_GL_ARB_texture_compression
68 #define need_GL_ARB_vertex_buffer_object
69 #define need_GL_ARB_vertex_program
70 #define need_GL_ATI_fragment_shader
71 #define need_GL_EXT_blend_minmax
72 #define need_GL_EXT_fog_coord
73 #define need_GL_EXT_multi_draw_arrays
74 #define need_GL_EXT_secondary_color
75 #define need_GL_EXT_blend_equation_separate
76 #define need_GL_EXT_blend_func_separate
77 #define need_GL_NV_vertex_program
78 #define need_GL_ARB_point_parameters
79 #include "extension_helper.h"
80
81 #define DRIVER_DATE "20060602"
82
83 #include "vblank.h"
84 #include "utils.h"
85 #include "xmlpool.h" /* for symbolic values of enum-type options */
86
87 /* Return various strings for glGetString().
88 */
89 static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
90 {
91 r200ContextPtr rmesa = R200_CONTEXT(ctx);
92 static char buffer[128];
93 unsigned offset;
94 GLuint agp_mode = (rmesa->radeon.radeonScreen->card_type == RADEON_CARD_PCI)? 0 :
95 rmesa->radeon.radeonScreen->AGPMode;
96
97 switch ( name ) {
98 case GL_VENDOR:
99 return (GLubyte *)"Tungsten Graphics, Inc.";
100
101 case GL_RENDERER:
102 offset = driGetRendererString( buffer, "R200", DRIVER_DATE,
103 agp_mode );
104
105 sprintf( & buffer[ offset ], " %sTCL",
106 !(rmesa->radeon.TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
107 ? "" : "NO-" );
108
109 return (GLubyte *)buffer;
110
111 default:
112 return NULL;
113 }
114 }
115
116
117 /* Extension strings exported by the R200 driver.
118 */
119 const struct dri_extension card_extensions[] =
120 {
121 { "GL_ARB_multisample", GL_ARB_multisample_functions },
122 { "GL_ARB_multitexture", NULL },
123 { "GL_ARB_texture_border_clamp", NULL },
124 { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
125 { "GL_ARB_texture_env_add", NULL },
126 { "GL_ARB_texture_env_combine", NULL },
127 { "GL_ARB_texture_env_dot3", NULL },
128 { "GL_ARB_texture_env_crossbar", NULL },
129 { "GL_ARB_texture_mirrored_repeat", NULL },
130 { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
131 { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
132 { "GL_EXT_blend_subtract", NULL },
133 { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
134 { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions },
135 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
136 { "GL_EXT_stencil_wrap", NULL },
137 { "GL_EXT_texture_edge_clamp", NULL },
138 { "GL_EXT_texture_env_combine", NULL },
139 { "GL_EXT_texture_env_dot3", NULL },
140 { "GL_EXT_texture_filter_anisotropic", NULL },
141 { "GL_EXT_texture_lod_bias", NULL },
142 { "GL_EXT_texture_mirror_clamp", NULL },
143 { "GL_EXT_texture_rectangle", NULL },
144 { "GL_ATI_texture_env_combine3", NULL },
145 { "GL_ATI_texture_mirror_once", NULL },
146 { "GL_MESA_pack_invert", NULL },
147 { "GL_NV_blend_square", NULL },
148 { "GL_SGIS_generate_mipmap", NULL },
149 { NULL, NULL }
150 };
151
152 const struct dri_extension blend_extensions[] = {
153 { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
154 { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
155 { NULL, NULL }
156 };
157
158 const struct dri_extension ARB_vp_extension[] = {
159 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }
160 };
161
162 const struct dri_extension NV_vp_extension[] = {
163 { "GL_NV_vertex_program", GL_NV_vertex_program_functions }
164 };
165
166 const struct dri_extension ATI_fs_extension[] = {
167 { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions }
168 };
169
170 const struct dri_extension point_extensions[] = {
171 { "GL_ARB_point_sprite", NULL },
172 { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
173 { NULL, NULL }
174 };
175
176 extern const struct tnl_pipeline_stage _r200_render_stage;
177 extern const struct tnl_pipeline_stage _r200_tcl_stage;
178
179 static const struct tnl_pipeline_stage *r200_pipeline[] = {
180
181 /* Try and go straight to t&l
182 */
183 &_r200_tcl_stage,
184
185 /* Catch any t&l fallbacks
186 */
187 &_tnl_vertex_transform_stage,
188 &_tnl_normal_transform_stage,
189 &_tnl_lighting_stage,
190 &_tnl_fog_coordinate_stage,
191 &_tnl_texgen_stage,
192 &_tnl_texture_transform_stage,
193 &_tnl_point_attenuation_stage,
194 &_tnl_vertex_program_stage,
195 /* Try again to go to tcl?
196 * - no good for asymmetric-twoside (do with multipass)
197 * - no good for asymmetric-unfilled (do with multipass)
198 * - good for material
199 * - good for texgen
200 * - need to manipulate a bit of state
201 *
202 * - worth it/not worth it?
203 */
204
205 /* Else do them here.
206 */
207 /* &_r200_render_stage, */ /* FIXME: bugs with ut2003 */
208 &_tnl_render_stage, /* FALLBACK: */
209 NULL,
210 };
211
212
213
214 /* Initialize the driver's misc functions.
215 */
216 static void r200InitDriverFuncs( struct dd_function_table *functions )
217 {
218 functions->GetBufferSize = NULL; /* OBSOLETE */
219 functions->GetString = r200GetString;
220 }
221
222 static const struct dri_debug_control debug_control[] =
223 {
224 { "fall", DEBUG_FALLBACKS },
225 { "tex", DEBUG_TEXTURE },
226 { "ioctl", DEBUG_IOCTL },
227 { "prim", DEBUG_PRIMS },
228 { "vert", DEBUG_VERTS },
229 { "state", DEBUG_STATE },
230 { "code", DEBUG_CODEGEN },
231 { "vfmt", DEBUG_VFMT },
232 { "vtxf", DEBUG_VFMT },
233 { "verb", DEBUG_VERBOSE },
234 { "dri", DEBUG_DRI },
235 { "dma", DEBUG_DMA },
236 { "san", DEBUG_SANITY },
237 { "sync", DEBUG_SYNC },
238 { "pix", DEBUG_PIXEL },
239 { "mem", DEBUG_MEMORY },
240 { NULL, 0 }
241 };
242
243 static void r200_get_lock(radeonContextPtr radeon)
244 {
245 r200ContextPtr rmesa = (r200ContextPtr)radeon;
246 drm_radeon_sarea_t *sarea = radeon->sarea;
247 int i;
248
249 R200_STATECHANGE( rmesa, ctx );
250 if (rmesa->radeon.sarea->tiling_enabled) {
251 rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
252 }
253 else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~R200_COLOR_TILE_ENABLE;
254
255 if ( sarea->ctx_owner != rmesa->radeon.dri.hwContext ) {
256 sarea->ctx_owner = rmesa->radeon.dri.hwContext;
257 }
258
259 for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) {
260 DRI_AGE_TEXTURES( rmesa->radeon.texture_heaps[ i ] );
261 }
262 }
263
264 static void r200_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
265 {
266 }
267
268
269 static void r200_init_vtbl(radeonContextPtr radeon)
270 {
271 radeon->vtbl.get_lock = r200_get_lock;
272 radeon->vtbl.update_viewport_offset = r200UpdateViewportOffset;
273 radeon->vtbl.update_draw_buffer = r200UpdateDrawBuffer;
274 radeon->vtbl.emit_cs_header = r200_vtbl_emit_cs_header;
275 radeon->vtbl.swtcl_flush = r200_swtcl_flush;
276 }
277
278
279 /* Create the device specific rendering context.
280 */
281 GLboolean r200CreateContext( const __GLcontextModes *glVisual,
282 __DRIcontextPrivate *driContextPriv,
283 void *sharedContextPrivate)
284 {
285 __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
286 radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
287 struct dd_function_table functions;
288 r200ContextPtr rmesa;
289 GLcontext *ctx;
290 int i;
291 int tcl_mode;
292
293 assert(glVisual);
294 assert(driContextPriv);
295 assert(screen);
296
297 /* Allocate the R200 context */
298 rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );
299 if ( !rmesa )
300 return GL_FALSE;
301
302 r200_init_vtbl(&rmesa->radeon);
303 /* init exp fog table data */
304 r200InitStaticFogData();
305
306 /* Parse configuration files.
307 * Do this here so that initialMaxAnisotropy is set before we create
308 * the default textures.
309 */
310 driParseConfigFiles (&rmesa->radeon.optionCache, &screen->optionCache,
311 screen->driScreen->myNum, "r200");
312 rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache,
313 "def_max_anisotropy");
314
315 if ( driQueryOptionb( &rmesa->radeon.optionCache, "hyperz" ) ) {
316 if ( sPriv->drm_version.minor < 13 )
317 fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
318 "disabling.\n", sPriv->drm_version.minor );
319 else
320 rmesa->using_hyperz = GL_TRUE;
321 }
322
323 if ( sPriv->drm_version.minor >= 15 )
324 rmesa->texmicrotile = GL_TRUE;
325
326 /* Init default driver functions then plug in our R200-specific functions
327 * (the texture functions are especially important)
328 */
329 _mesa_init_driver_functions(&functions);
330 r200InitDriverFuncs(&functions);
331 r200InitIoctlFuncs(&functions);
332 r200InitStateFuncs(&functions);
333 r200InitTextureFuncs(&functions);
334 r200InitShaderFuncs(&functions);
335
336 if (!radeonInitContext(&rmesa->radeon, &functions,
337 glVisual, driContextPriv,
338 sharedContextPrivate)) {
339 FREE(rmesa);
340 return GL_FALSE;
341 }
342
343
344 (void) memset( rmesa->radeon.texture_heaps, 0, sizeof( rmesa->radeon.texture_heaps ) );
345 make_empty_list( & rmesa->radeon.swapped );
346
347 rmesa->radeon.nr_heaps = 1 /* screen->numTexHeaps */ ;
348 assert(rmesa->radeon.nr_heaps < RADEON_NR_TEX_HEAPS);
349 #if 0
350 for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) {
351 rmesa->radeon.texture_heaps[i] = driCreateTextureHeap( i, rmesa,
352 screen->texSize[i],
353 12,
354 RADEON_NR_TEX_REGIONS,
355 (drmTextureRegionPtr)rmesa->radeon.sarea->tex_list[i],
356 & rmesa->radeon.sarea->tex_age[i],
357 & rmesa->radeon.swapped,
358 sizeof( radeonTexObj ),
359 (destroy_texture_object_t *) r200DestroyTexObj );
360 }
361 #endif
362 rmesa->radeon.texture_depth = driQueryOptioni (&rmesa->radeon.optionCache,
363 "texture_depth");
364 if (rmesa->radeon.texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
365 rmesa->radeon.texture_depth = ( screen->cpp == 4 ) ?
366 DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
367
368 rmesa->radeon.swtcl.RenderIndex = ~0;
369 rmesa->radeon.hw.all_dirty = 1;
370
371 /* Set the maximum texture size small enough that we can guarentee that
372 * all texture units can bind a maximal texture and have all of them in
373 * texturable memory at once. Depending on the allow_large_textures driconf
374 * setting allow larger textures.
375 */
376
377 ctx = rmesa->radeon.glCtx;
378 ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->radeon.optionCache,
379 "texture_units");
380 ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
381 ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
382
383 i = driQueryOptioni( &rmesa->radeon.optionCache, "allow_large_textures");
384
385 driCalculateMaxTextureLevels( rmesa->radeon.texture_heaps,
386 rmesa->radeon.nr_heaps,
387 & ctx->Const,
388 4,
389 11, /* max 2D texture size is 2048x2048 */
390 #if ENABLE_HW_3D_TEXTURE
391 8, /* max 3D texture size is 256^3 */
392 #else
393 0, /* 3D textures unsupported */
394 #endif
395 11, /* max cube texture size is 2048x2048 */
396 11, /* max texture rectangle size is 2048x2048 */
397 12,
398 GL_FALSE,
399 i );
400
401 ctx->Const.MaxTextureMaxAnisotropy = 16.0;
402
403 /* No wide AA points.
404 */
405 ctx->Const.MinPointSize = 1.0;
406 ctx->Const.MinPointSizeAA = 1.0;
407 ctx->Const.MaxPointSizeAA = 1.0;
408 ctx->Const.PointSizeGranularity = 0.0625;
409 if (rmesa->radeon.radeonScreen->drmSupportsPointSprites)
410 ctx->Const.MaxPointSize = 2047.0;
411 else
412 ctx->Const.MaxPointSize = 1.0;
413
414 /* mesa initialization problem - _mesa_init_point was already called */
415 ctx->Point.MaxSize = ctx->Const.MaxPointSize;
416
417 ctx->Const.MinLineWidth = 1.0;
418 ctx->Const.MinLineWidthAA = 1.0;
419 ctx->Const.MaxLineWidth = 10.0;
420 ctx->Const.MaxLineWidthAA = 10.0;
421 ctx->Const.LineWidthGranularity = 0.0625;
422
423 ctx->Const.VertexProgram.MaxNativeInstructions = R200_VSF_MAX_INST;
424 ctx->Const.VertexProgram.MaxNativeAttribs = 12;
425 ctx->Const.VertexProgram.MaxNativeTemps = R200_VSF_MAX_TEMPS;
426 ctx->Const.VertexProgram.MaxNativeParameters = R200_VSF_MAX_PARAM;
427 ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
428
429 /* Initialize the software rasterizer and helper modules.
430 */
431 _swrast_CreateContext( ctx );
432 _vbo_CreateContext( ctx );
433 _tnl_CreateContext( ctx );
434 _swsetup_CreateContext( ctx );
435 _ae_create_context( ctx );
436
437 /* Install the customized pipeline:
438 */
439 _tnl_destroy_pipeline( ctx );
440 _tnl_install_pipeline( ctx, r200_pipeline );
441
442 /* Try and keep materials and vertices separate:
443 */
444 /* _tnl_isolate_materials( ctx, GL_TRUE ); */
445
446
447 /* Configure swrast and TNL to match hardware characteristics:
448 */
449 _swrast_allow_pixel_fog( ctx, GL_FALSE );
450 _swrast_allow_vertex_fog( ctx, GL_TRUE );
451 _tnl_allow_pixel_fog( ctx, GL_FALSE );
452 _tnl_allow_vertex_fog( ctx, GL_TRUE );
453
454
455 for ( i = 0 ; i < R200_MAX_TEXTURE_UNITS ; i++ ) {
456 _math_matrix_ctr( &rmesa->TexGenMatrix[i] );
457 _math_matrix_set_identity( &rmesa->TexGenMatrix[i] );
458 }
459 _math_matrix_ctr( &rmesa->tmpmat );
460 _math_matrix_set_identity( &rmesa->tmpmat );
461
462 driInitExtensions( ctx, card_extensions, GL_TRUE );
463 if (!(rmesa->radeon.radeonScreen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) {
464 /* yuv textures don't work with some chips - R200 / rv280 okay so far
465 others get the bit ordering right but don't actually do YUV-RGB conversion */
466 _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
467 }
468 if (rmesa->radeon.glCtx->Mesa_DXTn) {
469 _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
470 _mesa_enable_extension( ctx, "GL_S3_s3tc" );
471 }
472 else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) {
473 _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
474 }
475
476 if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR200)
477 _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
478 if (rmesa->radeon.radeonScreen->drmSupportsBlendColor) {
479 driInitExtensions( ctx, blend_extensions, GL_FALSE );
480 }
481 if(rmesa->radeon.radeonScreen->drmSupportsVertexProgram)
482 driInitSingleExtension( ctx, ARB_vp_extension );
483 if(driQueryOptionb(&rmesa->radeon.optionCache, "nv_vertex_program"))
484 driInitSingleExtension( ctx, NV_vp_extension );
485
486 if ((ctx->Const.MaxTextureUnits == 6) && rmesa->radeon.radeonScreen->drmSupportsFragShader)
487 driInitSingleExtension( ctx, ATI_fs_extension );
488 if (rmesa->radeon.radeonScreen->drmSupportsPointSprites)
489 driInitExtensions( ctx, point_extensions, GL_FALSE );
490 #if 0
491 r200InitDriverFuncs( ctx );
492 r200InitIoctlFuncs( ctx );
493 r200InitStateFuncs( ctx );
494 r200InitTextureFuncs( ctx );
495 #endif
496 /* plug in a few more device driver functions */
497 /* XXX these should really go right after _mesa_init_driver_functions() */
498 radeonInitSpanFuncs( ctx );
499 r200InitPixelFuncs( ctx );
500 r200InitTnlFuncs( ctx );
501 r200InitState( rmesa );
502 r200InitSwtcl( ctx );
503
504 rmesa->prefer_gart_client_texturing =
505 (getenv("R200_GART_CLIENT_TEXTURES") != 0);
506
507 #if DO_DEBUG
508 R200_DEBUG = driParseDebugString( getenv( "R200_DEBUG" ),
509 debug_control );
510 R200_DEBUG |= driParseDebugString( getenv( "RADEON_DEBUG" ),
511 debug_control );
512 #endif
513
514 tcl_mode = driQueryOptioni(&rmesa->radeon.optionCache, "tcl_mode");
515 if (driQueryOptionb(&rmesa->radeon.optionCache, "no_rast")) {
516 fprintf(stderr, "disabling 3D acceleration\n");
517 FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);
518 }
519 else if (tcl_mode == DRI_CONF_TCL_SW || getenv("R200_NO_TCL") ||
520 !(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) {
521 if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
522 rmesa->radeon.radeonScreen->chip_flags &= ~RADEON_CHIPSET_TCL;
523 fprintf(stderr, "Disabling HW TCL support\n");
524 }
525 TCL_FALLBACK(rmesa->radeon.glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
526 }
527
528 return GL_TRUE;
529 }
530
531
532 /* Destroy the device specific context.
533 */
534 /* Destroy the Mesa and driver specific context data.
535 */
536 void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
537 {
538 GET_CURRENT_CONTEXT(ctx);
539 r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
540 r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL;
541
542 /* check if we're deleting the currently bound context */
543 if (rmesa == current) {
544 radeon_firevertices(&rmesa->radeon);
545 _mesa_make_current(NULL, NULL, NULL);
546 }
547
548 /* Free r200 context resources */
549 assert(rmesa); /* should never be null */
550 if ( rmesa ) {
551 GLboolean release_texture_heaps;
552
553
554 release_texture_heaps = (rmesa->radeon.glCtx->Shared->RefCount == 1);
555 _swsetup_DestroyContext( rmesa->radeon.glCtx );
556 _tnl_DestroyContext( rmesa->radeon.glCtx );
557 _vbo_DestroyContext( rmesa->radeon.glCtx );
558 _swrast_DestroyContext( rmesa->radeon.glCtx );
559
560 r200DestroySwtcl( rmesa->radeon.glCtx );
561 r200ReleaseArrays( rmesa->radeon.glCtx, ~0 );
562
563 if (rmesa->radeon.dma.current) {
564 rcommonFlushCmdBuf( &rmesa->radeon, __FUNCTION__ );
565 }
566
567 if (rmesa->radeon.state.scissor.pClipRects) {
568 FREE(rmesa->radeon.state.scissor.pClipRects);
569 rmesa->radeon.state.scissor.pClipRects = NULL;
570 }
571
572
573 if ( release_texture_heaps ) {
574 /* This share group is about to go away, free our private
575 * texture object data.
576 */
577 int i;
578
579 for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) {
580 driDestroyTextureHeap( rmesa->radeon.texture_heaps[ i ] );
581 rmesa->radeon.texture_heaps[ i ] = NULL;
582 }
583
584 assert( is_empty_list( & rmesa->radeon.swapped ) );
585 }
586
587 radeonCleanupContext(&rmesa->radeon);
588
589 FREE( rmesa );
590 }
591 }
592
593
594
595 /* Force the context `c' to be unbound from its buffer.
596 */
597 GLboolean
598 r200UnbindContext( __DRIcontextPrivate *driContextPriv )
599 {
600 r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
601
602 if (R200_DEBUG & DEBUG_DRI)
603 fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)rmesa->radeon.glCtx);
604
605 return GL_TRUE;
606 }