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_multi_draw_arrays
70 #define need_GL_EXT_secondary_color
71 #define need_GL_EXT_blend_equation_separate
72 #define need_GL_EXT_blend_func_separate
73 #define need_GL_NV_vertex_program
74 #define need_GL_ARB_point_parameters
75 #include "extension_helper.h"
77 #define DRIVER_DATE "20060602"
81 #include "xmlpool.h" /* for symbolic values of enum-type options */
86 /* Return various strings for glGetString().
88 static const GLubyte
*r200GetString( GLcontext
*ctx
, GLenum name
)
90 r200ContextPtr rmesa
= R200_CONTEXT(ctx
);
91 static char buffer
[128];
93 GLuint agp_mode
= (rmesa
->r200Screen
->card_type
== RADEON_CARD_PCI
)? 0 :
94 rmesa
->r200Screen
->AGPMode
;
98 return (GLubyte
*)"Tungsten Graphics, Inc.";
101 offset
= driGetRendererString( buffer
, "R200", DRIVER_DATE
,
104 sprintf( & buffer
[ offset
], " %sTCL",
105 !(rmesa
->TclFallback
& R200_TCL_FALLBACK_TCL_DISABLE
)
108 return (GLubyte
*)buffer
;
116 /* Extension strings exported by the R200 driver.
118 const struct dri_extension card_extensions
[] =
120 { "GL_ARB_multitexture", NULL
},
121 { "GL_ARB_texture_border_clamp", NULL
},
122 { "GL_ARB_texture_env_add", NULL
},
123 { "GL_ARB_texture_env_combine", NULL
},
124 { "GL_ARB_texture_env_dot3", NULL
},
125 { "GL_ARB_texture_env_crossbar", NULL
},
126 { "GL_ARB_texture_mirrored_repeat", NULL
},
127 { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions
},
128 { "GL_EXT_blend_subtract", NULL
},
129 { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions
},
130 { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions
},
131 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions
},
132 { "GL_EXT_stencil_wrap", NULL
},
133 { "GL_EXT_texture_edge_clamp", NULL
},
134 { "GL_EXT_texture_env_combine", NULL
},
135 { "GL_EXT_texture_env_dot3", NULL
},
136 { "GL_EXT_texture_filter_anisotropic", NULL
},
137 { "GL_EXT_texture_lod_bias", NULL
},
138 { "GL_EXT_texture_mirror_clamp", NULL
},
139 { "GL_EXT_texture_rectangle", NULL
},
140 { "GL_ATI_texture_env_combine3", NULL
},
141 { "GL_ATI_texture_mirror_once", NULL
},
142 { "GL_MESA_pack_invert", NULL
},
143 { "GL_NV_blend_square", NULL
},
144 { "GL_SGIS_generate_mipmap", NULL
},
148 const struct dri_extension blend_extensions
[] = {
149 { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions
},
150 { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions
},
154 const struct dri_extension ARB_vp_extension
[] = {
155 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions
}
158 const struct dri_extension NV_vp_extension
[] = {
159 { "GL_NV_vertex_program", GL_NV_vertex_program_functions
}
162 const struct dri_extension ATI_fs_extension
[] = {
163 { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions
}
166 const struct dri_extension point_extensions
[] = {
167 { "GL_ARB_point_sprite", NULL
},
168 { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions
},
172 extern const struct tnl_pipeline_stage _r200_render_stage
;
173 extern const struct tnl_pipeline_stage _r200_tcl_stage
;
175 static const struct tnl_pipeline_stage
*r200_pipeline
[] = {
177 /* Try and go straight to t&l
181 /* Catch any t&l fallbacks
183 &_tnl_vertex_transform_stage
,
184 &_tnl_normal_transform_stage
,
185 &_tnl_lighting_stage
,
186 &_tnl_fog_coordinate_stage
,
188 &_tnl_texture_transform_stage
,
189 &_tnl_point_attenuation_stage
,
190 &_tnl_vertex_program_stage
,
191 /* Try again to go to tcl?
192 * - no good for asymmetric-twoside (do with multipass)
193 * - no good for asymmetric-unfilled (do with multipass)
194 * - good for material
196 * - need to manipulate a bit of state
198 * - worth it/not worth it?
201 /* Else do them here.
203 /* &_r200_render_stage, */ /* FIXME: bugs with ut2003 */
204 &_tnl_render_stage
, /* FALLBACK: */
210 /* Initialize the driver's misc functions.
212 static void r200InitDriverFuncs( struct dd_function_table
*functions
)
214 functions
->GetBufferSize
= NULL
; /* OBSOLETE */
215 functions
->GetString
= r200GetString
;
218 static const struct dri_debug_control debug_control
[] =
220 { "fall", DEBUG_FALLBACKS
},
221 { "tex", DEBUG_TEXTURE
},
222 { "ioctl", DEBUG_IOCTL
},
223 { "prim", DEBUG_PRIMS
},
224 { "vert", DEBUG_VERTS
},
225 { "state", DEBUG_STATE
},
226 { "code", DEBUG_CODEGEN
},
227 { "vfmt", DEBUG_VFMT
},
228 { "vtxf", DEBUG_VFMT
},
229 { "verb", DEBUG_VERBOSE
},
230 { "dri", DEBUG_DRI
},
231 { "dma", DEBUG_DMA
},
232 { "san", DEBUG_SANITY
},
233 { "sync", DEBUG_SYNC
},
234 { "pix", DEBUG_PIXEL
},
235 { "mem", DEBUG_MEMORY
},
240 /* Create the device specific rendering context.
242 GLboolean
r200CreateContext( const __GLcontextModes
*glVisual
,
243 __DRIcontextPrivate
*driContextPriv
,
244 void *sharedContextPrivate
)
246 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
247 radeonScreenPtr screen
= (radeonScreenPtr
)(sPriv
->private);
248 struct dd_function_table functions
;
249 r200ContextPtr rmesa
;
250 GLcontext
*ctx
, *shareCtx
;
252 int tcl_mode
, fthrottle_mode
;
255 assert(driContextPriv
);
258 /* Allocate the R200 context */
259 rmesa
= (r200ContextPtr
) CALLOC( sizeof(*rmesa
) );
263 /* init exp fog table data */
264 r200InitStaticFogData();
266 /* Parse configuration files.
267 * Do this here so that initialMaxAnisotropy is set before we create
268 * the default textures.
270 driParseConfigFiles (&rmesa
->optionCache
, &screen
->optionCache
,
271 screen
->driScreen
->myNum
, "r200");
272 rmesa
->initialMaxAnisotropy
= driQueryOptionf(&rmesa
->optionCache
,
273 "def_max_anisotropy");
275 if ( driQueryOptionb( &rmesa
->optionCache
, "hyperz" ) ) {
276 if ( sPriv
->drm_version
.minor
< 13 )
277 fprintf( stderr
, "DRM version 1.%d too old to support HyperZ, "
278 "disabling.\n", sPriv
->drm_version
.minor
);
280 rmesa
->using_hyperz
= GL_TRUE
;
283 if ( sPriv
->drm_version
.minor
>= 15 )
284 rmesa
->texmicrotile
= GL_TRUE
;
286 /* Init default driver functions then plug in our R200-specific functions
287 * (the texture functions are especially important)
289 _mesa_init_driver_functions(&functions
);
290 r200InitDriverFuncs(&functions
);
291 r200InitIoctlFuncs(&functions
);
292 r200InitStateFuncs(&functions
);
293 r200InitTextureFuncs(&functions
);
294 r200InitShaderFuncs(&functions
);
296 /* Allocate and initialize the Mesa context */
297 if (sharedContextPrivate
)
298 shareCtx
= ((r200ContextPtr
) sharedContextPrivate
)->glCtx
;
301 rmesa
->glCtx
= _mesa_create_context(glVisual
, shareCtx
,
302 &functions
, (void *) rmesa
);
307 driContextPriv
->driverPrivate
= rmesa
;
309 /* Init r200 context data */
310 rmesa
->dri
.context
= driContextPriv
;
311 rmesa
->dri
.screen
= sPriv
;
312 rmesa
->dri
.drawable
= NULL
; /* Set by XMesaMakeCurrent */
313 rmesa
->dri
.hwContext
= driContextPriv
->hHWContext
;
314 rmesa
->dri
.hwLock
= &sPriv
->pSAREA
->lock
;
315 rmesa
->dri
.fd
= sPriv
->fd
;
316 rmesa
->dri
.drmMinor
= sPriv
->drm_version
.minor
;
318 rmesa
->r200Screen
= screen
;
319 rmesa
->sarea
= (drm_radeon_sarea_t
*)((GLubyte
*)sPriv
->pSAREA
+
320 screen
->sarea_priv_offset
);
323 rmesa
->dma
.buf0_address
= rmesa
->r200Screen
->buffers
->list
[0].address
;
325 (void) memset( rmesa
->texture_heaps
, 0, sizeof( rmesa
->texture_heaps
) );
326 make_empty_list( & rmesa
->swapped
);
328 rmesa
->nr_heaps
= 1 /* screen->numTexHeaps */ ;
329 assert(rmesa
->nr_heaps
< RADEON_NR_TEX_HEAPS
);
330 for ( i
= 0 ; i
< rmesa
->nr_heaps
; i
++ ) {
331 rmesa
->texture_heaps
[i
] = driCreateTextureHeap( i
, rmesa
,
334 RADEON_NR_TEX_REGIONS
,
335 (drmTextureRegionPtr
)rmesa
->sarea
->tex_list
[i
],
336 & rmesa
->sarea
->tex_age
[i
],
338 sizeof( r200TexObj
),
339 (destroy_texture_object_t
*) r200DestroyTexObj
);
341 rmesa
->texture_depth
= driQueryOptioni (&rmesa
->optionCache
,
343 if (rmesa
->texture_depth
== DRI_CONF_TEXTURE_DEPTH_FB
)
344 rmesa
->texture_depth
= ( screen
->cpp
== 4 ) ?
345 DRI_CONF_TEXTURE_DEPTH_32
: DRI_CONF_TEXTURE_DEPTH_16
;
347 rmesa
->swtcl
.RenderIndex
= ~0;
348 rmesa
->hw
.all_dirty
= 1;
350 /* Set the maximum texture size small enough that we can guarentee that
351 * all texture units can bind a maximal texture and have all of them in
352 * texturable memory at once. Depending on the allow_large_textures driconf
353 * setting allow larger textures.
357 ctx
->Const
.MaxTextureUnits
= driQueryOptioni (&rmesa
->optionCache
,
359 ctx
->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureUnits
;
360 ctx
->Const
.MaxTextureCoordUnits
= ctx
->Const
.MaxTextureUnits
;
362 i
= driQueryOptioni( &rmesa
->optionCache
, "allow_large_textures");
364 driCalculateMaxTextureLevels( rmesa
->texture_heaps
,
368 11, /* max 2D texture size is 2048x2048 */
369 #if ENABLE_HW_3D_TEXTURE
370 8, /* max 3D texture size is 256^3 */
372 0, /* 3D textures unsupported */
374 11, /* max cube texture size is 2048x2048 */
375 11, /* max texture rectangle size is 2048x2048 */
380 ctx
->Const
.MaxTextureMaxAnisotropy
= 16.0;
382 /* No wide AA points.
384 ctx
->Const
.MinPointSize
= 1.0;
385 ctx
->Const
.MinPointSizeAA
= 1.0;
386 ctx
->Const
.MaxPointSizeAA
= 1.0;
387 ctx
->Const
.PointSizeGranularity
= 0.0625;
388 if (rmesa
->r200Screen
->drmSupportsPointSprites
)
389 ctx
->Const
.MaxPointSize
= 2047.0;
391 ctx
->Const
.MaxPointSize
= 1.0;
393 /* mesa initialization problem - _mesa_init_point was already called */
394 ctx
->Point
.MaxSize
= ctx
->Const
.MaxPointSize
;
396 ctx
->Const
.MinLineWidth
= 1.0;
397 ctx
->Const
.MinLineWidthAA
= 1.0;
398 ctx
->Const
.MaxLineWidth
= 10.0;
399 ctx
->Const
.MaxLineWidthAA
= 10.0;
400 ctx
->Const
.LineWidthGranularity
= 0.0625;
402 ctx
->Const
.VertexProgram
.MaxNativeInstructions
= R200_VSF_MAX_INST
;
403 ctx
->Const
.VertexProgram
.MaxNativeAttribs
= 12;
404 ctx
->Const
.VertexProgram
.MaxNativeTemps
= R200_VSF_MAX_TEMPS
;
405 ctx
->Const
.VertexProgram
.MaxNativeParameters
= R200_VSF_MAX_PARAM
;
406 ctx
->Const
.VertexProgram
.MaxNativeAddressRegs
= 1;
408 /* Initialize the software rasterizer and helper modules.
410 _swrast_CreateContext( ctx
);
411 _vbo_CreateContext( ctx
);
412 _tnl_CreateContext( ctx
);
413 _swsetup_CreateContext( ctx
);
414 _ae_create_context( ctx
);
416 /* Install the customized pipeline:
418 _tnl_destroy_pipeline( ctx
);
419 _tnl_install_pipeline( ctx
, r200_pipeline
);
421 /* Try and keep materials and vertices separate:
423 /* _tnl_isolate_materials( ctx, GL_TRUE ); */
426 /* Configure swrast and TNL to match hardware characteristics:
428 _swrast_allow_pixel_fog( ctx
, GL_FALSE
);
429 _swrast_allow_vertex_fog( ctx
, GL_TRUE
);
430 _tnl_allow_pixel_fog( ctx
, GL_FALSE
);
431 _tnl_allow_vertex_fog( ctx
, GL_TRUE
);
434 for ( i
= 0 ; i
< R200_MAX_TEXTURE_UNITS
; i
++ ) {
435 _math_matrix_ctr( &rmesa
->TexGenMatrix
[i
] );
436 _math_matrix_set_identity( &rmesa
->TexGenMatrix
[i
] );
438 _math_matrix_ctr( &rmesa
->tmpmat
);
439 _math_matrix_set_identity( &rmesa
->tmpmat
);
441 driInitExtensions( ctx
, card_extensions
, GL_TRUE
);
442 if (!(rmesa
->r200Screen
->chip_flags
& R200_CHIPSET_YCBCR_BROKEN
)) {
443 /* yuv textures don't work with some chips - R200 / rv280 okay so far
444 others get the bit ordering right but don't actually do YUV-RGB conversion */
445 _mesa_enable_extension( ctx
, "GL_MESA_ycbcr_texture" );
447 if (rmesa
->glCtx
->Mesa_DXTn
) {
448 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
449 _mesa_enable_extension( ctx
, "GL_S3_s3tc" );
451 else if (driQueryOptionb (&rmesa
->optionCache
, "force_s3tc_enable")) {
452 _mesa_enable_extension( ctx
, "GL_EXT_texture_compression_s3tc" );
455 if (rmesa
->r200Screen
->drmSupportsCubeMapsR200
)
456 _mesa_enable_extension( ctx
, "GL_ARB_texture_cube_map" );
457 if (rmesa
->r200Screen
->drmSupportsBlendColor
) {
458 driInitExtensions( ctx
, blend_extensions
, GL_FALSE
);
460 if(rmesa
->r200Screen
->drmSupportsVertexProgram
)
461 driInitSingleExtension( ctx
, ARB_vp_extension
);
462 if(driQueryOptionb(&rmesa
->optionCache
, "nv_vertex_program"))
463 driInitSingleExtension( ctx
, NV_vp_extension
);
465 if ((ctx
->Const
.MaxTextureUnits
== 6) && rmesa
->r200Screen
->drmSupportsFragShader
)
466 driInitSingleExtension( ctx
, ATI_fs_extension
);
467 if (rmesa
->r200Screen
->drmSupportsPointSprites
)
468 driInitExtensions( ctx
, point_extensions
, GL_FALSE
);
470 r200InitDriverFuncs( ctx
);
471 r200InitIoctlFuncs( ctx
);
472 r200InitStateFuncs( ctx
);
473 r200InitTextureFuncs( ctx
);
475 /* plug in a few more device driver functions */
476 /* XXX these should really go right after _mesa_init_driver_functions() */
477 r200InitPixelFuncs( ctx
);
478 r200InitSpanFuncs( ctx
);
479 r200InitTnlFuncs( ctx
);
480 r200InitState( rmesa
);
481 r200InitSwtcl( ctx
);
483 fthrottle_mode
= driQueryOptioni(&rmesa
->optionCache
, "fthrottle_mode");
484 rmesa
->iw
.irq_seq
= -1;
485 rmesa
->irqsEmitted
= 0;
486 rmesa
->do_irqs
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_IRQS
&&
487 rmesa
->r200Screen
->irq
);
489 rmesa
->do_usleeps
= (fthrottle_mode
== DRI_CONF_FTHROTTLE_USLEEPS
);
493 "IRQ's not enabled, falling back to %s: %d %d\n",
494 rmesa
->do_usleeps
? "usleeps" : "busy waits",
496 rmesa
->r200Screen
->irq
);
498 rmesa
->prefer_gart_client_texturing
=
499 (getenv("R200_GART_CLIENT_TEXTURES") != 0);
501 (*sPriv
->systemTime
->getUST
)( & rmesa
->swap_ust
);
505 R200_DEBUG
= driParseDebugString( getenv( "R200_DEBUG" ),
507 R200_DEBUG
|= driParseDebugString( getenv( "RADEON_DEBUG" ),
511 tcl_mode
= driQueryOptioni(&rmesa
->optionCache
, "tcl_mode");
512 if (driQueryOptionb(&rmesa
->optionCache
, "no_rast")) {
513 fprintf(stderr
, "disabling 3D acceleration\n");
514 FALLBACK(rmesa
, R200_FALLBACK_DISABLE
, 1);
516 else if (tcl_mode
== DRI_CONF_TCL_SW
|| getenv("R200_NO_TCL") ||
517 !(rmesa
->r200Screen
->chip_flags
& RADEON_CHIPSET_TCL
)) {
518 if (rmesa
->r200Screen
->chip_flags
& RADEON_CHIPSET_TCL
) {
519 rmesa
->r200Screen
->chip_flags
&= ~RADEON_CHIPSET_TCL
;
520 fprintf(stderr
, "Disabling HW TCL support\n");
522 TCL_FALLBACK(rmesa
->glCtx
, R200_TCL_FALLBACK_TCL_DISABLE
, 1);
529 /* Destroy the device specific context.
531 /* Destroy the Mesa and driver specific context data.
533 void r200DestroyContext( __DRIcontextPrivate
*driContextPriv
)
535 GET_CURRENT_CONTEXT(ctx
);
536 r200ContextPtr rmesa
= (r200ContextPtr
) driContextPriv
->driverPrivate
;
537 r200ContextPtr current
= ctx
? R200_CONTEXT(ctx
) : NULL
;
539 /* check if we're deleting the currently bound context */
540 if (rmesa
== current
) {
541 R200_FIREVERTICES( rmesa
);
542 _mesa_make_current(NULL
, NULL
, NULL
);
545 /* Free r200 context resources */
546 assert(rmesa
); /* should never be null */
548 GLboolean release_texture_heaps
;
551 release_texture_heaps
= (rmesa
->glCtx
->Shared
->RefCount
== 1);
552 _swsetup_DestroyContext( rmesa
->glCtx
);
553 _tnl_DestroyContext( rmesa
->glCtx
);
554 _vbo_DestroyContext( rmesa
->glCtx
);
555 _swrast_DestroyContext( rmesa
->glCtx
);
557 r200DestroySwtcl( rmesa
->glCtx
);
558 r200ReleaseArrays( rmesa
->glCtx
, ~0 );
560 if (rmesa
->dma
.current
.buf
) {
561 r200ReleaseDmaRegion( rmesa
, &rmesa
->dma
.current
, __FUNCTION__
);
562 r200FlushCmdBuf( rmesa
, __FUNCTION__
);
565 if (rmesa
->state
.scissor
.pClipRects
) {
566 FREE(rmesa
->state
.scissor
.pClipRects
);
567 rmesa
->state
.scissor
.pClipRects
= NULL
;
570 if ( release_texture_heaps
) {
571 /* This share group is about to go away, free our private
572 * texture object data.
576 for ( i
= 0 ; i
< rmesa
->nr_heaps
; i
++ ) {
577 driDestroyTextureHeap( rmesa
->texture_heaps
[ i
] );
578 rmesa
->texture_heaps
[ i
] = NULL
;
581 assert( is_empty_list( & rmesa
->swapped
) );
584 /* free the Mesa context */
585 rmesa
->glCtx
->DriverCtx
= NULL
;
586 _mesa_destroy_context( rmesa
->glCtx
);
588 /* free the option cache */
589 driDestroyOptionCache (&rmesa
->optionCache
);
599 r200SwapBuffers( __DRIdrawablePrivate
*dPriv
)
601 if (dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
602 r200ContextPtr rmesa
;
604 rmesa
= (r200ContextPtr
) dPriv
->driContextPriv
->driverPrivate
;
606 if (ctx
->Visual
.doubleBufferMode
) {
607 _mesa_notifySwapBuffers( ctx
); /* flush pending rendering comands */
608 if ( rmesa
->doPageFlip
) {
609 r200PageFlip( dPriv
);
612 r200CopyBuffer( dPriv
, NULL
);
617 /* XXX this shouldn't be an error but we can't handle it for now */
618 _mesa_problem(NULL
, "%s: drawable has no context!", __FUNCTION__
);
623 r200CopySubBuffer( __DRIdrawablePrivate
*dPriv
,
624 int x
, int y
, int w
, int h
)
626 if (dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
627 r200ContextPtr rmesa
;
629 rmesa
= (r200ContextPtr
) dPriv
->driContextPriv
->driverPrivate
;
631 if (ctx
->Visual
.doubleBufferMode
) {
632 drm_clip_rect_t rect
;
633 rect
.x1
= x
+ dPriv
->x
;
634 rect
.y1
= (dPriv
->h
- y
- h
) + dPriv
->y
;
635 rect
.x2
= rect
.x1
+ w
;
636 rect
.y2
= rect
.y1
+ h
;
637 _mesa_notifySwapBuffers( ctx
); /* flush pending rendering comands */
638 r200CopyBuffer( dPriv
, &rect
);
642 /* XXX this shouldn't be an error but we can't handle it for now */
643 _mesa_problem(NULL
, "%s: drawable has no context!", __FUNCTION__
);
647 /* Force the context `c' to be the current context and associate with it
651 r200MakeCurrent( __DRIcontextPrivate
*driContextPriv
,
652 __DRIdrawablePrivate
*driDrawPriv
,
653 __DRIdrawablePrivate
*driReadPriv
)
655 if ( driContextPriv
) {
656 r200ContextPtr newCtx
=
657 (r200ContextPtr
) driContextPriv
->driverPrivate
;
659 if (R200_DEBUG
& DEBUG_DRI
)
660 fprintf(stderr
, "%s ctx %p\n", __FUNCTION__
, (void *)newCtx
->glCtx
);
662 newCtx
->dri
.readable
= driReadPriv
;
664 if ( newCtx
->dri
.drawable
!= driDrawPriv
||
665 newCtx
->lastStamp
!= driDrawPriv
->lastStamp
) {
666 if (driDrawPriv
->swap_interval
== (unsigned)-1) {
667 driDrawPriv
->vblFlags
= (newCtx
->r200Screen
->irq
!= 0)
668 ? driGetDefaultVBlankFlags(&newCtx
->optionCache
)
669 : VBLANK_FLAG_NO_IRQ
;
671 driDrawableInitVBlank( driDrawPriv
);
674 newCtx
->dri
.drawable
= driDrawPriv
;
676 r200SetCliprects(newCtx
);
677 r200UpdateViewportOffset( newCtx
->glCtx
);
680 _mesa_make_current( newCtx
->glCtx
,
681 (GLframebuffer
*) driDrawPriv
->driverPrivate
,
682 (GLframebuffer
*) driReadPriv
->driverPrivate
);
684 _mesa_update_state( newCtx
->glCtx
);
685 r200ValidateState( newCtx
->glCtx
);
688 if (R200_DEBUG
& DEBUG_DRI
)
689 fprintf(stderr
, "%s ctx is null\n", __FUNCTION__
);
690 _mesa_make_current( NULL
, NULL
, NULL
);
693 if (R200_DEBUG
& DEBUG_DRI
)
694 fprintf(stderr
, "End %s\n", __FUNCTION__
);
698 /* Force the context `c' to be unbound from its buffer.
701 r200UnbindContext( __DRIcontextPrivate
*driContextPriv
)
703 r200ContextPtr rmesa
= (r200ContextPtr
) driContextPriv
->driverPrivate
;
705 if (R200_DEBUG
& DEBUG_DRI
)
706 fprintf(stderr
, "%s ctx %p\n", __FUNCTION__
, (void *)rmesa
->glCtx
);