2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
28 * \author John Sheng (presumably of either VIA Technologies or S3 Graphics)
29 * \author Others at VIA Technologies?
30 * \author Others at S3 Graphics?
37 #include "simple_list.h"
38 #include "extensions.h"
40 #include "swrast/swrast.h"
41 #include "swrast_setup/swrast_setup.h"
43 #include "array_cache/acache.h"
45 #include "tnl/t_pipeline.h"
47 #include "drivers/common/driverfuncs.h"
49 #include "via_screen.h"
52 #include "via_state.h"
56 #include "via_ioctl.h"
62 #define DRIVER_DATE "20041215"
73 * Return various strings for \c glGetString.
77 static const GLubyte
*viaGetString(GLcontext
*ctx
, GLenum name
)
79 static char buffer
[128];
85 return (GLubyte
*)"VIA Technology";
88 static const char * const chipset_names
[] = {
90 "CastleRock (CLE266)",
93 "UniChrome (PM8x0/CN400)",
95 const viaContext
* const via
= VIA_CONTEXT(ctx
);
96 const unsigned id
= via
->viaScreen
->deviceID
;
98 offset
= driGetRendererString( buffer
,
99 chipset_names
[(id
> VIA_PM800
) ? 0 : id
],
101 return (GLubyte
*)buffer
;
111 * Calculate a width that satisfies the hardware's alignment requirements.
112 * On the Unichrome hardware, each scanline must be aligned to a multiple of
115 * \param width Minimum buffer width, in pixels.
117 * \returns A pixel width that meets the alignment requirements.
119 static __inline__
unsigned
120 buffer_align( unsigned width
)
122 return (width
+ 0x0f) & ~0x0f;
127 * Calculate the framebuffer parameters for all buffers (front, back, depth,
128 * and stencil) associated with the specified context.
131 * This function also calls \c AllocateBuffer to actually allocate the
137 calculate_buffer_parameters( viaContextPtr vmesa
)
139 const unsigned shift
= vmesa
->viaScreen
->bitsPerPixel
/ 16;
140 const unsigned extra
= 32;
144 /* Allocate front-buffer */
145 if (vmesa
->drawType
== GLX_PBUFFER_BIT
) {
146 w
= vmesa
->driDrawable
->w
;
147 h
= vmesa
->driDrawable
->h
;
149 vmesa
->front
.bpp
= vmesa
->viaScreen
->bitsPerPixel
;
150 vmesa
->front
.pitch
= buffer_align( w
) << shift
;
151 vmesa
->front
.size
= vmesa
->front
.pitch
* h
;
153 if (vmesa
->front
.map
)
154 via_free_draw_buffer(vmesa
, &vmesa
->front
);
155 if (!via_alloc_draw_buffer(vmesa
, &vmesa
->front
))
160 w
= vmesa
->viaScreen
->width
;
161 h
= vmesa
->viaScreen
->height
;
163 vmesa
->front
.bpp
= vmesa
->viaScreen
->bitsPerPixel
;
164 vmesa
->front
.pitch
= buffer_align( w
) << shift
;
165 vmesa
->front
.size
= vmesa
->front
.pitch
* h
;
166 vmesa
->front
.offset
= 0;
167 vmesa
->front
.map
= (char *) vmesa
->driScreen
->pFB
;
171 /* Allocate back-buffer */
172 if (vmesa
->hasBack
) {
173 vmesa
->back
.bpp
= vmesa
->viaScreen
->bitsPerPixel
;
174 vmesa
->back
.pitch
= (buffer_align( vmesa
->driDrawable
->w
) << shift
) + extra
;
175 vmesa
->back
.size
= vmesa
->back
.pitch
* vmesa
->driDrawable
->h
;
177 via_free_draw_buffer(vmesa
, &vmesa
->back
);
178 if (!via_alloc_draw_buffer(vmesa
, &vmesa
->back
))
183 via_free_draw_buffer(vmesa
, &vmesa
->back
);
184 (void) memset( &vmesa
->back
, 0, sizeof( vmesa
->back
) );
188 /* Allocate depth-buffer */
189 if ( vmesa
->hasStencil
|| vmesa
->hasDepth
) {
190 vmesa
->depth
.bpp
= vmesa
->depthBits
;
191 if (vmesa
->depth
.bpp
== 24)
192 vmesa
->depth
.bpp
= 32;
194 vmesa
->depth
.pitch
= (buffer_align( vmesa
->driDrawable
->w
) * (vmesa
->depth
.bpp
/8)) + extra
;
195 vmesa
->depth
.size
= vmesa
->depth
.pitch
* vmesa
->driDrawable
->h
;
197 if (vmesa
->depth
.map
)
198 via_free_draw_buffer(vmesa
, &vmesa
->depth
);
199 if (!via_alloc_draw_buffer(vmesa
, &vmesa
->depth
)) {
204 if (vmesa
->depth
.map
)
205 via_free_draw_buffer(vmesa
, &vmesa
->depth
);
206 (void) memset( & vmesa
->depth
, 0, sizeof( vmesa
->depth
) );
209 /*=* John Sheng [2003.5.31] flip *=*/
210 if( vmesa
->viaScreen
->width
== vmesa
->driDrawable
->w
&&
211 vmesa
->viaScreen
->height
== vmesa
->driDrawable
->h
) {
212 #define ALLOW_EXPERIMENTAL_PAGEFLIP 0
213 #if ALLOW_EXPERIMENTAL_PAGEFLIP
214 vmesa
->doPageFlip
= GL_TRUE
;
215 /* vmesa->currentPage = 0; */
216 assert(vmesa
->back
.pitch
== vmesa
->front
.pitch
);
218 vmesa
->doPageFlip
= GL_FALSE
;
222 vmesa
->doPageFlip
= GL_FALSE
;
228 void viaReAllocateBuffers(GLframebuffer
*drawbuffer
)
230 GET_CURRENT_CONTEXT(ctx
);
231 viaContextPtr vmesa
= VIA_CONTEXT(ctx
);
233 _swrast_alloc_buffers( drawbuffer
);
234 calculate_buffer_parameters( vmesa
);
237 static void viaBufferSize(GLframebuffer
*buffer
, GLuint
*width
, GLuint
*height
)
239 GET_CURRENT_CONTEXT(ctx
);
240 viaContextPtr vmesa
= VIA_CONTEXT(ctx
);
241 *width
= vmesa
->driDrawable
->w
;
242 *height
= vmesa
->driDrawable
->h
;
245 /* Extension strings exported by the Unichrome driver.
247 static const char * const card_extensions
[] =
249 "GL_ARB_multitexture",
250 "GL_ARB_point_parameters",
251 "GL_ARB_texture_env_add",
252 "GL_ARB_texture_env_combine",
253 "GL_ARB_texture_env_dot3",
254 "GL_ARB_texture_mirrored_repeat",
255 "GL_EXT_stencil_wrap",
256 "GL_EXT_texture_env_combine",
257 "GL_EXT_texture_env_dot3",
258 "GL_EXT_texture_lod_bias",
259 "GL_EXT_secondary_color",
261 "GL_NV_blend_square",
265 extern const struct tnl_pipeline_stage _via_fastrender_stage
;
266 extern const struct tnl_pipeline_stage _via_render_stage
;
268 static const struct tnl_pipeline_stage
*via_pipeline
[] = {
269 &_tnl_vertex_transform_stage
,
270 &_tnl_normal_transform_stage
,
271 &_tnl_lighting_stage
,
272 &_tnl_fog_coordinate_stage
,
274 &_tnl_texture_transform_stage
,
275 /* REMOVE: point attenuation stage */
276 &_via_fastrender_stage
, /* ADD: unclipped rastersetup-to-dma */
283 AllocateDmaBuffer(const GLvisual
*visual
, viaContextPtr vmesa
)
286 via_free_dma_buffer(vmesa
);
288 if (!via_alloc_dma_buffer(vmesa
))
292 vmesa
->dmaCliprectAddr
= ~0;
297 FreeBuffer(viaContextPtr vmesa
)
299 if (vmesa
->front
.map
&& vmesa
->drawType
== GLX_PBUFFER_BIT
)
300 via_free_draw_buffer(vmesa
, &vmesa
->front
);
303 via_free_draw_buffer(vmesa
, &vmesa
->back
);
305 if (vmesa
->depth
.map
)
306 via_free_draw_buffer(vmesa
, &vmesa
->depth
);
309 via_free_dma_buffer(vmesa
);
313 get_ust_nop( int64_t * ust
)
320 viaCreateContext(const __GLcontextModes
*mesaVis
,
321 __DRIcontextPrivate
*driContextPriv
,
322 void *sharedContextPrivate
)
324 GLcontext
*ctx
, *shareCtx
;
326 __DRIscreenPrivate
*sPriv
= driContextPriv
->driScreenPriv
;
327 viaScreenPrivate
*viaScreen
= (viaScreenPrivate
*)sPriv
->private;
328 drm_via_sarea_t
*saPriv
= (drm_via_sarea_t
*)
329 (((GLubyte
*)sPriv
->pSAREA
) + viaScreen
->sareaPrivOffset
);
330 struct dd_function_table functions
;
332 /* Allocate via context */
333 vmesa
= (viaContextPtr
) CALLOC_STRUCT(via_context_t
);
337 if (VIA_DEBUG
) fprintf(stderr
, "%s - in\n", __FUNCTION__
);
339 /* Parse configuration files.
341 driParseConfigFiles (&vmesa
->optionCache
, &viaScreen
->optionCache
,
342 sPriv
->myNum
, "via");
344 /* pick back buffer */
345 vmesa
->hasBack
= mesaVis
->doubleBufferMode
;
347 switch(mesaVis
->depthBits
) {
349 vmesa
->hasDepth
= GL_FALSE
;
350 vmesa
->depthBits
= 0;
351 vmesa
->depth_max
= 1.0;
354 vmesa
->hasDepth
= GL_TRUE
;
355 vmesa
->depthBits
= mesaVis
->depthBits
;
356 vmesa
->have_hw_stencil
= GL_FALSE
;
357 vmesa
->depth_max
= (GLfloat
)0xffff;
358 vmesa
->depth_clear_mask
= 0xf << 28;
359 vmesa
->ClearDepth
= 0xffff;
360 vmesa
->polygon_offset_scale
= 1.0 / vmesa
->depth_max
;
363 vmesa
->hasDepth
= GL_TRUE
;
364 vmesa
->depthBits
= mesaVis
->depthBits
;
365 vmesa
->depth_max
= (GLfloat
) 0xffffff;
366 vmesa
->depth_clear_mask
= 0xe << 28;
367 vmesa
->ClearDepth
= 0xffffff00;
369 assert(mesaVis
->haveStencilBuffer
);
370 assert(mesaVis
->stencilBits
== 8);
372 vmesa
->have_hw_stencil
= GL_TRUE
;
373 vmesa
->stencilBits
= mesaVis
->stencilBits
;
374 vmesa
->stencil_clear_mask
= 0x1 << 28;
375 vmesa
->polygon_offset_scale
= 2.0 / vmesa
->depth_max
;
378 vmesa
->hasDepth
= GL_TRUE
;
379 vmesa
->depthBits
= mesaVis
->depthBits
;
380 assert(!mesaVis
->haveStencilBuffer
);
381 vmesa
->have_hw_stencil
= GL_FALSE
;
382 vmesa
->depth_max
= (GLfloat
)0xffffffff;
383 vmesa
->depth_clear_mask
= 0xf << 28;
384 vmesa
->ClearDepth
= 0xffffffff;
385 vmesa
->polygon_offset_scale
= 2.0 / vmesa
->depth_max
;
393 _mesa_init_driver_functions(&functions
);
394 viaInitTextureFuncs(&functions
);
396 /* Allocate the Mesa context */
397 if (sharedContextPrivate
)
398 shareCtx
= ((viaContextPtr
) sharedContextPrivate
)->glCtx
;
402 vmesa
->glCtx
= _mesa_create_context(mesaVis
, shareCtx
, &functions
, (void*) vmesa
);
404 vmesa
->shareCtx
= shareCtx
;
410 driContextPriv
->driverPrivate
= vmesa
;
414 ctx
->Const
.MaxTextureLevels
= 10;
415 ctx
->Const
.MaxTextureUnits
= 2;
416 ctx
->Const
.MaxTextureImageUnits
= ctx
->Const
.MaxTextureUnits
;
417 ctx
->Const
.MaxTextureCoordUnits
= ctx
->Const
.MaxTextureUnits
;
419 ctx
->Const
.MinLineWidth
= 1.0;
420 ctx
->Const
.MinLineWidthAA
= 1.0;
421 ctx
->Const
.MaxLineWidth
= 1.0;
422 ctx
->Const
.MaxLineWidthAA
= 1.0;
423 ctx
->Const
.LineWidthGranularity
= 1.0;
425 ctx
->Const
.MinPointSize
= 1.0;
426 ctx
->Const
.MinPointSizeAA
= 1.0;
427 ctx
->Const
.MaxPointSize
= 1.0;
428 ctx
->Const
.MaxPointSizeAA
= 1.0;
429 ctx
->Const
.PointSizeGranularity
= 1.0;
431 ctx
->Driver
.GetBufferSize
= viaBufferSize
;
432 /* ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; *//* FIXME ?? */
433 ctx
->Driver
.GetString
= viaGetString
;
435 ctx
->DriverCtx
= (void *)vmesa
;
438 /* Initialize the software rasterizer and helper modules.
440 _swrast_CreateContext(ctx
);
441 _ac_CreateContext(ctx
);
442 _tnl_CreateContext(ctx
);
443 _swsetup_CreateContext(ctx
);
445 /* Install the customized pipeline:
447 _tnl_destroy_pipeline(ctx
);
448 _tnl_install_pipeline(ctx
, via_pipeline
);
450 /* Configure swrast and T&L to match hardware characteristics:
452 _swrast_allow_pixel_fog(ctx
, GL_FALSE
);
453 _swrast_allow_vertex_fog(ctx
, GL_TRUE
);
454 _tnl_allow_pixel_fog(ctx
, GL_FALSE
);
455 _tnl_allow_vertex_fog(ctx
, GL_TRUE
);
457 /* vmesa->display = dpy; */
458 vmesa
->display
= sPriv
->display
;
460 vmesa
->hHWContext
= driContextPriv
->hHWContext
;
461 vmesa
->driFd
= sPriv
->fd
;
462 vmesa
->driHwLock
= &sPriv
->pSAREA
->lock
;
464 vmesa
->viaScreen
= viaScreen
;
465 vmesa
->driScreen
= sPriv
;
466 vmesa
->sarea
= saPriv
;
467 vmesa
->glBuffer
= NULL
;
469 vmesa
->texHeap
= mmInit(0, viaScreen
->textureSize
);
470 vmesa
->renderIndex
= ~0;
471 vmesa
->setupIndex
= ~0;
472 vmesa
->hwPrimitive
= GL_POLYGON
+1;
474 /* KW: Hardwire this. Was previously set bogusly in
475 * viaCreateBuffer. Needs work before PBUFFER can be used:
477 vmesa
->drawType
= GLX_WINDOW_BIT
;
480 make_empty_list(&vmesa
->TexObjList
);
481 make_empty_list(&vmesa
->SwappedOut
);
483 vmesa
->CurrentTexObj
[0] = 0;
484 vmesa
->CurrentTexObj
[1] = 0;
486 _math_matrix_ctr(&vmesa
->ViewportMatrix
);
488 /* Do this early, before VIA_FLUSH_DMA can be called:
490 if (!AllocateDmaBuffer(mesaVis
, vmesa
)) {
491 fprintf(stderr
,"AllocateDmaBuffer fail\n");
497 driInitExtensions( ctx
, card_extensions
, GL_TRUE
);
498 viaInitStateFuncs(ctx
);
499 viaInitTextures(ctx
);
500 viaInitTriFuncs(ctx
);
501 viaInitSpanFuncs(ctx
);
502 viaInitIoctlFuncs(ctx
);
506 if (getenv("VIA_DEBUG"))
512 if (getenv("VIA_NO_RAST"))
513 FALLBACK(vmesa
, VIA_FALLBACK_USER_DISABLE
, 1);
515 if (getenv("VIA_CONFORM"))
516 vmesa
->strictConformance
= 1;
518 /* I don't understand why this isn't working:
520 vmesa
->vblank_flags
=
521 vmesa
->viaScreen
->irqEnabled
?
522 driGetDefaultVBlankFlags(&vmesa
->optionCache
) : VBLANK_FLAG_NO_IRQ
;
524 /* Hack this up in its place:
526 vmesa
->vblank_flags
= getenv("VIA_VSYNC") ? VBLANK_FLAG_SYNC
: VBLANK_FLAG_NO_IRQ
;
529 vmesa
->get_ust
= (PFNGLXGETUSTPROC
) glXGetProcAddress( (const GLubyte
*) "__glXGetUST" );
530 if ( vmesa
->get_ust
== NULL
) {
531 vmesa
->get_ust
= get_ust_nop
;
533 vmesa
->get_ust( &vmesa
->swap_ust
);
536 vmesa
->regMMIOBase
= (GLuint
*)((GLuint
)viaScreen
->reg
);
537 vmesa
->pnGEMode
= (GLuint
*)((GLuint
)viaScreen
->reg
+ 0x4);
538 vmesa
->regEngineStatus
= (GLuint
*)((GLuint
)viaScreen
->reg
+ 0x400);
539 vmesa
->regTranSet
= (GLuint
*)((GLuint
)viaScreen
->reg
+ 0x43C);
540 vmesa
->regTranSpace
= (GLuint
*)((GLuint
)viaScreen
->reg
+ 0x440);
541 vmesa
->agpBase
= viaScreen
->agpBase
;
543 fprintf(stderr
, "regEngineStatus = %x\n", *vmesa
->regEngineStatus
);
546 if (VIA_DEBUG
) fprintf(stderr
, "%s - out\n", __FUNCTION__
);
551 viaDestroyContext(__DRIcontextPrivate
*driContextPriv
)
553 GET_CURRENT_CONTEXT(ctx
);
554 viaContextPtr vmesa
= (viaContextPtr
)driContextPriv
->driverPrivate
;
555 viaContextPtr current
= ctx
? VIA_CONTEXT(ctx
) : NULL
;
556 if (VIA_DEBUG
) fprintf(stderr
, "%s - in\n", __FUNCTION__
);
557 assert(vmesa
); /* should never be null */
559 /* check if we're deleting the currently bound context */
560 if (vmesa
== current
) {
561 VIA_FLUSH_DMA(vmesa
);
562 _mesa_make_current2(NULL
, NULL
, NULL
);
566 /*=* John Sheng [2003.5.31] agp tex *=*/
568 if(VIA_DEBUG
) fprintf(stderr
, "agpFullCount = %d\n", vmesa
->agpFullCount
);
570 _swsetup_DestroyContext(vmesa
->glCtx
);
571 _tnl_DestroyContext(vmesa
->glCtx
);
572 _ac_DestroyContext(vmesa
->glCtx
);
573 _swrast_DestroyContext(vmesa
->glCtx
);
575 /* free the Mesa context */
576 _mesa_destroy_context(vmesa
->glCtx
);
580 if (VIA_DEBUG
) fprintf(stderr
, "%s - out\n", __FUNCTION__
);
584 void viaXMesaWindowMoved(viaContextPtr vmesa
)
586 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
587 GLuint bytePerPixel
= vmesa
->viaScreen
->bitsPerPixel
>> 3;
592 switch (vmesa
->glCtx
->Color
._DrawDestMask
[0]) {
593 case DD_FRONT_LEFT_BIT
:
594 if (dPriv
->numBackClipRects
== 0) {
595 vmesa
->numClipRects
= dPriv
->numClipRects
;
596 vmesa
->pClipRects
= dPriv
->pClipRects
;
599 vmesa
->numClipRects
= dPriv
->numBackClipRects
;
600 vmesa
->pClipRects
= dPriv
->pBackClipRects
;
603 case DD_BACK_LEFT_BIT
:
604 vmesa
->numClipRects
= dPriv
->numClipRects
;
605 vmesa
->pClipRects
= dPriv
->pClipRects
;
608 vmesa
->numClipRects
= 0;
612 if (vmesa
->drawW
!= dPriv
->w
||
613 vmesa
->drawH
!= dPriv
->h
)
614 calculate_buffer_parameters( vmesa
);
616 vmesa
->drawXoff
= (GLuint
)(((dPriv
->x
* bytePerPixel
) & 0x1f) / bytePerPixel
);
617 vmesa
->drawX
= dPriv
->x
- vmesa
->drawXoff
;
618 vmesa
->drawY
= dPriv
->y
;
619 vmesa
->drawW
= dPriv
->w
;
620 vmesa
->drawH
= dPriv
->h
;
622 vmesa
->front
.orig
= (vmesa
->front
.offset
+
623 vmesa
->drawY
* vmesa
->front
.pitch
+
624 vmesa
->drawX
* bytePerPixel
);
626 vmesa
->front
.origMap
= (vmesa
->front
.map
+
627 vmesa
->drawY
* vmesa
->front
.pitch
+
628 vmesa
->drawX
* bytePerPixel
);
630 vmesa
->back
.orig
= vmesa
->back
.offset
;
631 vmesa
->depth
.orig
= vmesa
->depth
.offset
;
632 vmesa
->back
.origMap
= vmesa
->back
.map
;
633 vmesa
->depth
.origMap
= vmesa
->depth
.map
;
635 viaCalcViewport(vmesa
->glCtx
);
639 viaUnbindContext(__DRIcontextPrivate
*driContextPriv
)
641 if (VIA_DEBUG
) fprintf(stderr
, "%s - in\n", __FUNCTION__
);
642 if (VIA_DEBUG
) fprintf(stderr
, "%s - out\n", __FUNCTION__
);
647 viaMakeCurrent(__DRIcontextPrivate
*driContextPriv
,
648 __DRIdrawablePrivate
*driDrawPriv
,
649 __DRIdrawablePrivate
*driReadPriv
)
651 if (VIA_DEBUG
) fprintf(stderr
, "%s - in\n", __FUNCTION__
);
654 fprintf(stderr
, "driContextPriv = %08x\n", (GLuint
)driContextPriv
);
655 fprintf(stderr
, "driDrawPriv = %08x\n", (GLuint
)driDrawPriv
);
656 fprintf(stderr
, "driReadPriv = %08x\n", (GLuint
)driReadPriv
);
659 if (driContextPriv
) {
660 viaContextPtr vmesa
= (viaContextPtr
)driContextPriv
->driverPrivate
;
661 GLcontext
*ctx
= vmesa
->glCtx
;
663 if ( vmesa
->driDrawable
!= driDrawPriv
) {
664 driDrawableInitVBlank( driDrawPriv
, vmesa
->vblank_flags
);
665 vmesa
->driDrawable
= driDrawPriv
;
666 if ( ! calculate_buffer_parameters( vmesa
) ) {
669 ctx
->Driver
.DrawBuffer( ctx
, ctx
->Color
.DrawBuffer
[0] );
671 if (VIA_DEBUG
) fprintf(stderr
, "viaMakeCurrent: w = %d\n", vmesa
->driDrawable
->w
);
673 _mesa_make_current2(vmesa
->glCtx
,
674 (GLframebuffer
*)driDrawPriv
->driverPrivate
,
675 (GLframebuffer
*)driReadPriv
->driverPrivate
);
676 if (VIA_DEBUG
) fprintf(stderr
, "Context %d MakeCurrent\n", vmesa
->hHWContext
);
678 viaXMesaWindowMoved(vmesa
);
679 ctx
->Driver
.Scissor(vmesa
->glCtx
,
680 vmesa
->glCtx
->Scissor
.X
,
681 vmesa
->glCtx
->Scissor
.Y
,
682 vmesa
->glCtx
->Scissor
.Width
,
683 vmesa
->glCtx
->Scissor
.Height
);
686 _mesa_make_current(0,0);
689 if (VIA_DEBUG
) fprintf(stderr
, "%s - out\n", __FUNCTION__
);
693 void viaGetLock(viaContextPtr vmesa
, GLuint flags
)
695 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
696 __DRIscreenPrivate
*sPriv
= vmesa
->driScreen
;
698 drmGetLock(vmesa
->driFd
, vmesa
->hHWContext
, flags
);
700 DRI_VALIDATE_DRAWABLE_INFO( sPriv
, dPriv
);
702 if (vmesa
->sarea
->ctxOwner
!= vmesa
->hHWContext
) {
703 vmesa
->sarea
->ctxOwner
= vmesa
->hHWContext
;
704 vmesa
->newEmitState
= ~0;
707 if (vmesa
->lastStamp
!= dPriv
->lastStamp
) {
708 viaXMesaWindowMoved(vmesa
);
709 vmesa
->lastStamp
= dPriv
->lastStamp
;
715 viaSwapBuffers(__DRIdrawablePrivate
*drawablePrivate
)
717 __DRIdrawablePrivate
*dPriv
= (__DRIdrawablePrivate
*)drawablePrivate
;
718 if (VIA_DEBUG
) fprintf(stderr
, "%s - in\n", __FUNCTION__
);
719 if (dPriv
&& dPriv
->driContextPriv
&& dPriv
->driContextPriv
->driverPrivate
) {
723 vmesa
= (viaContextPtr
)dPriv
->driContextPriv
->driverPrivate
;
725 if (ctx
->Visual
.doubleBufferMode
) {
726 _mesa_notifySwapBuffers(ctx
);
727 if (vmesa
->doPageFlip
) {
731 viaCopyBuffer(dPriv
);
735 VIA_FLUSH_DMA(vmesa
);
738 _mesa_problem(NULL
, "viaSwapBuffers: drawable has no context!\n");
740 if (VIA_DEBUG
) fprintf(stderr
, "%s - out\n", __FUNCTION__
);