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_vertex_program
66 #define need_GL_ATI_fragment_shader
67 #define need_GL_EXT_blend_minmax
68 #define need_GL_EXT_fog_coord
69 #define need_GL_EXT_secondary_color
70 #define need_GL_EXT_blend_equation_separate
71 #define need_GL_EXT_blend_func_separate
72 #define need_GL_NV_vertex_program
73 #define need_GL_ARB_point_parameters
74 #include "extension_helper.h"
76 #define DRIVER_DATE "20060602"
80 #include "xmlpool.h" /* for symbolic values of enum-type options */
85 /* Return various strings for glGetString().
87 static const GLubyte
*r200GetString( GLcontext
*ctx
, GLenum name
)
89 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
90 static char buffer
[128];
92 GLuint agp_mode
= (rmesa
->r200Screen
->card_type
== RADEON_CARD_PCI
)? 0 :
93 rmesa
->r200Screen
->AGPMode
;
97 return (GLubyte
*)"Tungsten Graphics, Inc.";
100 offset
= driGetRendererString( buffer
, "R200", DRIVER_DATE
,
103 sprintf( & buffer
[ offset
], " %sTCL",
104 !(rmesa
->TclFallback
& R200_TCL_FALLBACK_TCL_DISABLE
)
107 return (GLubyte
*)buffer
;
115 /* Extension strings exported by the R200 driver.
117 const struct dri_extension card_extensions
[] =
119 { "GL_ARB_multitexture", NULL
},
120 { "GL_ARB_texture_border_clamp", NULL
},
121 { "GL_ARB_texture_env_add", NULL
},
122 { "GL_ARB_texture_env_combine", NULL
},
123 { "GL_ARB_texture_env_dot3", NULL
},
124 { "GL_ARB_texture_env_crossbar", NULL
},
125 { "GL_ARB_texture_mirrored_repeat", NULL
},
126 { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions
},
127 { "GL_EXT_blend_subtract", NULL
},
128 { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions
},
129 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
130 { "GL_EXT_stencil_wrap", NULL
},
131 { "GL_EXT_texture_edge_clamp", NULL
},
132 { "GL_EXT_texture_env_combine", NULL
},
133 { "GL_EXT_texture_env_dot3", NULL
},
134 { "GL_EXT_texture_filter_anisotropic", NULL
},
135 { "GL_EXT_texture_lod_bias", NULL
},
136 { "GL_EXT_texture_mirror_clamp", NULL
},
137 { "GL_EXT_texture_rectangle", NULL
},
138 { "GL_ATI_texture_env_combine3", NULL
},
139 { "GL_ATI_texture_mirror_once", NULL
},
140 { "GL_MESA_pack_invert", NULL
},
141 { "GL_NV_blend_square", NULL
},
142 { "GL_SGIS_generate_mipmap", NULL
},
146 const struct dri_extension blend_extensions
[] = {
147 { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions
},
148 { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions
},
152 const struct dri_extension ARB_vp_extension
[] = {
153 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions
}
156 const struct dri_extension NV_vp_extension
[] = {
157 { "GL_NV_vertex_program", GL_NV_vertex_program_functions
}
160 const struct dri_extension ATI_fs_extension
[] = {
161 { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions
}
164 const struct dri_extension point_extensions
[] = {
165 { "GL_ARB_point_sprite", NULL
},
166 { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions
},
170 extern const struct tnl_pipeline_stage _r200_render_stage
;
171 extern const struct tnl_pipeline_stage _r200_tcl_stage
;
173 static const struct tnl_pipeline_stage
*r200_pipeline
[] = {
175 /* Try and go straight to t&l
179 /* Catch any t&l fallbacks
181 &_tnl_vertex_transform_stage
,
182 &_tnl_normal_transform_stage
,
183 &_tnl_lighting_stage
,
184 &_tnl_fog_coordinate_stage
,
186 &_tnl_texture_transform_stage
,
187 &_tnl_point_attenuation_stage
,
188 &_tnl_vertex_program_stage
,
189 /* Try again to go to tcl?
190 * - no good for asymmetric-twoside (do with multipass)
191 * - no good for asymmetric-unfilled (do with multipass)
192 * - good for material
194 * - need to manipulate a bit of state
196 * - worth it/not worth it?
199 /* Else do them here.
201 /* &_r200_render_stage, */ /* FIXME: bugs with ut2003 */
202 &_tnl_render_stage
, /* FALLBACK: */
208 /* Initialize the driver's misc functions.
210 static void r200InitDriverFuncs( struct dd_function_table
*functions
)
212 functions
->GetBufferSize
= NULL
; /* OBSOLETE */
213 functions
->GetString
= r200GetString
;
216 static const struct dri_debug_control debug_control
[] =
218 { "fall", DEBUG_FALLBACKS
},
219 { "tex", DEBUG_TEXTURE
},
220 { "ioctl", DEBUG_IOCTL
},
221 { "prim", DEBUG_PRIMS
},
222 { "vert", DEBUG_VERTS
},
223 { "state", DEBUG_STATE
},
224 { "code", DEBUG_CODEGEN
},
225 { "vfmt", DEBUG_VFMT
},
226 { "vtxf", DEBUG_VFMT
},
227 { "verb", DEBUG_VERBOSE
},
228 { "dri", DEBUG_DRI
},
229 { "dma", DEBUG_DMA
},
230 { "san", DEBUG_SANITY
},
231 { "sync", DEBUG_SYNC
},
232 { "pix", DEBUG_PIXEL
},
233 { "mem", DEBUG_MEMORY
},
238 /* Create the device specific rendering context.
240 GLboolean
r200CreateContext( const __GLcontextModes
*glVisual
,
241 __DRIcontextPrivate
*driContextPriv
,
242 void *sharedContextPrivate
)
244 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
245 radeonScreenPtr screen
= (radeonScreenPtr
)(sPriv
->private);
246 struct dd_function_table functions
;
247 r200ContextPtr rmesa
;
248 GLcontext
*ctx
, *shareCtx
;
250 int tcl_mode
, fthrottle_mode
;
253 assert(driContextPriv
);
256 /* Allocate the R200 context */
257 rmesa
= (r200ContextPtr
) CALLOC( sizeof(*rmesa
) );
261 /* init exp fog table data */
262 r200InitStaticFogData();
264 /* Parse configuration files.
265 * Do this here so that initialMaxAnisotropy is set before we create
266 * the default textures.
268 driParseConfigFiles (&rmesa
->optionCache
, &screen
->optionCache
,
269 screen
->driScreen
->myNum
, "r200");
270 rmesa
->initialMaxAnisotropy
= driQueryOptionf(&rmesa
->optionCache
,
271 "def_max_anisotropy");
273 if ( driQueryOptionb( &rmesa
->optionCache
, "hyperz" ) ) {
274 if ( sPriv
->drm_version
.minor
< 13 )
275 fprintf( stderr
, "DRM version 1.%d too old to support HyperZ, "
276 "disabling.\n", sPriv
->drm_version
.minor
);
278 rmesa
->using_hyperz
= GL_TRUE
;
281 if ( sPriv
->drm_version
.minor
>= 15 )
282 rmesa
->texmicrotile
= GL_TRUE
;
284 /* Init default driver functions then plug in our R200-specific functions
285 * (the texture functions are especially important)
287 _mesa_init_driver_functions(&functions
);
288 r200InitDriverFuncs(&functions
);
289 r200InitIoctlFuncs(&functions
);
290 r200InitStateFuncs(&functions
);
291 r200InitTextureFuncs(&functions
);
292 r200InitShaderFuncs(&functions
);
294 /* Allocate and initialize the Mesa context */
295 if (sharedContextPrivate
)
296 shareCtx
= ((r200ContextPtr
) sharedContextPrivate
)->glCtx
;
299 rmesa
->glCtx
= _mesa_create_context(glVisual
, shareCtx
,
300 &functions
, (void *) rmesa
);
305 driContextPriv
->driverPrivate
= rmesa
;
307 /* Init r200 context data */
308 rmesa
->dri
.context
= driContextPriv
;
309 rmesa
->dri
.screen
= sPriv
;
310 rmesa
->dri
.drawable
= NULL
; /* Set by XMesaMakeCurrent */
311 rmesa
->dri
.hwContext
= driContextPriv
->hHWContext
;
312 rmesa
->dri
.hwLock
= &sPriv
->pSAREA
->lock
;
313 rmesa
->dri
.fd
= sPriv
->fd
;
314 rmesa
->dri
.drmMinor
= sPriv
->drm_version
.minor
;
316 rmesa
->r200Screen
= screen
;
317 rmesa
->sarea
= (drm_radeon_sarea_t
*)((GLubyte
*)sPriv
->pSAREA
+
318 screen
->sarea_priv_offset
);
321 rmesa
->dma
.buf0_address
= rmesa
->r200Screen
->buffers
->list
[0].address
;
323 (void) memset( rmesa
->texture_heaps
, 0, sizeof( rmesa
->texture_heaps
) );
324 make_empty_list( & rmesa
->swapped
);
326 rmesa
->nr_heaps
= 1 /* screen->numTexHeaps */ ;
327 assert(rmesa
->nr_heaps
< RADEON_NR_TEX_HEAPS
);
328 for ( i
= 0 ; i
< rmesa
->nr_heaps
; i
++ ) {
329 rmesa
->texture_heaps
[i
] = driCreateTextureHeap( i
, rmesa
,
332 RADEON_NR_TEX_REGIONS
,
333 (drmTextureRegionPtr
)rmesa
->sarea
->tex_list
[i
],
334 & rmesa
->sarea
->tex_age
[i
],
336 sizeof( r200TexObj
),
337 (destroy_texture_object_t
*) r200DestroyTexObj
);
339 rmesa
->texture_depth
= driQueryOptioni (&rmesa
->optionCache
,
341 if (rmesa
->texture_depth
== DRI_CONF_TEXTURE_DEPTH_FB
)
342 rmesa
->texture_depth
= ( screen
->cpp
== 4 ) ?
343 DRI_CONF_TEXTURE_DEPTH_32
: DRI_CONF_TEXTURE_DEPTH_16
;
345 rmesa
->swtcl
.RenderIndex
= ~0;
346 rmesa
->hw
.all_dirty
= 1;
348 /* Set the maximum texture size small enough that we can guarentee that
349 * all texture units can bind a maximal texture and have all of them in
350 * texturable memory at once. Depending on the allow_large_textures driconf
351 * setting allow larger textures.
355 ctx
->Const
.MaxTextureUnits
= driQueryOptioni (&rmesa
->optionCache
,
357 ctx
->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureUnits
;
358 ctx
->Const
.MaxTextureCoordUnits
= ctx
->Const
.MaxTextureUnits
;
360 i
= driQueryOptioni( &rmesa
->optionCache
, "allow_large_textures");
362 driCalculateMaxTextureLevels( rmesa
->texture_heaps
,
366 11, /* max 2D texture size is 2048x2048 */
367 #if ENABLE_HW_3D_TEXTURE
368 8, /* max 3D texture size is 256^3 */
370 0, /* 3D textures unsupported */
372 11, /* max cube texture size is 2048x2048 */
373 11, /* max texture rectangle size is 2048x2048 */
378 ctx
->Const
.MaxTextureMaxAnisotropy
= 16.0;
380 /* No wide AA points.
382 ctx
->Const
.MinPointSize
= 1.0;
383 ctx
->Const
.MinPointSizeAA
= 1.0;
384 ctx
->Const
.MaxPointSizeAA
= 1.0;
385 ctx
->Const
.PointSizeGranularity
= 0.0625;
386 if (rmesa
->r200Screen
->drmSupportsPointSprites
)
387 ctx
->Const
.MaxPointSize
= 2047.0;
389 ctx
->Const
.MaxPointSize
= 1.0;
391 /* mesa initialization problem - _mesa_init_point was already called */
392 ctx
->Point
.MaxSize
= ctx
->Const
.MaxPointSize
;
394 ctx
->Const
.MinLineWidth
= 1.0;
395 ctx
->Const
.MinLineWidthAA
= 1.0;
396 ctx
->Const
.MaxLineWidth
= 10.0;
397 ctx
->Const
.MaxLineWidthAA
= 10.0;
398 ctx
->Const
.LineWidthGranularity
= 0.0625;
400 ctx
->Const
.VertexProgram
.MaxNativeInstructions
= R200_VSF_MAX_INST
;
401 ctx
->Const
.VertexProgram
.MaxNativeAttribs
= 12;
402 ctx
->Const
.VertexProgram
.MaxNativeTemps
= R200_VSF_MAX_TEMPS
;
403 ctx
->Const
.VertexProgram
.MaxNativeParameters
= R200_VSF_MAX_PARAM
;
404 ctx
->Const
.VertexProgram
.MaxNativeAddressRegs
= 1;
406 /* Initialize the software rasterizer and helper modules.
408 _swrast_CreateContext( ctx
);
409 _vbo_CreateContext( ctx
);
410 _tnl_CreateContext( ctx
);
411 _swsetup_CreateContext( ctx
);
412 _ae_create_context( ctx
);
414 /* Install the customized pipeline:
416 _tnl_destroy_pipeline( ctx
);
417 _tnl_install_pipeline( ctx
, r200_pipeline
);
419 /* Try and keep materials and vertices separate:
421 /* _tnl_isolate_materials( ctx, GL_TRUE ); */
424 /* Configure swrast and TNL to match hardware characteristics:
426 _swrast_allow_pixel_fog( ctx
, GL_FALSE
);
427 _swrast_allow_vertex_fog( ctx
, GL_TRUE
);
428 _tnl_allow_pixel_fog( ctx
, GL_FALSE
);
429 _tnl_allow_vertex_fog( ctx
, GL_TRUE
);
432 for ( i
= 0 ; i
< R200_MAX_TEXTURE_UNITS
; i
++ ) {
433 _math_matrix_ctr( &rmesa
->TexGenMatrix
[i
] );
434 _math_matrix_set_identity( &rmesa
->TexGenMatrix
[i
] );
436 _math_matrix_ctr( &rmesa
->tmpmat
);
437 _math_matrix_set_identity( &rmesa
->tmpmat
);
439 driInitExtensions( ctx
, card_extensions
, GL_TRUE
);
440 if (!(rmesa
->r200Screen
->chip_flags
& R200_CHIPSET_YCBCR_BROKEN
)) {
441 /* yuv textures don't work with some chips - R200 / rv280 okay so far
442 others get the bit ordering right but don't actually do YUV-RGB conversion */
443 _mesa_enable_extension( ctx
, "GL_MESA_ycbcr_texture" );
445 if (rmesa
->glCtx
->Mesa_DXTn
) {
446 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
447 _mesa_enable_extension( ctx
, "GL_S3_s3tc" );
449 else if (driQueryOptionb (&rmesa
->optionCache
, "force_s3tc_enable")) {
450 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
453 if (rmesa
->r200Screen
->drmSupportsCubeMapsR200
)
454 _mesa_enable_extension( ctx
, "GL_ARB_texture_cube_map" );
455 if (rmesa
->r200Screen
->drmSupportsBlendColor
) {
456 driInitExtensions( ctx
, blend_extensions
, GL_FALSE
);
458 if(rmesa
->r200Screen
->drmSupportsVertexProgram
)
459 driInitSingleExtension( ctx
, ARB_vp_extension
);
460 if(driQueryOptionb(&rmesa
->optionCache
, "nv_vertex_program"))
461 driInitSingleExtension( ctx
, NV_vp_extension
);
463 if ((ctx
->Const
.MaxTextureUnits
== 6) && rmesa
->r200Screen
->drmSupportsFragShader
)
464 driInitSingleExtension( ctx
, ATI_fs_extension
);
465 if (rmesa
->r200Screen
->drmSupportsPointSprites
)
466 driInitExtensions( ctx
, point_extensions
, GL_FALSE
);
468 r200InitDriverFuncs( ctx
);
469 r200InitIoctlFuncs( ctx
);
470 r200InitStateFuncs( ctx
);
471 r200InitTextureFuncs( ctx
);
473 /* plug in a few more device driver functions */
474 /* XXX these should really go right after _mesa_init_driver_functions() */
475 r200InitPixelFuncs( ctx
);
476 r200InitSpanFuncs( ctx
);
477 r200InitTnlFuncs( ctx
);
478 r200InitState( rmesa
);
479 r200InitSwtcl( ctx
);
481 fthrottle_mode
= driQueryOptioni(&rmesa
->optionCache
, "fthrottle_mode");
482 rmesa
->iw
.irq_seq
= -1;
483 rmesa
->irqsEmitted
= 0;
484 rmesa
->do_irqs
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_IRQS
&&
485 rmesa
->r200Screen
->irq
);
487 rmesa
->do_usleeps
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_USLEEPS
);
491 "IRQ's not enabled, falling back to %s: %d %d\n",
492 rmesa
->do_usleeps
? "usleeps" : "busy waits",
494 rmesa
->r200Screen
->irq
);
496 rmesa
->prefer_gart_client_texturing
=
497 (getenv("R200_GART_CLIENT_TEXTURES") != 0);
499 (*sPriv
->systemTime
->getUST
)( & rmesa
->swap_ust
);
503 R200_DEBUG
= driParseDebugString( getenv( "R200_DEBUG" ),
505 R200_DEBUG
|= driParseDebugString( getenv( "RADEON_DEBUG" ),
509 tcl_mode
= driQueryOptioni(&rmesa
->optionCache
, "tcl_mode");
510 if (driQueryOptionb(&rmesa
->optionCache
, "no_rast")) {
511 fprintf(stderr
, "disabling 3D acceleration\n");
512 FALLBACK(rmesa
, R200_FALLBACK_DISABLE
, 1);
514 else if (tcl_mode
== DRI_CONF_TCL_SW
|| getenv("R200_NO_TCL") ||
515 !(rmesa
->r200Screen
->chip_flags
& RADEON_CHIPSET_TCL
)) {
516 if (rmesa
->r200Screen
->chip_flags
& RADEON_CHIPSET_TCL
) {
517 rmesa
->r200Screen
->chip_flags
&= ~RADEON_CHIPSET_TCL
;
518 fprintf(stderr
, "Disabling HW TCL support\n");
520 TCL_FALLBACK(rmesa
->glCtx
, R200_TCL_FALLBACK_TCL_DISABLE
, 1);
527 /* Destroy the device specific context.
529 /* Destroy the Mesa and driver specific context data.
531 void r200DestroyContext( __DRIcontextPrivate
*driContextPriv
)
533 GET_CURRENT_CONTEXT(ctx
);
534 r200ContextPtr rmesa
= (r200ContextPtr
) driContextPriv
->driverPrivate
;
535 r200ContextPtr current
= ctx
? R200_CONTEXT(ctx
) : NULL
;
537 /* check if we're deleting the currently bound context */
538 if (rmesa
== current
) {
539 R200_FIREVERTICES( rmesa
);
540 _mesa_make_current(NULL
, NULL
, NULL
);
543 /* Free r200 context resources */
544 assert(rmesa
); /* should never be null */
546 GLboolean release_texture_heaps
;
549 release_texture_heaps
= (rmesa
->glCtx
->Shared
->RefCount
== 1);
550 _swsetup_DestroyContext( rmesa
->glCtx
);
551 _tnl_DestroyContext( rmesa
->glCtx
);
552 _vbo_DestroyContext( rmesa
->glCtx
);
553 _swrast_DestroyContext( rmesa
->glCtx
);
555 r200DestroySwtcl( rmesa
->glCtx
);
556 r200ReleaseArrays( rmesa
->glCtx
, ~0 );
558 if (rmesa
->dma
.current
.buf
) {
559 r200ReleaseDmaRegion( rmesa
, &rmesa
->dma
.current
, __FUNCTION__
);
560 r200FlushCmdBuf( rmesa
, __FUNCTION__
);
563 if (rmesa
->state
.scissor
.pClipRects
) {
564 FREE(rmesa
->state
.scissor
.pClipRects
);
565 rmesa
->state
.scissor
.pClipRects
= NULL
;
568 if ( release_texture_heaps
) {
569 /* This share group is about to go away, free our private
570 * texture object data.
574 for ( i
= 0 ; i
< rmesa
->nr_heaps
; i
++ ) {
575 driDestroyTextureHeap( rmesa
->texture_heaps
[ i
] );
576 rmesa
->texture_heaps
[ i
] = NULL
;
579 assert( is_empty_list( & rmesa
->swapped
) );
582 /* free the Mesa context */
583 rmesa
->glCtx
->DriverCtx
= NULL
;
584 _mesa_destroy_context( rmesa
->glCtx
);
586 /* free the option cache */
587 driDestroyOptionCache (&rmesa
->optionCache
);
597 r200SwapBuffers( __DRIdrawablePrivate
*dPriv
)
599 if (dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
600 r200ContextPtr rmesa
;
602 rmesa
= (r200ContextPtr
) dPriv
->driContextPriv
->driverPrivate
;
604 if (ctx
->Visual
.doubleBufferMode
) {
605 _mesa_notifySwapBuffers( ctx
); /* flush pending rendering comands */
606 if ( rmesa
->doPageFlip
) {
607 r200PageFlip( dPriv
);
610 r200CopyBuffer( dPriv
, NULL
);
615 /* XXX this shouldn't be an error but we can't handle it for now */
616 _mesa_problem(NULL
, "%s: drawable has no context!", __FUNCTION__
);
621 r200CopySubBuffer( __DRIdrawablePrivate
*dPriv
,
622 int x
, int y
, int w
, int h
)
624 if (dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
625 r200ContextPtr rmesa
;
627 rmesa
= (r200ContextPtr
) dPriv
->driContextPriv
->driverPrivate
;
629 if (ctx
->Visual
.doubleBufferMode
) {
630 drm_clip_rect_t rect
;
631 rect
.x1
= x
+ dPriv
->x
;
632 rect
.y1
= (dPriv
->h
- y
- h
) + dPriv
->y
;
633 rect
.x2
= rect
.x1
+ w
;
634 rect
.y2
= rect
.y1
+ h
;
635 _mesa_notifySwapBuffers( ctx
); /* flush pending rendering comands */
636 r200CopyBuffer( dPriv
, &rect
);
640 /* XXX this shouldn't be an error but we can't handle it for now */
641 _mesa_problem(NULL
, "%s: drawable has no context!", __FUNCTION__
);
645 /* Force the context `c' to be the current context and associate with it
649 r200MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
650 __DRIdrawablePrivate
*driDrawPriv
,
651 __DRIdrawablePrivate
*driReadPriv
)
653 if ( driContextPriv
) {
654 r200ContextPtr newCtx
=
655 (r200ContextPtr
) driContextPriv
->driverPrivate
;
657 if (R200_DEBUG
& DEBUG_DRI
)
658 fprintf(stderr
, "%s ctx %p\n", __FUNCTION__
, (void *)newCtx
->glCtx
);
660 newCtx
->dri
.readable
= driReadPriv
;
662 if ( newCtx
->dri
.drawable
!= driDrawPriv
||
663 newCtx
->lastStamp
!= driDrawPriv
->lastStamp
) {
664 if (driDrawPriv
->swap_interval
== (unsigned)-1) {
665 driDrawPriv
->vblFlags
= (newCtx
->r200Screen
->irq
!= 0)
666 ? driGetDefaultVBlankFlags(&newCtx
->optionCache
)
667 : VBLANK_FLAG_NO_IRQ
;
669 driDrawableInitVBlank( driDrawPriv
);
672 newCtx
->dri
.drawable
= driDrawPriv
;
674 r200SetCliprects(newCtx
);
675 r200UpdateViewportOffset( newCtx
->glCtx
);
678 _mesa_make_current( newCtx
->glCtx
,
679 (GLframebuffer
*) driDrawPriv
->driverPrivate
,
680 (GLframebuffer
*) driReadPriv
->driverPrivate
);
682 _mesa_update_state( newCtx
->glCtx
);
683 r200ValidateState( newCtx
->glCtx
);
686 if (R200_DEBUG
& DEBUG_DRI
)
687 fprintf(stderr
, "%s ctx is null\n", __FUNCTION__
);
688 _mesa_make_current( NULL
, NULL
, NULL
);
691 if (R200_DEBUG
& DEBUG_DRI
)
692 fprintf(stderr
, "End %s\n", __FUNCTION__
);
696 /* Force the context `c' to be unbound from its buffer.
699 r200UnbindContext( __DRIcontextPrivate
*driContextPriv
)
701 r200ContextPtr rmesa
= (r200ContextPtr
) driContextPriv
->driverPrivate
;
703 if (R200_DEBUG
& DEBUG_DRI
)
704 fprintf(stderr
, "%s ctx %p\n", __FUNCTION__
, (void *)rmesa
->glCtx
);