patch to import Jon Smirl's work from Bitkeeper
[mesa.git] / src / mesa / drivers / dri / mga / mgadd.c
1 /*
2 * Copyright 2000-2001 VA Linux Systems, Inc.
3 * All Rights Reserved.
4 *
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
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 * VA LINUX SYSTEMS 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
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keith@tungstengraphics.com>
26 */
27 /* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.c,v 1.14 2002/10/30 12:51:35 alanh Exp $ */
28
29
30 #include "mtypes.h"
31
32 #include "mm.h"
33 #include "mgacontext.h"
34 #include "mgadd.h"
35 #include "mgastate.h"
36 #include "mgaspan.h"
37 #include "mgatex.h"
38 #include "mgatris.h"
39 #include "mgavb.h"
40 #include "mga_xmesa.h"
41 #include "utils.h"
42
43 #define DRIVER_DATE "20030328"
44
45
46 /***************************************
47 * Mesa's Driver Functions
48 ***************************************/
49
50
51 static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
52 {
53 mgaContextPtr mmesa = MGA_CONTEXT( ctx );
54 static char buffer[128];
55 unsigned offset;
56
57 switch ( name ) {
58 case GL_VENDOR:
59 return (GLubyte *) "VA Linux Systems Inc.";
60
61 case GL_RENDERER:
62 offset = driGetRendererString( buffer,
63 MGA_IS_G400(mmesa) ? "G400" :
64 MGA_IS_G200(mmesa) ? "G200" : "MGA",
65 DRIVER_DATE,
66 mmesa->mgaScreen->agpMode );
67
68 return (GLubyte *)buffer;
69
70 default:
71 return NULL;
72 }
73 }
74
75
76
77 static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
78 {
79 GET_CURRENT_CONTEXT(ctx);
80 mgaContextPtr mmesa = MGA_CONTEXT(ctx);
81
82 /* Need to lock to make sure the driDrawable is uptodate. This
83 * information is used to resize Mesa's software buffers, so it has
84 * to be correct.
85 */
86 LOCK_HARDWARE( mmesa );
87 *width = mmesa->driDrawable->w;
88 *height = mmesa->driDrawable->h;
89 UNLOCK_HARDWARE( mmesa );
90 }
91
92 void mgaDDInitDriverFuncs( GLcontext *ctx )
93 {
94 ctx->Driver.GetBufferSize = mgaBufferSize;
95 ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
96 ctx->Driver.GetString = mgaDDGetString;
97 }