c08c411e22dc93de250f32f0525528599fd628a2
[mesa.git] / src / mesa / drivers / dri / r200 / r200_context.c
1 /* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.c,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
2 /*
3 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4
5 The Weather Channel (TM) funded Tungsten Graphics to develop the
6 initial release of the Radeon 8500 driver under the XFree86 license.
7 This notice must be preserved.
8
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial
19 portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 **************************************************************************/
30
31 /*
32 * Authors:
33 * Keith Whitwell <keith@tungstengraphics.com>
34 */
35
36 #include "glheader.h"
37 #include "api_arrayelt.h"
38 #include "context.h"
39 #include "simple_list.h"
40 #include "imports.h"
41 #include "matrix.h"
42 #include "extensions.h"
43 #include "state.h"
44
45 #include "swrast/swrast.h"
46 #include "swrast_setup/swrast_setup.h"
47 #include "array_cache/acache.h"
48
49 #include "tnl/tnl.h"
50 #include "tnl/t_pipeline.h"
51
52 #include "r200_context.h"
53 #include "r200_ioctl.h"
54 #include "r200_state.h"
55 #include "r200_span.h"
56 #include "r200_pixel.h"
57 #include "r200_tex.h"
58 #include "r200_swtcl.h"
59 #include "r200_tcl.h"
60 #include "r200_vtxfmt.h"
61 #include "r200_maos.h"
62
63 #define DRIVER_DATE "20030328"
64
65 #include "vblank.h"
66 #include "utils.h"
67 #ifndef R200_DEBUG
68 int R200_DEBUG = (0);
69 #endif
70
71
72 /* R200 configuration
73 */
74 #include "xmlpool.h"
75
76 const char __driConfigOptions[] =
77 DRI_CONF_BEGIN
78 DRI_CONF_SECTION_PERFORMANCE
79 DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
80 DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
81 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
82 DRI_CONF_SECTION_END
83 DRI_CONF_SECTION_QUALITY
84 DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
85 DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
86 DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
87 DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
88 DRI_CONF_SECTION_END
89 DRI_CONF_SECTION_DEBUG
90 DRI_CONF_NO_RAST(false)
91 DRI_CONF_SECTION_END
92 DRI_CONF_END;
93 const GLuint __driNConfigOptions = 8;
94
95
96 /* Return the width and height of the given buffer.
97 */
98 static void r200GetBufferSize( GLframebuffer *buffer,
99 GLuint *width, GLuint *height )
100 {
101 GET_CURRENT_CONTEXT(ctx);
102 r200ContextPtr rmesa = R200_CONTEXT(ctx);
103
104 LOCK_HARDWARE( rmesa );
105 *width = rmesa->dri.drawable->w;
106 *height = rmesa->dri.drawable->h;
107 UNLOCK_HARDWARE( rmesa );
108 }
109
110 /* Return various strings for glGetString().
111 */
112 static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
113 {
114 r200ContextPtr rmesa = R200_CONTEXT(ctx);
115 static char buffer[128];
116 unsigned offset;
117 GLuint agp_mode = rmesa->r200Screen->IsPCI ? 0 :
118 rmesa->r200Screen->AGPMode;
119
120 switch ( name ) {
121 case GL_VENDOR:
122 return (GLubyte *)"Tungsten Graphics, Inc.";
123
124 case GL_RENDERER:
125 offset = driGetRendererString( buffer, "R200", DRIVER_DATE,
126 agp_mode );
127
128 sprintf( & buffer[ offset ], " %sTCL",
129 !(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
130 ? "" : "NO-" );
131
132 return (GLubyte *)buffer;
133
134 default:
135 return NULL;
136 }
137 }
138
139
140 /* Extension strings exported by the R200 driver.
141 */
142 static const char * const card_extensions[] =
143 {
144 "GL_ARB_multisample",
145 "GL_ARB_multitexture",
146 "GL_ARB_texture_border_clamp",
147 "GL_ARB_texture_compression",
148 "GL_ARB_texture_env_add",
149 "GL_ARB_texture_env_combine",
150 "GL_ARB_texture_env_dot3",
151 "GL_ARB_texture_mirrored_repeat",
152 "GL_EXT_blend_logic_op",
153 "GL_EXT_blend_minmax",
154 "GL_EXT_blend_subtract",
155 "GL_EXT_secondary_color",
156 "GL_EXT_stencil_wrap",
157 "GL_EXT_texture_edge_clamp",
158 "GL_EXT_texture_env_add",
159 "GL_EXT_texture_env_combine",
160 "GL_EXT_texture_env_dot3",
161 "GL_EXT_texture_filter_anisotropic",
162 "GL_EXT_texture_lod_bias",
163 "GL_ATI_texture_env_combine3",
164 "GL_ATI_texture_mirror_once",
165 "GL_IBM_texture_mirrored_repeat",
166 "GL_MESA_pack_invert",
167 "GL_MESA_ycbcr_texture",
168 "GL_NV_blend_square",
169 "GL_NV_texture_rectangle",
170 "GL_SGIS_generate_mipmap",
171 "GL_SGIS_texture_border_clamp",
172 "GL_SGIS_texture_edge_clamp",
173 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
194 /* Try again to go to tcl?
195 * - no good for asymmetric-twoside (do with multipass)
196 * - no good for asymmetric-unfilled (do with multipass)
197 * - good for material
198 * - good for texgen
199 * - need to manipulate a bit of state
200 *
201 * - worth it/not worth it?
202 */
203
204 /* Else do them here.
205 */
206 /* &_r200_render_stage, */ /* FIXME: bugs with ut2003 */
207 &_tnl_render_stage, /* FALLBACK: */
208 0,
209 };
210
211
212
213 /* Initialize the driver's misc functions.
214 */
215 static void r200InitDriverFuncs( GLcontext *ctx )
216 {
217 ctx->Driver.GetBufferSize = r200GetBufferSize;
218 ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
219 ctx->Driver.GetString = r200GetString;
220
221 ctx->Driver.Error = NULL;
222 ctx->Driver.DrawPixels = NULL;
223 ctx->Driver.Bitmap = NULL;
224 }
225
226 static const struct dri_debug_control debug_control[] =
227 {
228 { "fall", DEBUG_FALLBACKS },
229 { "tex", DEBUG_TEXTURE },
230 { "ioctl", DEBUG_IOCTL },
231 { "prim", DEBUG_PRIMS },
232 { "vert", DEBUG_VERTS },
233 { "state", DEBUG_STATE },
234 { "code", DEBUG_CODEGEN },
235 { "vfmt", DEBUG_VFMT },
236 { "vtxf", DEBUG_VFMT },
237 { "verb", DEBUG_VERBOSE },
238 { "dri", DEBUG_DRI },
239 { "dma", DEBUG_DMA },
240 { "san", DEBUG_SANITY },
241 { "sync", DEBUG_SYNC },
242 { "pix", DEBUG_PIXEL },
243 { "mem", DEBUG_MEMORY },
244 { NULL, 0 }
245 };
246
247
248 static int
249 get_ust_nop( int64_t * ust )
250 {
251 *ust = 1;
252 return 0;
253 }
254
255
256 /* Create the device specific context.
257 */
258 GLboolean r200CreateContext( const __GLcontextModes *glVisual,
259 __DRIcontextPrivate *driContextPriv,
260 void *sharedContextPrivate)
261 {
262 __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
263 r200ScreenPtr screen = (r200ScreenPtr)(sPriv->private);
264 r200ContextPtr rmesa;
265 GLcontext *ctx, *shareCtx;
266 int i;
267 int tcl_mode, fthrottle_mode;
268
269 assert(glVisual);
270 assert(driContextPriv);
271 assert(screen);
272
273 /* Allocate the R200 context */
274 rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );
275 if ( !rmesa )
276 return GL_FALSE;
277
278 /* Allocate the Mesa context */
279 if (sharedContextPrivate)
280 shareCtx = ((r200ContextPtr) sharedContextPrivate)->glCtx;
281 else
282 shareCtx = NULL;
283 rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) rmesa, GL_TRUE);
284 if (!rmesa->glCtx) {
285 FREE(rmesa);
286 return GL_FALSE;
287 }
288 driContextPriv->driverPrivate = rmesa;
289
290 /* Init r200 context data */
291 rmesa->dri.context = driContextPriv;
292 rmesa->dri.screen = sPriv;
293 rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
294 rmesa->dri.hwContext = driContextPriv->hHWContext;
295 rmesa->dri.hwLock = &sPriv->pSAREA->lock;
296 rmesa->dri.fd = sPriv->fd;
297 rmesa->dri.drmMinor = sPriv->drmMinor;
298
299 /* Parse configuration files */
300 driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
301 screen->driScreen->myNum, "r200");
302
303 rmesa->r200Screen = screen;
304 rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
305 screen->sarea_priv_offset);
306
307
308 rmesa->dma.buf0_address = rmesa->r200Screen->buffers->list[0].address;
309
310 (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );
311 make_empty_list( & rmesa->swapped );
312
313 rmesa->nr_heaps = 1 /* screen->numTexHeaps */ ;
314 for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
315 rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
316 screen->texSize[i],
317 12,
318 RADEON_NR_TEX_REGIONS,
319 rmesa->sarea->texList[i],
320 & rmesa->sarea->texAge[i],
321 & rmesa->swapped,
322 sizeof( r200TexObj ),
323 (destroy_texture_object_t *) r200DestroyTexObj );
324 }
325 rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
326 "texture_depth");
327 if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
328 rmesa->texture_depth = ( screen->cpp == 4 ) ?
329 DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
330
331 rmesa->swtcl.RenderIndex = ~0;
332 rmesa->lost_context = 1;
333
334 /* Set the maximum texture size small enough that we can guarentee that
335 * all texture units can bind a maximal texture and have them both in
336 * texturable memory at once.
337 */
338
339 ctx = rmesa->glCtx;
340 ctx->Const.MaxTextureUnits = 2;
341
342 driCalculateMaxTextureLevels( rmesa->texture_heaps,
343 rmesa->nr_heaps,
344 & ctx->Const,
345 4,
346 11, /* max 2D texture size is 2048x2048 */
347 #if ENABLE_HW_3D_TEXTURE
348 8, /* max 3D texture size is 256^3 */
349 #else
350 0, /* 3D textures unsupported */
351 #endif
352 11, /* max cube texture size is 2048x2048 */
353 11, /* max texture rectangle size is 2048x2048 */
354 12,
355 GL_FALSE );
356
357 ctx->Const.MaxTextureMaxAnisotropy = 16.0;
358
359 /* No wide points.
360 */
361 ctx->Const.MinPointSize = 1.0;
362 ctx->Const.MinPointSizeAA = 1.0;
363 ctx->Const.MaxPointSize = 1.0;
364 ctx->Const.MaxPointSizeAA = 1.0;
365
366 ctx->Const.MinLineWidth = 1.0;
367 ctx->Const.MinLineWidthAA = 1.0;
368 ctx->Const.MaxLineWidth = 10.0;
369 ctx->Const.MaxLineWidthAA = 10.0;
370 ctx->Const.LineWidthGranularity = 0.0625;
371
372 /* Initialize the software rasterizer and helper modules.
373 */
374 _swrast_CreateContext( ctx );
375 _ac_CreateContext( ctx );
376 _tnl_CreateContext( ctx );
377 _swsetup_CreateContext( ctx );
378 _ae_create_context( ctx );
379
380 /* Install the customized pipeline:
381 */
382 _tnl_destroy_pipeline( ctx );
383 _tnl_install_pipeline( ctx, r200_pipeline );
384 ctx->Driver.FlushVertices = r200FlushVertices;
385
386 /* Try and keep materials and vertices separate:
387 */
388 _tnl_isolate_materials( ctx, GL_TRUE );
389
390
391 /* Configure swrast to match hardware characteristics:
392 */
393 _swrast_allow_pixel_fog( ctx, GL_FALSE );
394 _swrast_allow_vertex_fog( ctx, GL_TRUE );
395
396
397 _math_matrix_ctr( &rmesa->TexGenMatrix[0] );
398 _math_matrix_ctr( &rmesa->TexGenMatrix[1] );
399 _math_matrix_ctr( &rmesa->tmpmat );
400 _math_matrix_set_identity( &rmesa->TexGenMatrix[0] );
401 _math_matrix_set_identity( &rmesa->TexGenMatrix[1] );
402 _math_matrix_set_identity( &rmesa->tmpmat );
403
404 driInitExtensions( ctx, card_extensions, GL_TRUE );
405 if (rmesa->r200Screen->drmSupportsCubeMaps)
406 _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
407
408 r200InitDriverFuncs( ctx );
409 r200InitIoctlFuncs( ctx );
410 r200InitStateFuncs( ctx );
411 r200InitSpanFuncs( ctx );
412 r200InitPixelFuncs( ctx );
413 r200InitTextureFuncs( ctx );
414 r200InitState( rmesa );
415 r200InitSwtcl( ctx );
416
417 fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
418 rmesa->iw.irq_seq = -1;
419 rmesa->irqsEmitted = 0;
420 rmesa->do_irqs = (rmesa->dri.drmMinor >= 6 &&
421 fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
422 rmesa->r200Screen->irq);
423
424 rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
425
426 if (!rmesa->do_irqs)
427 fprintf(stderr,
428 "IRQ's not enabled, falling back to %s: %d %d %d\n",
429 rmesa->do_usleeps ? "usleeps" : "busy waits",
430 rmesa->dri.drmMinor,
431 fthrottle_mode,
432 rmesa->r200Screen->irq);
433
434 rmesa->vblank_flags = (rmesa->r200Screen->irq != 0)
435 ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
436
437 rmesa->prefer_gart_client_texturing =
438 (getenv("R200_GART_CLIENT_TEXTURES") != 0);
439 #ifndef _SOLO
440 rmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" );
441 if ( rmesa->get_ust == NULL ) {
442 rmesa->get_ust = get_ust_nop;
443 }
444 #else
445 rmesa->get_ust = get_ust_nop;
446 #endif
447 (*rmesa->get_ust)( & rmesa->swap_ust );
448
449
450 #if DO_DEBUG
451 R200_DEBUG = driParseDebugString( getenv( "R200_DEBUG" ),
452 debug_control );
453 R200_DEBUG |= driParseDebugString( getenv( "RADEON_DEBUG" ),
454 debug_control );
455 #endif
456
457 tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
458 if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
459 fprintf(stderr, "disabling 3D acceleration\n");
460 FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);
461 }
462 else if (tcl_mode == DRI_CONF_TCL_SW) {
463 fprintf(stderr, "disabling TCL support\n");
464 TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
465 }
466 else {
467 if (tcl_mode >= DRI_CONF_TCL_VTXFMT) {
468 r200VtxfmtInit( ctx, tcl_mode >= DRI_CONF_TCL_CODEGEN );
469 }
470 _tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
471 }
472 return GL_TRUE;
473 }
474
475
476 /* Destroy the device specific context.
477 */
478 /* Destroy the Mesa and driver specific context data.
479 */
480 void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
481 {
482 GET_CURRENT_CONTEXT(ctx);
483 r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
484 r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL;
485
486 /* check if we're deleting the currently bound context */
487 if (rmesa == current) {
488 R200_FIREVERTICES( rmesa );
489 _mesa_make_current2(NULL, NULL, NULL);
490 }
491
492 /* Free r200 context resources */
493 assert(rmesa); /* should never be null */
494 if ( rmesa ) {
495 GLboolean release_texture_heaps;
496
497
498 release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);
499 _swsetup_DestroyContext( rmesa->glCtx );
500 _tnl_DestroyContext( rmesa->glCtx );
501 _ac_DestroyContext( rmesa->glCtx );
502 _swrast_DestroyContext( rmesa->glCtx );
503
504 r200DestroySwtcl( rmesa->glCtx );
505 r200ReleaseArrays( rmesa->glCtx, ~0 );
506
507 if (rmesa->dma.current.buf) {
508 r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
509 r200FlushCmdBuf( rmesa, __FUNCTION__ );
510 }
511
512 if (!(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)) {
513 int tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
514 if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
515 r200VtxfmtDestroy( rmesa->glCtx );
516 }
517
518 /* free the Mesa context */
519 rmesa->glCtx->DriverCtx = NULL;
520 _mesa_destroy_context( rmesa->glCtx );
521
522 if (rmesa->state.scissor.pClipRects) {
523 FREE(rmesa->state.scissor.pClipRects);
524 rmesa->state.scissor.pClipRects = 0;
525 }
526
527 if ( release_texture_heaps ) {
528 /* This share group is about to go away, free our private
529 * texture object data.
530 */
531 int i;
532
533 /* this assert is wrong. The default textures are always on swap list
534 assert( is_empty_list( & rmesa->swapped ) ); */
535
536 for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
537 driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
538 rmesa->texture_heaps[ i ] = NULL;
539 }
540 }
541
542 /* free the option cache */
543 driDestroyOptionCache (&rmesa->optionCache);
544
545 FREE( rmesa );
546 }
547 }
548
549
550
551
552 void
553 r200SwapBuffers( __DRIdrawablePrivate *dPriv )
554 {
555 if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
556 r200ContextPtr rmesa;
557 GLcontext *ctx;
558 rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
559 ctx = rmesa->glCtx;
560 if (ctx->Visual.doubleBufferMode) {
561 _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
562 if ( rmesa->doPageFlip ) {
563 r200PageFlip( dPriv );
564 }
565 else {
566 r200CopyBuffer( dPriv );
567 }
568 }
569 }
570 else {
571 /* XXX this shouldn't be an error but we can't handle it for now */
572 _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
573 }
574 }
575
576
577 /* Force the context `c' to be the current context and associate with it
578 * buffer `b'.
579 */
580 GLboolean
581 r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
582 __DRIdrawablePrivate *driDrawPriv,
583 __DRIdrawablePrivate *driReadPriv )
584 {
585 if ( driContextPriv ) {
586 r200ContextPtr newCtx =
587 (r200ContextPtr) driContextPriv->driverPrivate;
588
589 if (R200_DEBUG & DEBUG_DRI)
590 fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newCtx->glCtx);
591
592 if ( newCtx->dri.drawable != driDrawPriv ) {
593 driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
594 newCtx->dri.drawable = driDrawPriv;
595 r200UpdateWindow( newCtx->glCtx );
596 r200UpdateViewportOffset( newCtx->glCtx );
597 }
598
599 _mesa_make_current2( newCtx->glCtx,
600 (GLframebuffer *) driDrawPriv->driverPrivate,
601 (GLframebuffer *) driReadPriv->driverPrivate );
602
603 if ( !newCtx->glCtx->Viewport.Width ) {
604 _mesa_set_viewport( newCtx->glCtx, 0, 0,
605 driDrawPriv->w, driDrawPriv->h );
606 }
607
608 if (newCtx->vb.enabled)
609 r200VtxfmtMakeCurrent( newCtx->glCtx );
610
611 _mesa_update_state( newCtx->glCtx );
612 r200ValidateState( newCtx->glCtx );
613
614 } else {
615 if (R200_DEBUG & DEBUG_DRI)
616 fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
617 _mesa_make_current( 0, 0 );
618 }
619
620 if (R200_DEBUG & DEBUG_DRI)
621 fprintf(stderr, "End %s\n", __FUNCTION__);
622 return GL_TRUE;
623 }
624
625 /* Force the context `c' to be unbound from its buffer.
626 */
627 GLboolean
628 r200UnbindContext( __DRIcontextPrivate *driContextPriv )
629 {
630 r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
631
632 if (R200_DEBUG & DEBUG_DRI)
633 fprintf(stderr, "%s ctx %p\n", __FUNCTION__, rmesa->glCtx);
634
635 r200VtxfmtUnbindContext( rmesa->glCtx );
636 return GL_TRUE;
637 }